aboutsummaryrefslogtreecommitdiff
path: root/.config/nvim/init.vim
blob: 35566e8f3ab8474bfbfdcd52a42ea791e4252bd8 (plain)
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
let mapleader = " "
set modeline
set wrap
set autoindent
set noexpandtab
set tabstop=2
set shiftwidth=2
set termguicolors
set shortmess=I
set splitbelow splitright
set noshowmode
set ignorecase
set smartcase
set timeoutlen=500
set updatetime=100
set mouse=a
set cino=N-s,E-s,l1,g-1,j1
set linebreak " set wrap but don't wrap inside words
set viminfo+='1000,n~/.local/nvim/viminfo
set guifont=JetBrainsMono\ Nerd\ Font:h9:#e-subpixelantialias:#h-slight
set linespace=5
let g:sneak#label = 1
let g:which_key_map = {}
let g:airline_powerline_fonts = 1
let g:minimap_highlight='Visual'
let g:python3_host_prog='/usr/bin/python3'
let g:vimtex_quickfix_open_on_warning = 0
let g:vimtex_imaps_enabled = 0

if exists("g:neovide")
	nmap <silent> <C-=> :lua vim.g.neovide_scale_factor = vim.g.neovide_scale_factor + 0.1<CR>
	nmap <silent> <C-ScrollWheelUp> :lua vim.g.neovide_scale_factor = vim.g.neovide_scale_factor + 0.1<CR>
	nmap <silent> <C--> :lua vim.g.neovide_scale_factor = vim.g.neovide_scale_factor - 0.1<CR>
	nmap <silent> <C-ScrollWheelDown> :lua vim.g.neovide_scale_factor = vim.g.neovide_scale_factor - 0.1<CR>
	nmap <silent> <C-0> :lua vim.g.neovide_scale_factor = 1<CR>
	let g:neovide_scroll_animation_length = 0.18
	let g:neovide_floating_shadow = v:false
	let g:neovide_cursor_animation_length = 0.06
	let g:neovide_cursor_trail_size = 0.0
	let g:neovide_padding_top=16
	let g:neovide_padding_left=16
	let g:neovide_padding_right=16
	let g:neovide_padding_bottom=16
endif

" plugged
call plug#begin('~/.config/nvim/plugged')
" quality of life
Plug 'jiangmiao/auto-pairs'
Plug 'tpope/vim-surround'
Plug 'itchyny/lightline.vim'
Plug 'terryma/vim-multiple-cursors'
Plug 'liuchengxu/vim-which-key'
Plug 'justinmk/vim-sneak'
Plug 'mbbill/undotree'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'puremourning/vimspector'
Plug 'junegunn/goyo.vim'
Plug 'psliwka/vim-smoothie'
" Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
Plug 'wellle/targets.vim'
" Plug 'dstein64/vim-startuptime'
Plug 'rrethy/vim-hexokinase', { 'do': 'make hexokinase' }
Plug 'dkarter/bullets.vim'
Plug 'editorconfig/editorconfig-vim'

" language plugins
Plug 'lervag/vimtex'
" Plug 'pangloss/vim-javascript'
Plug 'hail2u/vim-css3-syntax'
Plug 'octol/vim-cpp-enhanced-highlight'
Plug 'vim-python/python-syntax'
Plug 'dart-lang/dart-vim-plugin'
Plug 'bartlomiejdanek/vim-dart'
Plug 'HerringtonDarkholme/yats.vim'
Plug 'cespare/vim-toml'
Plug 'tikhomirov/vim-glsl'
" Plug 'gabrielelana/vim-markdown'
Plug 'vim-scripts/syntaxm4.vim'
Plug 'elkowar/yuck.vim'
Plug 'eraserhd/parinfer-rust', {'do': 'cargo build --release'}
Plug 'kaarmu/typst.vim'
Plug 'aklt/plantuml-syntax'
Plug 'fymyte/rasi.vim'
Plug 'habamax/vim-asciidoctor'
Plug 'lonkaars/coc-khard'

" themes
Plug 'arzg/vim-colors-xcode'
Plug '~/.config/nvim/local/bliss'
Plug '~/.config/nvim/local/polarlight.vim'
Plug '~/.config/nvim/local/autonyaa.vim'
Plug 'lonkaars/blubber'
Plug 'romgrk/github-light.vim'
Plug 'vv9k/vim-github-dark'
Plug 'rose-pine/neovim'
call plug#end()

