nvim: Drop incremental search as in-built suffices

Also use vim-searchlight for search highlighting the word under cursor.
Add custom highlight color to make the word being searched under cursor
stand out for our color schemes and better key mappings to shift through
searches in command line.

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
This commit is contained in:
Sanchayan Maity 2020-06-16 17:53:59 +05:30
parent 7b35dd4e78
commit 8365e134d8
6 changed files with 20 additions and 10 deletions

View file

@ -1,9 +0,0 @@
map / <Plug>(incsearch-forward)
map ? <Plug>(incsearch-backward)
map g/ <Plug>(incsearch-stay)
map n <Plug>(incsearch-nohl-n)
map N <Plug>(incsearch-nohl-N)
map * <Plug>(incsearch-nohl-*)
map # <Plug>(incsearch-nohl-#)
map g* <Plug>(incsearch-nohl-g*)
map g# <Plug>(incsearch-nohl-g#)

View file

@ -9,6 +9,11 @@ augroup ResizeWindowsProportionally
autocmd VimResized * :wincmd = autocmd VimResized * :wincmd =
augroup END augroup END
augroup ToggleSearchHighlighting
autocmd!
autocmd InsertEnter * setlocal nohlsearch
augroup END
augroup UserStatusline augroup UserStatusline
autocmd! autocmd!
autocmd BufEnter,WinEnter,TermOpen * setlocal statusline=%!ActiveStatus() autocmd BufEnter,WinEnter,TermOpen * setlocal statusline=%!ActiveStatus()

View file

@ -115,6 +115,8 @@ hi NonText guifg=#465457
hi SpecialKey guifg=#465457 hi SpecialKey guifg=#465457
hi Conceal guifg=#f92672 guibg=bg hi Conceal guifg=#f92672 guibg=bg
hi Searchlight guifg=#FF00FF guibg=#000000
" Must be at the end, because of ctermbg=234 bug. " Must be at the end, because of ctermbg=234 bug.
" https://groups.google.com/forum/#!msg/vim_dev/afPqwAFNdrU/nqh6tOM87QUJ " https://groups.google.com/forum/#!msg/vim_dev/afPqwAFNdrU/nqh6tOM87QUJ
set background=dark set background=dark

View file

@ -92,5 +92,7 @@ hi link MoreMsg Question
hi ModeMsg guifg=#F6F3E8 guibg=NONE gui=NONE hi ModeMsg guifg=#F6F3E8 guibg=NONE gui=NONE
hi Searchlight guifg=#FF00FF guibg=#000000
" Custom stuff " Custom stuff
hi Modified guifg=black guibg=#FFA500 hi Modified guifg=black guibg=#FFA500

View file

@ -5,7 +5,7 @@ Plug 'justinmk/vim-sneak'
" Search " Search
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim' Plug 'junegunn/fzf.vim'
Plug 'haya14busa/incsearch.vim' Plug 'PeterRincker/vim-searchlight'
Plug 'wincent/ferret' Plug 'wincent/ferret'
" Remove extraneous whitespace when edit mode is exited " Remove extraneous whitespace when edit mode is exited
Plug 'axelf4/vim-strip-trailing-whitespace' Plug 'axelf4/vim-strip-trailing-whitespace'

View file

@ -126,11 +126,21 @@ nnoremap <silent> <LocalLeader> :<C-U>WhichKey ','<CR>
nnoremap <C-\> :vsp <CR>:exec("tag ".expand("<cword>"))<CR> nnoremap <C-\> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
nnoremap <A-]> :sp <CR>:exec("tag ".expand("<cword>"))<CR> nnoremap <A-]> :sp <CR>:exec("tag ".expand("<cword>"))<CR>
" Use Tab & S-Tab instead of C-g and C-t for incsearch
cno <expr> <Tab> getcmdtype() =~ '[?/]' ? '<C-g>' : feedkeys('<Tab>', 'int')[1]
cno <expr> <S-Tab> getcmdtype() =~ '[?/]' ? '<C-t>' : feedkeys('<S-Tab>', 'int')[1]
nnoremap <silent> <Leader>n :nohlsearch<CR>
" Move across wrapped lines like regular lines " Move across wrapped lines like regular lines
" Go to the first non-blank character of a line " Go to the first non-blank character of a line
noremap 0 ^ noremap 0 ^
" Just in case you need to go to the very beginning of a line " Just in case you need to go to the very beginning of a line
noremap ^ 0 noremap ^ 0
" Centre the window on each search movement
nnoremap n nzz
nnoremap N Nzz
vnoremap n nzz
vnoremap N Nzz
" Make dot work on visually selected lines " Make dot work on visually selected lines
vnoremap . :norm.<CR> vnoremap . :norm.<CR>