From f9d2fc0778167c05834da5f4eb576201411f7bd3 Mon Sep 17 00:00:00 2001 From: arielherself Date: Tue, 31 Dec 2024 17:26:07 +0800 Subject: [PATCH] feat(vim): compatibility with Neovim --- .vimrc | 34 +++++++++++++++++++++++++++++++--- home-manager/home.nix | 18 +++++++++++++----- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/.vimrc b/.vimrc index d6129be..848bc9e 100644 --- a/.vimrc +++ b/.vimrc @@ -46,6 +46,20 @@ set noshowmode set guicursor=n-v-c:block,i:ver25,a:blinkon0 set incsearch set hlsearch +set mouse=a +set ttimeoutlen=0 +set wildmenu +set wildoptions=fuzzy,pum +if has('nvim') + set signcolumn=yes:2 + set cmdheight=0 + set pumblend=40 + set winblend=40 +endif +if !has('nvim') + set noesckeys +endif +set updatetime=0 " legacy set nocompatible @@ -104,6 +118,7 @@ Plug 'airblade/vim-gitgutter' Plug 'tpope/vim-fugitive' Plug 'Yggdroot/indentLine' Plug '907th/vim-auto-save' +Plug 'markonm/traces.vim' call plug#end() @@ -131,15 +146,19 @@ let g:lsp_completion_documentation_delay = 0 let g:lsp_diagnostics_echo_delay = 0 let g:lsp_diagnostics_highlights_delay = 0 let g:lsp_diagnostics_signs_delay = 0 +let g:lsp_diagnostics_virtual_text_enabled = 0 let g:lsp_diagnostics_virtual_text_delay = 0 let g:lsp_document_code_action_signs_delay = 0 let g:lsp_inlay_hints_delay = 0 let g:lsp_document_highlight_delay = 0 let g:lsp_preview_max_width = 50 +let g:lsp_diagnostics_float_cursor = 1 +let g:lsp_diagnostics_float_delay = 500 +let g:lsp_preview_autoclose = 0 let g:lsp_float_max_width = 50 let g:lsp_inlay_hints_enabled = 1 let g:lsp_diagnostics_virtual_text_padding_left = 12 -let g:lsp_diagnostics_echo_cursor = 1 +let g:lsp_diagnostics_echo_cursor = 0 let g:lsp_settings = { \ 'clangd': { 'cmd': [ 'clangd' ] }, \} @@ -170,6 +189,7 @@ endfunction let g:asyncomplete_preprocessor = [function('s:truncate_labels')] " Personal keybindings +tnoremap N nnoremap w (easymotion-bd-w) vnoremap w (easymotion-bd-w) nnoremap o Files @@ -179,10 +199,9 @@ nnoremap gd LspDefinition nnoremap dd LspDocumentDiagnostics nnoremap dn LspNextDiagnostic nnoremap dp LspPreviousDiagnostic -nnoremap r LspRename +nnoremap grr LspRename nnoremap a LspCodeAction nnoremap K LspHover -nnoremap ` term zsh nnoremap Q q nnoremap q inoremap {A}%li$ik^i @@ -192,6 +211,12 @@ vnoremap >gv vnoremap ggVG nnoremap gy `[v`] +nnoremap noh +if has('nvim') + nnoremap ` splitterm zshi +else + nnoremap ` splitterm ++curwin zsh +endif """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Bclose @@ -282,5 +307,8 @@ let g:cursorword_delay = 1 let g:auto_save = 0 +" recover cursor shape +autocmd VimLeave * silent !echo -ne "\e[6 q" + " Why?! set noshowmode diff --git a/home-manager/home.nix b/home-manager/home.nix index e422765..70a751c 100644 --- a/home-manager/home.nix +++ b/home-manager/home.nix @@ -98,9 +98,17 @@ in { source = ../xournalpp; recursive = true; }; - "nvim" = { - source = ../nvim; - recursive = true; + # "nvim" = { + # source = ../nvim; + # recursive = true; + # }; + "nvim/init.vim" = { + text= '' + set runtimepath+=${config.home.homeDirectory}/.vim,${config.home.homeDirectory}/.vim/after + set packpath+=${config.home.homeDirectory}/.vim + source ${config.home.homeDirectory}/.vimrc + set undodir=${config.home.homeDirectory}/.vim/undofiles + ''; }; "nvim/ftplugin/java.lua" = { text = '' @@ -337,7 +345,7 @@ in { autosuggestion.enable = true; syntaxHighlighting.enable = true; shellAliases = { - upgrade = "nix-channel --update && sudo nixos-rebuild switch && home-manager switch"; + upgrade = "nix-channel --update && sudo nixos-rebuild switch --upgrade && home-manager switch"; commit = "git commit -S -m"; }; oh-my-zsh = { @@ -393,7 +401,7 @@ in { # This may not apply. Also try `git config --global gpg.ssh.program "/home/user/.nix-profile/bin/op-ssh-sign"` # gpg."ssh".program = "${unstable._1password-gui}/bin/op-ssh-sign"; push.autoSetupRemote = true; - core.editor = "nvim"; + core.editor = "vim"; }; };