nvim: Fix indentation

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
This commit is contained in:
Sanchayan Maity 2020-02-28 12:56:49 +05:30
parent 9315523206
commit 065a281e7e

View file

@ -363,118 +363,118 @@ nnoremap ab :AnyJumpBack<CR>
nnoremap al :AnyJumpLastResults<CR> nnoremap al :AnyJumpLastResults<CR>
command! -bang -nargs=* GGrep command! -bang -nargs=* GGrep
\ call fzf#vim#grep( \ call fzf#vim#grep(
\ 'git grep --line-number '.shellescape(<q-args>), 0, \ 'git grep --line-number '.shellescape(<q-args>), 0,
\ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0) \ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)
" --------------------------- Autocmd groups --------------------------------- " --------------------------- Autocmd groups ---------------------------------
augroup vimplug_maps augroup vimplug_maps
au! au!
au FileType vim nmap pg :PlugUpgrade<CR> au FileType vim nmap pg :PlugUpgrade<CR>
au FileType vim nmap pd :PlugUpdate<CR> au FileType vim nmap pd :PlugUpdate<CR>
au FileType vim nmap pc :PlugClean<CR> au FileType vim nmap pc :PlugClean<CR>
au FileType vim nmap pr :so %<CR> au FileType vim nmap pr :so %<CR>
augroup END augroup END
augroup haskell_maps augroup haskell_maps
au! au!
" https://www.reddit.com/r/neovim/comments/es8wn7/haskell_makeprg_for_stack_build/ " https://www.reddit.com/r/neovim/comments/es8wn7/haskell_makeprg_for_stack_build/
" https://github.com/maxigit/vimrc/tree/2020/compiler " https://github.com/maxigit/vimrc/tree/2020/compiler
au FileType haskell compiler stack au FileType haskell compiler stack
au FileType haskell setlocal makeprg=stack\ build au FileType haskell setlocal makeprg=stack\ build
au FileType haskell setlocal keywordprg=:Hoogle au FileType haskell setlocal keywordprg=:Hoogle
au FileType haskell nmap <LocalLeader>b :Neomake!<CR> au FileType haskell nmap <LocalLeader>b :Neomake!<CR>
au FileType haskell nmap <LocalLeader>t :NeomakeSh stack exec -- hasktags -x -c .<CR> au FileType haskell nmap <LocalLeader>t :NeomakeSh stack exec -- hasktags -x -c .<CR>
au FileType haskell nmap <LocalLeader>g :Ghcid<CR> au FileType haskell nmap <LocalLeader>g :Ghcid<CR>
au FileType haskell nmap <LocalLeader>k :GhcidKill<CR> au FileType haskell nmap <LocalLeader>k :GhcidKill<CR>
au FileType haskell nmap <LocalLeader>c :HoogleClose<CR> au FileType haskell nmap <LocalLeader>c :HoogleClose<CR>
au FileType haskell nmap <LocalLeader>o :exe ':Hoogle ' . expand('<cword>')<CR> au FileType haskell nmap <LocalLeader>o :exe ':Hoogle ' . expand('<cword>')<CR>
au FileType haskell nmap <LocalLeader>i :exe ':HoogleInfo ' . expand('<cword>')<CR> au FileType haskell nmap <LocalLeader>i :exe ':HoogleInfo ' . expand('<cword>')<CR>
au FileType haskell nnoremap <buffer><silent> ]] :call JumpHaskellFunction(0)<CR> au FileType haskell nnoremap <buffer><silent> ]] :call JumpHaskellFunction(0)<CR>
au FileType haskell nnoremap <buffer><silent> [[ :call JumpHaskellFunction(1)<CR> au FileType haskell nnoremap <buffer><silent> [[ :call JumpHaskellFunction(1)<CR>
au FileType haskell inoremap <buffer> ;; <ESC>:call MakeArrow(1)<CR> au FileType haskell inoremap <buffer> ;; <ESC>:call MakeArrow(1)<CR>
au FileType haskell inoremap <buffer> ;: <ESC>:call MakeArrow(0)<CR> au FileType haskell inoremap <buffer> ;: <ESC>:call MakeArrow(0)<CR>
augroup END augroup END
augroup c_maps augroup c_maps
au! au!
au FileType c nmap <LocalLeader>ct :NeomakeSh ctags -R .<CR> au FileType c nmap <LocalLeader>ct :NeomakeSh ctags -R .<CR>
au FileType c nmap <LocalLeader>cu :NeomakeSh cscope -bqR<CR> au FileType c nmap <LocalLeader>cu :NeomakeSh cscope -bqR<CR>
au FileType c nmap <LocalLeader>cr :cs reset<CR> au FileType c nmap <LocalLeader>cr :cs reset<CR>
au FileType c nmap <silent> <LocalLeader>s <Plug>(quickr_cscope_symbols) au FileType c nmap <silent> <LocalLeader>s <Plug>(quickr_cscope_symbols)
au FileType c nmap <silent> <LocalLeader>g <Plug>(quickr_cscope_global) au FileType c nmap <silent> <LocalLeader>g <Plug>(quickr_cscope_global)
au FileType c nmap <silent> <LocalLeader>h <Plug>(quickr_cscope_global_split) au FileType c nmap <silent> <LocalLeader>h <Plug>(quickr_cscope_global_split)
au FileType c nmap <silent> <LocalLeader>v <Plug>(quickr_cscope_global_vert_split) au FileType c nmap <silent> <LocalLeader>v <Plug>(quickr_cscope_global_vert_split)
au FileType c nmap <silent> <LocalLeader>d <Plug>(quickr_cscope_functions) au FileType c nmap <silent> <LocalLeader>d <Plug>(quickr_cscope_functions)
au FileType c nmap <silent> <LocalLeader>c <Plug>(quickr_cscope_callers) au FileType c nmap <silent> <LocalLeader>c <Plug>(quickr_cscope_callers)
au FileType c nmap <silent> <LocalLeader>t <Plug>(quickr_cscope_text) au FileType c nmap <silent> <LocalLeader>t <Plug>(quickr_cscope_text)
au FileType c nmap <silent> <LocalLeader>e <Plug>(quickr_cscope_egrep) au FileType c nmap <silent> <LocalLeader>e <Plug>(quickr_cscope_egrep)
au FileType c nmap <silent> <LocalLeader>f <Plug>(quickr_cscope_files) au FileType c nmap <silent> <LocalLeader>f <Plug>(quickr_cscope_files)
au FileType c nmap <silent> <LocalLeader>i <Plug>(quickr_cscope_includes) au FileType c nmap <silent> <LocalLeader>i <Plug>(quickr_cscope_includes)
au FileType c nmap <silent> <LocalLeader>a <Plug>(quickr_cscope_assignments) au FileType c nmap <silent> <LocalLeader>a <Plug>(quickr_cscope_assignments)
augroup END augroup END
augroup rust_maps augroup rust_maps
au! au!
" Taken from http://seenaburns.com/vim-setup-for-rust/ " Taken from http://seenaburns.com/vim-setup-for-rust/
" Neomake " Neomake
" Gross hack to stop Neomake running when exitting because it creates a zombie cargo check process " Gross hack to stop Neomake running when exitting because it creates a zombie cargo check process
" which holds the lock and never exits. But then, if you only have QuitPre, closing one pane will " which holds the lock and never exits. But then, if you only have QuitPre, closing one pane will
" disable neomake, so BufEnter reenables when you enter another buffer. " disable neomake, so BufEnter reenables when you enter another buffer.
let s:quitting = 0 let s:quitting = 0
au FileType rust au QuitPre let s:quitting = 1 au FileType rust au QuitPre let s:quitting = 1
au FileType rust au BufEnter let s:quitting = 0 au FileType rust au BufEnter let s:quitting = 0
au FileType rust au BufWritePost if ! s:quitting | Neomake | else | echom "Neomake disabled" | endif au FileType rust au BufWritePost if ! s:quitting | Neomake | else | echom "Neomake disabled" | endif
augroup END augroup END
augroup rainbow_lisp augroup rainbow_lisp
autocmd! autocmd!
autocmd FileType lisp,clojure,scheme RainbowParentheses autocmd FileType lisp,clojure,scheme RainbowParentheses
augroup END augroup END
" Toggles search highlighting off/on according to current mode. Source: http://blog.sanctum.geek.nz/vim-search-highlighting/ " Toggles search highlighting off/on according to current mode. Source: http://blog.sanctum.geek.nz/vim-search-highlighting/
augroup toggle_search augroup toggle_search
autocmd! autocmd!
autocmd InsertEnter * setlocal nohlsearch autocmd InsertEnter * setlocal nohlsearch
autocmd InsertLeave * setlocal hlsearch autocmd InsertLeave * setlocal hlsearch
augroup END augroup END
augroup quickfix augroup quickfix
au! au!
" Close QF window if it is last window " Close QF window if it is last window
au WinEnter * if winnr('$') == 1 && &buftype == "quickfix"|q|endif au WinEnter * if winnr('$') == 1 && &buftype == "quickfix"|q|endif
" Existing bindings for QFGrep " Existing bindings for QFGrep
" <Leader>g input pattern to do further filtering " <Leader>g input pattern to do further filtering
" <Leader>v input pattern to do further inverted filtering " <Leader>v input pattern to do further inverted filtering
" <Leader>r restore the Quickfix/location list with original entries " <Leader>r restore the Quickfix/location list with original entries
augroup END augroup END
augroup terminal_job augroup terminal_job
au! au!
au TermOpen * startinsert au TermOpen * startinsert
au TermOpen * setlocal listchars= nonumber norelativenumber au TermOpen * setlocal listchars= nonumber norelativenumber
augroup END augroup END
augroup spell_check augroup spell_check
au! au!
autocmd FileType gitcommit setlocal spell textwidth=72 autocmd FileType gitcommit setlocal spell textwidth=72
autocmd BufRead,BufNewFile *.md,*.txt setlocal spell autocmd BufRead,BufNewFile *.md,*.txt setlocal spell
augroup END augroup END
augroup ResizeWindowsProportionally augroup ResizeWindowsProportionally
au! au!
autocmd VimResized * :wincmd = autocmd VimResized * :wincmd =
augroup END augroup END
augroup LSP augroup LSP
au! au!
nnoremap <LocalLeader>le :call lsp#enable()<CR> nnoremap <LocalLeader>le :call lsp#enable()<CR>
nnoremap <LocalLeader>ld :call lsp#disable()<CR> nnoremap <LocalLeader>ld :call lsp#disable()<CR>
nnoremap <LocalLeader>lh :LspStopServer()<CR> nnoremap <LocalLeader>lh :LspStopServer()<CR>
nnoremap <LocalLeader>ls :LspStatus<CR> nnoremap <LocalLeader>ls :LspStatus<CR>
au User lsp_server_init call s:on_lsp_server_init() au User lsp_server_init call s:on_lsp_server_init()
augroup END augroup END
augroup VimLspSettings augroup VimLspSettings
@ -510,27 +510,27 @@ augroup VimLspSettings
augroup END augroup END
augroup AsyncCompleteSetup augroup AsyncCompleteSetup
au! au!
au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#tags#get_source_options({ au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#tags#get_source_options({
\ 'name': 'tags', \ 'name': 'tags',
\ 'whitelist': ['c', 'haskell'], \ 'whitelist': ['c', 'haskell'],
\ 'completor': function('asyncomplete#sources#tags#completor'), \ 'completor': function('asyncomplete#sources#tags#completor'),
\ })) \ }))
au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#buffer#get_source_options({ au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#buffer#get_source_options({
\ 'name': 'buffer', \ 'name': 'buffer',
\ 'whitelist': ['*'], \ 'whitelist': ['*'],
\ 'blacklist': ['go'], \ 'blacklist': ['go'],
\ 'completor': function('asyncomplete#sources#buffer#completor'), \ 'completor': function('asyncomplete#sources#buffer#completor'),
\ 'config': { \ 'config': {
\ 'max_buffer_size': 5000000, \ 'max_buffer_size': 5000000,
\ }, \ },
\ })) \ }))
au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#file#get_source_options({ au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#file#get_source_options({
\ 'name': 'file', \ 'name': 'file',
\ 'whitelist': ['*'], \ 'whitelist': ['*'],
\ 'priority': 10, \ 'priority': 10,
\ 'completor': function('asyncomplete#sources#file#completor') \ 'completor': function('asyncomplete#sources#file#completor')
\ })) \ }))
augroup END augroup END
" --------------------------- Plugin settings -------------------------------- " --------------------------- Plugin settings --------------------------------
@ -556,14 +556,14 @@ let g:haskell_indent_case_alternative = 1
let g:cabal_indent_section = 2 let g:cabal_indent_section = 2
" Either check empty($IN_NIX_SHELL) for nix specific or executable('ghcid') " Either check empty($IN_NIX_SHELL) for nix specific or executable('ghcid')
if executable('ghcid') if executable('ghcid')
let g:ghcid_command = 'ghcid' let g:ghcid_command = 'ghcid'
else else
let g:ghcid_command = 'stack exec -- ghcid' let g:ghcid_command = 'stack exec -- ghcid'
endif endif
if executable('hoogle') if executable('hoogle')
let g:hoogle_search_bin = 'hoogle' let g:hoogle_search_bin = 'hoogle'
else else
let g:hoogle_search_bin = 'stack exec -- hoogle' let g:hoogle_search_bin = 'stack exec -- hoogle'
endif endif
let g:hoogle_search_count = 30 let g:hoogle_search_count = 30
@ -600,9 +600,9 @@ let g:neomake_open_list = 2
let g:neomake_warning_sign = {'text': '?'} let g:neomake_warning_sign = {'text': '?'}
let g:neomake_c_enabled_makers = ['gcc'] let g:neomake_c_enabled_makers = ['gcc']
let g:neomake_c_gcc_maker = { let g:neomake_c_gcc_maker = {
\ 'exe': 'gcc', \ 'exe': 'gcc',
\ 'args': ['-Wall', '-Iinclude', '-Wextra', '-Weverything', '-pedantic', '-Wno-sign-conversion'], \ 'args': ['-Wall', '-Iinclude', '-Wextra', '-Weverything', '-pedantic', '-Wno-sign-conversion'],
\ } \ }
" Automatically detect style file and apply style to formatting " Automatically detect style file and apply style to formatting
let g:clang_format#detect_style_file = 1 let g:clang_format#detect_style_file = 1
@ -618,14 +618,14 @@ let g:workspace_session_disable_on_args = 1
let g:toggle_list_no_mappings = 1 let g:toggle_list_no_mappings = 1
let g:nvimgdb_config_override = { let g:nvimgdb_config_override = {
\ 'key_next': 'n', \ 'key_next': 'n',
\ 'key_step': 's', \ 'key_step': 's',
\ 'key_finish': 'f', \ 'key_finish': 'f',
\ 'key_continue': 'c', \ 'key_continue': 'c',
\ 'key_until': 'u', \ 'key_until': 'u',
\ 'key_breakpoint': 'b', \ 'key_breakpoint': 'b',
\ 'set_tkeymaps': "NvimGdbNoTKeymaps", \ 'set_tkeymaps': "NvimGdbNoTKeymaps",
\ } \ }
let g:mapleader = "\<Space>" let g:mapleader = "\<Space>"
let g:maplocalleader = ',' let g:maplocalleader = ','
@ -657,15 +657,15 @@ let g:lsp_auto_enable = 0
" Vista " Vista
let g:vista_executive_for = { let g:vista_executive_for = {
\ 'c': 'ctags', \ 'c': 'ctags',
\ 'haskell': 'vim_lsp', \ 'haskell': 'vim_lsp',
\ 'rust': 'vim_lsp', \ 'rust': 'vim_lsp',
\ 'purescript': 'vim_lsp', \ 'purescript': 'vim_lsp',
\ 'python': 'vim_lsp', \ 'python': 'vim_lsp',
\ } \ }
let g:vista_ctags_cmd = { let g:vista_ctags_cmd = {
\ 'haskell': 'stack exec -- hasktags -x -o - -c .', \ 'haskell': 'stack exec -- hasktags -x -o - -c .',
\ } \ }
" Allow nightfly theme to set indentline colors " Allow nightfly theme to set indentline colors
let g:indentLine_setColors = 0 let g:indentLine_setColors = 0
@ -698,87 +698,87 @@ endfunction
" Stolen from https://github.com/camspiers/dotfiles/blob/master/files/.config/nvim/init.vim " Stolen from https://github.com/camspiers/dotfiles/blob/master/files/.config/nvim/init.vim
function! CreateCentredFloatingWindow() function! CreateCentredFloatingWindow()
let width = float2nr(&columns * 0.8) let width = float2nr(&columns * 0.8)
let height = float2nr(&lines * 0.4) let height = float2nr(&lines * 0.4)
let top = ((&lines - height) / 2) - 1 let top = ((&lines - height) / 2) - 1
let left = (&columns - width) / 2 let left = (&columns - width) / 2
let opts = {'relative': 'editor', 'row': top, 'col': left, 'width': width, 'height': height, 'style': 'minimal'} let opts = {'relative': 'editor', 'row': top, 'col': left, 'width': width, 'height': height, 'style': 'minimal'}
let top = "╭" . repeat("─", width - 2) . "╮" let top = "╭" . repeat("─", width - 2) . "╮"
let mid = "│" . repeat(" ", width - 2) . "│" let mid = "│" . repeat(" ", width - 2) . "│"
let bot = "╰" . repeat("─", width - 2) . "╯" let bot = "╰" . repeat("─", width - 2) . "╯"
let lines = [top] + repeat([mid], height - 2) + [bot] let lines = [top] + repeat([mid], height - 2) + [bot]
let s:buf = nvim_create_buf(v:false, v:true) let s:buf = nvim_create_buf(v:false, v:true)
call nvim_buf_set_lines(s:buf, 0, -1, v:true, lines) call nvim_buf_set_lines(s:buf, 0, -1, v:true, lines)
call nvim_open_win(s:buf, v:true, opts) call nvim_open_win(s:buf, v:true, opts)
set winhl=Normal:Floating set winhl=Normal:Floating
let opts.row += 1 let opts.row += 1
let opts.height -= 2 let opts.height -= 2
let opts.col += 2 let opts.col += 2
let opts.width -= 4 let opts.width -= 4
call nvim_open_win(nvim_create_buf(v:false, v:true), v:true, opts) call nvim_open_win(nvim_create_buf(v:false, v:true), v:true, opts)
au BufWipeout <buffer> exe 'bw '.s:buf au BufWipeout <buffer> exe 'bw '.s:buf
endfunction endfunction
function! s:incsearch_config(...) abort function! s:incsearch_config(...) abort
return incsearch#util#deepextend(deepcopy({ return incsearch#util#deepextend(deepcopy({
\ 'modules': [incsearch#config#easymotion#module({'overwin': 1})], \ 'modules': [incsearch#config#easymotion#module({'overwin': 1})],
\ 'keymap': { \ 'keymap': {
\ "\<CR>": '<Over>(easymotion)' \ "\<CR>": '<Over>(easymotion)'
\ }, \ },
\ 'is_expr': 0 \ 'is_expr': 0
\ }), get(a:, 1, {})) \ }), get(a:, 1, {}))
endfunction endfunction
function! JumpHaskellFunction(reverse) function! JumpHaskellFunction(reverse)
call search('\C[[:alnum:]]*\s*::', a:reverse ? 'bW' : 'W') call search('\C[[:alnum:]]*\s*::', a:reverse ? 'bW' : 'W')
endfunction endfunction
function! MakeArrow(type) function! MakeArrow(type)
if a:type if a:type
if (matchstr(getline('.'), '\%' . col('.') . 'c.') ==? ' ') if (matchstr(getline('.'), '\%' . col('.') . 'c.') ==? ' ')
exe "norm! a-> " exe "norm! a-> "
else
exe "norm! a -> "
endif
exe "startreplace"
else else
if (matchstr(getline('.'), '\%' . col('.') . 'c.') ==? ' ') exe "norm! a -> "
exe "norm! a=> "
else
exe "norm! a => "
endif
exe "startreplace"
endif endif
exe "startreplace"
else
if (matchstr(getline('.'), '\%' . col('.') . 'c.') ==? ' ')
exe "norm! a=> "
else
exe "norm! a => "
endif
exe "startreplace"
endif
endfunction endfunction
function! s:on_lsp_server_init() abort function! s:on_lsp_server_init() abort
setlocal omnifunc=lsp#complete setlocal omnifunc=lsp#complete
setlocal signcolumn=yes setlocal signcolumn=yes
" Always expected to work " Always expected to work
nmap <buffer> gd :LspDefinition<CR> nmap <buffer> gd :LspDefinition<CR>
nmap <buffer> gpd :LspPeekDefinition<CR> nmap <buffer> gpd :LspPeekDefinition<CR>
nmap <buffer> gk :LspHover<CR> nmap <buffer> gk :LspHover<CR>
" May or may not be available depending on language server " May or may not be available depending on language server
nmap <buffer> gx :LspReferences<CR> nmap <buffer> gx :LspReferences<CR>
nmap <buffer> gr :LspRename<CR> nmap <buffer> gr :LspRename<CR>
nmap <buffer> <LocalLeader>ca :LspCodeAction<CR> nmap <buffer> <LocalLeader>ca :LspCodeAction<CR>
nmap <buffer> <LocalLeader>dd :LspDocumentDiagnostics<CR> nmap <buffer> <LocalLeader>dd :LspDocumentDiagnostics<CR>
nmap <buffer> <LocalLeader>df :LspDocumentFormat<CR> nmap <buffer> <LocalLeader>df :LspDocumentFormat<CR>
nmap <buffer> <LocalLeader>rf :LspDocumentRangeFormat<CR> nmap <buffer> <LocalLeader>rf :LspDocumentRangeFormat<CR>
nmap <buffer> <LocalLeader>ds :LspDocumentSymbol<CR> nmap <buffer> <LocalLeader>ds :LspDocumentSymbol<CR>
nmap <buffer> <LocalLeader>di :LspImplementation<CR> nmap <buffer> <LocalLeader>di :LspImplementation<CR>
nmap <buffer> <LocalLeader>nd :LspNextDiagnostic<CR> nmap <buffer> <LocalLeader>nd :LspNextDiagnostic<CR>
nmap <buffer> <LocalLeader>pd :LspPreviousDiagnostic<CR> nmap <buffer> <LocalLeader>pd :LspPreviousDiagnostic<CR>
nmap <buffer> <LocalLeader>ne :LspNextError<CR> nmap <buffer> <LocalLeader>ne :LspNextError<CR>
nmap <buffer> <LocalLeader>pe :LspPreviousError<CR> nmap <buffer> <LocalLeader>pe :LspPreviousError<CR>
nmap <buffer> <LocalLeader>nr :LspNextReference<CR> nmap <buffer> <LocalLeader>nr :LspNextReference<CR>
nmap <buffer> <LocalLeader>pr :LspPreviousReference<CR> nmap <buffer> <LocalLeader>pr :LspPreviousReference<CR>
nmap <buffer> <LocalLeader>nw :LspNextWarning<CR> nmap <buffer> <LocalLeader>nw :LspNextWarning<CR>
nmap <buffer> <LocalLeader>pw :LspPreviousWarning<CR> nmap <buffer> <LocalLeader>pw :LspPreviousWarning<CR>
nmap <buffer> <LocalLeader>dt :LspTypeDefinition<CR> nmap <buffer> <LocalLeader>dt :LspTypeDefinition<CR>
nmap <buffer> <LocalLeader>td :LspPeekTypeDefinition<CR> nmap <buffer> <LocalLeader>td :LspPeekTypeDefinition<CR>
nmap <buffer> <LocalLeader>pi :LspPeekImplementation<CR> nmap <buffer> <LocalLeader>pi :LspPeekImplementation<CR>
endfunction endfunction