" keybinds
tnoremap <Esc> <C-\><C-n>

nnoremap tt :tabnew<CR>

nmap <CR> o<Esc>
nmap <leader>qf <Plug>(coc-fix-current)

nnoremap <silent> <A-j> :m +1<CR>
nnoremap <silent> <A-k> :m -2<CR>

imap <C-h> <Left>
imap <C-j> <Down>
imap <C-k> <Up>
imap <C-l> <Right>

command UTF2Latex
			\ :%s/‘/`/ge |
			\ :%s/’/'/ge |
			\ :%s/“/``/ge |
			\ :%s/”/''/ge |
			\ :%s/–/--/ge |
			\ :%s/—/---/ge
command UTF2Ascii
			\ :%s/‘/'/ge |
			\ :%s/’/'/ge |
			\ :%s/“/"/ge |
			\ :%s/”/"/ge |
			\ :%s/–/--/ge |
			\ :%s/—/---/ge

" leader keybindings
nnoremap <silent> <leader> :WhichKey '<space>'<CR>

map <leader>vo <Plug>VimspectorContinue
map <leader>vq <Plug>VimspectorStop
map <leader>vr <Plug>VimspectorRestart
map <leader>vp <Plug>VimspectorPause
map <leader>vb <Plug>VimspectorToggleBreakpoint
map <leader>vc <Plug>VimspectorToggleConditionalBreakpoint
map <leader>vf <Plug>VimspectorAddFunctionBreakpoint
map <leader>vn <Plug>VimspectorStepOver
map <leader>vi <Plug>VimspectorStepInto
map <leader>vu <Plug>VimspectorStepOut
let g:which_key_map.v = {
			\ 'name': '+vimspector',
			\ 'o': 'continue',
			\ 'q': 'stop',
			\ 'r': 'restart',
			\ 'p': 'pause',
			\ 'b': 'toggle breakpoint',
			\ 'c': 'toggle conditional breakpoint',
			\ 'f': 'add function breakpoint',
			\ 'n': 'step over',
			\ 'i': 'step into',
			\ 'u': 'step out'
			\ }

map <leader>p "+p
map <leader>y "+y
let g:which_key_map.p = 'x11 paste'
let g:which_key_map.y = 'x11 yank'

map <silent> <leader>w :w<cr>
let g:which_key_map.w = 'write'

map <silent> <leader>dv :VimtexView<cr>
map <silent> <leader>dc :VimtexCompile<cr>
map <silent> <leader>de :VimtexErrors<cr>
map <silent> <leader>dt :VimtexTocToggle<cr>
let g:which_key_map.d = {
			\ 'name': '+document',
			\ 'v': 'view',
			\ 'c': 'compile',
			\ 'e': 'errors',
			\ 't': 'table of contents'
			\ }

map <silent> <leader>ts :sp term://zsh<cr>i
map <silent> <leader>tv :vsp term://zsh<cr>i
map <silent> <leader>tt :tabnew term://zsh<cr>i
let g:which_key_map.t = {
			\ 'name': '+term',
			\ 's': 'split',
			\ 'v': 'vsplit',
			\ 't': 'tab'
			\ }

map <silent> <leader>.v :tabnew ~/.config/nvim/init.vim<cr>
let g:which_key_map['.'] = {
			\ 'name': '+config',
			\ 'v': 'vim',
			\ }

map <silent> <leader>u :UndotreeToggle<cr>
let g:which_key_map.u = 'toggle undo tree'

" cmd maps
cnoreabbrev W w
cnoreabbrev sudow w !sudo tee %

" hexokinase
let g:Hexokinase_termDisabled = 1
let g:Hexokinase_optOutPatterns = [ 'colour_names' ]

" lightline
let g:lightline = {
			\ 'colorscheme': 'auto',
			\ 'mode_map': {
			\	'n' : 'norm',
			\	'i' : 'ins',
			\	'R' : 'rep',
			\	'v' : 'vis',
			\	'V' : 'v-l',
			\	"\<C-v>": 'v-b',
			\	'c' : 'cmd',
			\	's' : 'sel',
			\	'S' : 's-l',
			\	"\<C-s>": 's-b',
			\	't': 'term'
			\ },
			\ 'active': {
			\	'left': [
			\		[ 'mode', 'paste' ],
			\		[ 'readonly', 'filename', 'modified']
			\	],
			\	'right': [
			\		[ 'lineinfo' ]
			\	]
			\ },
			\ 'inactive': {
			\	'left': [
			\		[ 'readonly', 'filename', 'modified']
			\	],
			\	'right': [  ]
			\ },
			\ }
let g:lightline.tabline = {
		    \ 'left': [ [ 'tabs' ] ],
		    \ 'right': [ ] }
call lightline#init()

" vimtex config
let g:tex_flavor = 'latex'
let g:vimtex_compiler_latexmk = {
			\ 'backend' : 'nvim',
			\ 'background' : 1,
			\ 'build_dir' : '',
			\ 'callback' : 1,
			\ 'continuous' : 1,
			\ 'executable' : 'latexmk',
			\ 'engine' : 'xelatex',
			\ 'hooks' : [],
			\ 'options' : [
			\   '-xelatex',
			\   '-file-line-error',
			\   '-synctex=1',
			\   '-interaction=nonstopmode',
			\ ],
			\}

" TeX quotes
autocmd FileType tex let b:surround_{char2nr("q")} = "`\r'"
autocmd FileType tex let b:surround_{char2nr('Q')} = "``\r''"
autocmd FileType tex let b:AutoPairs = AutoPairsDefine({'(':')', '[':']', '{':'}', "``":"''", "`":"'", '$':'$', '"':'"'})

