-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
executable file
·384 lines (285 loc) · 10.8 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
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
source ~/vim/plugins.vim
let g:coc_global_extensions = [ 'coc-flutter', 'coc-python', 'coc-tsserver', 'coc-eslint', 'coc-json', 'coc-prettier', 'coc-css' ]
filetype off
let mapleader = ","
if has("gui_running")
set guioptions-=T
endif
" Make vim behave in a less vi compatible way
set nocompatible
"behave mswin
" vim-ctrlspace
set hidden
set encoding=utf-8
let g:CtrlSpaceDefaultMappingKey = "<C-space> "
set expandtab
set shiftwidth=2 " number of space characters inserted for indentation
set softtabstop=2
set tabstop=2 "number of space characters that will be inserted when the tab key is pressed
" Warn before reloading
set noautoread
au FocusGained * :checktime
" Sho spaces as dots `.`
"set list
"source ~/vim/denite.vim
source ~/vim/coc.vim
source ~/vim/NeoSnippet.vim
source ~/vim/airline.vim
" === echodoc === "
" Enable echodoc on startup
let g:echodoc#enable_at_startup = 1
" === vim-javascript === "
" Enable syntax highlighting for JSDoc
let g:javascript_plugin_jsdoc = 1
" === vim-jsx === "
" Highlight jsx syntax even in non .jsx files
let g:jsx_ext_required = 0
" === javascript-libraries-syntax === "
let g:used_javascript_libs = 'underscore,requirejs,chai,jquery'
" === Signify === "
let g:signify_sign_delete = '-'
" NeoSnippet
let g:neosnippet#enable_snipmate_compatibility=1
" ============================================================================ "
" === UI === "
" ============================================================================ "
" Enable true color support
set termguicolors
" Vim airline theme
"let g:airline_theme='space'
" Change vertical split character to be a space (essentially hide it)
set fillchars+=vert:.
" Set preview window to appear at bottom
set splitbelow
" Don't dispay mode in command line (airilne already shows it)
set noshowmode
" Set floating window to be slightly transparent
"set winbl=10
" <Space> - PageDown
" - - PageUp
noremap <Space> <PageDown>
noremap - <PageUp>
" Quick window switching
nmap <C-h> <C-w>h
nmap <C-j> <C-w>j
nmap <C-k> <C-w>k
nmap <C-l> <C-w>l
" === coc.nvim === "
" <leader>ac - Remap keys for applying codeAction to the current line.
" <leader>qf - Apply AutoFix to problem on the current line." <leader>dd - Jump to definition of current symbol
" <leader>dr - Jump to references of current symbol
" <leader>dj - Jump to implementation of current symbol
" <leader>ds - Fuzzy search current project symbols
nmap <leader>ac <Plug>(coc-codeaction)
nmap <leader>qf <Plug>(coc-fix-current)
nmap <silent> <leader>dd <Plug>(coc-definition)
nmap <silent> <leader>dr <Plug>(coc-references)
nmap <silent> <leader>dj <Plug>(coc-implementation)
nmap <silent> <leader>df <Plug>(coc-float-jump)
nmap <silent> <leader>dh <Plug>(coc-float-hide)
nnoremap <silent> <leader>ds :<C-u>CocList -I -N --top symbols<CR>
" FLoat bg / fg colors
highlight CocFloating guibg=DarkMagenta
highlight CocFloating guibg=DarkMagenta
" === vim-better-whitespace === "
" <leader>y - Automatically remove trailing whitespace
nmap <leader>y :StripWhitespace<CR>
" === Search shorcuts === "
" <leader>h - Find and replace
" <leader>/ - Claer highlighted search terms while preserving history
map <leader>h :%s///<left><left>
nmap <silent> <leader>/ :nohlsearch<CR>
" === Easy-motion shortcuts ==="
" <leader>w - Easy-motion highlights first word letters bi-directionally
map <leader>w <Plug>(easymotion-bd-w)
" Allows you to save files you opened without write permissions via sudo
cmap w!! w !sudo tee %
" === vim-jsdoc shortcuts ==="
" Generate jsdoc for function under cursor
nmap <leader>z :JsDoc<CR>
" Delete current visual selection and dump in black hole buffer before pasting
" Used when you want to paste over something without it getting copied to
" Vim's default buffer
vnoremap <leader>p "_dP
colorscheme torte
set incsearch " incremental search (as you type)
set hlsearch " highlight search
syntax on
filetype on
filetype plugin indent on
set spell
" visual bell
set vb
set number
set relativenumber
" put (~) backup files in /tmp.
set backupdir=./_backup,/tmp,.
" Python
let $PYTHONS='~/.vim/scripts/python.vim'
au FileType python source $PYTHONS
let python_highlight_all=1
let python_slow_sync=1
autocmd FileType python set ft=python.django " For SnipMate
autocmd FileType html set ft=htmldjango.html " For SnipMate
" Basic editing from http://sontek.net/turning-vim-into-a-modern-python-ide#id2
" Code folding
" Then you will be able to be inside a method and type 'za' to open and close a fold
set foldmethod=indent
set foldlevel=99
" Window splitting
"Vertical Split : Ctrl+w + v
"Horizontal Split: Ctrl+w + s
"Close current windows: Ctrl+w + q
" Window movement
"map <c-j> <c-w>j
"map <c-k> <c-w>k
"map <c-l> <c-w>l
"map <c-h> <c-w>h
" Snippets
" e.g. def<tab>
" Task list
map <leader>td <Plug>TaskList
" Revision History
map <leader>g :GundoToggle<CR>
let g:syntastic_python_checkers = ['flake8']
" change the max line length for PEP8
let g:syntastic_python_flake8_args = "--ignore=E128,E124 --max-line-length=90"
" use eslint for jav
"let g:syntastic_javascript_checkers = ['eslint']
" Tab complete and documentation
" Hit <leader>pw when our cursor is on a module to open help in a new window
au FileType python set omnifunc=pythoncomplete#Complete
let g:SuperTabDefaultCompletionType = "context"
set completeopt=menuone,longest,preview
" json highlighting and formatting
au! BufRead,BufNewFile *.json set filetype=json foldmethod=syntax
" Jenkinsfile highlighting and formatting
au BufNewFile,BufRead Jenkinsfile setf groovy
" markdown highlighting for files with extension md.
au BufRead,BufNewFile *.md set filetype=markdown
" preview markdown in chrome - requires a markdown plugin such as
" https://chrome.google.com/webstore/detail/markdown-preview-plus/febilkbfcbhebfnokafefeacimjdckgl
autocmd BufEnter *.md exe 'noremap <leader>p :!open -a "Google Chrome.app" %:p<CR>'
" Buffers
" Open files with :e <filename> to place in a buffer.
" List buffers with :buffers.
" Switch between the buffers using b<number>, such as :b1 for the first buffer.
" You can also use its name to match, so you can type :b mod<tab> to autocomplete opening the models.py buffer.
" To close a buffer you use :bd or :bw.
set wildignore=*.swp,*.bak,*.pyc,*.class,*.jar,*.gif,*.png,*.jpg,*.dcm
set wildignore=*/bower_components/**,*/node_modules/**
" Searching (with Ack)
nmap <leader>a <Esc>:Ack!
" Format (pretty print) json
" https://pascalprecht.github.io/posts/pretty-print-json-in-vim/
map <leader>fj :%!python -m json.tool
" Integration with Git
" Gblame: This allows you to view a line by line comparison of who the last person to touch that line of code is.
" Gwrite: This will stage your file for commit, basically doing git add <filename>
" Gread: This will basically run a git checkout <filename>
" Gcommit: This will just run git commit. Since its in a vim buffer, you can use keyword completion (Ctrl-N),
" like test_all<Ctrl-N> to find the method name in your buffer and complete it for the commit message.
" You can also use + and - on the filenames in the message to stage/unstage them for the commit.
"
"set statusline=%{fugitive#statusline()}
" Test Integration
"
" django nose
" This will just give you a green bar at the bottom of vim
" If your test passed or a red bar with the message of the failed test if it doesn't.
map <leader>dt :set makeprg=python\ manage.py\ test\|:call MakeGreen()<CR>
" py.test
" Execute the tests
nmap <silent><Leader>tf <Esc>:Pytest file<CR>
nmap <silent><Leader>tc <Esc>:Pytest class<CR>
nmap <silent><Leader>tm <Esc>:Pytest method<CR>
" cycle through test errors
nmap <silent><Leader>tn <Esc>:Pytest next<CR>
nmap <silent><Leader>tp <Esc>:Pytest previous<CR>
nmap <silent><Leader>te <Esc>:Pytest error<CR>
" Virtualenv
"
"" Add the virtualenv's site-packages to vim path
if has('python')
python << EOF
import os.path
import sys
import vim
try:
settings_module = os.environ['DJANGO_SETTINGS_MODULE']
if not settings_module: # If it's set but is an empty string.
raise KeyError
except KeyError:
import glob
settings_root = '.'
try:
settings_path = glob.glob(os.path.join(settings_root, '*/settings.py'))[0]
except IndexError:
pass
else:
os.environ['DJANGO_SETTINGS_MODULE'] = '%s.settings' % os.path.basename(os.path.dirname(settings_path))
if 'VIRTUAL_ENV' in os.environ:
project_base_dir = os.environ['VIRTUAL_ENV']
sys.path.insert(0, project_base_dir)
activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
if os.path.isfile(activate_this):
execfile(activate_this, dict(__file__=activate_this))
EOF
endif
" Add 80 characters soft limit.
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
match OverLength /\%81v.\+/
" Mapping for ArgWrap
let g:argwrap_tail_comma = 1
let g:argwrap_padded_braces = '{'
nnoremap <silent> <leader>w :ArgWrap<CR>
" SQLUtil
let g:sqlutil_align_where = 0
let g:sqlutil_align_keyword_right = 0
let g:sqlutil_wrap_expressions = 1
" Colorizer
let g:colorizer_auto_filetype='css,html,json'
let g:dart_style_guide = 2
let g:dart_format_on_save = 1
" Show autocomplete when Tab is pressed
"inoremap <silent><expr> <Tab> coc#refresh()
"" Remap keys for applying codeAction to the current line.
"nmap <leader>ac <Plug>(coc-codeaction)
"" Apply AutoFix to problem on the current line.
"nmap <leader>qf <Plug>(coc-fix-current)
"" 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)
" ale typescript linting
"let g:ale_fixers = {
"\ 'typescript': ['prettier', 'eslint'],
"\}
"let g:ale_linters = {}
"let g:ale_linters.typescript = ['eslint', 'tsserver']
"let g:ale_typescript_prettier_use_local_config = 1
"let g:ale_fix_on_save = 0
"let g:ale_linters_explicit = 1
"au FileType typescript set omnifunc=ale#completion#OmniFunc
" Scroll forwards backwards
inoremap <nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
inoremap <nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
inoremap <nowait><expr> <C-j> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1, 1)\<cr>" : "\<Down>"
inoremap <nowait><expr> <C-k> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0, 1)\<cr>" : "\<Up>"
" tabline
if has('nvim')
" Always show the tabline
set showtabline=2
endif
" tab shortcuts
nnoremap <leader>ta <cmd>tabnew<cr>
nnoremap <leader>tc <cmd>tabclose<cr>
nnoremap <leader>to <cmd>tabonly<cr>
nnoremap <leader>tn <cmd>tabn<cr>
nnoremap <leader>tp <cmd>tabp<cr>
nnoremap <leader>tmp <cmd>-tabmove<cr>
nnoremap <leader>tmn <cmd>+tabmove<cr>
let g:taboo_tab_format = ' %N:%P '
" vimspector
"let g:vimspector_enable_mappings = 'HUMAN'