-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.vim
287 lines (236 loc) · 8.02 KB
/
init.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
" requests:
" 1. nodejs
" 2. npm
" 3. yarn
" Export compile_commands.json
" cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -B build
"========================
"==== Enhance editor ====
"========================
set number
set encoding=utf-8
"This is esay to know how many
"lines you below current lines
set relativenumber
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
set ignorecase
set smartcase
set notimeout
set jumpoptions=stack
let mapleader="\<SPACE>"
"Install vim-plug
if empty(glob('~/.config/nvim/autoload/plug.vim'))
:exe '!curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
au VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" =======================
" === plugins begin ===
" =======================
call plug#begin('~/.config/nvim/plugged')
" any fold
Plug 'pseewald/vim-anyfold'
" vim terminal
Plug 'skywind3000/vim-terminal-help'
" enhance editor
Plug 'tomtom/tcomment_vim'
" git
Plug 'tpope/vim-fugitive'
" Theme & highlight
"Plug 'cateduo/vsdark.nvim'
Plug 'jackguo380/vim-lsp-cxx-highlight'
" Plug 'folke/tokyonight.nvim'
Plug 'shaunsingh/nord.nvim'
" file explorer
Plug 'preservim/nerdtree'
Plug 'kyazdani42/nvim-web-devicons' " for file icons
" Plug 'kyazdani42/nvim-tree.lua'
" lsp
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" file finder
Plug 'Yggdroot/LeaderF', { 'do': ':LeaderfInstallCExtension' }
" debug
Plug 'puremourning/vimspector', {'do': './install_gadget.py --enable-rust --enable-python'}
"statusline
Plug 'bling/vim-airline'
Plug 'vim-airline/vim-airline-themes'
"Icons
Plug 'ryanoasis/vim-devicons'
call plug#end()
" =======================
" === plugins end ===
" =======================
" ==== tomtom/tcomment_vim ====
let g:tcomment_textobject_inlinecomment = ''
nmap <LEADER>cn g>c
vmap <LEADER>cn g>
nmap <LEADER>cu g<c
vmap <LEADER>cu g<
" ==== Yggdroot/LeaderF ====
let g:Lf_WindowPosition='popup'
let g:Lf_PreviewInPopup=1
let g:Lf_CommandMap = {
\ '<C-p>': ['<C-k>'],
\ '<C-k>': ['<C-p>'],
\ '<C-j>': ['<C-n>']
\}
nmap <leader>f :Leaderf file<CR>
nmap <leader>b :Leaderf! buffer<CR>
nmap <leader>F :Leaderf rg<CR>
let g:Lf_DevIconsFont = "DroidSansMono Nerd Font Mono"
" ==== preservim/nerdtree ====
nnoremap <LEADER>e :NERDTreeToggle<CR>
" ==== cateduo/vsdark.nvim ====
set termguicolors
"let g:vsdark_style = "dark"
"colorscheme vsdark
" ==== neoclide/coc.nvim ====
" coc extensions
let g:coc_global_extensions = [
\ 'coc-clangd',
\ 'coc-json',
\ 'coc-tsserver',
\ 'coc-css',
\ 'coc-html',
\ 'coc-vimlsp',
\ 'coc-cmake',
\ 'coc-highlight',
\ 'coc-pyright'
\ ]
set signcolumn=number
" <TAB> to select candidate forward or
" pump completion candidate
inoremap <silent><expr> <C-n> coc#pum#visible() ? coc#pum#next(1) : "\<C-n>"
inoremap <silent><expr> <C-p> coc#pum#visible() ? coc#pum#prev(1) : "\<C-p>"
inoremap <silent><expr> <down> coc#pum#visible() ? coc#pum#next(0) : "\<down>"
inoremap <silent><expr> <up> coc#pum#visible() ? coc#pum#prev(0) : "\<up>"
inoremap <silent><expr> <PageDown> coc#pum#visible() ? coc#pum#scroll(1) : "\<PageDown>"
inoremap <silent><expr> <PageUp> coc#pum#visible() ? coc#pum#scroll(0) : "\<PageUp>"
inoremap <silent><expr> <C-e> coc#pum#visible() ? coc#pum#cancel() : "\<C-e>"
inoremap <silent><expr> <C-y> coc#pum#visible() ? coc#pum#confirm() : "\<C-y>"
" inoremap <silent><expr> <TAB>
" \ pumvisible() ? "\<C-n>" :
" \ <SID>check_back_space() ? "\<TAB>" :
" \ coc#refresh()
" " <s-TAB> to select candidate backward
" inoremap <expr><s-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
" function! s:check_back_space() abort
" let col = col('.')-1
" return !col || getline('.')[col - 1] =~# '\s'
" endfunction
"
" " <CR> to comfirm selected candidate
" " only when there's selected complete item
" if exists('*complete_info')
" inoremap <silent><expr> <CR> complete_info(['selected'])['selected'] != -1 ? "\<C-y>" : "\<C-g>u\<CR>"
" endif
"
" nnoremap <silent> K :call <SID>show_documentation()<CR>
" function! s:show_documentation()
" if(index(['vim', 'help'], &filetype) >= 0)
" execute 'h '.expand('<cword>')
" elseif (coc#rpc#ready())
" call CocActionAsync('doHover')
" else
" execute '!' . &keywordprg . " " . expand('<cword>')
" endif
" endfunction
"
" highlight link CocHighlightText Visual
" autocmd CursorHold * silent call CocActionAsync('highlight') " TODO
nmap <leader>rn <Plug>(coc-rename)
xmap <leader>f <Plug>(coc-format-selected)
command! -nargs=0 Format :call CocAction('format')
augroup mygroup
autocmd!
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" diagnostic info
nnoremap <silent><nowait> <LEADER>d :CocList diagnostics<CR>
nmap <silent> <LEADER>- <Plug>(coc-diagnostic-prev)
nmap <silent> <LEADER>= <Plug>(coc-diagnostic-next)
nmap <LEADER>qf <Plug>(coc-fix-current)
" Remap <C-f> and <C-b> for scroll float windows/popups.
if has('nvim-0.4.0') || has('patch-8.2.0750')
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<C-r>=coc#float#scroll(1)\<CR>" : "\<Right>"
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<C-r>=coc#float#scroll(0)\<CR>" : "\<Left>"
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
endif
" statusline support
" set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} "TODO
" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gD :tab sp<CR><Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
function! s:generate_compile_commands()
if empty(glob('CMakeLists.txt'))
echo "Can't find CMakeLists.txt"
return
endif
if empty(glob('.vscode'))
execute 'silent !mkdir .vscode'
endif
execute '!cmake -DCMAKE_BUILD_TYPE=debug
\ -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -S . -B .vscode'
endfunction
command! -nargs=0 Gcmake :call s:generate_compile_commands()
" ==== puremourning/vimspector ====
let g:vimspector_enable_mappings = 'HUMAN'
nmap <Leader>v <Plug>VimspectorBalloonEval
map <Leader>v <Plug>vimspectorBalloonEval
"airline
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_left_sep = '▶'
let g:airline_left_alt_sep = '❯'
let g:airline_right_sep = '◀'
let g:airline_right_alt_sep = '❮'
let g:airline_symbols.linenr = '-'
let g:airline_symbols.branch = '⎇'
" 是否打开tabline
let g:airline#extensions#tabline#enabled = 1
let g:airline_theme='bubblegum'
"let g:airline_section_b='%{strftime("%c")}'
let g:airline_sectiony='BN: %{bufnr("%)}'
"---------------alrLine Config--------------
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols.space = "\ua0"
let g:airline_exclude_filename = []
let g:Powerline_symbols='fancy'
let g:bufferline_echo=0
set laststatus=2
let g:airline_powerline_fonts = 1
set guifont=Powerline_Consolas:h14:cANSI
set t_Co=256
"set fillchars+=stl:\ ,stlnc:\
"
"---------------- Any fold config----------
filetype plugin indent on " required
syntax on " required
autocmd Filetype * AnyFoldActivate " activate for all filetypes
set foldlevel=99 " Open all folds
"colorscheme tokyonight
" There are also colorschemes for the different styles.
"colorscheme tokyonight-night
"colorscheme tokyonight-storm
"colorscheme tokyonight-day
"let g:lightline = {'colorscheme': 'tokyonight'}
colorscheme nord
let g:nord_contrast = v:true
let g:nord_borders = v:false
let g:nord_disable_background = v:false
let g:nord_italic = v:false
let g:nord_uniform_diff_background = v:true
let g:nord_bold = v:false