aboutsummaryrefslogtreecommitdiff
path: root/plugin/vim-options.vim
blob: 737ce814dea06a4b1fe37bc09341f2f5d3ab4c14 (plain)
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
" General Settings
filetype plugin on " Enable default plugins
set nocompatible " Disable vi-compatible
set wildmenu " Enable autocomple menu
set incsearch " Show search results as typing string
set hlsearch " Highlight matches to previos search string
set expandtab " In Insert mode: Use the appropriate number of spaces to insert <Tab>.
set tabstop=4 "Number of spaces that a <Tab> counts for
set shiftwidth=0 " Make shiftwidth value the same as tabstop
set relativenumber " Use relative numbers in the side bar
set nowrap " Turn off text wrapping long lines
set history=1000 " Set number of ':' commands
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 completeopt-=preview " Hide the preview/scratch window
set path=** " Allow commands like 'gf' to find files
set wildignore=*/app/cache,*/vendor,*/env,*.pyc,*/venv,*/__pycache__,*/venv " Ignore folders
set sessionoptions+=globals " Append global variables to the default session options (Window Names)
set backspace=2 " Make backspace work like most other programs
set hidden " Allow hidden buffers, no complain about unsaved work
set nostartofline " Don't jump cursor to start of line
set spelllang=en_ca " Set spelling language to Canadian English


" 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 filetypes
au FileType vim,ledger,yaml,html,htmldjango setlocal tabstop=2
au FileType sh,python setlocal tabstop=4
au FileType make setlocal tabstop=4 noexpandtab
au FileType markdown set tw=80 tabstop=2

" Setup colorscheme
syntax enable 
colorscheme nord " 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
" Disable Background Color for transparency
hi Normal guibg=NONE ctermbg=NONE
hi Search ctermbg=None ctermfg=166

" Highlight lines at 80 mark/120 mark
highlight ColorColumn ctermbg=cyan
au BufEnter *.py let w:m1=matchadd('ColorColumn', '\%81v', 100)
au BufEnter *.py let w:m2=matchadd('Error', '\%121v', 100)
au BufLeave *.py call clearmatches()


" Neovim (Docker) vs Vim
if has('nvim')
  let $EditorDir=$HOME.'/.config/nvim/'
else
  let $EditorDir=$HOME.'/.vim/'
endif

" Set leader
let mapleader="\<Space>"
" For easier copying
nnoremap <leader>y :call system('nc -w 1 127.0.0.1 41401', @0)<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>
" Visually select pasted text
nnoremap gp `[v`]
" Vimdiff commands
nnoremap <leader>du :diffupdate<CR>
nnoremap <leader>dd :diffget<CR>
nnoremap <leader>df :diffput<CR>
nnoremap _ [c
nnoremap = ]c
" Visually select line without ending
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
" After searching pull entry to current position
nnoremap <leader>ly vapy<C-o>p{{jvEy}jvEpl
" Accept current autocomplete suggestion
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>"
" Faster jumping for linting errors
nnoremap [q :lprev<CR>
nnoremap ]q :lnext<CR>
nnoremap [w :cprev<CR>
nnoremap ]w :cnext<CR>
" Set breakpoint in python
noremap <leader>ep ofrom pudb import set_trace; set_trace()<ESC>
" Vertical split instead of horiztonal
noremap <c-w>f <c-w>f<c-w>L
" Follow file into new tab
noremap <c-w><c-f> <c-w>f<c-w>T
" <c-w>] uses path not tags file? 
noremap <c-w>] <c-w>v<c-]><c-w>L
" <c-w>] to new tab
noremap <c-w><c-]> <c-w>v<c-]><c-w>T
"Create New tab
nnoremap <C-w>t :tabnew<CR>
"Duplicate current buffer into another tab
nnoremap <C-w><C-t> <C-w>v<C-w>T
"Run Linter
noremap <leader>ei :ALEFix<CR>
" Reload a file
noremap <leader>ee :e!<CR>
" Session saving
function! SaveSession()
  :mksession! ./session.vim
  :echo 'Session Saved!'
endfunction
nnoremap <leader>ess :call SaveSession()<CR>
nnoremap <leader>esr :source ./session.vim<CR>
" Delete current file and purge buffer
function! Rm()
  :call delete(expand('%')) | bdelete!
endfunction
nnoremap <leader>erm :call Rm()<CR>
" Add numbered jumps to the jump list
nnoremap <expr> k (v:count > 1 ? "m'" . v:count : '') . 'k'
nnoremap <expr> j (v:count > 1 ? "m'" . v:count : '') . 'j'
" Quick open and close quickfix
nnoremap <leader>co :copen<CR>
nnoremap <leader>cc :cclose<CR>