" AutoPairs for plantuml
autocmd FileType plantuml let b:AutoPairs = {'(':')', '[':']', '{':'}', '`':'`'}

" coc.vim <tab> completion and <cr> stuff
function! CheckBackspace() abort
  let col = col('.') - 1
  return !col || getline('.')[col - 1]  =~# '\s'
endfunction
inoremap <silent><expr> <TAB>
      \ coc#pum#visible() ? coc#pum#next(1) :
      \ CheckBackspace() ? "\<Tab>" :
      \ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"

function! s:check_back_space() abort
	let col = col('.') - 1
	return !col || getline('.')[col - 1]  =~# '\s'
endfunction

if has("patch-8.1.1564")
  set signcolumn=number
else
  set signcolumn=yes
endif

inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm() : "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"

" coc code navigation
map <silent> <leader>cd <Plug>(coc-definition)
map <silent> <leader>cy <Plug>(coc-type-definition)
map <silent> <leader>ci <Plug>(coc-implementation)
map <silent> <leader>cr <Plug>(coc-references)
map <leader>cn <Plug>(coc-rename)
let g:which_key_map.c = {
			\ 'name': '+coc',
			\ 'd': 'definition',
			\ 'y': 'type definition',
			\ 'i': 'implementation',
			\ 'r': 'references',
			\ 'n': 'rename'
			\ }

" use <c-space>for trigger completion
inoremap <silent><expr> <c-space> coc#refresh()

" auto-comment uit
" autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o

" which key register dict
call which_key#register('<Space>', "g:which_key_map")

" no line numbers in terminal
augroup TerminalStuff
	" Clear old autocommands
	au!
	autocmd TermOpen * setlocal nonumber norelativenumber
	autocmd TermOpen * set signcolumn=no
augroup END

" python-syntax
" let g:python_highlight_all = 1
let g:python_recommended_style = 0
" autocmd FileType python setlocal noexpandtab
au BufRead,BufNewFile *.py set expandtab

function! SynStack()
	if !exists("*synstack")
		return
	endif
	echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc

" markdown
let g:markdown_enable_spell_checking = 0
au FileType markdown set expandtab

" asciidoc
au FileType asciidoctor set expandtab

" binary files
augroup Binary
  au!
  au BufReadPre  *.bin let &bin=1
  au BufReadPost *.bin if &bin | %!xxd
  au BufReadPost *.bin set ft=xxd | endif
  au BufWritePre *.bin if &bin | %!xxd -r
  au BufWritePre *.bin endif
  au BufWritePost *.bin if &bin | %!xxd
  au BufWritePost *.bin set nomod | endif
  au BufWritePost *.bin set noeol
augroup END

" sneak
let g:sneak#use_ic_scs = 0

" fcitx5
autocmd InsertEnter * call system("fcitx5-temp-restore &")
autocmd InsertLeave * call system("fcitx5-temp-off &")

" colorscheme
source $XDG_CONFIG_HOME/nvim/mode.vim