-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.vim
355 lines (306 loc) · 10.6 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
set nocompatible " not compatible to vi
set autoindent
set dir=~/nvimtmp
set expandtab
set fileencoding=utf-8
set fileformat=unix
set hidden
set hlsearch
set ignorecase
set langmenu=en_US.UTF-8 " show status message in English
set nu
set laststatus=2
set nobackup
set novb
set ruler
set smartcase
set ts=2 sw=2 et
set statusline+=%F
set statusline+=%#warningmsg#
set statusline+=%*
set swapfile
set cc=80,120
set updatetime=200 " for gitgutter
" solution for slow tmux navigator
"set shell=/bin/bash\ -i
set shell=sh " this resolves slow pane changing nvim opened pane and other pane with tmux navigator
" alrline settings
let g:airline#extensions#tabline#enabled = 0 " for bufferline
let g:airline#extensions#tabline#fnamemod = ':t'
let g:airline#extensions#tabline#show_close_button = 0
" go settings
let g:go_fmt_command = "gopls"
let g:go_gopls_gofumpt=1
let $HIGHLIGHT_SETTINGS = join(['array_whitespace_error', 'build_constraints',
\ 'chan_whitespace_error', 'extra_types', 'fields', 'format_strings',
\ 'function_arguments', 'function_calls', 'functions', 'generate_tags',
\ 'operators', 'space_tab_error', 'string_spellcheck',
\ 'trailing_whitespace_error', 'types', 'variable_assignments',
\ 'variable_declarations'], ' ')
for s:s in split($HIGHLIGHT_SETTINGS, ' ')
call execute('let g:go_highlight_' . s:s . ' = 1')
endfor
let g:go_metalinter_enabled = ['vet', 'golint', 'errcheck']
" gitgutter settings
let g:gitgutter_override_sign_column_highlight = 0
let g:gitgutter_sign_added = '✚'
let g:gitgutter_sign_modified = '~'
let g:gitgutter_sign_removed = '_'
let g:gitgutter_sign_removed = '_'
" indent_guides settings
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_guide_size = 1
let g:indent_guides_auto_colors = 0
let g:indent_guides_start_level = 2
" markdown extension configuration
let g:vim_markdown_folding_disabled = 1
" nord colorscheme configuration
let g:nord_italic = 1
let g:nord_italic_comments = 1
let g:nord_underline = 1
let g:nord_uniform_status_lines = 1
let g:nord_cursor_line_number_background = 1
" racer settings
let g:racer_cmd = "/Users/gallen/.cargo/bin/racer"
let g:racer_experimental_completer = 1
let g:html_indent_tags = 'p\|li\|nav'
let g:strip_whitespace_on_save = 1
let g:better_whitespace_enabled=1
let g:airline_theme = 'base16_material'
" autocmd settings
autocmd BufNewFile,BufRead *.html.erb set filetype=html
autocmd BufNewFile,BufRead *.html.tera set filetype=html
autocmd BufNewFile,BufRead *.rs set filetype=rust
autocmd BufNewFile,BufRead *.ex set filetype=elixir
autocmd BufNewFile,BufRead *.exs set filetype=elixir
autocmd BufNewFile,BufRead *.scss set filetype=css
autocmd BufNewFile,BufRead *.sh set filetype=sh
autocmd BufNewFile,BufRead *.yml set filetype=yaml
autocmd BufNewFile,BufRead *.txt set filetype=txt
autocmd BufWritePre *.go :silent call CocAction('runCommand', 'editor.action.organizeImport')
autocmd FileType go nmap gtj :CocCommand go.tags.add json<cr>
autocmd FileType go nmap gty :CocCommand go.tags.add yaml<cr>
autocmd FileType go nmap gtx :CocCommand go.tags.clear<cr>
autocmd FileType python let b:coc_root_patterns = ['.git', '.env']
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd ctermbg=2
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=4
autocmd Filetype elixir
\ set ts=2 |
\ set sw=2
autocmd Filetype html
\ set tabstop=2 |
\ set shiftwidth=2 |
\ set softtabstop=2 |
autocmd BufNewFile,BufRead *.tsx
\ set tabstop=2 |
\ set shiftwidth=2 |
\ set softtabstop=2 |
autocmd BufNewFile,BufRead *.ts
\ set tabstop=2 |
\ set shiftwidth=2 |
\ set softtabstop=2 |
autocmd Filetype js
\ colo material-theme |
autocmd FileType python set cc=80,120
autocmd FileType txt set cc=105
autocmd FileType markdown set cc=120
" vim-racer settings
autocmd Filetype rust
\ nmap gd <Plug>(rust-def) |
\ nmap gs <Plug>(rust-def-split) |
\ nmap gx <Plug>(rust-def-vertical) |
\ nmap <leader>gd <Plug>(rust-doc) |
\ set cc=80,120
autocmd Filetype sh
\ set ts=2 |
\ set sw=2
autocmd Filetype yaml
\ set ts=2 |
\ set sw=2
syntax enable
" Plugins "
call plug#begin('~/.config/nvim/plugged')
Plug 'rust-lang/rust.vim'
Plug 'airblade/vim-gitgutter'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'racer-rust/vim-racer'
Plug 'tmux-plugins/vim-tmux'
Plug 'cespare/vim-toml'
Plug 'peterhoeg/vim-qml'
Plug 'preservim/vim-indent-guides'
Plug 'ntpeters/vim-better-whitespace'
Plug 'christoomey/vim-tmux-navigator'
Plug 'jason0x43/vim-js-indent'
Plug 'Shougo/vimproc.vim', {'do' : 'make'}
Plug 'slashmili/alchemist.vim'
Plug 'elixir-lang/vim-elixir'
Plug 'derekwyatt/vim-scala'
Plug 'sheerun/vim-polyglot'
Plug 'plasticboy/vim-markdown'
Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Plug 'junegunn/rainbow_parentheses.vim'
"-------
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'nvim-tree/nvim-tree.lua'
Plug 'nvim-tree/nvim-web-devicons' " Recommended (for coloured icons)
Plug 'akinsho/bufferline.nvim', { 'tag': '*' }
Plug 'folke/which-key.nvim'
Plug 'https://github.com/qpkorr/vim-bufkill'
"-------
let g:rainbow#pairs = [['(', ')'], ['[', ']']]
augroup rainbow_lisp
autocmd!
autocmd FileType python,rust,sh,fish,vim RainbowParentheses
augroup END
" telescope key (leader: \ key)
nnoremap <leader>ff :Telescope find_files<cr>
nnoremap <leader>fg :Telescope live_grep<cr>
nnoremap <leader>fb :Telescope buffers<cr>
nnoremap <leader>fh :Telescope help_tags<cr>
"autocompletion plugin
Plug 'neoclide/coc.nvim', {'branch': 'release', 'do': './install.sh'}
if executable('rls')
au User lsp_setup call lsp#register_server({
\ 'name': 'rls',
\ 'cmd': {server_info->['rustup', 'run', 'stable', 'rls']},
\ 'workspace_config': {'rust': {'clippy_preference': 'on'}},
\ 'whitelist': ['rust'],
\ })
endif
"=== coc settings =====================
" GoTo code navigation.
nmap <silent> gd <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
" use <tab> for trigger completion and navigate to the next complete item
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()
" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>
"
inoremap <silent><expr> <CR> pumvisible() ? coc#_select_confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<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
" 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
" ====================================
" colorscheme install
Plug 'kaicataldo/material.vim', { 'branch': 'main' }
Plug 'michaelmalick/vim-colors-bluedrake'
Plug 'folke/tokyonight.nvim', { 'branch': 'main' }
Plug 'neanias/everforest-nvim', { 'branch': 'main' }
Plug 'whatyouhide/vim-gotham'
Plug 'rebelot/kanagawa.nvim'
Plug 'AlexvZyl/nordic.nvim', { 'branch': 'main' }
Plug 'EdenEast/nightfox.nvim'
" tabline / status install
Plug 'nvim-lualine/lualine.nvim'
Plug 'nvim-tree/nvim-web-devicons'
let g:material_theme_style = 'palenight' " palenight | ocean
call plug#end()
"vim key settings
noremap <buffer> <silent> k gk
noremap <buffer> <silent> j gj
noremap <buffer> <silent> O gO
noremap <buffer> <silent> $ g$
nnoremap <silent> <BS> :TmuxNavigateLeft<cr>
nnoremap <C-n> :bnext<CR>
nnoremap <C-p> :bprevious<CR>
nnoremap <C-i> a <ESC>r
nnoremap <F8> :NvimTreeToggle<CR>
" command line mode mapping
cnoremap bd BD
set termguicolors
lua << EOF
require("bufferline").setup()
require("nvim-tree").setup()
local virtual_env = function()
-- only show virtual env for Python
if vim.bo.filetype ~= 'python' then
return ""
end
local venv_path = os.getenv('VIRTUAL_ENV')
if venv_path == nil then
return ""
else
local venv_name = vim.fn.fnamemodify(venv_path, ':t')
return string.format(" (%s)", venv_name)
end
end
require('lualine').setup {
options = {
theme = 'everforest',
},
sections = {
lualine_a = {'mode'},
lualine_b = {'branch', 'diff', 'diagnostics'},
lualine_c = {'filename'},
lualine_x = {'encoding', 'fileformat', 'filetype', virtual_env},
lualine_y = {'progress'},
lualine_z = {'location'}
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {'filename'},
lualine_x = {'location'},
lualine_y = {},
lualine_z = {}
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {}
}
EOF
colo everforest
highlight CocHintSign guifg=#CCF384 ctermfg=203
highlight CocHintHighlight guibg=#CCF384 ctermbg=203
highlight CocErrorSign guifg=#F47293 ctermfg=203
highlight CocErrorHighlight guibg=#F47293 ctermbg=203
highlight CocWarningSign guifg=#72F4D7 ctermfg=50
highlight CocWarningHighlight guibg=#72F4D7 ctermbg=50
highlight ExtraWhitespace ctermbg=255 guibg=#ffffff
highlight IndentGuidesEven guibg=#5c7080 ctermbg=2
highlight IndentGuidesOdd guibg=#4c6070 ctermbg=4
"highlight LineNr guibg=NONE ctermbg=NONE
"highlight Normal guibg=NONE ctermbg=NONE
highlight SpellBad term=reverse ctermbg=118 ctermfg=016 guibg=#87ff00 guifg=#000000
highlight clear SignColumn
highlight SignColumn guibg=NONE ctermbg=NONE
highlight Visual ctermbg=3
highlight ColorColumn ctermbg=2
let g:indent_guides_start_level = 2