4 " Files and indentation
6 " In order to display Chinese in GBK
7 set fileencodings=utf-8,gbk
14 set backspace=indent,eol,start
15 " Auto added comment leader; see :h formatoptions
16 set formatoptions+=/ro
31 set laststatus=2 "always show status line
35 highlight ColorColumn ctermbg=0 guibg=lightgrey
36 " Create folds only after a Tree-sitter parser is started.
41 " Indent summaries one level past the retained first line, not a continuation.
42 let &foldtext = 'repeat(" ", indent(v:foldstart - 1) + shiftwidth()) . printf("… %d lines …", v:foldend - v:foldstart + 1)'
43 set fillchars+=fold:\ " Leave the rest of the summary line blank.
45 " Interaction and persistence
55 set undodir=~/.cache/nvim/undodir
58 " Writes to the unnamed register also writes to the * and + registers. This
59 " makes it easy to interact with the system clipboard
60 if has ('unnamedplus')
61 set clipboard=unnamedplus
68 "setting gf (go file) path
69 "change kernel version to your version, for kernel development
70 set path=.,lib;,include;,includes;
71 set path+=/usr/include,/usr/include/c++/*
72 set path+=/usr/local/include
76 Plug 'morhetz/gruvbox'
77 Plug 'vim-airline/vim-airline'
78 Plug 'lukas-reineke/indent-blankline.nvim'
81 Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
82 Plug 'junegunn/fzf.vim'
83 Plug 'preservim/nerdtree'
84 Plug 'christoomey/vim-tmux-navigator'
85 Plug 'mbbill/undotree'
86 Plug 'stevearc/aerial.nvim'
89 Plug 'nvim-treesitter/nvim-treesitter'
90 Plug 'neoclide/coc.nvim', {'branch': 'release'}
91 Plug 'zbirenbaum/copilot.lua'
94 Plug 'lewis6991/gitsigns.nvim'
95 Plug 'kdheepak/lazygit.nvim'
98 Plug 'MeanderingProgrammer/render-markdown.nvim'
99 Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && npx --yes yarn install' }
102 " execute 'source' fnameescape(expand('<sfile>:p:h') . '/opt/avante.vim')
103 " execute 'source' fnameescape(expand('<sfile>:p:h') . '/opt/leetcode.vim')
108 if has_key(plugs, 'gruvbox')
112 if has_key(plugs, 'vim-airline')
113 "tabline with airline
114 ":help airline-tabline
115 let g:airline#extensions#tabline#enabled = 1
116 let g:airline#extensions#tabline#show_buffers = 0
117 let g:airline#extensions#tabline#show_splits = 0
118 let g:airline#extensions#tabline#show_tab_count = 0
119 let g:airline#extensions#tabline#show_close_button = 0
122 if has_key(plugs, 'indent-blankline.nvim')
123 lua require('ibl').setup()
127 if has_key(plugs, 'fzf.vim')
128 command! -bang -nargs=* GGrep
130 \ 'git grep --line-number -- ' . fzf#shellescape(<q-args>),
131 \ fzf#vim#with_preview({
132 \ 'dir': systemlist(['git', '-C', expand('%:p:h'), 'rev-parse', '--show-toplevel'])[0]
134 nnoremap <C-p> :GFiles<CR>
135 nnoremap <C-f> :GGrep<CR>
138 if has_key(plugs, 'nerdtree')
139 autocmd StdinReadPre * let s:std_in=1
140 "when vim openning with no file, open NERDTree
141 autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
142 nnoremap <leader>n :NERDTreeToggle<CR>
145 if has_key(plugs, 'undotree')
146 nnoremap <leader>u :UndotreeToggle<CR>
149 if has_key(plugs, 'aerial.nvim')
150 lua require('aerial').setup()
151 nnoremap <leader>a <cmd>AerialToggle!<CR>
155 if has_key(plugs, 'nvim-treesitter')
156 lua require('plugin-config/nvim-treesitter')
159 if has_key(plugs, "coc.nvim")
160 " Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
161 nmap <silent> <leader>g[ <Plug>(coc-diagnostic-prev)
162 nmap <silent> <leader>g] <Plug>(coc-diagnostic-next)
164 " GoTo code navigation.
165 nmap <silent> <leader>gd <Plug>(coc-definition)
166 nmap <silent> <leader>gr <Plug>(coc-references)
167 nmap <silent> <leader>gy <Plug>(coc-type-definition)
168 nmap <silent> <leader>gi <Plug>(coc-implementation)
170 " Highlight the symbol and its references when holding the cursor.
171 autocmd CursorHold * silent call CocActionAsync('highlight')
174 nmap <leader>rn <Plug>(coc-rename)
176 " Formatting selected code.
177 xmap <leader>f <Plug>(coc-format-selected)
178 nmap <leader>f <Plug>(coc-format-selected)
180 " Apply AutoFix to problem on the current line.
181 nmap <leader>qf <Plug>(coc-fix-current)
184 nmap <leader>gh :CocCommand clangd.switchSourceHeader<CR>
186 " Use K to show documentation in preview window.
187 nnoremap <silent> <leader>h :call <SID>show_documentation()<CR>
188 function! s:show_documentation()
189 if (index(['vim','help'], &filetype) >= 0)
190 execute 'h '.expand('<cword>')
191 elseif (coc#rpc#ready())
192 call CocActionAsync('doHover')
194 execute '!' . &keywordprg . " " . expand('<cword>')
198 let g:coc_default_semantic_highlight_groups = 1
199 let g:coc_global_extensions = [
214 if has_key(plugs, 'copilot.lua')
215 lua require('plugin-config/copilot')
219 if has_key(plugs, 'gitsigns.nvim')
220 lua require('plugin-config/gitsigns')
223 if has_key(plugs, 'lazygit.nvim')
224 nnoremap <silent> <leader>lg :LazyGit<CR>
228 if has_key(plugs, 'avante.nvim')
229 lua require('plugin-config/avante')
232 if has_key(plugs, 'leetcode.nvim')
233 lua require('plugin-config/leetcode')
237 nnoremap J :tabprevious<CR>
238 nnoremap K :tabnext<CR>
239 nnoremap <leader>J :tabmove -1<CR>
240 nnoremap <leader>K :tabmove +1<CR>
241 nnoremap <leader>" viw<esc>a"<esc>bi"<esc>lel
242 nnoremap <leader>' viw<esc>a'<esc>bi'<esc>lel
243 nnoremap <silent> <Leader>+ :resize +5<CR>
244 nnoremap <silent> <Leader>- :resize -5<CR>
245 nnoremap <silent> <Leader>v+ :vertical resize +5<CR>
246 nnoremap <silent> <Leader>v- :vertical resize -5<CR>
252 "HighLight trailing whitespace"
253 highlight ExtraWhitespace ctermbg=red guibg=red
254 match ExtraWhitespace /\s\+$/