-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.vim
307 lines (243 loc) · 7.77 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
call plug#begin(stdpath('data') . '/plugged')
"""" Looks
"""""" Color schemes aaw yeah
Plug 'rakr/vim-one' " Dark and light themes
Plug 'sonph/onehalf', {'rtp': 'vim/'} " Alternative take on one
Plug 'ayu-theme/ayu-vim' " Great dark theme (imho)
Plug 'cormacrelf/vim-colors-github' " another nice light theme
Plug 'preservim/vim-colors-pencil'
Plug 'itchyny/lightline.vim'
Plug 'cespare/vim-toml', {'for': 'toml'}
Plug 'frazrepo/vim-rainbow'
Plug 'Yggdroot/indentLine' " Indent guides
" Usability
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } " Fuzzy finder
Plug 'junegunn/fzf.vim'
Plug 'wincent/ferret' "Use :Ack for search
Plug 'junegunn/vim-peekaboo' " Preview registers
Plug 'simeji/winresizer' " use <Leader>w to resize/move/focus windows
Plug 'simnalamburt/vim-mundo' " the undo tree
Plug 'preservim/nerdtree' ", { 'on': ['NERDTreeToggle', 'NERDTreeFind']}
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'ryanoasis/vim-devicons'
Plug 'bryanmylee/vim-colorscheme-icons'
Plug 'tpope/vim-commentary' "comment-out by gc
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'cohama/lexima.vim'
Plug 'andymass/vim-matchup'
Plug 'vim-scripts/python_match.vim'
" Programming
"" IntelliSense
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" testing, debugging
Plug 'vim-test/vim-test'
Plug 'puremourning/vimspector'
"" Tags
Plug 'ludovicchabant/vim-gutentags', {'for': ['py', 'js']}
Plug 'preservim/tagbar'
Plug 'liuchengxu/vista.vim'
" Python
Plug 'fisadev/vim-isort'
Plug 'psf/black', { 'branch': 'stable', 'for': 'python'}
Plug 'alfredodeza/coveragepy.vim', {'for': 'python'}
"" Git
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb'
Plug 'shumphrey/fugitive-gitlab.vim'
Plug 'junegunn/gv.vim'
"GraphQL
Plug 'jparise/vim-graphql'
call plug#end()
" Use pyenv `nvim` as python for neovim
let g:python3_host_prog='~/.pyenv/versions/nvim/bin/python'
if !empty($PYENV_VIRTUAL_ENV)
let g:pyenv_name = split($PYENV_VIRTUAL_ENV, "/")[-1:][0]
" Set correct python version for pyright
call coc#config('python', {
\ 'pythonPath': $PYENV_VIRTUAL_ENV . '/bin/python'
\ })
endif
"""" Looks
let g:default_plugin_sidebar_size=42
" Lightline
function! PrefixedBranch()
let branch_name = FugitiveHead()
if !empty(branch_name)
return '' . ' ' . branch_name
endif
return ""
endfunction
function! Pyenv()
if !empty($PYENV_VIRTUAL_ENV)
return ' ' . g:pyenv_name
endif
return ""
endfunction
let g:lightline = {
\ "colorscheme": "ayu",
\ "active": {
\ "left": [ [ "mode", "paste" ],
\ [ "readonly", "filename", "modified", "git_branch", "pyenv" ] ]
\ },
\ "component_function": {
\ "git_branch": "PrefixedBranch",
\ "pyenv": "Pyenv"
\ },
\ }
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
set termguicolors
let auycolor="dark"
colo ayu
" set background=light
" colo github
set cursorline
set colorcolumn=89,121
"override the nasty yellow background
" highlight CursorLine guibg=#eeeeee
" highlight CursorLineNr guibg=#cccccc guifg=#006699
" give the colorcolumn a color
" highlight ColorColumn guibg=#eeeeee
set number
let g:indentLine_char = '▏'
let g:indentLine_first_char = '▏'
let g:indentLine_color_term = 239
let g:indentLine_show_first_level=1
let g:indentLine_showFirstIndentLevel = 1
" indentLine would set conceallevel, hiding the quotes in JSON files and ** in markdown
let g:indentLine_fileTypeExclude = ['json', 'markdown']
let g:markdown_fenced_languages = ["python", "javascript"]
"""" Usability
let mapleader=';'
let maplocalleader=';'
let g:peekaboo_window = 'vertical botright 42new'
" move a line down/up
" -o: do not start with comment leader when adding a new line from normal mode using o/O
" -t: do not autowrap using textwidth
set formatoptions-=ot
nnoremap <silent> <Leader>/ :noh<CR>
nmap <leader>fb :Black
" 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)
nmap <leader>t :Vista!!<cr>
nnoremap <Leader>> :GitGutterNextHunk<CR>
nnoremap <Leader>< :GitGutterPrevHunk<CR>
" Open split below and right
set splitbelow
set splitright
" open 2 folds
set foldlevel=2
"Move between splits with CTRL+Direction
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
let g:winresizer_start_key="<Leader>w"
" FZF
" Define :Find commmand
" --column: Show column number
" --line-number: Show line number
" --no-heading: Do not show file headings in results
" --fixed-strings: Search term as a literal string
" --ignore-case: Case insensitive search
" --no-ignore: Do not respect .gitignore, etc...
" --hidden: Search hidden files and folders
" --follow: Follow symlinks
" --glob: Additional conditions for search (in this case ignore everything in the .git/ folder)
" --color: Search color options
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --no-ignore --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>), 1, <bang>0)
" file browsing and searching
nnoremap <Leader>; :FZF<CR>
nnoremap <Leader><Space> :Find<Space>
nnoremap <Leader>fg :GitFiles<CR>
nnoremap <Leader>ft :Tags<CR>
nnoremap <Leader>e :Buffers<CR>
let NERDTreeAutoDeleteBuffer = 1
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
let NERDTreeMapOpenSplit = "x"
let NERDTreeMapPreviewSplit = "gx"
let NERDTreeMapOpenVSplit = "v"
let NERDTreeMapPreviewVSplit = "gv"
let g:NERDTreeWinSize=g:default_plugin_sidebar_size
nnoremap <Leader>n :NERDTreeToggle<Enter>
nnoremap <silent> <Leader>. :NERDTreeFind<CR>
" Git status in nerdtree
let g:NERDTreeGitStatusUseNerdFonts = 1
let g:NERDTreeGitStatusIndicatorMapCustom = {
\ 'Modified' :'*',
\ 'Staged' :'+',
\ 'Untracked' :'%',
\ 'Renamed' :'~',
\ 'Unmerged' :'=',
\ 'Deleted' :'-',
\ 'Dirty' :'•',
\ 'Ignored' :'.',
\ 'Clean' :' ',
\ 'Unknown' :'?',
\ }
let NERDTreeIgnore=["node_modules", "__pycache__"]
" Personally, I find swap files annoying.
set noswapfile
set nobackup
" Keep undo history
set undofile
set undodir=~/.local/share/nvim/undo
" don't wrap lines please
set nowrap
" Autocompletion behavior like bash
set wildmode=longest:full,full
" Search
set ignorecase " case insensitive...
set smartcase " ... until typing an uppercase
"""" Programming
"Syntax
"" Tabs, indents and other PEP8 stuff
set tabstop=4
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
autocmd BufNewFile,BufRead *.py,*.sh
\ set tabstop=4 |
\ set softtabstop=4 |
\ set shiftwidth=4 |
\ set textwidth=120 |
\ set expandtab |
\ set autoindent |
\ set fileformat=unix
autocmd BufNewFile,BufRead *.js,*.html,*.css,*.yaml,*.yml
\ set tabstop=4 |
\ set softtabstop=4 |
\ set shiftwidth=4 |
\ set textwidth=9999 | " Prevent wrapping
\ set expandtab |
\ set autoindent |
\ set fileformat=unix
set tags=.tags
let g:gutentags_ctags_tagfile='.tags'
let g:vista_sidebar_width=g:default_plugin_sidebar_size
" let g:vista_default_executive = 'coc'
let g:vimspector_enable_mappings = 'HUMAN'
" Python
" Linting / fixing
nnoremap <Leader>fb :Black<cr>
" Testing
let test#python#runner = 'pytest'
let test#python#pytest#file_pattern = '\.py'
let test#strategy='neovim'
"""" Misc
" C-A-t to open terminal split below, esc to enter normal mode
function! OpenTerminal()
split term://zsh
resize 12
endfunction
nnoremap <Leader>- :call OpenTerminal()<CR>
" ESC out of the terminal
tnoremap <Esc> <C-\><C-n>
"""" Git / remote repository browsing by Gbrowse
let g:fugitive_gitlab_domains = ['https://gitlab.wearemoose.io']