nvim: Miscellaneous cleanups & improvements

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
This commit is contained in:
Sanchayan Maity 2020-01-06 19:39:10 +05:30
parent ef32c9c6d9
commit a3777e9d45

View file

@ -117,7 +117,7 @@ let maplocalleader=","
set colorcolumn=80 " Highlight 80th column
set laststatus=2 " Always show status bar
set updatetime=500 " Let plugins show effects after 500ms
set updatetime=300 " Let plugins show effects after 500ms
set mouse-=a " Disable mouse click to go to position
set encoding=utf-8
set exrc " Allow loading local .nvimrc files
@ -147,6 +147,7 @@ set nowritebackup " only in case you don't want a backup file while editin
set noswapfile " no swap files
set foldmethod=syntax " Create folds based on files syntax
set nofoldenable " Open folds by default
set undofile " Enable undo persistence across sessions
" Wild menu
set wildmenu
@ -466,6 +467,8 @@ augroup END
augroup terminal_job
au!
au TermOpen * setlocal statusline=%{b:terminal_job_id}
au TermOpen * startinsert
au TermOpen * setlocal listchars= nonumber norelativenumber
augroup END
augroup indentation_defaults
@ -473,10 +476,10 @@ augroup indentation_defaults
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
au BufNewFile,BufRead *.lua setlocal noet ts=4 sw=4 sts=4
au BufNewFile,BufRead *.py setlocal tabstop=4 softtabstop=4 shiftwidth=4 textwidth=80 smarttab expandtab
au BufRead,BufNewFile *.vim setlocal noet ts=4 sw=4 sts=4
au BufRead,BufNewFile *.txt setlocal noet ts=4 sw=4
au BufRead,BufNewFile *.lua setlocal noet ts=4 sw=4 sts=4
au BufRead,BufNewFile *.py setlocal tabstop=4 softtabstop=4 shiftwidth=4 textwidth=80 smarttab expandtab
au BufRead,BufNewFile */gst-*/*.[ch] set et sw=2
au BufRead,BufNewFile */gstreamer-*/*.[ch] set et sw=2
au BufRead,BufNewFile */pulseaudio/*.[ch] set et sw=4 tw=128
@ -679,7 +682,7 @@ function! Cscope(option, query)
\ '--multi', '--bind', 'alt-a:select-all,alt-d:deselect-all',
\ '--color', 'info:144,prompt:161,spinner:135,pointer:135,marker:118',
\ '--color', 'fg:252,bg:233,hl:67,fg+:252,bg+:235,hl+:81'],
\ 'window': 'call FloatingFZF()'
\ 'window': 'call CreateCentredFloatingWindow()'
\ }
function! opts.sink(lines)
let data = split(a:lines)
@ -726,24 +729,29 @@ function! NvimGdbNoTKeymaps()
endfunction
let $FZF_DEFAULT_OPTS='--layout=reverse'
let g:fzf_layout = { 'window': 'call FloatingFZF()' }
function! FloatingFZF()
let buf = nvim_create_buf(v:false, v:true)
let height = float2nr(&lines * 0.4)
let width = float2nr(&columns * 0.8)
let horizontal = float2nr((&columns - width) / 2)
let vertical = float2nr((&columns - width) / 2)
let g:fzf_layout = { 'window': 'call CreateCentredFloatingWindow()' }
" Stolen from https://github.com/camspiers/dotfiles/blob/master/files/.config/nvim/init.vim
function! CreateCentredFloatingWindow()
let width = float2nr(&columns * 0.8)
let height = float2nr(&lines * 0.4)
let top = ((&lines - height) / 2) - 1
let left = (&columns - width) / 2
let opts = {'relative': 'editor', 'row': top, 'col': left, 'width': width, 'height': height, 'style': 'minimal'}
let opts = {
\ 'relative': 'editor',
\ 'row': vertical,
\ 'col': horizontal,
\ 'width': width,
\ 'height': height
\ }
" open the new window, floating, and enter to it
call nvim_open_win(buf, v:true, opts)
let top = "╭" . repeat("─", width - 2) . "╮"
let mid = "│" . repeat(" ", width - 2) . "│"
let bot = "╰" . repeat("─", width - 2) . "╯"
let lines = [top] + repeat([mid], height - 2) + [bot]
let s:buf = nvim_create_buf(v:false, v:true)
call nvim_buf_set_lines(s:buf, 0, -1, v:true, lines)
call nvim_open_win(s:buf, v:true, opts)
set winhl=Normal:Floating
let opts.row += 1
let opts.height -= 2
let opts.col += 2
let opts.width -= 4
call nvim_open_win(nvim_create_buf(v:false, v:true), v:true, opts)
au BufWipeout <buffer> exe 'bw '.s:buf
endfunction
function! s:incsearch_config(...) abort