X-Git-Url: https://git.xinqibao.xyz/dotfiles.git/blobdiff_plain/657a096a9b51afbd00b8139950a36b9f5bc0a5ff..5bf55e7a327bc780b3390b7a42685a2151937011:/.config/nvim/init.vim diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 9ec564b..ed35c32 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -3,16 +3,14 @@ let mapleader=" " set background=dark set termguicolors -set t_Co=256 "terminal color -set t_ut="" -"set term=xterm-256color "In order to display chinese in GBK -"let &termencoding=&encoding set fileencodings=utf-8,gbk set fileformat=unix set foldmethod=indent -set encoding=utf-8 "required for ycm +set foldlevelstart=99 +set foldlevel=99 +set encoding=utf-8 set tabstop=4 set softtabstop=4 @@ -47,6 +45,9 @@ set nowritebackup set undodir=~/.cache/nvim/undodir set undofile +" auto added comment leader, detail for :h formatoptions +set formatoptions+=/ro + set tags=tags~;,tags~ "setting gf (go file) path "change kernel version to your version, for kernel development @@ -68,10 +69,9 @@ endif call plug#begin() Plug 'morhetz/gruvbox' - Plug 'Yggdroot/indentLine' + Plug 'lukas-reineke/indent-blankline.nvim' Plug 'christoomey/vim-tmux-navigator' Plug 'vim-airline/vim-airline' - "Plug 'vim-airline/vim-airline-themes' Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf.vim' @@ -81,20 +81,22 @@ call plug#begin() Plug 'preservim/nerdtree' Plug 'majutsushi/tagbar' - Plug 'plasticboy/vim-markdown' + Plug 'MeanderingProgrammer/render-markdown.nvim' + Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && npx --yes yarn install' } Plug 'tpope/vim-fugitive' - Plug 'airblade/vim-gitgutter' + Plug 'lewis6991/gitsigns.nvim' Plug 'kdheepak/lazygit.nvim' - "Plug 'ycm-core/YouCompleteMe' - "Plug 'rhysd/vim-clang-format' - Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'nvim-treesitter/nvim-treesitter' - "Plug 'mfussenegger/nvim-dap' - "Plug 'puremourning/vimspector' + + Plug 'zbirenbaum/copilot.lua' + + " execute 'source' fnameescape(expand(':p:h') . '/opt/avante.vim') + " execute 'source' fnameescape(expand(':p:h') . '/opt/leetcode.vim') + call plug#end() "---------------------- @@ -121,10 +123,22 @@ endif " fzf.vim setting "---------------------- if has_key(plugs, 'fzf.vim') - "mapping for fzf.vim + function! s:ProjectRg(query) abort + let dir = expand('%:p:h') + let dir = isdirectory(dir) ? dir : getcwd() + let root = systemlist('git -C ' . shellescape(dir) . ' rev-parse --show-toplevel 2>/dev/null') + if v:shell_error || empty(root) + echoerr 'Not in a Git repository' + return + endif + call fzf#vim#grep2( + \ 'rg --hidden --glob "!.git" --column --line-number --no-heading --color=always --smart-case -- ', + \ a:query, fzf#vim#with_preview({'dir': root[0]})) + endfunction + + command! -nargs=* ProjectRg call ProjectRg() nnoremap :GFiles - "as default / pair used to page down/up entire page - nnoremap :Tags + nnoremap :ProjectRg endif "---------------------- @@ -151,23 +165,6 @@ if has_key(plugs, 'tagbar') nnoremap t :TagbarToggle endif -"---------------------- -" YouCompleteMe setting -"---------------------- -if has_key(plugs, 'YouCompleteMe') - let g:ycm_global_ycm_extra_conf = '~/.config/nvim/ycm_extra_conf.py' - let g:ycm_confirm_extra_conf = 0 - let g:ycm_enable_diagnostic_signs = 0 - let g:ycm_always_populate_location_list = 1 - "let g:ycm_show_diagnostics_ui = 0 - let g:ycm_add_preview_to_completeopt = 1 - let g:ycm_autoclose_preview_window_after_completion = 1 - let g:ycm_auto_hover = 'no' - - nnoremap gd :YcmCompleter GoTo - nnoremap gr :YcmCompleter GoToReferences -endif - "---------------------- " coc.vim setting "---------------------- @@ -231,21 +228,45 @@ endif "---------------------- if has_key(plugs, 'nvim-treesitter') lua require('plugin-config/nvim-treesitter') +endif - set foldmethod=expr - set foldexpr=nvim_treesitter#foldexpr() - set foldlevel=99 +if has_key(plugs, 'indent-blankline.nvim') + lua require('ibl').setup({ scope = { enabled = false } }) endif +if has_key(plugs, 'gitsigns.nvim') + lua require('plugin-config/gitsigns') +endif + +if has_key(plugs, 'lazygit.nvim') + nnoremap lg :LazyGit +endif + +"---------------------- +" copilot.lua setting +"---------------------- +if has_key(plugs, 'copilot.lua') + lua require('plugin-config/copilot') +endif + +"---------------------- +" avante.nvim setting +"---------------------- +if has_key(plugs, 'avante.nvim') + lua require('plugin-config/avante') +endif + +"---------------------- +" leetcode.nvim setting +"---------------------- +if has_key(plugs, 'leetcode.nvim') + lua require('plugin-config/leetcode') +endif nnoremap J :tabprevious nnoremap K :tabnext nnoremap J :tabmove -1 nnoremap K :tabmove +1 -nnoremap h -nnoremap j -nnoremap k -nnoremap l nnoremap " viwa"bi"lel nnoremap ' viwa'bi'lel nnoremap + :resize +5 @@ -257,13 +278,10 @@ nnoremap v- :vertical resize -5 nnoremap fi :set foldmethod=indent nnoremap fd :set foldmethod=manualggVGzD +" 禁用 +nnoremap +xnoremap + "HighLight trailing whitespace" highlight ExtraWhitespace ctermbg=red guibg=red match ExtraWhitespace /\s\+$/ - -"use powerline-vim for normal use -"instead of installing for both user and root -"run to install lib: pip3 install --user powerline-status -"python3 from powerline.vim import setup as powerline_setup -"python3 powerline_setup() -"python3 del powerline_setup