-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.vim
586 lines (470 loc) · 16.2 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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
syntax on
set t_Co=256
set ignorecase
set smartcase
set scrolloff=18
set incsearch
set nohlsearch
set expandtab
set tabstop=2
set softtabstop=2
set shiftwidth=2
set updatetime=50
set number relativenumber
set nu rnu
set noswapfile
set termguicolors
set hidden
" Some servers have issues with backup files, see #649.
set nobackup
set nowritebackup
set nowrap
let g:python3_host_prog = '~/.config/nvim/neovim_env/bin/python'
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
" set mouse=a
set laststatus=3
let mapleader=' '
" " Use ctrl-[hjkl] to select the active split!
" nmap <silent> <c-k> :wincmd k<CR>
" nmap <silent> <c-j> :wincmd j<CR>
" nmap <silent> <c-h> :wincmd h<CR>
" nmap <silent> <c-l> :wincmd l<CR>
" use leader and hjkl to navigate splits
nnoremap <leader>k :wincmd k<CR>
nnoremap <leader>j :wincmd j<CR>
nnoremap <leader>h :wincmd h<CR>
nnoremap <leader>l :wincmd l<CR>
nnoremap <leader>o <C-O>
nnoremap <leader>i <C-i>
" open current buffer in smerge
nnoremap <leader>sm <cmd>!smerge log %<cr>
nnoremap <leader>sl :execute ":!smerge search 'file:% line:"..line('.').."-"..line('.').."'"<cr>
" bind noh to escape to hide it fast
" nnoremap <esc> :noh<return><esc>
" plugin manager
call plug#begin()
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.1' }
Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' }
Plug 'fannheyward/telescope-coc.nvim'
Plug 'tpope/vim-commentary'
Plug 'neoclide/coc.nvim', {'branch': 'release', 'do': { -> coc#util#install() } }
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'nvim-treesitter/nvim-treesitter-context'
"Plug 'https://github.com/airblade/vim-gitgutter.git'
" Plug 'tanvirtin/vgit.nvim'
Plug 'jparise/vim-graphql'
Plug 'styled-components/vim-styled-components'
Plug 'kyazdani42/nvim-web-devicons'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'TimUntersberger/neogit'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb'
Plug 'ellisonleao/glow.nvim'
Plug 'voldikss/vim-floaterm'
Plug 'mechatroner/rainbow_csv'
" Colorscheme switcher
Plug 'vimpostor/vim-lumen'
" colorschemes
Plug 'navarasu/onedark.nvim'
Plug 'nanotech/jellybeans.vim'
Plug 'folke/tokyonight.nvim', { 'branch': 'main' }
Plug 'Yazeed1s/minimal.nvim'
Plug 'savq/melange'
Plug 'fcpg/vim-farout'
Plug 'RRethy/nvim-base16'
Plug 'morhetz/gruvbox'
Plug 'catppuccin/nvim', {'as': 'catppuccin'}
Plug 'rose-pine/neovim', {'as': 'rose-pine'}
Plug 'kaiuri/nvim-juliana'
Plug 'github/copilot.vim'
call plug#end()
" plugin remapping
" xnoremap <silent>g <cmd>gc
" Telescope mappings
nnoremap <silent> <C-p> <cmd>Telescope find_files theme=dropdown<cr>
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
nnoremap <leader>fp <cmd>Telescope commands<cr>
nnoremap <leader>fi <cmd>Telescope quickfix<cr>
nnoremap <leader>fk <cmd>Telescope keymaps<cr>
nnoremap <leader>fr <cmd>Telescope coc references<cr>
nnoremap <leader>fd <cmd>Telescope coc definitions<cr>
nnoremap <leader>ft <cmd>Telescope colorscheme<cr>
" nnoremap <leader>gg <cmd>Telescope git_status<cr>
nnoremap <leader>gl <cmd>Telescope git_commits<cr>
" " remap git to not conflict with split navigation
" nnoremap <leader>gp <Plug>(GitGutterPreviewHunk)
" nnoremap <leader>gu <Plug>(GitGutterUndoHunk)
" nnoremap <leader>gs <Plug>(GitGutterStageHunk)
" xnoremap <leader>gs <Plug>(GitGutterStageHunk)
" remap git to not conflict with split navigation
" nnoremap <leader>gp <cmd>VGit buffer_hunk_preview<cr>
" nnoremap <leader>gs <cmd>VGit buffer_hunk_stage<cr>
" nnoremap <leader>gu <cmd>VGit buffer_unstage<cr>
" nmap <silent> [c <cmd>VGit hunk_up<cr>
" nmap <silent> ]c <cmd>VGit hunk_down<cr>
nnoremap <leader>gg <cmd>vertical Git<cr>
command G :vertical Git
lua << EOF
require'treesitter-context'.setup{
enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit.
trim_scope = 'outer', -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer'
min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit.
patterns = { -- Match patterns for TS nodes. These get wrapped to match at word boundaries.
-- For all filetypes
-- Note that setting an entry here replaces all other patterns for this entry.
-- By setting the 'default' entry below, you can control which nodes you want to
-- appear in the context window.
default = {
'class',
'function',
'method',
'for',
'while',
'if',
'switch',
'case',
},
-- Patterns for specific filetypes
-- If a pattern is missing, *open a PR* so everyone can benefit.
tex = {
'chapter',
'section',
'subsection',
'subsubsection',
},
rust = {
'impl_item',
'struct',
'enum',
},
scala = {
'object_definition',
},
vhdl = {
'process_statement',
'architecture_body',
'entity_declaration',
},
markdown = {
'section',
},
elixir = {
'anonymous_function',
'arguments',
'block',
'do_block',
'list',
'map',
'tuple',
'quoted_content',
},
json = {
'pair',
},
yaml = {
'block_mapping_pair',
},
},
exact_patterns = {
-- Example for a specific filetype with Lua patterns
-- Treat patterns.rust as a Lua pattern (i.e "^impl_item$" will
-- exactly match "impl_item" only)
-- rust = true,
},
-- [!] The options below are exposed but shouldn't require your attention,
-- you can safely ignore them.
zindex = 20, -- The Z-index of the context window
mode = 'cursor', -- Line used to calculate context. Choices: 'cursor', 'topline'
-- Separator between context and content. Should be a single character string, like '-'.
-- When separator is set, the context will only show up when there are at least 2 lines above cursorline.
separator = nil,
}
EOF
" " NERDTree
" nnoremap <leader>n :NERDTreeFocus<CR>
" nnoremap <C-n> :NERDTree<CR>
" nnoremap <C-t> :NERDTreeToggle<CR>
" nnoremap <C-f> :NERDTreeFind<CR>
nmap <leader>e <Cmd>CocCommand explorer --width 35<CR>
lua << EOF
-- require('vgit').setup({
-- settings = {
-- scene = {
-- diff_preference = 'split',
-- },
-- live_blame = {
-- enabled = false,
-- },
-- authorship_code_lens = {
-- enabled = false,
-- },
-- }
-- })
require('telescope').setup{
defaults = {
file_ignore_patterns = { "node_modules", ".plugins", ".static", ".public", "env"},
path_display = { truncate }
}
}
require'nvim-treesitter.configs'.setup {
-- A list of parser names, or "all"
ensure_installed = { "lua", "python" },
-- Automatically install missing parsers when entering buffer
auto_install = true,
-- List of parsers to ignore installing (for "all")
ignore_install = { "javascript", "tsx", "typescript" },
highlight = {
-- `false` will disable the whole extension
enable = true,
-- disable = { "tsx", "typescript", "javascript"},
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
},
}
EOF
let g:coc_global_extensions = [
\'coc-tsserver',
\'coc-prettier',
\'coc-pairs',
\'coc-html',
\'coc-json',
\'coc-css',
\'coc-styled-components',
\'coc-explorer',
\'coc-pyright']
" coc-vim settings
" TextEdit might fail if hidden is not set.
" Give more space for displaying messages.
" set cmdheight=2
" Don't pass messages to |ins-completion-menu|.
set shortmess+=c
" " Always show the signcolumn, otherwise it would shift the text each time
" " diagnostics appear/become resolved.
" if has("nvim-0.5.0") || has("patch-8.1.1564")
" " Recently vim can merge signcolumn and number column into one
" set signcolumn=number
" else
" set signcolumn=yes
" endif
set signcolumn=yes
" " Use tab for trigger completion with characters ahead and navigate.
" " NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" " other plugin before putting this into your config.
" inoremap <silent><expr> <TAB>
" \ pumvisible() ? "\<C-n>" :
" \ CheckBackspace() ? "\<TAB>" :
" \ coc#refresh()
" inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
" function! CheckBackspace() abort
" let col = col('.') - 1
" return !col || getline('.')[col - 1] =~# '\s'
" endfunction
" inoremap <silent><expr> <TAB>
" \ coc#pum#visible() ? coc#_select_confirm() :
" \ coc#expandableOrJumpable() ?
" \ "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
" \ <SID>check_back_space() ? "\<TAB>" :
" \ coc#refresh()
" function! s:check_back_space() abort
" let col = col('.') - 1
" return !col || getline('.')[col - 1] =~# '\s'
" endfunction
" let g:coc_snippet_next = '<tab>'
" inoremap <silent><expr> <TAB>
" \ coc#pum#visible() ? coc#_select_confirm() :
" \ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
" \ CheckBackspace() ? "\<TAB>" :
" \ coc#refresh()
" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
inoremap <silent><expr> jj coc#refresh()
" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gv :vsp<CR><Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Use K to show documentation in preview window.
nnoremap <silent> K :call ShowDocumentation()<CR>
function! ShowDocumentation()
if CocAction('hasProvider', 'hover')
call CocActionAsync('doHover')
else
call feedkeys('K', 'in')
endif
endfunction
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" Add (Neo)Vim's native statusline support.
" NOTE: Please see `:h coc-status` for integrations with external plugins that
" provide custom statusline: lightline.vim, vim-airline.
" set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
command! -nargs=0 Tsc :call CocAction('runCommand', 'tsserver.watchBuild')
augroup neovim_terminal
autocmd!
" Enter Terminal-mode (insert) automatically
" autocmd TermOpen * startinsert
" Disables number lines on terminal buffers
autocmd TermOpen * :set nonumber norelativenumber
" allows you to use Ctrl-c on terminal window
autocmd TermOpen * nnoremap <buffer> <C-c> i<C-c>
augroup END
tnoremap <S-Esc> <C-\><C-n>
" tnoremap <Esc><Esc> <C-\><C-n>
let g:floaterm_width=0.8
let g:floaterm_height=0.8
let g:floaterm_autoclose=1
" Set floaterm window's background to black
" hi Floaterm guibg=black
" Set floating window border line color to cyan, and background to orange
" hi FloatermBorder guibg=black guifg=cyan
nnoremap <leader>tt <cmd>FloatermToggle<cr>
nnoremap <leader>tg <cmd>FloatermNew lazygit<cr>
nnoremap <leader>ts <cmd>FloatermNew spt --tick-rate 16<cr>
nnoremap <leader>tn <cmd>FloatermNext<cr>
nnoremap <leader>tx <cmd>FloatermKill<cr>
" colorscheme setup
" https://github.com/navarasu/onedark.nvim
" lua << EOF
" require('onedark').setup {
" style = 'warm',
" transparent = true,
" colors = {
" -- purple = "#c678dd",
" purple = "#9578b0",
" fg = "#bfb1a3",
" cyan = "#5eaba1",
" blue = "#689bc4",
" yellow = "#c98f59",
" orange = "#d6b569",
" },
" }
" require('onedark').load()
" EOF
" let g:airline_theme='angr'
" let g:irline_theme='distinguished'
" let g:airline_theme='jet'
" let g:airline_theme='base16'
" let g:airline_theme='onedark'
" colorscheme base16-solarized-light
" colorscheme base16-onedark
set noshowmode
" let g:airline_theme='minimalist'
let g:airline_theme='minimalist'
" set fillchars+=vert:\ "
colorscheme base16-classic-dark
" au User LumenLight set background=light
" au User LumenLight colorscheme base16-solarized-light
au User LumenLight colorscheme base16-humanoid-light
au User LumenLight let g:airline_theme='minimalist'
" au User LumenDark set background=dark
" au User LumenDark colorscheme base16-twilight
au User LumenDark colorscheme base16-classic-dark
au User LumenDark let g:airline_theme='minimalist'
:command Togg colorscheme base16-humanoid-light | let g:airline_theme='minimalist'
" let g:airline_section_z='%p%%%#__accent_bold#%{g:airline_symbols.linenr}%l%#__restore__#%#__accent_bold#/%L%{g:airline_symbols.maxlinenr}%#__restore__#%#__accent_bold#%{g:airline_symbols.colnr}%v%#__restore__#'
"let g:airline_section_z='%L%{g:airline_symbols.maxlinenr}'
" lua << EOF
" require('nightfox').setup({
" options = { transparent = true }
" })
" EOF
"" lua << EOF
"" require('base16-colorscheme').setup({
"" base00 = '#16161D'
"" })
"" EOF
""
" let g:airline_theme='minimalist'
" let g:airline_theme='nightfox'
" let g:airline_theme='jellybeans'
" let g:airline_theme='farout'
" let g:airline_theme='base16'
" colorscheme base16-twilight
" let g:airline_theme='gruvbox'
" let g:gruvbox_contrast_dark='hard'
" let g:gruvbox_transparent_bg='1'
" let g:gruvbox_sign_column='bg0'
" colorscheme gruvbox
" let g:airline_theme='farout'
" colorscheme farout
" autocmd VimEnter * hi Normal ctermbg=none
" colorscheme base16-default-dark
" colorscheme farout
autocmd BufNewFile,BufRead *.csv set filetype=csv
autocmd BufNewFile,BufRead *.csv set laststatus=3
nnoremap <leader>si <CMD>CocCommand pyright.organizeimports<CR>
" Cool idea but makes braces laggy
" inoremap {<Enter> {<Enter>}<Esc>O<Tab>
" Because I don't know how to type
command Wq :wq
command W :w
nnoremap <leader>q <cmd>q<cr>
augroup JsonToJsonc
autocmd! FileType json set filetype=jsonc
augroup END
" air-line
let g:airline_powerline_fonts = 1
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let s:hidden_all = 0
function! ToggleHiddenAll()
if s:hidden_all == 0
let s:hidden_all = 1
set noshowmode
set noruler
set laststatus=0
set noshowcmd
else
let s:hidden_all = 0
set showmode
set ruler
set laststatus=3
set showcmd
endif
endfunction
nnoremap <S-h> :call ToggleHiddenAll()<CR>
" unicode symbols
let g:airline_left_sep = '»'
let g:airline_left_sep = '▶'
let g:airline_right_sep = '«'
let g:airline_right_sep = '◀'
let g:airline_symbols.linenr = '␊'
let g:airline_symbols.linenr = ''
let g:airline_symbols.linenr = '¶'
let g:airline_symbols.branch = '⎇'
let g:airline_symbols.paste = 'ρ'
let g:airline_symbols.paste = 'Þ'
let g:airline_symbols.paste = '∥'
let g:airline_symbols.whitespace = 'Ξ'
" airline symbols
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.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = ''
set laststatus=3