"-----------------------------------------------------------------------------------------------------------------------
" Ack Searching
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/ack.vim/plugin/ack.vim'))
  nnoremap <leader>/ :call AckSearch()<CR><c-w><c-p>
  noremap <leader>ea :Ack <cword><CR><c-w><c-p>
  function! AckSearch()
    call inputsave()
    let term = input('Search: ')
    call inputrestore()
    if !empty(term)
        execute "Ack! " . term
    endif
  endfunction
  " Setting better default settings
  let g:ackprg =
      \ "ack -s -H --nocolor --nogroup --column --ignore-dir=.venv/ --ignore-dir=.vimcache/ --ignore-dir=migrations/ --ignore-dir=.mypy_cache/ --ignore-file=is:tags --nojs --nocss --nosass"
endif
"-----------------------------------------------------------------------------------------------------------------------



"-----------------------------------------------------------------------------------------------------------------------
" Argwrap
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/vim-argwrap/plugin/argwrap.vim'))
	nnoremap <leader>ew :ArgWrap<CR>
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
      G
      res 15
    endif
  endfunction
  command ToggleGStatus :call ToggleGStatus()
  nnoremap <leader>gs :ToggleGStatus<CR>
  nnoremap <leader>gc :Gcommit --verbose<CR>
  nnoremap <leader>gd :Git diff<CR>
endif
"-----------------------------------------------------------------------------------------------------------------------



"-----------------------------------------------------------------------------------------------------------------------
" fzf.vim
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/fzf.vim/plugin/fzf.vim'))
  nnoremap <leader>ff :Files<CR>
  nnoremap <leader>fb :Buffers<CR>
  nnoremap <leader>ft :Tags<CR>
  nnoremap <leader>fm :Marks<CR>
  nnoremap <leader>fc :Commits<CR>
  nnoremap <leader>fg :GFiles?<CR>
  " Find Directories
  nnoremap <leader>fd :call fzf#run(fzf#wrap({'source': 'find * -type d'}))<CR>
  " Enable C-N and C-P to go backwards in history
  let g:fzf_history_dir = '~/.local/share/fzf-history'
  " [Buffers] Jump to the existing window if possible
  let g:fzf_buffers_jump = 1
  " Show hidden directories
  let $FZF_DEFAULT_COMMAND = 'find . -type f -not -path "*/\.git/*" -not -path "*/\.mypy_cache/*"'
endif
"-----------------------------------------------------------------------------------------------------------------------



"-----------------------------------------------------------------------------------------------------------------------
" Indent Guides
"-----------------------------------------------------------------------------------------------------------------------
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
  au VimEnter,Colorscheme * :hi IndentGuidesOdd ctermbg=235
  au VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=237
  au BufEnter *.py,*.html :IndentGuidesEnable 
  au BufLeave *.py,*.html :IndentGuidesDisable
endif
"-----------------------------------------------------------------------------------------------------------------------



"-----------------------------------------------------------------------------------------------------------------------
" Taboo
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/taboo.vim/plugin/taboo.vim'))
  function! RenameTab()
    call inputsave()
    let term = input('Tabname: ')
    call inputrestore()
    if !empty(term)
      execute ":TabooRename " . term
    endif
  endfunction
  nnoremap <leader>err :call RenameTab()<CR>
endif
"-----------------------------------------------------------------------------------------------------------------------



"-----------------------------------------------------------------------------------------------------------------------
" Ale
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/ale/autoload/ale.vim'))
  let g:ale_pattern_options = {
  \ '\.py$': {'ale_linters': ['flake8'], 'ale_fixers': ['isort', 'black']},
  \}

  let g:ale_lint_on_enter = 0
  let g:ale_sign_column_always = 1
  let g:ale_lint_on_text_changed = 'never'
  let g:ale_python_mypy_options='--ignore-missing-imports --disallow-untyped-defs'
  let g:ale_history_enabled = 0 
  highlight clear ALEErrorSign
  highlight clear ALEWarningSign
  " Change gutter color
  highlight SignColumn cterm=NONE ctermfg=0 ctermbg=None
endif
"-----------------------------------------------------------------------------------------------------------------------



"-----------------------------------------------------------------------------------------------------------------------
" RainbowParentheses
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/rainbow_parentheses.vim/plugin/rainbow_parentheses.vim'))
  " Don't active on html, conflicts with jinja/htmldjango syntax
  function! EnableRainbows()
    :call rainbow_parentheses#load(0)
    :call rainbow_parentheses#load(1)
    :call rainbow_parentheses#load(2)
    :RainbowParenthesesActivate
  endfunction
  au BufEnter *.py call EnableRainbows()
  au Syntax *.py RainbowParenthesesLoadRound
  au Syntax *.py RainbowParenthesesLoadSquare
  au Syntax *.py RainbowParenthesesLoadBraces  
  let g:rbpt_colorpairs = [
    \ ['darkblue',         'RoyalBlue3'],
    \ ['magenta',    'DarkOrchid3'],
    \ ['yellow',         'firebrick3'],
    \ ['darkcyan',     'SeaGreen3'],
    \ ['red', 'SeaGreen3'],
    \ ['blue',        'DarkOrchid3'],
    \ ['gray',        'firebrick3'],
    \ ['cyan',        'DarkOrchid3'],
    \ ['darkred',     'firebrick3'],
    \ ['brown',       'RoyalBlue3'],
    \ ['gray',        'firebrick3'],
    \ ['darkgreen',   'RoyalBlue3'],
    \ ['red',       'SeaGreen3'],
    \ ['darkcyan',    'DarkOrchid3'],
    \ ['green',       'RoyalBlue3'],
    \ ]
