diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim index c4203a9..4a82d37 100644 --- a/nvim/.config/nvim/init.vim +++ b/nvim/.config/nvim/init.vim @@ -363,118 +363,118 @@ nnoremap ab :AnyJumpBack nnoremap al :AnyJumpLastResults command! -bang -nargs=* GGrep - \ call fzf#vim#grep( - \ 'git grep --line-number '.shellescape(), 0, - \ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), 0) + \ call fzf#vim#grep( + \ 'git grep --line-number '.shellescape(), 0, + \ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), 0) " --------------------------- Autocmd groups --------------------------------- augroup vimplug_maps - au! - au FileType vim nmap pg :PlugUpgrade - au FileType vim nmap pd :PlugUpdate - au FileType vim nmap pc :PlugClean - au FileType vim nmap pr :so % + au! + au FileType vim nmap pg :PlugUpgrade + au FileType vim nmap pd :PlugUpdate + au FileType vim nmap pc :PlugClean + au FileType vim nmap pr :so % 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 b :Neomake! - au FileType haskell nmap t :NeomakeSh stack exec -- hasktags -x -c . - au FileType haskell nmap g :Ghcid - au FileType haskell nmap k :GhcidKill - au FileType haskell nmap c :HoogleClose - au FileType haskell nmap o :exe ':Hoogle ' . expand('') - au FileType haskell nmap i :exe ':HoogleInfo ' . expand('') + 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 b :Neomake! + au FileType haskell nmap t :NeomakeSh stack exec -- hasktags -x -c . + au FileType haskell nmap g :Ghcid + au FileType haskell nmap k :GhcidKill + au FileType haskell nmap c :HoogleClose + au FileType haskell nmap o :exe ':Hoogle ' . expand('') + au FileType haskell nmap i :exe ':HoogleInfo ' . expand('') - au FileType haskell nnoremap ]] :call JumpHaskellFunction(0) - au FileType haskell nnoremap [[ :call JumpHaskellFunction(1) - au FileType haskell inoremap ;; :call MakeArrow(1) - au FileType haskell inoremap ;: :call MakeArrow(0) + au FileType haskell nnoremap ]] :call JumpHaskellFunction(0) + au FileType haskell nnoremap [[ :call JumpHaskellFunction(1) + au FileType haskell inoremap ;; :call MakeArrow(1) + au FileType haskell inoremap ;: :call MakeArrow(0) augroup END augroup c_maps - au! - au FileType c nmap ct :NeomakeSh ctags -R . - au FileType c nmap cu :NeomakeSh cscope -bqR - au FileType c nmap cr :cs reset + au! + au FileType c nmap ct :NeomakeSh ctags -R . + au FileType c nmap cu :NeomakeSh cscope -bqR + au FileType c nmap cr :cs reset - au FileType c nmap s (quickr_cscope_symbols) - au FileType c nmap g (quickr_cscope_global) - au FileType c nmap h (quickr_cscope_global_split) - au FileType c nmap v (quickr_cscope_global_vert_split) - au FileType c nmap d (quickr_cscope_functions) - au FileType c nmap c (quickr_cscope_callers) - au FileType c nmap t (quickr_cscope_text) - au FileType c nmap e (quickr_cscope_egrep) - au FileType c nmap f (quickr_cscope_files) - au FileType c nmap i (quickr_cscope_includes) - au FileType c nmap a (quickr_cscope_assignments) + au FileType c nmap s (quickr_cscope_symbols) + au FileType c nmap g (quickr_cscope_global) + au FileType c nmap h (quickr_cscope_global_split) + au FileType c nmap v (quickr_cscope_global_vert_split) + au FileType c nmap d (quickr_cscope_functions) + au FileType c nmap c (quickr_cscope_callers) + au FileType c nmap t (quickr_cscope_text) + au FileType c nmap e (quickr_cscope_egrep) + au FileType c nmap f (quickr_cscope_files) + au FileType c nmap i (quickr_cscope_includes) + au FileType c nmap a (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 - " g input pattern to do further filtering - " v input pattern to do further inverted filtering - " 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 + " g input pattern to do further filtering + " v input pattern to do further inverted filtering + " 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 le :call lsp#enable() - nnoremap ld :call lsp#disable() - nnoremap lh :LspStopServer() - nnoremap ls :LspStatus - au User lsp_server_init call s:on_lsp_server_init() + au! + nnoremap le :call lsp#enable() + nnoremap ld :call lsp#disable() + nnoremap lh :LspStopServer() + nnoremap ls :LspStatus + 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 = "\" 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 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 exe 'bw '.s:buf endfunction function! s:incsearch_config(...) abort - return incsearch#util#deepextend(deepcopy({ - \ 'modules': [incsearch#config#easymotion#module({'overwin': 1})], - \ 'keymap': { - \ "\": '(easymotion)' - \ }, - \ 'is_expr': 0 - \ }), get(a:, 1, {})) + return incsearch#util#deepextend(deepcopy({ + \ 'modules': [incsearch#config#easymotion#module({'overwin': 1})], + \ 'keymap': { + \ "\": '(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 gd :LspDefinition - nmap gpd :LspPeekDefinition - nmap gk :LspHover + " Always expected to work + nmap gd :LspDefinition + nmap gpd :LspPeekDefinition + nmap gk :LspHover - " May or may not be available depending on language server - nmap gx :LspReferences - nmap gr :LspRename - nmap ca :LspCodeAction - nmap dd :LspDocumentDiagnostics - nmap df :LspDocumentFormat - nmap rf :LspDocumentRangeFormat - nmap ds :LspDocumentSymbol - nmap di :LspImplementation - nmap nd :LspNextDiagnostic - nmap pd :LspPreviousDiagnostic - nmap ne :LspNextError - nmap pe :LspPreviousError - nmap nr :LspNextReference - nmap pr :LspPreviousReference - nmap nw :LspNextWarning - nmap pw :LspPreviousWarning - nmap dt :LspTypeDefinition - nmap td :LspPeekTypeDefinition - nmap pi :LspPeekImplementation + " May or may not be available depending on language server + nmap gx :LspReferences + nmap gr :LspRename + nmap ca :LspCodeAction + nmap dd :LspDocumentDiagnostics + nmap df :LspDocumentFormat + nmap rf :LspDocumentRangeFormat + nmap ds :LspDocumentSymbol + nmap di :LspImplementation + nmap nd :LspNextDiagnostic + nmap pd :LspPreviousDiagnostic + nmap ne :LspNextError + nmap pe :LspPreviousError + nmap nr :LspNextReference + nmap pr :LspPreviousReference + nmap nw :LspNextWarning + nmap pw :LspPreviousWarning + nmap dt :LspTypeDefinition + nmap td :LspPeekTypeDefinition + nmap pi :LspPeekImplementation endfunction