From bc6a097739d8ff6e1a67f3415e896cfaac315a69 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Fri, 22 May 2020 11:28:55 +0530 Subject: [PATCH] nvim: Miscellaneous clean up 1. Clean up the remnants of Neomake and grepper config left behind 2. Drop quickui and use a custom preview function for items in QF window stolen from floaterm plugin's author 3. Cleanups for vim default configuration settings like wildignore Signed-off-by: Sanchayan Maity --- nvim/.config/nvim/after/ftplugin/qf.vim | 41 ++++++++++++-- nvim/.config/nvim/config.vim | 71 +++++++++++++------------ nvim/.config/nvim/init.vim | 5 +- nvim/.config/nvim/plugin_settings.vim | 21 -------- 4 files changed, 76 insertions(+), 62 deletions(-) diff --git a/nvim/.config/nvim/after/ftplugin/qf.vim b/nvim/.config/nvim/after/ftplugin/qf.vim index a9cfa4e..c4833e7 100644 --- a/nvim/.config/nvim/after/ftplugin/qf.vim +++ b/nvim/.config/nvim/after/ftplugin/qf.vim @@ -1,11 +1,42 @@ -setlocal nolist norelativenumber nowrap number nocursorline -setlocal scrolloff=0 +" Quit vim if the last window is qf +autocmd BufEnter if winnr('$') < 2| q | endif -noremap p :call quickui#tools#preview_quickfix() +setlocal scrolloff=0 +setlocal nowrap +setlocal norelativenumber number +setlocal linebreak +setlocal nolist +setlocal nocursorline +setlocal nobuflisted +setlocal nospell nnoremap [- :colder nnoremap ]+ :cnewer nnoremap g :Cfilter -" Close QF window if it is last window -autocmd WinEnter * if winnr('$') == 1 && &buftype == "quickfix" | q | endif +nnoremap o p +nnoremap p :call preview_file() + +let b:qf_isLoc = ! empty(getloclist(0)) +if b:qf_isLoc == 1 + nnoremap q :lclose +else + nnoremap q :cclose +endif + +" Taken from https://github.com/voldikss/dotfiles +function! s:preview_file() + let winwidth = &columns + let cur_list = b:qf_isLoc == 1 ? getloclist('.') : getqflist() + let cur_line = getline(line('.')) + let cur_file = fnameescape(substitute(cur_line, '|.*$', '', '')) + if cur_line =~# '|\d\+' + let cur_pos = substitute(cur_line, '^\(.\{-}|\)\(\d\+\)\(.*\)', '\2', '') + execute 'vertical pedit! +'.cur_pos.' '.cur_file + else + execute 'vertical pedit! '.cur_file + endif + wincmd P + execute 'vert resize '.(winwidth / 2) + wincmd p +endfunction diff --git a/nvim/.config/nvim/config.vim b/nvim/.config/nvim/config.vim index 62ebf17..37499a4 100644 --- a/nvim/.config/nvim/config.vim +++ b/nvim/.config/nvim/config.vim @@ -33,45 +33,50 @@ set hidden set noautochdir set hlsearch set relativenumber +set nostartofline " Do not jump to first character with page commands. +set ignorecase " Make searching case insensitive +set smartcase " ... unless the query has capital letters. +set magic " Use 'magic' patterns (extended regular expressions). +set autoread " Autoload file if it changes on disk +set termguicolors " Enable colors for terminal +set completeopt-=menu +set completeopt+=menuone " Show the completions UI even with only 1 item +set completeopt-=longest " Don't insert the longest common text +set completeopt-=preview " Hide the documentation preview window +set completeopt+=noinsert " Don't insert text automatically +set completeopt-=noselect " Highlight the first completion automatically +" Required for vim-workspace +" See https://github.com/thaerkh/vim-workspace/issues/11 +set sessionoptions-=blank +set fileformat=unix +set inccommand=split +set switchbuf=useopen +set backspace=indent,eol,start +set scrolloff=3 " Show next 3 lines while scrolling. +set sidescrolloff=5 " Show next 5 columns while side-scrolling. " Wild menu set wildmenu set wildmode=list:longest,full set wildoptions=pum set pumblend=30 -set wildignore+=.hg,.git,.svn " Version control -set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files -set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images -set wildignore+=*.o " compiled object files -set wildignore+=*.sw? " Vim swap files -set wildignore+=*.luac " Lua byte code -set wildignore+=*.pyc " Python byte code -set wildignore+=*.orig " Merge resolution files -set wildignore+=**/node_modules/** " Ignore garbage node_modules -set wildignore+=**/output/** " Ignore Purescript output directory - -if !&scrolloff - set scrolloff=3 " Show next 3 lines while scrolling. -endif -if !&sidescrolloff - set sidescrolloff=5 " Show next 5 columns while side-scrolling. -endif -set nostartofline " Do not jump to first character with page commands. - -set ignorecase " Make searching case insensitive -set smartcase " ... unless the query has capital letters. -set magic " Use 'magic' patterns (extended regular expressions). -set autoread " Autoload file if it changes on disk -set termguicolors " Enable colors for terminal -set fileformat=unix -set inccommand=split -set switchbuf=useopen - -set backspace=indent,eol,start -set completeopt=menu,noselect,preview,noinsert -" Required for vim-workspace -" See https://github.com/thaerkh/vim-workspace/issues/11 -set sessionoptions-=blank +set wildignore=*.o,*.obj,*~,*.exe,*.a,*.pdb,*.lib +set wildignore+=__pycache__,.stversions,*.spl,*.out,%* +set wildignore+=*.so,*.dll,*.swp,*.egg,*.jar,*.class,*.pyc,*.pyo,*.bin,*.dex +set wildignore+=*.zip,*.7z,*.rar,*.gz,*.tar,*.gzip,*.bz2,*.tgz,*.xz +set wildignore+=*DS_Store*,*.ipch +set wildignore+=*.gem +set wildignore+=*.png,*.jpg,*.gif,*.bmp,*.tga,*.pcx,*.ppm,*.img,*.iso +set wildignore+=*.so,*.swp,*.zip,*/.Trash/**,*.pdf,*.dmg,*/.rbenv/** +set wildignore+=*/.nx/**,*.app,*.git,.git +set wildignore+=*.wav,*.mp3,*.ogg,*.pcm +set wildignore+=*.mht,*.suo,*.sdf,*.jnlp +set wildignore+=*.chm,*.epub,*.pdf,*.mobi,*.ttf +set wildignore+=*.mp4,*.avi,*.flv,*.mov,*.mkv,*.swf,*.swc +set wildignore+=*.ppt,*.pptx,*.docx,*.xlt,*.xls,*.xlsx,*.odt,*.wps +set wildignore+=*.msi,*.crx,*.deb,*.vfd,*.apk,*.ipa,*.bin,*.msu +set wildignore+=*.gba,*.sfc,*.078,*.nds,*.smd,*.smc +set wildignore+=*.linux2,*.win32,*.darwin,*.freebsd,*.linux,*.android " Disable providers we do not give a shit about let g:loaded_python_provider = 0 diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim index 28714c2..041b036 100644 --- a/nvim/.config/nvim/init.vim +++ b/nvim/.config/nvim/init.vim @@ -21,7 +21,7 @@ Plug 'wellle/tmux-complete.vim' " Git support Plug 'lambdalisue/gina.vim' Plug 'airblade/vim-gitgutter' -Plug 'rhysd/git-messenger.vim' +Plug 'rhysd/git-messenger.vim', { 'on': 'GitMessenger' } Plug 'rhysd/conflict-marker.vim' Plug 'whiteinge/diffconflicts' Plug 'salcode/vim-interactive-rebase-reverse' @@ -39,7 +39,6 @@ Plug 'hauleth/asyncdo.vim' Plug 'ronakg/quickr-cscope.vim' Plug 'stefandtw/quickfix-reflector.vim' Plug 'milkypostman/vim-togglelist' -Plug 'skywind3000/vim-quickui' Plug 'yssl/QFEnter' " Text Object plugins Plug 'kana/vim-textobj-user' @@ -74,7 +73,7 @@ Plug 'Twinside/vim-hoogle', { 'for': 'haskell' } Plug 'godlygeek/tabular', { 'for': 'haskell' } Plug 'ndmitchell/ghcid', { 'rtp': 'plugins/nvim' } " Rust -Plug 'rust-lang/rust.vim' +Plug 'rust-lang/rust.vim', { 'for': 'rust' } Plug 'sebastianmarkow/deoplete-rust', { 'for': 'rust' } " Purescript Plug 'purescript-contrib/purescript-vim' diff --git a/nvim/.config/nvim/plugin_settings.vim b/nvim/.config/nvim/plugin_settings.vim index e558dbc..69289ce 100644 --- a/nvim/.config/nvim/plugin_settings.vim +++ b/nvim/.config/nvim/plugin_settings.vim @@ -10,17 +10,6 @@ let g:gitgutter_sign_removed = '-r' let g:gitgutter_sign_removed_first_line = '^^' let g:gitgutter_sign_modified_removed = 'mr' -" Neomake -" 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': '?'} -let g:neomake_c_enabled_makers = ['gcc'] -let g:neomake_c_gcc_maker = { - \ 'exe': 'gcc', - \ 'args': ['-Wall', '-Iinclude', '-Wextra', '-Weverything', '-pedantic', '-Wno-sign-conversion'], - \ } - " Automatically detect style file and apply style to formatting let g:clang_format#detect_style_file = 1 " Fix tab behaviour while switching through completion options @@ -63,16 +52,6 @@ let g:floaterm_height = 0.8 let g:floaterm_winblend = 0 let g:floaterm_borderchars = ['─', '│', '─', '│', '╭', '╮', '╯', '╰'] -" Vim grepper -let g:grepper = {} -let g:grepper.tools = ['rg'] -let g:grepper.quickfix = 1 -let g:grepper.buffer = 0 -let g:grepper.buffers = 0 -let g:grepper.switch = 0 -let g:grepper.append = 0 -let g:grepper.prompt = 0 - " Incremental search let g:incsearch#auto_nohlsearch = 1