endif
"-----------------------------------------------------------------------------------------------------------------------



"-----------------------------------------------------------------------------------------------------------------------
" Pymode
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/python-mode/plugin/pymode.vim'))
  let g:pymode_python = 'python3'
  let g:pymode_run = 1
  let g:pymode_indent = 1
  let g:pymode_motion = 1
  let g:pymode_options_colorcolumn = 0
  let g:pymode_lint = 0
  let g:pymode_rope = 0
  let g:pymode_doc = 0
  let g:pymode_breakpoint = 0
  let g:pymode_lint = 0
  let g:pymode_folding = 0
  let g:pymode_motion = 0 " Disable error when using fzf to switch files
endif
"-----------------------------------------------------------------------------------------------------------------------



"-----------------------------------------------------------------------------------------------------------------------
" Ranger Intergration
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/ranger.vim/plugin/ranger.vim'))
  let g:ranger_map_keys = 0
  nnoremap <leader>m :Ranger<CR>
  nnoremap <leader>n :RangerWorkingDirectory<CR>
  let g:ranger_replace_netrw = 1 " open ranger when vim open a directory
endif
"-----------------------------------------------------------------------------------------------------------------------



"-----------------------------------------------------------------------------------------------------------------------
" Jinja Highlighting
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/vim-jinja2-syntax/indent/jinja.vim'))
  au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm set ft=jinja
endif
"-----------------------------------------------------------------------------------------------------------------------



"-----------------------------------------------------------------------------------------------------------------------
" Markdown
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/vim-markdown/ftplugin/markdown.vim'))
  let g:vim_markdown_folding_disabled=1
  let g:vim_markdown_auto_insert_bullets=0
  let g:vim_markdown_new_list_item_indent=0
  " autocmd BufRead,BufNewFile *.md setlocal comments=fb:>,fb:*,fb:+,fb:-
  autocmd BufRead,BufNewFile *.md setlocal comments=b:>
endif
"-----------------------------------------------------------------------------------------------------------------------



"-----------------------------------------------------------------------------------------------------------------------
" Terraform
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/vim-terraform/ftplugin/terraform.vim'))
  let g:terraform_align=1
  let g:terraform_commentstring='//%s'
endif
"-----------------------------------------------------------------------------------------------------------------------



"-----------------------------------------------------------------------------------------------------------------------
" CamelCaseMotion
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/CamelCaseMotion/plugin/camelcasemotion.vim'))
  " Remap normal ',' to ',,' so we don't lose it
  nnoremap ,, ,
  xnoremap ,, ,
  onoremap ,, ,
endif
"-----------------------------------------------------------------------------------------------------------------------



"-----------------------------------------------------------------------------------------------------------------------
" YouCompleteMe
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/YouCompleteMe/plugin/youcompleteme.vim'))
  let g:ycm_keep_logfiles = 0
endif
"-----------------------------------------------------------------------------------------------------------------------



"-----------------------------------------------------------------------------------------------------------------------
" Bullets
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/bullets.vim/plugin/bullets.vim'))
  let g:bullets_enabled_file_types = [
    \ 'markdown'
    \]
endif
"-----------------------------------------------------------------------------------------------------------------------



"-----------------------------------------------------------------------------------------------------------------------
" RG Searching
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/vim-ripgrep/plugin/vim-ripgrep.vim'))
  nnoremap <leader>/ :call RgSearch()<CR><c-w><c-p>
  noremap <leader>ea :Rg <cword><CR><c-w><c-p>
  function! RgSearch()
    call inputsave()
    let term = input('Search: ')
    call inputrestore()
    if !empty(term)
        execute "Rg " . term
    endif
  endfunction
endif


"-------------------------------------------------------------------------------------------------------->
" Easymotion Plugin
"-------------------------------------------------------------------------------------------------------->
if !empty(glob($EditorDir.'plugged/vim-easymotion/plugin/EasyMotion.vim'))
  hi link EasyMotionTarget ErrorMsg
  hi link EasyMotionTarget2First ErrorMsg
  hi link EasyMotionTarget2Second ErrorMsg
  hi link EasyMotionShade Comment
  hi EasyMotionTarget ctermbg=none ctermfg=1 cterm=bold
  let g:EasyMotion_move_highlight = 0
  nmap s <Plug>(easymotion-repeat)
  let g:EasyMotion_startofline = 0 " keep cursor colum when JK motion
  map  <leader>s <Plug>(easymotion-sn)
  omap <leader>s <Plug>(easymotion-tn)
endif
"-------------------------------------------------------------------------------------------------------->



"-------------------------------------------------------------------------------------------------------->
" SuperTab Plugin
"-------------------------------------------------------------------------------------------------------->
if !empty(glob($EditorDir.'plugged/supertab/plugin/supertab.vim'))
  let g:SuperTabDefaultCompletionType = "<c-n>"
endif