From dd2ddfc9d16d0189f9fcea3b949dd5563503eed4 Mon Sep 17 00:00:00 2001 From: xerus2000 <27jf@pm.me> Date: Fri, 4 Sep 2020 12:02:34 +0200 Subject: [PATCH] config/nvim: Update environment & config --- .config/nvim/init.vim | 9 ++++--- .config/nvim/init/general.vim | 15 +++++++---- .config/nvim/init/keys.vim | 14 ++++++----- .config/nvim/init/plug.vim | 40 +++++++++++++++++++----------- .config/nvim/init/pluginConfig.vim | 33 ++++++++++++++++-------- 5 files changed, 71 insertions(+), 40 deletions(-) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 99e193d..5fd947b 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -1,4 +1,5 @@ -source $XDG_CONFIG_HOME/nvim/init/plug.vim -source $XDG_CONFIG_HOME/nvim/init/general.vim -source $XDG_CONFIG_HOME/nvim/init/pluginConfig.vim -source $XDG_CONFIG_HOME/nvim/init/keys.vim +let $INITDIR=stdpath('config') +source $INITDIR/init/plug.vim +source $INITDIR/init/general.vim +source $INITDIR/init/pluginConfig.vim +source $INITDIR/init/keys.vim diff --git a/.config/nvim/init/general.vim b/.config/nvim/init/general.vim index 185c824..78cfb77 100644 --- a/.config/nvim/init/general.vim +++ b/.config/nvim/init/general.vim @@ -2,14 +2,14 @@ set termguicolors set mouse=a " Enable mouse in all modes set undofile -set wildmode=longest,list,full " Auto-completion +set wildmode=longest,list,full " Auto-completion for cmdline set clipboard+=unnamedplus " Merge with system clipboard set tabstop=4 shiftwidth=4 " Indentation " visuals set number relativenumber " Relative line numbering on the left -set wrap linebreak +set linebreak set cursorline cursorcolumn set scrolloff=7 sidescrolloff=20 " Keep some context when scrolling @@ -37,11 +37,16 @@ filetype plugin on autocmd FileType json syntax match Comment +\/\/.\+$+ " Comment highlighting in JSON autocmd Filetype * set formatoptions-=o " Don't automatically comment on o " custom hardcoded types -autocmd BufRead,BufNewFile $SHELL_CONFIG/* set filetype=zsh -autocmd BufRead,BufNewFile www.mixxx.org_wiki* set filetype=dokuwiki scrolloff=1 +autocmd BufRead,BufNewFile $CONFIG_SHELLS/*,$CONFIG_ZSH/* setlocal filetype=zsh +autocmd BufRead $XDG_CONFIG_HOME/yadm/bootstrap setlocal filetype=sh + +" shebang shortcut - https://www.reddit.com/r/vim/comments/4z7z7s/add_shebang_lines_to_your_vim_files_automatically/d6v7op8 and https://stackoverflow.com/a/52135425 +inoreabbrev #!! "#!/usr/bin/env" . (empty(&filetype) ? '' : ' '.&filetype) +autocmd BufNewFile *.sh,$HOME/.local/bin/* execute 'silent! 1s/.*/#!\/bin\/sh\r\r'| setlocal filetype=sh | :startinsert +"autocmd BufNewFile * if !empty(&filetype) | execute 'silent! 1s/.*/#!\/usr\/bin\/' . &filetype . '\r\r'| :startinsert | endif set spelllang=en_us,de_de -autocmd FileType markdown setlocal spell " Spell checking in markdown +autocmd FileType markdown setlocal wrap spell colorcolumn= " Spell checking & no guiding columns in markdown " Center on insert mode autocmd InsertEnter * norm zz diff --git a/.config/nvim/init/keys.vim b/.config/nvim/init/keys.vim index fb43b32..a5c7f8c 100644 --- a/.config/nvim/init/keys.vim +++ b/.config/nvim/init/keys.vim @@ -1,3 +1,5 @@ +let @c = '/^\n i```Ni```j0/``` lllkxNA' + " Save file as root when I forgot to use sudoedit cnoremap w!! execute 'write !sudo tee % >/dev/null' edit! " Write file & source vimrc (really only makes sense from within vimrc to quickly test changes) @@ -6,18 +8,15 @@ command! WS write source $MYVIMRC command! FormatJSON %!python -m json.tool command! DiffSwap :diffsp % " Diff for swap - replaced by 'chrisbra/Recover.vim' -" shebang shortcut - https://www.reddit.com/r/vim/comments/4z7z7s/add_shebang_lines_to_your_vim_files_automatically/d6v7op8 and https://stackoverflow.com/a/52135425 -inoreabbrev #!! "#!/usr/bin/env" . (empty(&filetype) ? '' : ' '.&filetype) -autocmd BufNewFile *.sh execute 'silent! 1s/.*/#!\/bin\/sh\r\r'| :startinsert -"autocmd BufNewFile * if !empty(&filetype) | execute 'silent! 1s/.*/#!\/usr\/bin\/' . &filetype . '\r\r'| :startinsert | endif - " Sane yanking map Y y$ " Disable Ex mode - https://vi.stackexchange.com/q/457 -nnoremap Q +nnoremap Q @q let mapleader=" " +nnoremap " ysiW" + " Alias write and quit to leader nnoremap q :wq nnoremap w :w @@ -48,5 +47,8 @@ map C :setlocal formatoptions=cro map i :setlocal autoindent! map s :setlocal spell! +map ls :setlocal colorcolumn=81,121 nowrap +map lw :setlocal colorcolumn=81 textwidth=80 +map ln :setlocal colorcolumn= textwidth=0 wrap " }}} diff --git a/.config/nvim/init/plug.vim b/.config/nvim/init/plug.vim index d9abe0b..c7236c6 100644 --- a/.config/nvim/init/plug.vim +++ b/.config/nvim/init/plug.vim @@ -1,18 +1,21 @@ " Plug -if empty(glob('~/.local/share/nvim/site/autoload/plug.vim')) - silent !curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs - \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim - - autocmd VimEnter * PlugInstall --sync | source $MYVIMRC +let plug_install = 0 +let autoload_plug_path = stdpath('data') . '/site/autoload/plug.vim' +if !filereadable(autoload_plug_path) + silent exe '!curl -fL --create-dirs -o ' . autoload_plug_path . + \ ' https://raw.github.com/junegunn/vim-plug/master/plug.vim' + execute 'source ' . fnameescape(autoload_plug_path) + let plug_install = 1 endif +unlet autoload_plug_path call plug#begin() " Editing " text objects -Plug 'xerus2000/argtextobj.vim' " arguments in brackets as text objects -Plug 'tpope/vim-surround' " edit surroundings - cs, ds, ys -Plug 'bkad/CamelCaseMotion' " move through camel case words +Plug 'xerus2000/argtextobj.vim' " arguments in brackets as text objects +Plug 'tpope/vim-surround' " edit surroundings - cs, ds, ys +Plug 'bkad/CamelCaseMotion' " move through camel case words " commands Plug 'inkarkat/vim-ReplaceWithRegister' " gr to replace with register Plug 'tpope/vim-commentary' " gc to comment out (gcap for paragraph) @@ -33,19 +36,19 @@ Plug 'jreybert/vimagit' " Magit for vim - git stage individual changes Plug 'doy/vim-diff-changes' " Commands for diffing - :DiffAgainstFilesystem :DiffAgainstVCS :DiffStop Plug 'junegunn/fzf' " File selection with :FZF " Browse -Plug 'tyru/open-browser.vim' " :OpenBrowser, :OpenBrowserSearch +Plug 'tyru/open-browser.vim' " :OpenBrowser, :OpenBrowserSearch Plug 'tyru/open-browser-github.vim' " QOL -Plug 'farmergreg/vim-lastplace' " Automatically jump to last edit position -Plug 'chrisbra/Recover.vim' " Add Recover options for swap files +Plug 'farmergreg/vim-lastplace' " Automatically jump to last edit position +Plug 'chrisbra/Recover.vim' " Add Recover options for swap files Plug 'ntpeters/vim-better-whitespace' " Tools for trailing whitespace & mixed indents " Aesthetic -Plug 'vim-airline/vim-airline' " Status bar on the bottom -Plug 'psliwka/vim-smoothie' " Smooth scrolling -Plug 'romainl/vim-cool' " Automatically stop highlighting search results when moving - https://stackoverflow.com/questions/657447/vim-clear-last-search-highlighting -Plug 'airblade/vim-gitgutter' " Git info on the left +Plug 'vim-airline/vim-airline' " Status bar on the bottom +Plug 'psliwka/vim-smoothie' " Smooth scrolling +Plug 'romainl/vim-cool' " Automatically stop highlighting search results when moving - https://stackoverflow.com/questions/657447/vim-clear-last-search-highlighting +Plug 'airblade/vim-gitgutter' " Git info on the left Plug 'norcalli/nvim-colorizer.lua' " Highlights color literals " Visual indent guides Plug 'nathanaelkane/vim-indent-guides' @@ -57,6 +60,13 @@ Plug 'neoclide/coc.nvim', {'branch': 'release' } Plug 'udalov/kotlin-vim' Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' } Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } } +Plug 'mipmip/vim-scimark' " Edit markdown tables +Plug 'APZelos/blamer.nvim' " Inline git blame call plug#end() +" Install plugins automatically after installing plug +if plug_install + PlugInstall --sync +endif +unlet plug_install diff --git a/.config/nvim/init/pluginConfig.vim b/.config/nvim/init/pluginConfig.vim index d9e816f..7491582 100644 --- a/.config/nvim/init/pluginConfig.vim +++ b/.config/nvim/init/pluginConfig.vim @@ -6,12 +6,19 @@ command! PU PlugUpdate | PlugUpgrade lua require 'colorizer'.setup({ '*'; markdown = { names = false; }; }) let g:strip_whitespace_on_save=1 +autocmd FileType taskedit,crontab,markdown DisableStripWhitespaceOnSave let g:show_spaces_that_precede_tabs=1 let g:better_whitespace_skip_empty_lines=1 let g:better_whitespace_guicolor=$THEME == 'light' ? 'LightGrey' : 'DarkGrey' -autocmd FileType taskedit,markdown DisableWhitespace " see https://github.com/ntpeters/vim-better-whitespace/issues/134 - autocmd OptionSet background let g:better_whitespace_guicolor=&background == 'light' ? 'LightYellow' : 'Brown' +let g:blamer_enabled = 1 +let g:blamer_template = ': ' +let g:blamer_relative_time = 1 +let g:blamer_delay = 300 +" let g:blamer_show_in_visual_modes = 0 + +" remap movement commands to respect CamelCase map w CamelCaseMotion_w map b CamelCaseMotion_b map e CamelCaseMotion_e @@ -39,23 +46,29 @@ let g:firenvim_config = { \ }, \ 'localSettings': { \ '.*': { - \ 'cmdline': 'neovim', + \ 'cmdline': 'firenvim', \ 'priority': 0, - \ 'selector': 'textarea:not([readonly]):not([class="handsontableInput"]), div[role="textbox"]', + \ 'selector': 'textarea:not([readonly]):not([class="handsontableInput"]), div[role="textbox"]:not([aria-label="Search"])', \ 'takeover': 'always', \ }, - \ '.*notion\.so.*': { 'priority': 1, 'takeover': 'never', }, - \ '.*openstreetmap\.org.*': { 'priority': 1, 'takeover': 'never', }, + \ '.*notion\.so.*': { 'priority': 9, 'takeover': 'never', }, + \ '.*docs\.google\.com.*': { 'priority': 9, 'takeover': 'never', }, + \ '.*mail\.protonmail\.com.*': { 'priority': 9, 'takeover': 'never', }, + \ '.*cloud.atomtoast.xyz.*': { 'priority': 9, 'takeover': 'never', }, \ } \ } if exists('g:started_by_firenvim') + let g:smoothie_no_default_mappings=1 "extremely slow, see https://github.com/psliwka/vim-smoothie/issues/17 + + nnoremap :call firenvim#focus_page() + autocmd FocusLost,InsertLeave,BufLeave * ++nested call WriteSilent() function WriteSilent() - let tmp=b:better_whitespace_enabled - let b:better_whitespace_enabled=0 + let was_enabled=b:strip_whitespace_on_save + DisableStripWhitespaceOnSave write - let b:better_whitespace_enabled=tmp + if was_enabled + EnableStripWhitespaceOnSave + endif endfunction - nnoremap :call firenvim#focus_page() - let g:strip_whitespace_on_save=0 endif