From 2e769d92a37f8d6cdd9f689b5275101eaec43758 Mon Sep 17 00:00:00 2001 From: Malte Brandy Date: Tue, 19 Jan 2021 05:09:48 +0100 Subject: [PATCH] Improve vim config --- home-manager/roles/neovim/default.nix | 4 +++- home-manager/roles/neovim/vimrc | 27 +++++++++++++++++++++++---- overlays/10-previews.nix | 2 ++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/home-manager/roles/neovim/default.nix b/home-manager/roles/neovim/default.nix index 853fdcbb..8cb8a2e5 100644 --- a/home-manager/roles/neovim/default.nix +++ b/home-manager/roles/neovim/default.nix @@ -9,13 +9,13 @@ let # coc-tabnine (TODO: Why doesn‘t it work?) # TODO: tabnine config in home-manager # TODO: tabnine lsp: nix, rust, pandoc/latex lsp? was noch? - # TODO: coc-explorer, coc-markdownlints are installed statefully right now # === # Basic IDE plugins coc-nvim airline # same word highlighting when not supported by language coc-highlight + coc-explorer # searches coc-fzf fzf-vim @@ -38,6 +38,7 @@ let haskell-vim vim-hoogle # nix syntax highlighting vim-nix + vim-markdown # latex vimtex coc-vimtex # not sure if I need two # ledger @@ -64,6 +65,7 @@ let "diagnostic.maxWindowHeight" = 60; "diagnostic.virtualText" = true; "diagnostic.virtualTextCurrentLineOnly" = false; + "coc.preferences.hoverTarget" = "preview"; "codeLens.enable" = true; languageserver = { markdown = { diff --git a/home-manager/roles/neovim/vimrc b/home-manager/roles/neovim/vimrc index 0aa0ad34..6a681a12 100644 --- a/home-manager/roles/neovim/vimrc +++ b/home-manager/roles/neovim/vimrc @@ -34,7 +34,7 @@ augroup focus au BufLeave * silent! wall augroup END -nnoremap :nohlsearch +nnoremap :pc:nohlsearch vnoremap < >gv nnoremap @@ -136,13 +136,32 @@ nmap gc :Gcommit function! s:show_documentation() if (index(['vim','help'], &filetype) >= 0) - execute 'h '.expand('') + elseif (coc#rpc#ready()) + call CocActionAsync('doHover') else - call CocAction('doHover') + execute '!' . &keywordprg . " " . expand('') endif endfunction -nmap i :call show_documentation() +"nmap i :call show_documentation() +autocmd CursorHold * silent call s:show_documentation() + +function! Preview_func() + if &pvw + setlocal foldcolumn=0 + setlocal signcolumn=no + setlocal nonumber + let idealheight=line('$')+2 + let width=min([&columns-40]) + let left=&columns-width + let height=min([idealheight,&lines-3,60]) + let top=&lines-2-height + call nvim_win_set_config(0,{'relative': 'editor','width':width,'height':height,'row':top,'col':left}) + endif +endfunction + +autocmd BufWinEnter * call Preview_func() + " Remap for rename current word nmap r (coc-rename) diff --git a/overlays/10-previews.nix b/overlays/10-previews.nix index a306a3fc..59dcd958 100644 --- a/overlays/10-previews.nix +++ b/overlays/10-previews.nix @@ -9,4 +9,6 @@ let in { laminar = laminarPkgs.laminar; syncthingNext = unstable.syncthing; + vimPlugins = unstable.vimPlugins; + fzf = unstable.fzf; }