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>
command! -bang -nargs=* GGrep
\ call fzf#vim#grep(
\ 'git grep --line-number '.shellescape(<q-args>), 0,
\ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)
\ call fzf#vim#grep(
\ 'git grep --line-number '.shellescape(<q-args>), 0,
\ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)
" --------------------------- Autocmd groups ---------------------------------
augroup vimplug_maps
au!
au FileType vim nmap pg :PlugUpgrade<CR>
au FileType vim nmap pd :PlugUpdate<CR>
au FileType vim nmap pc :PlugClean<CR>
au FileType vim nmap pr :so %<CR>
au!
au FileType vim nmap pg :PlugUpgrade<CR>
au FileType vim nmap pd :PlugUpdate<CR>
au FileType vim nmap pc :PlugClean<CR>
au FileType vim nmap pr :so %<CR>
augroup END
augroup haskell_maps
au!
" https://www.reddit.com/r/neovim/comments/es8wn7/haskell_makeprg_for_stack_build/
" https://github.com/maxigit/vimrc/tree/2020/compiler
au FileType haskell compiler stack
au FileType haskell setlocal makeprg=stack\ build
au FileType haskell setlocal keywordprg=:Hoogle
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>g :Ghcid<CR>
au FileType haskell nmap <LocalLeader>k :GhcidKill<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>i :exe ':HoogleInfo ' . expand('<cword>')<CR>
au!
" https://www.reddit.com/r/neovim/comments/es8wn7/haskell_makeprg_for_stack_build/
" https://github.com/maxigit/vimrc/tree/2020/compiler
au FileType haskell compiler stack
au FileType haskell setlocal makeprg=stack\ build
au FileType haskell setlocal keywordprg=:Hoogle
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>g :Ghcid<CR>
au FileType haskell nmap <LocalLeader>k :GhcidKill<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>i :exe ':HoogleInfo ' . expand('<cword>')<CR>
au FileType haskell nnoremap <buffer><silent> ]] :call JumpHaskellFunction(0)<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(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 inoremap <buffer> ;; <ESC>:call MakeArrow(1)<CR>
au FileType haskell inoremap <buffer> ;: <ESC>:call MakeArrow(0)<CR>
augroup END
augroup c_maps
au!
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>cr :cs reset<CR>
au!
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>cr :cs reset<CR>
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>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>d <Plug>(quickr_cscope_functions)
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>e <Plug>(quickr_cscope_egrep)
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>a <Plug>(quickr_cscope_assignments)
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>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>d <Plug>(quickr_cscope_functions)
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>e <Plug>(quickr_cscope_egrep)
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>a <Plug>(quickr_cscope_assignments)
augroup END
augroup rust_maps
au!
" Taken from http://seenaburns.com/vim-setup-for-rust/
" Neomake
" 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
" disable neomake, so BufEnter reenables when you enter another buffer.
let s:quitting = 0
au FileType rust au QuitPre let s:quitting = 1
au FileType rust au BufEnter let s:quitting = 0
au FileType rust au BufWritePost if ! s:quitting | Neomake | else | echom "Neomake disabled" | endif
au!
" Taken from http://seenaburns.com/vim-setup-for-rust/
" Neomake
" 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
" disable neomake, so BufEnter reenables when you enter another buffer.
let s:quitting = 0
au FileType rust au QuitPre let s:quitting = 1
au FileType rust au BufEnter let s:quitting = 0
au FileType rust au BufWritePost if ! s:quitting | Neomake | else | echom "Neomake disabled" | endif
augroup END
augroup rainbow_lisp
autocmd!
autocmd FileType lisp,clojure,scheme RainbowParentheses
autocmd!
autocmd FileType lisp,clojure,scheme RainbowParentheses
augroup END
" Toggles search highlighting off/on according to current mode. Source: http://blog.sanctum.geek.nz/vim-search-highlighting/
augroup toggle_search
autocmd!
autocmd InsertEnter * setlocal nohlsearch
autocmd InsertLeave * setlocal hlsearch
autocmd!
autocmd InsertEnter * setlocal nohlsearch
autocmd InsertLeave * setlocal hlsearch
augroup END
augroup quickfix
au!
" Close QF window if it is last window
au WinEnter * if winnr('$') == 1 && &buftype == "quickfix"|q|endif
" Existing bindings for QFGrep
" <Leader>g input pattern to do further filtering
" <Leader>v input pattern to do further inverted filtering
" <Leader>r restore the Quickfix/location list with original entries
au!
" Close QF window if it is last window
au WinEnter * if winnr('$') == 1 && &buftype == "quickfix"|q|endif
" Existing bindings for QFGrep
" <Leader>g input pattern to do further filtering
" <Leader>v input pattern to do further inverted filtering
" <Leader>r restore the Quickfix/location list with original entries
augroup END
augroup terminal_job
au!
au TermOpen * startinsert
au TermOpen * setlocal listchars= nonumber norelativenumber
au!
au TermOpen * startinsert
au TermOpen * setlocal listchars= nonumber norelativenumber
augroup END
augroup spell_check
au!
autocmd FileType gitcommit setlocal spell textwidth=72
autocmd BufRead,BufNewFile *.md,*.txt setlocal spell
au!
autocmd FileType gitcommit setlocal spell textwidth=72
autocmd BufRead,BufNewFile *.md,*.txt setlocal spell
augroup END
augroup ResizeWindowsProportionally
au!
autocmd VimResized * :wincmd =
au!
autocmd VimResized * :wincmd =
augroup END
augroup LSP
au!
nnoremap <LocalLeader>le :call lsp#enable()<CR>
nnoremap <LocalLeader>ld :call lsp#disable()<CR>
nnoremap <LocalLeader>lh :LspStopServer()<CR>
nnoremap <LocalLeader>ls :LspStatus<CR>
au User lsp_server_init call s:on_lsp_server_init()
au!
nnoremap <LocalLeader>le :call lsp#enable()<CR>
nnoremap <LocalLeader>ld :call lsp#disable()<CR>
nnoremap <LocalLeader>lh :LspStopServer()<CR>
nnoremap <LocalLeader>ls :LspStatus<CR>
au User lsp_server_init call s:on_lsp_server_init()
augroup END
augroup VimLspSettings
@ -510,27 +510,27 @@ augroup VimLspSettings
augroup END
augroup AsyncCompleteSetup
au!
au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#tags#get_source_options({
\ 'name': 'tags',
\ 'whitelist': ['c', 'haskell'],
\ 'completor': function('asyncomplete#sources#tags#completor'),
\ }))
au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#buffer#get_source_options({
\ 'name': 'buffer',
\ 'whitelist': ['*'],
\ 'blacklist': ['go'],
\ 'completor': function('asyncomplete#sources#buffer#completor'),
\ 'config': {
\ 'max_buffer_size': 5000000,
\ },
\ }))
au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#file#get_source_options({
\ 'name': 'file',
\ 'whitelist': ['*'],
\ 'priority': 10,
\ 'completor': function('asyncomplete#sources#file#completor')
\ }))
au!
au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#tags#get_source_options({
\ 'name': 'tags',
\ 'whitelist': ['c', 'haskell'],
\ 'completor': function('asyncomplete#sources#tags#completor'),
\ }))
au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#buffer#get_source_options({
\ 'name': 'buffer',
\ 'whitelist': ['*'],
\ 'blacklist': ['go'],
\ 'completor': function('asyncomplete#sources#buffer#completor'),
\ 'config': {
\ 'max_buffer_size': 5000000,
\ },
\ }))
au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#file#get_source_options({
\ 'name': 'file',
\ 'whitelist': ['*'],
\ 'priority': 10,
\ 'completor': function('asyncomplete#sources#file#completor')
\ }))
augroup END
" --------------------------- Plugin settings --------------------------------
@ -556,14 +556,14 @@ let g:haskell_indent_case_alternative = 1
let g:cabal_indent_section = 2
" Either check empty($IN_NIX_SHELL) for nix specific or executable('ghcid')
if executable('ghcid')
let g:ghcid_command = 'ghcid'
let g:ghcid_command = 'ghcid'
else
let g:ghcid_command = 'stack exec -- ghcid'
let g:ghcid_command = 'stack exec -- ghcid'
endif
if executable('hoogle')
let g:hoogle_search_bin = 'hoogle'
let g:hoogle_search_bin = 'hoogle'
else
let g:hoogle_search_bin = 'stack exec -- hoogle'
let g:hoogle_search_bin = 'stack exec -- hoogle'
endif
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_c_enabled_makers = ['gcc']
let g:neomake_c_gcc_maker = {
\ 'exe': 'gcc',
\ 'args': ['-Wall', '-Iinclude', '-Wextra', '-Weverything', '-pedantic', '-Wno-sign-conversion'],
\ }
\ '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
@ -618,14 +618,14 @@ let g:workspace_session_disable_on_args = 1
let g:toggle_list_no_mappings = 1
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",
\ }
\ 'key_next': 'n',
\ 'key_step': 's',
\ 'key_finish': 'f',
\ 'key_continue': 'c',
\ 'key_until': 'u',
\ 'key_breakpoint': 'b',
\ 'set_tkeymaps': "NvimGdbNoTKeymaps",
\ }
let g:mapleader = "\<Space>"
let g:maplocalleader = ','
@ -657,15 +657,15 @@ let g:lsp_auto_enable = 0
" Vista
let g:vista_executive_for = {
\ 'c': 'ctags',
\ 'haskell': 'vim_lsp',
\ 'rust': 'vim_lsp',
\ 'purescript': 'vim_lsp',
\ 'python': 'vim_lsp',
\ }
\ 'c': 'ctags',
\ 'haskell': 'vim_lsp',
\ 'rust': 'vim_lsp',
\ 'purescript': 'vim_lsp',
\ 'python': 'vim_lsp',
\ }
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
let g:indentLine_setColors = 0
@ -698,87 +698,87 @@ endfunction
" 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 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 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
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
return incsearch#util#deepextend(deepcopy({
\ 'modules': [incsearch#config#easymotion#module({'overwin': 1})],
\ 'keymap': {
\ "\<CR>": '<Over>(easymotion)'
\ },
\ 'is_expr': 0
\ }), get(a:, 1, {}))
return incsearch#util#deepextend(deepcopy({
\ 'modules': [incsearch#config#easymotion#module({'overwin': 1})],
\ 'keymap': {
\ "\<CR>": '<Over>(easymotion)'
\ },
\ 'is_expr': 0
\ }), get(a:, 1, {}))
endfunction
function! JumpHaskellFunction(reverse)
call search('\C[[:alnum:]]*\s*::', a:reverse ? 'bW' : 'W')
call search('\C[[:alnum:]]*\s*::', a:reverse ? 'bW' : 'W')
endfunction
function! MakeArrow(type)
if a:type
if (matchstr(getline('.'), '\%' . col('.') . 'c.') ==? ' ')
exe "norm! a-> "
else
exe "norm! a -> "
endif
exe "startreplace"
if a:type
if (matchstr(getline('.'), '\%' . col('.') . 'c.') ==? ' ')
exe "norm! a-> "
else
if (matchstr(getline('.'), '\%' . col('.') . 'c.') ==? ' ')
exe "norm! a=> "
else
exe "norm! a => "
endif
exe "startreplace"
exe "norm! a -> "
endif
exe "startreplace"
else
if (matchstr(getline('.'), '\%' . col('.') . 'c.') ==? ' ')
exe "norm! a=> "
else
exe "norm! a => "
endif
exe "startreplace"
endif
endfunction
function! s:on_lsp_server_init() abort
setlocal omnifunc=lsp#complete
setlocal signcolumn=yes
setlocal omnifunc=lsp#complete
setlocal signcolumn=yes
" Always expected to work
nmap <buffer> gd :LspDefinition<CR>
nmap <buffer> gpd :LspPeekDefinition<CR>
nmap <buffer> gk :LspHover<CR>
" Always expected to work
nmap <buffer> gd :LspDefinition<CR>
nmap <buffer> gpd :LspPeekDefinition<CR>
nmap <buffer> gk :LspHover<CR>
" May or may not be available depending on language server
nmap <buffer> gx :LspReferences<CR>
nmap <buffer> gr :LspRename<CR>
nmap <buffer> <LocalLeader>ca :LspCodeAction<CR>
nmap <buffer> <LocalLeader>dd :LspDocumentDiagnostics<CR>
nmap <buffer> <LocalLeader>df :LspDocumentFormat<CR>
nmap <buffer> <LocalLeader>rf :LspDocumentRangeFormat<CR>
nmap <buffer> <LocalLeader>ds :LspDocumentSymbol<CR>
nmap <buffer> <LocalLeader>di :LspImplementation<CR>
nmap <buffer> <LocalLeader>nd :LspNextDiagnostic<CR>
nmap <buffer> <LocalLeader>pd :LspPreviousDiagnostic<CR>
nmap <buffer> <LocalLeader>ne :LspNextError<CR>
nmap <buffer> <LocalLeader>pe :LspPreviousError<CR>
nmap <buffer> <LocalLeader>nr :LspNextReference<CR>
nmap <buffer> <LocalLeader>pr :LspPreviousReference<CR>
nmap <buffer> <LocalLeader>nw :LspNextWarning<CR>
nmap <buffer> <LocalLeader>pw :LspPreviousWarning<CR>
nmap <buffer> <LocalLeader>dt :LspTypeDefinition<CR>
nmap <buffer> <LocalLeader>td :LspPeekTypeDefinition<CR>
nmap <buffer> <LocalLeader>pi :LspPeekImplementation<CR>
" May or may not be available depending on language server
nmap <buffer> gx :LspReferences<CR>
nmap <buffer> gr :LspRename<CR>
nmap <buffer> <LocalLeader>ca :LspCodeAction<CR>
nmap <buffer> <LocalLeader>dd :LspDocumentDiagnostics<CR>
nmap <buffer> <LocalLeader>df :LspDocumentFormat<CR>
nmap <buffer> <LocalLeader>rf :LspDocumentRangeFormat<CR>
nmap <buffer> <LocalLeader>ds :LspDocumentSymbol<CR>
nmap <buffer> <LocalLeader>di :LspImplementation<CR>
nmap <buffer> <LocalLeader>nd :LspNextDiagnostic<CR>
nmap <buffer> <LocalLeader>pd :LspPreviousDiagnostic<CR>
nmap <buffer> <LocalLeader>ne :LspNextError<CR>
nmap <buffer> <LocalLeader>pe :LspPreviousError<CR>
nmap <buffer> <LocalLeader>nr :LspNextReference<CR>
nmap <buffer> <LocalLeader>pr :LspPreviousReference<CR>
nmap <buffer> <LocalLeader>nw :LspNextWarning<CR>
nmap <buffer> <LocalLeader>pw :LspPreviousWarning<CR>
nmap <buffer> <LocalLeader>dt :LspTypeDefinition<CR>
nmap <buffer> <LocalLeader>td :LspPeekTypeDefinition<CR>
nmap <buffer> <LocalLeader>pi :LspPeekImplementation<CR>
endfunction