-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
306 lines (240 loc) · 6.49 KB
/
vimrc
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
"""""""""""""""""""
"vimplug settings "
"""""""""""""""""""
"plugin loading vim-plug
call plug#begin('~/.dotfiles/vim/pack/')
"git in vim native :D
Plug 'airblade/vim-gitgutter'
"scheme
Plug 'vim-airline/vim-airline'
Plug 'crusoexia/vim-monokai'
"syntax and linting
Plug 'https://github.com/tpope/vim-surround'
Plug 'https://github.com/dense-analysis/ale'
"autocomplete/language
Plug 'ycm-core/YouCompleteMe'
"vim compilation and completion
"optional:
Plug 'https://github.com/lervag/vimtex'
Plug 'https://github.com/lervag/vimtex'
Plug 'https://github.com/nathangrigg/vim-beancount'
"snippets
"Plug 'SirVer/ultisnips'
"Plug 'honza/vim-snippets'
"utility
Plug 'https://github.com/scrooloose/nerdtree'
Plug 'https://github.com/Konfekt/FastFold'
"Python folding
Plug 'https://github.com/tmhedberg/SimpylFold'
"Theme:
Plug 'crusoexia/vim-monokai'
"Plug 'tomasr/molokai'
call plug#end()
"update helptags
call plug#helptags()
"""""""""""""""""""""""
"vimplug settings done"
"""""""""""""""""""""""
"""""""""""""""""""
" builtin settings"
"""""""""""""""""""
"fix background issue
"set background=dark
"backup and undo!
if has('vms')
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file (restore to previous version)
if has('persistent_undo')
set undofile " keep an undo file (undo changes after closing)
endif
endif
"highlighting!
if &t_Co > 2 || has('gui_running')
" Switch on highlighting the last used search pattern.
set hlsearch
endif
" Only do this part when compiled with support for autocommands.
if has('lautocmd')
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=80
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
"adding plugin filetype:
"set nocp " 'compatible' is not set
filetype plugin on " plugins are enabled
"syntax on
syntax on
" show existing tab with 4 spaces width
set tabstop=2
" when indenting with '>', use 4 spaces width
set shiftwidth=2
" On pressing tab, insert 4 spaces
set expandtab
"turn on autoindent
set autoindent
"line numbers
set number
set relativenumber
"organize files!
set backupdir=~/.vim/tmp,.
set directory=~/.vim/tmp,.
set undodir=~/.vim/undo
set viminfo+=n~/.vim/viminfo
"add set list
set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
noremap Ll :set list!<CR>
"folding on syntax
set foldmethod=syntax
" spelling remaps
" https://vimtricks.com/p/vimtrick-spell-checking-in-vim/
nnoremap <silent> ss :call SpellToggle()<cr>
let g:NoSpell=1
function! SpellToggle()
if g:NoSpell
let g:NoSpell=0
set spell spelllang=en_us
else
let g:NoSpell=1
set nospell
endif
endfunction
"spelling shortcuts
""add a word: zg
""remove a word: zg
nnoremap zn ]s
nnoremap zp [s
nnoremap zP [s<esc>z=
nnoremap zN ]s<esc>z=
noremap zz z=
"kill buffer cleanly
nnoremap BD :bp<bar>sp<bar>bn<bar>bd<CR>
"security, stops local vimrc from running autocmd
" don't know if it actually does anything, but stumbled on it
let secure=1
"""""""""""""""""""""""""
" builtin settings done "
"""""""""""""""""""""""""
"""""""""""""""""""""""
" ycm completion settings "
"""""""""""""""""""""""
"let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
"let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
"preview-window functions
let g:ycm_add_preview_to_completeopt = 1
let g:ycm_autoclose_preview_window_after_insertion = 1
"let g:ycm_semantic_triggers = {
"\ 'python': ['.', '(' ],
"\ }
"enable ycm for markdown and other blacklists
let g:ycm_filetype_blacklist = {}
"GoTo:
nnoremap <silent> [g :YcmCompleter GoTo<cr>
nnoremap <silent> [d :YcmCompleter GoToDeclaration<cr>
nnoremap <silent> [r :YcmCompleter GoToReferences<cr>
"""""""""""""""""""""""
" completion settings "
"""""""""""""""""""""""
""""""""""""""""""""
"ultisnips settings "
""""""""""""""""""""
" let g:UltiSnipsExpandTrigger="<tab>"
" let g:UltiSnipsJumpForwardTrigger = "<tab>"
" let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
""""""""""""""""""""""""
"ultisnips settings done"
""""""""""""""""""""""""
"""""""""""""""""""
" vimtex settings "
"""""""""""""""""""
let g:vimtex_quickfix_latexlog = {
\'general': 0,
\}
let g:tex_flavor = "latex"
let g:vimex_fold_enabled = 1
let g:vimtex_fold_manual = 1
let g:vimtex_compiler_progname = 'nvr'
" fast typing//conceal
" https://castel.dev/post/lecture-notes-1/
"let g:vimtex_quickfix_mode=0
set conceallevel=1
let g:tex_conceal='abdmg'
inoremap <C-l> <c-g>u<Esc>[s1z=`]a<c-g>u
"force to use pdflatex
"let g:vimtex_compiler_latexrun_engines = {
" \ 'background' : 1,
" \ 'build_dir' : '',
" \ 'options' : [
" \ '-verbose-cmds',
" \ '--latex-args="-synctex=1"',
" \ '-pdf',
" \ ],
" \}
"""""""""""""""""""""""
" vimtex settings done"
"""""""""""""""""""""""
"""""""""""""""""
" ale settings "
"""""""""""""""""
let g:ale_linters = {
\ 'scala': [ 'sbtserver', 'scalac' ] ,
\ 'python': [''],
\ 'tex': ['texlab'],
\ }
" python3
let g:python3_host_prog='/usr/local/bin/python3'
"latex
let home = $HOME
let g:ale_tex_texlab_executable = home.'/.dotfiles/texlab/target/release/texlab'
"completion
"let g:ale_completion_enabled = 1
"set omnifunc=ale#completion#OmniFunc
"""""""""""""""""""""
" ale settings done"
"""""""""""""""""""""
""""""""""""""""""""
" airline settings "
""""""""""""""""""""
"set smarter tab line
let g:airline#extensions#tabline#enabled = 1
" better buffer switching:
"Note: bd to close current buffer
nnoremap gB :bnext<CR>
nnoremap gb :bprevious<CR>
nnoremap B :bnext<CR>
" unique_tail
let g:airline#extensions#tabline#formatter = 'unique_tail'
"""""""""""""""""""""""""
" airline settings done"
"""""""""""""""""""""""""
""""""""""""""""
" Git settings "
""""""""""""""""
function! Gitgutter()
:GitGutterToggle
:GitGutterSignsToggle
:GitGutterLineHighlightsToggle
endfunction
let g:gitgutter_enabled = 0
"TODO: fix this!
nnoremap <silent> gG :exec Gitgutter()<CR>
""""""""""""""""""""
" Git settings done"
""""""""""""""""""""
"""""""""""""""""""""""""
"Misc small settings"
"""""""""""""""""""""""""
" Add your own mapping. For example:
map <C-h> :NERDTreeToggle<CR>
"FastFold
let g:fastfold_savehook = 1
let g:tex_fold_enabled = 1
"colorscheme
set t_Co=256 " vim-monokai now only support 256 colours in terminal.
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
colorscheme monokai