From 84f874bd27877cb0f264f02e83a7c335472e429c Mon Sep 17 00:00:00 2001 From: Drezil Date: Fri, 12 May 2023 16:37:43 +0200 Subject: [PATCH] cleanup & added clojure --- nvim-config/coc-settings.json | 3 +- nvim-config/init.vim | 208 +++++++++++++++++++++++----------- 2 files changed, 143 insertions(+), 68 deletions(-) diff --git a/nvim-config/coc-settings.json b/nvim-config/coc-settings.json index 184ecf2..3d033b1 100644 --- a/nvim-config/coc-settings.json +++ b/nvim-config/coc-settings.json @@ -6,5 +6,6 @@ "rootPatterns": ["*.cabal", "stack.yaml", "cabal.project", "package.yaml", "hie.yaml"], "filetypes": ["haskell", "lhaskell"] } - } + }, + "coc.source.iced.enable": true } diff --git a/nvim-config/init.vim b/nvim-config/init.vim index b806c6c..9cce418 100644 --- a/nvim-config/init.vim +++ b/nvim-config/init.vim @@ -21,26 +21,16 @@ Plug 'frankier/neovim-colors-solarized-truecolor-only' " rainbow-parentethies Plug 'luochen1990/rainbow' -" search in files/buffers for filenames - replaced by fzf -" Plug 'https://github.com/ctrlpvim/ctrlp.vim.git' " fuzzy finder Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } Plug 'junegunn/fzf.vim' -" show buffers in statusline -" Plug 'bling/vim-bufferline' " git-gutter (little + - and ~ left) Plug 'https://github.com/airblade/vim-gitgutter.git' -" apply hlint-suggestions -" Plug 'https://github.com/mpickering/hlint-refactor-vim.git' - " Tabular Plug 'https://github.com/godlygeek/tabular.git' -" Shakespearian template-highlighting -" Plug 'https://github.com/pbrisbin/vim-syntax-shakespeare.git' - " Multiline-Comments Plug 'tomtom/tcomment_vim' @@ -73,26 +63,16 @@ Plug 'xolox/vim-session' | Plug 'xolox/vim-misc' " CoC Plug 'neoclide/coc.nvim', {'branch': 'release'} +" Clojure +Plug 'guns/vim-sexp', {'for': 'clojure'} +Plug 'liquidz/vim-iced', {'for': 'clojure'} +Plug 'liquidz/vim-iced-coc-source', {'for': 'clojure'} + call plug#end() " SETTINGS -" recommended by syntastic -" set statusline+=%#warningmsg# -" set statusline+=%{SyntasticStatuslineFlag()} -" set statusline+=%* -" set statusline+=%{fugitive#statusline()} -" -" let g:syntastic_always_populate_loc_list = 1 -" let g:syntastic_auto_loc_list = 1 -" let g:syntastic_check_on_open = 1 -" let g:syntastic_check_on_wq = 0 -" use autocompletion -let g:deoplete#enable_at_startup = 1 -" in case of problems with stack.. -" g:necoghc_use_stack = 1 - " set leader to space let mapleader= "\" @@ -140,6 +120,8 @@ highlight WinSeperator guibg=None set hidden +let g:loaded_perl_provider = 0 + " Use to clear the highlighting of :set hlsearch. if maparg('', 'n') ==# '' nnoremap :nohlsearch @@ -175,7 +157,7 @@ inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\" " use to Jump to definition instead of (default) -nnoremap +nmap " c-d to delete line in insert-mode inoremap ddi @@ -184,8 +166,129 @@ inoremap ddi tnoremap +""""""""""""""""""""""""""""""""""""""""""""" Coc Keys +" Use `[g` and `]g` to navigate diagnostics +" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list +nmap [g (coc-diagnostic-prev) +nmap ]g (coc-diagnostic-next) + +" GoTo code navigation +nmap gd (coc-definition) +nmap gy (coc-type-definition) +nmap gi (coc-implementation) +nmap gr (coc-references) + +" Use K to show documentation in preview window +nnoremap K :call ShowDocumentation() + +function! ShowDocumentation() + if CocAction('hasProvider', 'hover') + call CocActionAsync('doHover') + else + call feedkeys('K', 'in') + endif +endfunction + +" Highlight the symbol and its references when holding the cursor +autocmd CursorHold * silent call CocActionAsync('highlight') + +" Symbol renaming +nmap rn (coc-rename) + +" Formatting selected code +xmap f (coc-format-selected) +nmap f (coc-format-selected) + +augroup mygroup + autocmd! + " Setup formatexpr specified filetype(s) + autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') + " Update signature help on jump placeholder + autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') +augroup end + +" Applying code actions to the selected code block +" Example: `aap` for current paragraph +xmap a (coc-codeaction-selected) +nmap a (coc-codeaction-selected) + +" Remap keys for applying code actions at the cursor position +nmap ac (coc-codeaction-cursor) +" Remap keys for apply code actions affect whole buffer +nmap as (coc-codeaction-source) +" Apply the most preferred quickfix action to fix diagnostic on the current line +nmap qf (coc-fix-current) + +" Remap keys for applying refactor code actions +nmap re (coc-codeaction-refactor) +xmap r (coc-codeaction-refactor-selected) +nmap r (coc-codeaction-refactor-selected) + +" Run the Code Lens action on the current line +nmap cl (coc-codelens-action) + +" Map function and class text objects +" NOTE: Requires 'textDocument.documentSymbol' support from the language server +xmap if (coc-funcobj-i) +omap if (coc-funcobj-i) +xmap af (coc-funcobj-a) +omap af (coc-funcobj-a) +xmap ic (coc-classobj-i) +omap ic (coc-classobj-i) +xmap ac (coc-classobj-a) +omap ac (coc-classobj-a) + +" Remap and to scroll float windows/popups +if has('nvim-0.4.0') || has('patch-8.2.0750') + nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" + nnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" + inoremap coc#float#has_scroll() ? "\=coc#float#scroll(1)\" : "\" + inoremap coc#float#has_scroll() ? "\=coc#float#scroll(0)\" : "\" + vnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" + vnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" +endif + +" Use CTRL-S for selections ranges +" Requires 'textDocument/selectionRange' support of language server +nmap (coc-range-select) +xmap (coc-range-select) + +" Add `:Format` command to format current buffer +command! -nargs=0 Format :call CocActionAsync('format') + +" Add `:Fold` command to fold current buffer +command! -nargs=? Fold :call CocAction('fold', ) + +" Add `:OR` command for organize imports of the current buffer +command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport') + +" Add (Neo)Vim's native statusline support +" NOTE: Please see `:h coc-status` for integrations with external plugins that +" provide custom statusline: lightline.vim, vim-airline +set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} + +" Mappings for CoCList +" Show all diagnostics +nnoremap a :CocList diagnostics +" Manage extensions +nnoremap e :CocList extensions +" Show commands +nnoremap c :CocList commands +" Find symbol of current document +nnoremap o :CocList outline +" Search workspace symbols +nnoremap s :CocList -I symbols +" Do default action for next item +nnoremap j :CocNext +" Do default action for previous item +nnoremap k :CocPrev +" Resume latest coc list +nnoremap p :CocListResume + +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + " autoformat code if possible (read docs on vim-autoformat!) -noremap f :Autoformat +"noremap f :Autoformat noremap TM :TableModeToggle " multi-cursor @@ -212,9 +315,6 @@ nnoremap f :GFiles " Open Tag-Search nnoremap t :Tags -" Open File-Tree on left side -nmap :NERDTreeToggle - " Expand patterns in Haskell "nnoremap hc :GhcModSplitFunCase " Expand function signatures in Haskell @@ -234,12 +334,18 @@ nnoremap P "+P vnoremap p "+p vnoremap P "+P -" disable syntastic for haskell -let g:syntastic_haskell_checkers=[''] - " Clear stuff nnoremap :nohlsearch:cclose +" Clojure-Bindings +" Enable vim-iced's default key mapping +" This is recommended for newbies +let g:iced_enable_default_key_mappings = v:true +let g:sexp_enable_insert_mode_mappings = 0 " stop inserting brackets +let g:iced_enable_clj_kondo_analysis = v:true " kondo analysis +let g:iced_enable_clj_kondo_local_analysis = v:true " also analyse local. +let g:iced_enable_auto_document = 'any' " automatically open documentation + " THEME-RELATED STUFF syntax enable @@ -258,7 +364,7 @@ autocmd BufRead,BufNewFile *.md setlocal spell complete+=kspell textwidth=80 autocmd BufRead,BufNewFile *.markdown setlocal spell complete+=kspell textwidth=80 autocmd BufRead,BufNewFile *.md hi SpellBad guibg=#582828 gui=none autocmd BufRead,BufNewFile *.markdown hi SpellBad guibg=#582828 gui=none -autocmd FileType markdown nnoremap t :Toc +" autocmd FileType markdown nnoremap t :Toc " set languages to english and german set spelllang=de_de,en_us @@ -287,38 +393,6 @@ let g:haskell_indent_do = 3 let g:haskell_indent_in = 1 let g:haskell_indent_guard = 2 -" NERDTREE -map :NERDTreeToggle -autocmd StdinReadPre * let s:std_in=1 -let NERDTreeShowHidden=1 -let g:NERDTreeWinSize=45 -let g:NERDTreeAutoDeleteBuffer=1 - -function! NERDTreeHighlightFile(extension, fg, bg, guifg, guibg) -exec 'autocmd FileType nerdtree highlight ' . a:extension .' ctermbg='. a:bg .' ctermfg='. a:fg .' guibg='. a:guibg .' guifg='. a:guifg -exec 'autocmd FileType nerdtree syn match ' . a:extension .' #^\s\+.*'. a:extension .'$#' -endfunction - -call NERDTreeHighlightFile('jade', 'green', 'none', 'green', '#141e23') -call NERDTreeHighlightFile('ini', 'yellow', 'none', 'yellow', '#141e23') -call NERDTreeHighlightFile('md', 'blue', 'none', '#3366FF', '#141e23') -call NERDTreeHighlightFile('yml', 'yellow', 'none', 'yellow', '#141e23') -call NERDTreeHighlightFile('config', 'yellow', 'none', 'yellow', '#141e23') -call NERDTreeHighlightFile('conf', 'yellow', 'none', 'yellow', '#141e23') -call NERDTreeHighlightFile('json', 'yellow', 'none', 'yellow', '#141e23') -call NERDTreeHighlightFile('html', 'yellow', 'none', 'yellow', '#141e23') -call NERDTreeHighlightFile('styl', 'cyan', 'none', 'cyan', '#141e23') -call NERDTreeHighlightFile('css', 'cyan', 'none', 'cyan', '#141e23') -call NERDTreeHighlightFile('coffee', 'Red', 'none', 'red', '#141e23') -call NERDTreeHighlightFile('js', 'Red', 'none', '#ffa500', '#141e23') -call NERDTreeHighlightFile('ts', 'Blue', 'none', '#6699cc', '#141e23') -call NERDTreeHighlightFile('hs', 'Blue', 'none', '#6699cc', '#141e23') -call NERDTreeHighlightFile('php', 'Magenta', 'none', '#ff00ff', '#141e23') -call NERDTreeHighlightFile('ds_store', 'Gray', 'none', '#686868', '#141e23') -call NERDTreeHighlightFile('gitconfig', 'Gray', 'none', '#686868', '#141e23') -call NERDTreeHighlightFile('gitignore', 'Gray', 'none', '#686868', '#141e23') -call NERDTreeHighlightFile('bashrc', 'Gray', 'none', '#686868', '#141e23') -call NERDTreeHighlightFile('bashprofile', 'Gray', 'none', '#686868', '#141e23') " SNIPPETS @@ -349,7 +423,7 @@ call NERDTreeHighlightFile('bashprofile', 'Gray', 'none', '#686868', '#141e23') " autocmd FileType html,css EmmetInstall " AIRLINE -let g:airline#extensions#tabline#ignore_bufadd_pat = 'gundo|undotree|vimfiler|tagbar|nerd_tree|startify|!' +let g:airline#extensions#tabline#ignore_bufadd_pat = 'gundo|undotree|vimfiler|tagbar|netrw|startify|!' let g:airline#extensions#tabline#enabled = 1 set hidden let g:airline#extensions#tabline#fnamemod = ':t'