diff --git a/nvim/init.vim b/nvim/init.vim index 2f2d740..9c43032 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -325,7 +325,7 @@ command! -bang -nargs=* GGrep \ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), 0) " --------------------------- Autocmd groups --------------------------------- -augroup HaskellMaps +augroup haskell_maps au! au FileType haskell nmap ht :NeomakeSh stack exec -- fast-tags -R . au FileType haskell nmap hg :Ghcid @@ -335,7 +335,7 @@ augroup HaskellMaps au FileType haskell nmap hi :exe ':HoogleInfo ' . expand('') augroup END -augroup CMaps +augroup c_maps au! au FileType c nmap ct :NeomakeSh ctags -R . au FileType c nmap cu :NeomakeSh cscope -bqR @@ -362,7 +362,7 @@ augroup CMaps au FileType c nmap sa :call CscopeQuery("a") augroup END -augroup deopleteMaps +augroup rust_maps au! au FileType rust nmap rd DeopleteRustGoToDefinitionDefault au FileType rust nmap rc DeopleteRustShowDocumentation @@ -376,22 +376,25 @@ augroup rainbow_lisp autocmd FileType lisp,clojure,scheme RainbowParentheses augroup END -" Starts the REPL. -autocmd FileType scheme nnoremap rc :SchemeConnect -" Evaluates the outer most / top level form and jumps the cursor back to where it was. -autocmd FileType scheme nnoremap re :normal mscpaF`s -" Evaluates the entire file. -autocmd FileType scheme nnoremap rf :normal msggcpG`s +augroup scheme_maps + au! + " Starts the REPL. + autocmd FileType scheme nnoremap rc :SchemeConnect + " Evaluates the outer most / top level form and jumps the cursor back to where it was. + autocmd FileType scheme nnoremap re :normal mscpaF`s + " Evaluates the entire file. + autocmd FileType scheme nnoremap rf :normal msggcpG`s +augroup END " Toggles search highlighting off/on according to current mode. Source: http://blog.sanctum.geek.nz/vim-search-highlighting/ -augroup ToggleSearchHighlighting +augroup toggle_search autocmd! autocmd InsertEnter * setlocal nohlsearch autocmd InsertLeave * setlocal hlsearch augroup END " Close QF window if it is last window -augroup QFClose +augroup quickfix_close au! au WinEnter * if winnr('$') == 1 && &buftype == "quickfix"|q|endif augroup END @@ -406,32 +409,33 @@ au QuitPre *.rs let s:quitting = 1 au BufEnter *.rs let s:quitting = 0 au BufWritePost *.rs if ! s:quitting | Neomake | else | echom "Neomake disabled"| endif -augroup Terminal +augroup terminal_job au! au TermOpen * setlocal statusline=%{b:terminal_job_id} augroup END -" Default indentations -autocmd BufRead,BufNewFile */gst-*/*.[ch] set et sw=2 -autocmd BufRead,BufNewFile */gstreamer-*/*.[ch] set et sw=2 -autocmd BufRead,BufNewFile */pulseaudio/*.[ch] set et sw=4 tw=128 -" Configure expanding of tabs for various file types -au BufRead,BufNewFile *.c set noexpandtab -au BufRead,BufNewFile *.h set noexpandtab -au BufRead,BufNewFile Makefile* set noexpandtab -au BufNewFile,BufRead *.vim setlocal noet ts=4 sw=4 sts=4 -au BufNewFile,BufRead *.txt setlocal noet ts=4 sw=4 -" Lua settings -autocmd BufNewFile,BufRead *.lua setlocal noet ts=4 sw=4 sts=4 -" Python indent -autocmd BufNewFile,BufRead *.py setlocal tabstop=4 softtabstop=4 shiftwidth=4 textwidth=80 smarttab expandtab -" Shell/config/systemd settings -autocmd FileType fstab,systemd set noexpandtab -autocmd FileType gitconfig,sh,toml set noexpandtab -" Spell check for git commits -autocmd FileType gitcommit setlocal spell -" Spell Checking -autocmd BufRead,BufNewFile *.md,*.txt setlocal spell spelllang=en_uk +augroup indentation_defaults + au! + au BufRead,BufNewFile *.c set noexpandtab + au BufRead,BufNewFile *.h set noexpandtab + au BufRead,BufNewFile Makefile* set noexpandtab + au BufNewFile,BufRead *.vim setlocal noet ts=4 sw=4 sts=4 + au BufNewFile,BufRead *.txt setlocal noet ts=4 sw=4 + autocmd BufNewFile,BufRead *.lua setlocal noet ts=4 sw=4 sts=4 + autocmd BufNewFile,BufRead *.py setlocal tabstop=4 softtabstop=4 shiftwidth=4 textwidth=80 smarttab expandtab + autocmd FileType fstab,systemd set noexpandtab + autocmd FileType gitconfig,sh,toml set noexpandtab + autocmd BufRead,BufNewFile */gst-*/*.[ch] set et sw=2 + autocmd BufRead,BufNewFile */gstreamer-*/*.[ch] set et sw=2 + autocmd BufRead,BufNewFile */pulseaudio/*.[ch] set et sw=4 tw=128 +augroup END + +augroup spell_check + au! + autocmd FileType gitcommit setlocal spell + autocmd BufRead,BufNewFile *.md,*.txt setlocal spell spelllang=en_uk +augroup END + " Automatically resize the window autocmd VimResized * wincmd =