X-Git-Url: https://git.xinqibao.xyz/dotfiles.git/blobdiff_plain/19081f95987ce5223b39e6bbdf32c16d5a5e2f62..8da52ea9572302f078821aed54f154ae726d00b4:/.config/nvim/init.vim?ds=sidebyside diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 6971f46..e002a88 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -1,26 +1,23 @@ syntax enable 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 +" Files and indentation +set encoding=utf-8 +" In order to display Chinese in GBK set fileencodings=utf-8,gbk set fileformat=unix -set foldmethod=indent -set encoding=utf-8 "required for ycm - set tabstop=4 set softtabstop=4 set shiftwidth=4 set expandtab set smartindent set backspace=indent,eol,start +" Auto added comment leader; see :h formatoptions +set formatoptions+=/ro +" Display and search +set background=dark +set termguicolors set number set nowrap set signcolumn=auto @@ -34,7 +31,14 @@ set showtabline=2 set laststatus=2 "always show status line set noshowmode set wildmenu +set colorcolumn=120 +highlight ColorColumn ctermbg=0 guibg=lightgrey +" Fallback for filetypes without a Tree-sitter parser. +set foldmethod=indent +set foldlevelstart=99 +set foldlevel=99 +" Interaction and persistence set mouse=a set autochdir set updatetime=300 @@ -47,20 +51,6 @@ set nowritebackup set undodir=~/.cache/nvim/undodir set undofile -" auto added comment leader, detail for :h formatoptions -set formatoptions+=/ - -set tags=tags~;,tags~ -"setting gf (go file) path -"change kernel version to your version, for kernel development -set path=.,lib;,include;,includes; -set path+=/usr/include,/usr/include/c++/* -set path+=/usr/local/include - -"ColumnLimit -set colorcolumn=120 -highlight ColorColumn ctermbg=0 guibg=lightgrey - " Writes to the unnamed register also writes to the * and + registers. This " makes it easy to interact with the system clipboard if has ('unnamedplus') @@ -69,68 +59,52 @@ else set clipboard=unnamed endif +" File navigation +set tags=tags~;,tags~ +"setting gf (go file) path +"change kernel version to your version, for kernel development +set path=.,lib;,include;,includes; +set path+=/usr/include,/usr/include/c++/* +set path+=/usr/local/include + call plug#begin() + " Appearance Plug 'morhetz/gruvbox' - Plug 'Yggdroot/indentLine' - Plug 'christoomey/vim-tmux-navigator' Plug 'vim-airline/vim-airline' - "Plug 'vim-airline/vim-airline-themes' + Plug 'lukas-reineke/indent-blankline.nvim' + " Navigation Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf.vim' - Plug 'ludovicchabant/vim-gutentags' - - Plug 'mbbill/undotree' Plug 'preservim/nerdtree' - Plug 'majutsushi/tagbar' + Plug 'christoomey/vim-tmux-navigator' + Plug 'mbbill/undotree' + Plug 'stevearc/aerial.nvim' - Plug 'plasticboy/vim-markdown' + " Development + Plug 'nvim-treesitter/nvim-treesitter' + Plug 'neoclide/coc.nvim', {'branch': 'release'} + Plug 'zbirenbaum/copilot.lua' - Plug 'tpope/vim-fugitive' - Plug 'airblade/vim-gitgutter' + " Git + 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' - - """ - "" avante and its dependents - " Deps - Plug 'nvim-lua/plenary.nvim' - Plug 'MunifTanjim/nui.nvim' + " Markdown Plug 'MeanderingProgrammer/render-markdown.nvim' + Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && npx --yes yarn install' } - " Optional deps - Plug 'hrsh7th/nvim-cmp' - Plug 'nvim-tree/nvim-web-devicons' "or Plug 'echasnovski/mini.icons' - Plug 'HakonHarnes/img-clip.nvim' - Plug 'zbirenbaum/copilot.lua' - Plug 'stevearc/dressing.nvim' " for enhanced input UI - Plug 'folke/snacks.nvim' " for modern input UI - - " Yay, pass source=true if you want to build from source - Plug 'yetone/avante.nvim', { 'branch': 'main', 'do': 'make' } - "" - "" + " Optional + " execute 'source' fnameescape(expand(':p:h') . '/opt/avante.vim') + " execute 'source' fnameescape(expand(':p:h') . '/opt/leetcode.vim') call plug#end() -"---------------------- -" gruvbox setting -"---------------------- +" Appearance if has_key(plugs, 'gruvbox') colorscheme gruvbox endif -"---------------------- -" vim-airline setting -"---------------------- if has_key(plugs, 'vim-airline') "tabline with airline ":help airline-tabline @@ -141,26 +115,22 @@ if has_key(plugs, 'vim-airline') let g:airline#extensions#tabline#show_close_button = 0 endif -"---------------------- -" fzf.vim setting -"---------------------- -if has_key(plugs, 'fzf.vim') - "mapping for fzf.vim - nnoremap :GFiles - "as default / pair used to page down/up entire page - nnoremap :Tags +if has_key(plugs, 'indent-blankline.nvim') + lua require('ibl').setup() endif -"---------------------- -" undotree setting -"---------------------- -if has_key(plugs, 'undotree') - nnoremap u :UndotreeToggle +" Navigation +if has_key(plugs, 'fzf.vim') + command! -bang -nargs=* GGrep + \ call fzf#vim#grep( + \ 'git grep --line-number -- ' . fzf#shellescape(), + \ fzf#vim#with_preview({ + \ 'dir': systemlist(['git', '-C', expand('%:p:h'), 'rev-parse', '--show-toplevel'])[0] + \ }), 0) + nnoremap :GFiles + nnoremap :GGrep endif -"---------------------- -" nerdtree setting -"---------------------- if has_key(plugs, 'nerdtree') autocmd StdinReadPre * let s:std_in=1 "when vim openning with no file, open NERDTree @@ -168,33 +138,20 @@ if has_key(plugs, 'nerdtree') nnoremap n :NERDTreeToggle endif -"---------------------- -" tagbar setting -"---------------------- -if has_key(plugs, 'tagbar') - nnoremap t :TagbarToggle +if has_key(plugs, 'undotree') + nnoremap u :UndotreeToggle +endif + +if has_key(plugs, 'aerial.nvim') + lua require('aerial').setup() + nnoremap a AerialToggle! 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 +" Development +if has_key(plugs, 'nvim-treesitter') + lua require('plugin-config/nvim-treesitter') endif -"---------------------- -" coc.vim setting -"---------------------- if has_key(plugs, "coc.nvim") " Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. nmap g[ (coc-diagnostic-prev) @@ -250,32 +207,33 @@ if has_key(plugs, "coc.nvim") \] endif -"---------------------- -" nvim-treesitter setting -"---------------------- -if has_key(plugs, 'nvim-treesitter') - lua require('plugin-config/nvim-treesitter') +if has_key(plugs, 'copilot.lua') + lua require('plugin-config/copilot') +endif + +" Git +if has_key(plugs, 'gitsigns.nvim') + lua require('plugin-config/gitsigns') +endif - set foldmethod=expr - set foldexpr=nvim_treesitter#foldexpr() - set foldlevel=99 +if has_key(plugs, 'lazygit.nvim') + nnoremap lg :LazyGit endif -"---------------------- -" avante.nvim setting -"---------------------- +" Optional if has_key(plugs, 'avante.nvim') - lua require('plugin-config/nvim-avante') + lua require('plugin-config/avante') endif +if has_key(plugs, 'leetcode.nvim') + lua require('plugin-config/leetcode') +endif + +" General mappings 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 @@ -283,17 +241,10 @@ nnoremap - :resize -5 nnoremap v+ :vertical resize +5 nnoremap v- :vertical resize -5 -" shortcut for folding -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