From 236048fb2f646a774bd008c8d5798b8528ff8180 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Wed, 4 Dec 2019 12:38:00 +0530 Subject: [PATCH] nvim: init.vim: Group the configurations --- nvim/init.vim | 127 ++++++++++++++++++++++++++------------------------ 1 file changed, 65 insertions(+), 62 deletions(-) diff --git a/nvim/init.vim b/nvim/init.vim index 0dbfb3b..90937b3 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -1,6 +1,7 @@ " Specify a directory for plugins (for Neovim: ~/.local/share/nvim/plugged) call plug#begin('~/.config/nvim/plugged') +" ----------------------------- Plugins -------------------------------------- " Automatically match structures as you type Plug 'tpope/vim-endwise' " Tab completion @@ -95,9 +96,7 @@ Plug 'jpalardy/vim-slime' " Initialize plugin system call plug#end() -syntax on -filetype plugin indent on - +" ----------------------------- Settings ------------------------------------- " Set up leaders let mapleader="\" @@ -175,6 +174,7 @@ set sessionoptions-=blank syntax enable colorscheme monokai +" --------------------------- Key Bindings ----------------------------------- " Use to clear the highlighting of :set hlsearch. if maparg('', 'n') ==# '' nnoremap :nohlsearch @@ -301,6 +301,27 @@ noremap noremap noremap +nnoremap ss :call Cscope("s", expand('')) +nnoremap sg :call Cscope("g", expand('')) +nnoremap sd :call Cscope("d", expand('')) +nnoremap sc :call Cscope("c", expand('')) +nnoremap st :call Cscope("t", expand('')) +nnoremap se :call Cscope("e", expand('')) +nnoremap sf :call Cscope("f", expand('')) +nnoremap si :call Cscope("i", expand('')) +nnoremap sa :call Cscope("a", expand('')) + +nnoremap ss :call CscopeQuery("s") +nnoremap sg :call CscopeQuery("g") +nnoremap sd :call CscopeQuery("d") +nnoremap sc :call CscopeQuery("c") +nnoremap st :call CscopeQuery("t") +nnoremap se :call CscopeQuery("e") +nnoremap sf :call CscopeQuery("f") +nnoremap si :call CscopeQuery("i") +nnoremap sa :call CscopeQuery("a") + +" --------------------------- Autocmd groups --------------------------------- augroup deopleteMaps au! " For deoplete Rust @@ -345,8 +366,37 @@ let s:quitting = 0 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 -let g:neomake_warning_sign = {'text': '?'} +augroup Terminal + 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 +" Automatically resize the window +autocmd VimResized * wincmd = + +" --------------------------- Plugin settings -------------------------------- let g:haskell_enable_quantification = 1 " to enable highlighting of `forall` let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec` let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc` @@ -419,6 +469,7 @@ call neomake#configure#automake({ " When compilation is done, open the Location list or quickfix list " Value of 2 preserves cursor position let g:neomake_open_list = 2 +let g:neomake_warning_sign = {'text': '?'} " gutentags configuration " https://www.reddit.com/r/vim/comments/d77t6j/guide_how_to_setup_ctags_with_gutentags_properly/ @@ -467,35 +518,17 @@ let g:Lf_WindowPosition = 'popup' let g:Lf_PreviewInPopup = 1 let g:Lf_CommandMap = {'': [''], '': ['']} -augroup Terminal - 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 -" Automatically resize the window -autocmd VimResized * wincmd = +let g:nvimgdb_config_override = { + \ 'key_next': 'n', + \ 'key_step': 's', + \ 'key_finish': 'f', + \ 'key_continue': 'c', + \ 'key_until': 'u', + \ 'key_breakpoint': 'b', + \ 'set_tkeymaps': "NvimGdbNoTKeymaps", + \ } +" ----------------------------- Functions ------------------------------------ " For CScope and Quickfix " https://medium.com/@lakshmankumar12/quickfix-and-location-list-in-vim-ca0292ac894d " https://medium.com/@lakshmankumar12/vim-and-cscope-5f4558c8a8b8 @@ -541,36 +574,6 @@ function! CscopeQuery(option) endif endfunction -nnoremap ss :call Cscope("s", expand('')) -nnoremap sg :call Cscope("g", expand('')) -nnoremap sd :call Cscope("d", expand('')) -nnoremap sc :call Cscope("c", expand('')) -nnoremap st :call Cscope("t", expand('')) -nnoremap se :call Cscope("e", expand('')) -nnoremap sf :call Cscope("f", expand('')) -nnoremap si :call Cscope("i", expand('')) -nnoremap sa :call Cscope("a", expand('')) - -nnoremap ss :call CscopeQuery("s") -nnoremap sg :call CscopeQuery("g") -nnoremap sd :call CscopeQuery("d") -nnoremap sc :call CscopeQuery("c") -nnoremap st :call CscopeQuery("t") -nnoremap se :call CscopeQuery("e") -nnoremap sf :call CscopeQuery("f") -nnoremap si :call CscopeQuery("i") -nnoremap sa :call CscopeQuery("a") - function! NvimGdbNoTKeymaps() tnoremap endfunction - -let g:nvimgdb_config_override = { - \ 'key_next': 'n', - \ 'key_step': 's', - \ 'key_finish': 'f', - \ 'key_continue': 'c', - \ 'key_until': 'u', - \ 'key_breakpoint': 'b', - \ 'set_tkeymaps': "NvimGdbNoTKeymaps", - \ }