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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
|
"-----------------------------------------------------------------------------------------------------------------------
" General Settings
"----------------------------------------------------------------------------------------------------------------------
filetype plugin on " Enable default plugins
let mapleader="\<Space>"
" Vim options that neovim has turned on but vim has off/ignores
set backspace=indent,eol,start
set nocompatible " Vim is non-compatible with vi. Neovim ignores this
set wildmenu " Turn on wildmenu for vim, Neovim defaults to on
set incsearch " Shows results for '/' search as you are typing the search
set hlsearch " After a '/' search, highlight the matches
" Regular settings
set path=** " Set path to look at all directories under current root
set wildignore=*/app/cache,*/vendor,*/env,*.pyc,*/venv,*/__pycache__ " Wildmenu will ignore these folder/file types
set expandtab " Expand tabs into spaces
set tabstop=4 " Default to 4 spaces
set shiftwidth=0 " Make shiftwidth value the same as tabstop
set history=1000 " Set number of ':' commands
set relativenumber " Use relative numbers in the sidebar
set number " Show line numbers in side bar
set nowrap " Turn off text wrapping long lines
set wildmode=list:full " wildmenu show list complete to first result
set splitright " New windows split to the right of current one
set splitbelow " New windows split below the current one
set sessionoptions+=globals " Append globals to the default session options
set foldmethod=indent " Fold on Indent levels
" Custom status line
set statusline=
set statusline+=%1*\ %02c\ " Color
set statusline+=%2*\ » " RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
set statusline+=%3*\ %<%F\ " File+path
set statusline+=%2*\« " LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
set statusline+=%2*\ %=\ %l/%L\ (%02p%%)\ " Rownumber/total (%)
" Set spacing of file types
autocmd FileType html setlocal tabstop=2
autocmd FileType htmljinja setlocal tabstop=2
autocmd FileType htmldjango setlocal tabstop=2
autocmd FileType php setlocal tabstop=4
autocmd FileType python setlocal tabstop=4
autocmd FileType sh setlocal tabstop=4
autocmd FileType javascript setlocal tabstop=4
autocmd FileType json setlocal tabstop=4
autocmd FileType make setlocal tabstop=4 noexpandtab
autocmd FileType scss setlocal tabstop=2
autocmd FileType ledger setlocal tabstop=2
autocmd FileType vim setlocal tabstop=2
" Make netrw prettier
let g:netrw_banner = 0 " Hide the banner
let g:netrw_liststyle = 3 " Tree view
let g:netrw_list_hide = '\(^\|\s\s\)\zs\.\S\+' " Hide dotfiles
"-----------------------------------------------------------------------------------------------------------------------
"-----------------------------------------------------------------------------------------------------------------------
" Color/Theming Options
"-----------------------------------------------------------------------------------------------------------------------
" 0 = dark background // 1 = red
" 2 = green // 3 = yellow
" 4 = light blue // 5 = pink
" 6 = cyan // 7 = beige
" 8 = dark blue // 9 = orange
" 10 = dark grey // 11 = grey
" 12 = light grey // 13 = purple
" 14 = grey // 15 = white
" 16 = black
syntax enable " Enable syntax highlighiting of files
colorscheme gruvbox " Set the colorscheme
set background=dark " Use dark colorscheme
" Set vimdiff colors, make it easier to read
highlight DiffAdd cterm=BOLD ctermfg=NONE ctermbg=22
highlight DiffDelete cterm=BOLD ctermfg=NONE ctermbg=52
highlight DiffChange cterm=BOLD ctermfg=NONE ctermbg=23
highlight DiffText cterm=BOLD ctermfg=NONE ctermbg=23
" Set syntax of files that vim doesn't recognize
au BufRead,BufNewFile *.twig set syntax=htmljinja
au BufRead,BufNewFile *.html set syntax=htmljinja
au BufNewFile,BufRead *.yml set filetype=yaml
au BufNewFile,BufRead *.sls set filetype=yaml
au BufNewFile,BufRead *.inc set filetype=php
au BufNewFile,BufRead *.module set filetype=php
au BufRead,BufNewFile *.ejs set syntax=htmljinja
au BufRead,BufNewFile *.md set filetype=markdown
" Highligh current cursorline
hi CursorLineNR cterm=bold ctermfg=226
" Status line colors per mode
hi User1 ctermfg=NONE ctermbg=NONE cterm=bold
hi User3 ctermfg=NONE ctermbg=NONE
hi User2 ctermfg=NONE ctermbg=NONE
" Change gutter color
highlight SignColumn cterm=NONE ctermfg=0 ctermbg=None
" Highlight long lines at 80 mark
highlight ColorColumn ctermbg=cyan
au BufNewFile,BufRead * call matchadd('ColorColumn', '\%81v', 100)
" Highlight super long lines
au BufNewFile,BufRead * call matchadd('Error', '\%121v', 100)
" Disable background colors for transparency
hi Normal guibg=NONE ctermbg=NONE
"-----------------------------------------------------------------------------------------------------------------------
"-----------------------------------------------------------------------------------------------------------------------
" Vim vs Neovim settings
"-----------------------------------------------------------------------------------------------------------------------
if has('nvim')
let $HOME='.vimcache'
let $EditorDir='/root/.config/nvim/'
let $SessionDir='.vimcache'
silent! execute '!mkdir -p .vimcache/backup'
" Set Backup dirs
set backupdir=.vimcache/backup/
set directory=.vimcache/swp/
let g:syntastic_python_python_exec = '/usr/bin/python3'
set completeopt=menu,preview,noinsert " default is menu,preview. Don't insert text until selection is made
nnoremap <leader>er :call RestoreSession()<CR>
nnoremap <leader>y :call system('nc -w 1 172.17.0.1 41401', @0)<CR>
else
let $EditorDir=$HOME.'/.vim/'
let $SessionDir='.'
" Set Backup dirs
set backupdir=~/.vim/vim-files/backups/
set directory=~/.vim/vim-files/swaps/
let g:vimwiki_list = [{'path': '~/Wiki/wiki', 'path_html': '~/Wiki/wiki_html/', 'ext': '.wiki'}]
nnoremap <leader>y :call system('nc -w 1 localhost 41401', @0)<CR>
endif
"-----------------------------------------------------------------------------------------------------------------------
" Custom functions
"-----------------------------------------------------------------------------------------------------------------------
" Taken from ins-completion docs. Tab if only whitespace, autocomplete if there is text
function! CleverTab()
if strpart( getline('.'), 0, col('.')-1 ) =~ '^\s*$'
return "\<Tab>"
else
return "\<C-N>"
endif
endfunction
inoremap <Tab> <C-R>=CleverTab()<CR>
" type jj to get out of insert mode
inoremap jj <ESC>
" Ctags for python project
command! MakeTagsPython !ctags --languages=python --python-kinds=-i -R .
" Command for figuring out highlight group
map <leader>hi :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">" . " FG:" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"fg#")<CR>
" Turn off syntax highlighting
nnoremap <leader><leader> :noh<CR>
" Shortcuts for window
nnoremap <C-w>t :tabnew<CR>
" Shorcut for stubbing out find command
nnoremap <leader>s :find
" Formating a json file
com! Formatjson %!python -m json.tool
" Visually select pasted text
nnoremap gp `[v`]
" Yank withouth newline
nmap yY ^y$$
" Vimdiff commands
nnoremap <leader>du :diffupdate<CR>
nnoremap <leader>dd :diffget<CR>
nnoremap <leader>df :diffput<CR>
nnoremap _ [c
nnoremap = ]c
" Open folder of current file
nnoremap <leader>nn :e %:p:h<CR>
" Open NERDTree
nnoremap <leader>nm :e.<CR>
" Function for saving session
function! SaveSession()
:mksession! $SessionDir/session.vim
:echo 'Session Saved!'
endfunction
nnoremap <leader>ee :call SaveSession()<CR>
" Function for restoring session
function! RestoreSession()
:source $SessionDir/session.vim
endfunction
" Functions for deleting, changing, yanking 'in-line'
nnoremap <leader>v ^v$h
" Some very useful shortcuts for editing Ledger entries
" Copy the last entry
nnoremap <leader>ll G{jV}y}p10l
" Copy the current entry to the bottom, copy date from last entry
nnoremap <leader>lb {jV}yGp10l{{jvEy}jvEpl
" Copy the current entry to the next position
nnoremap <leader>ln {jV}y}p10l
" Jump down from line to replace dollar ammount
nnoremap <leader>ld j^f$lC
" Snippets
nnoremap <leader>,date :-1read !date +\%F<CR>
nnoremap <leader>,fabfile :-1read $EditorDir/plugged/vim-options/snippets/python/fabfile.py<CR>
nnoremap <leader>,cutf8 :-1read $EditorDir/plugged/vim-options/snippets/python/cutf8.py<CR>jf.i
nnoremap <leader>,pudb :-1read $EditorDir/plugged/vim-options/snippets/python/pudb.py<CR>V
nnoremap <leader>,pydef :-1read $EditorDir/plugged/vim-options/snippets/python/pydef.py<CR>/jump<CR>V12j
nnoremap <leader>,pyclass :-1read $EditorDir/plugged/vim-options/snippets/python/pyclass.py<CR>/jump<CR>
" Arrow keys move windows
noremap <Up> <C-w>k
noremap <Down> <C-w>j
noremap <Left> <C-w>h
noremap <Right> <C-w>l
"-----------------------------------------------------------------------------------------------------------------------
"-----------------------------------------------------------------------------------------------------------------------
" Ack Searching
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/ack.vim/plugin/ack.vim'))
nnoremap <leader>/ :call AckSearch()<CR>
function! AckSearch()
call inputsave()
let term = input('Search: ')
call inputrestore()
if !empty(term)
execute "Ack! '" . term . "'"
endif
endfunction
endif
"-----------------------------------------------------------------------------------------------------------------------
"-----------------------------------------------------------------------------------------------------------------------
" Argwrap
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/vim-argwrap/plugin/argwrap.vim'))
nnoremap <silent> <leader>a :ArgWrap<CR>
endif
"-----------------------------------------------------------------------------------------------------------------------
"-----------------------------------------------------------------------------------------------------------------------
" CamelCaseMotion
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/CamelCaseMotion/plugin/camelcasemotion.vim'))
map <silent> ,w <Plug>CamelCaseMotion_w
map <silent> ,e <Plug>CamelCaseMotion_e
map <silent> ,b <Plug>CamelCaseMotion_b
endif
"-----------------------------------------------------------------------------------------------------------------------
"-----------------------------------------------------------------------------------------------------------------------
" Fugitive
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/vim-fugitive/plugin/fugitive.vim'))
" Command for toggling git status
function! ToggleGStatus()
if buflisted(bufname('.git/index'))
bd .git/index
else
Gstatus
endif
endfunction
command ToggleGStatus :call ToggleGStatus()
nnoremap <leader>gs :ToggleGStatus<CR>
nnoremap <leader>gc :Gcommit --verbose<CR>
nnoremap <leader>gd :Gdiff<CR>
endif
"-----------------------------------------------------------------------------------------------------------------------
"-----------------------------------------------------------------------------------------------------------------------
" Indent Lines Plugin
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/vim-indent-guides/plugin/indent_guides.vim'))
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_auto_colors = 0
let g:indent_guides_exclude_filetypes =['help', 'nerdtree']
let g:indent_guides_start_level = 2
let g:indent_guides_guide_size = 1
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd ctermbg=235
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=237
autocmd VimEnter,Colorscheme * :IndentGuidesEnable
endif
"-----------------------------------------------------------------------------------------------------------------------
"-----------------------------------------------------------------------------------------------------------------------
" Ledger
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/SimpylFold/ftplugin/python/SimpylFold.vim'))
au BufNewFile,BufRead *.ldg,*.ledger setf ledger | comp ledger
endif
"-----------------------------------------------------------------------------------------------------------------------
"-----------------------------------------------------------------------------------------------------------------------
" Nerdtree Plugin
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/nerdtree/plugin/NERD_tree.vim'))
" Disable ? do I can fucking reverse search
:autocmd FileType nerdtree silent! nunmap <buffer> ?
let g:NERDTreeShowLineNumbers=1
let g:NERDTreeDirArrows=0
let g:NERDTreeWinSize = 40
let g:NERDTreeIgnore = ['\.pyc$']
let g:NERDTreeDirArrows = 1
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
let g:NERDTreeMapOpenSplit = 's'
let g:NERDTreeMapPreviewSplit = 'gs'
let g:NERDTreeMapOpenVSplit = 'v'
let g:NERDTreeMapPreviewVSplit = 'gv'
endif
"-----------------------------------------------------------------------------------------------------------------------
"-----------------------------------------------------------------------------------------------------------------------
" Markdown
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/vim-markdown/indent/markdown.vim'))
let g:vim_markdown_folding_disabled=1
endif
"-----------------------------------------------------------------------------------------------------------------------
"-----------------------------------------------------------------------------------------------------------------------
" Python-Syntax
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/python-syntax/syntax/python.vim'))
let python_highlight_all = 1
endif
"-----------------------------------------------------------------------------------------------------------------------
"-----------------------------------------------------------------------------------------------------------------------
" Syntastic
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/syntastic/plugin/syntastic.vim'))
let g:syntastic_php_checkers = ['php', 'phpcs']
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_python_checkers = ['pyton3', 'flake8', 'mypy']
let g:syntastic_scss_checkers = ['sass_lint']
let g:syntastic_php_phpcs_args = "--standard=/root/PEARish.xml,PSR2,Symfony2"
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 0
let g:syntastic_check_on_wq = 1
let g:syntastic_check_on_open = 1
let g:syntastic_aggregate_errors = 1
let g:syntastic_mode_map = { 'mode': 'active' }
function! ToggleSyntasticMode()
python << EOF
import vim
import ast
value = dict(vim.eval('g:syntastic_mode_map'))
vim.command('let l:syntastic_current_mode = \''+value['mode']+'\'')
EOF
SyntasticToggleMode
if l:syntastic_current_mode == 'passive'
SyntasticCheck
let g:syntastic_check_on_wq = 0
let g:syntastic_check_on_open = 0
else
let g:syntastic_check_on_wq = 1
let g:syntastic_check_on_open = 1
endif
endfunction
nnoremap <leader>a :call ToggleSyntasticMode()<CR>
endif
"-----------------------------------------------------------------------------------------------------------------------
"-----------------------------------------------------------------------------------------------------------------------
" Taboo
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/taboo.vim/plugin/taboo.vim'))
au BufNewFile,BufRead *.ldg,*.ledger setf ledger | comp ledger
function! RenameTab()
call inputsave()
let term = input('Tabname: ')
call inputrestore()
if !empty(term)
execute ":TabooRename " . term
endif
endfunction
nnoremap <leader>r :call RenameTab()<CR>
endif
"-----------------------------------------------------------------------------------------------------------------------
"-----------------------------------------------------------------------------------------------------------------------
" Vdebug Plugin
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/vdebug/plugin/vdebug.vim'))
let g:vdebug_options = {
\ "watch_window_style" : 'compact',
\ "port" : 9000,
\ "path_maps" : {
\ "/var/www/html": "/Users/hiarc/myprojectdir",
\ },
\}
"Delete all breakpoints
:command! BR BreakpointRemove *
endif
"-----------------------------------------------------------------------------------------------------------------------
"-----------------------------------------------------------------------------------------------------------------------
" Vim JSON
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/vim-json/indent/json.vim'))
let g:vim_json_syntax_conceal = 0
endif
"-----------------------------------------------------------------------------------------------------------------------
"-----------------------------------------------------------------------------------------------------------------------
" Vim EasyMotion Incsearch
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/incsearch-easymotion.vim/plugin/incsearch/easymotion.vim'))
" You can use other keymappings like <C-l> instead of <CR> if you want to
" use these mappings as default search and somtimes want to move cursor with
" EasyMotion.
function! s:incsearch_config(...) abort
return incsearch#util#deepextend(deepcopy({
\ 'modules': [incsearch#config#easymotion#module({'overwin': 1})],
\ 'keymap': {
\ "\<C-l>": '<Over>(easymotion)'
\ },
\ 'is_expr': 0
\ }), get(a:, 1, {}))
endfunction
noremap <silent><expr> / incsearch#go(<SID>incsearch_config())
noremap <silent><expr> ? incsearch#go(<SID>incsearch_config({'command': '?'}))
noremap <silent><expr> g/ incsearch#go(<SID>incsearch_config({'is_stay': 1}))
endif
"-----------------------------------------------------------------------------------------------------------------------
"-----------------------------------------------------------------------------------------------------------------------
" EasyMotion
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/vim-easymotion/autoload/EasyMotion.vim'))
" <Leader>f{char} to move to {char}{char}
map <Leader>f <Plug>(easymotion-bd-f2)
nmap <Leader>f <Plug>(easymotion-overwin-f2)
endif
"-----------------------------------------------------------------------------------------------------------------------
"-----------------------------------------------------------------------------------------------------------------------
" Ale
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/ale/autoload/ale.vim'))
let g:ale_sign_column_always = 1
let g:ale_lint_on_insert_leave = 1
highlight clear ALEErrorSign
highlight clear ALEWarningSign
endif
"-----------------------------------------------------------------------------------------------------------------------
"-----------------------------------------------------------------------------------------------------------------------
" Basic movements (h, j, k, l) require a number prefix. Break bad habits
"-----------------------------------------------------------------------------------------------------------------------
function! DisableIfNonCounted(move) range
if v:count
return a:move
else
" You can make this do something annoying like:
" echoerr "Count required!"
" sleep 2
return ""
endif
endfunction
function! SetDisablingOfBasicMotionsIfNonCounted(on)
let keys_to_disable = get(g:, "keys_to_disable_if_not_preceded_by_count", ["j", "k", "l", "h"])
if a:on
for key in keys_to_disable
execute "noremap <expr> <silent> " . key . " DisableIfNonCounted('" . key . "')"
endfor
let g:keys_to_disable_if_not_preceded_by_count = keys_to_disable
let g:is_non_counted_basic_motions_disabled = 1
else
for key in keys_to_disable
try
execute "unmap " . key
catch /E31:/
endtry
endfor
let g:is_non_counted_basic_motions_disabled = 0
endif
endfunction
function! ToggleDisablingOfBasicMotionsIfNonCounted()
let is_disabled = get(g:, "is_non_counted_basic_motions_disabled", 0)
if is_disabled
call SetDisablingOfBasicMotionsIfNonCounted(0)
else
call SetDisablingOfBasicMotionsIfNonCounted(1)
endif
endfunction
command! ToggleDisablingOfNonCountedBasicMotions :call ToggleDisablingOfBasicMotionsIfNonCounted()
command! DisableNonCountedBasicMotions :call SetDisablingOfBasicMotionsIfNonCounted(1)
command! EnableNonCountedBasicMotions :call SetDisablingOfBasicMotionsIfNonCounted(0)
" Call this function to enable Hard Mode
"DisableNonCountedBasicMotions
|