aboutsummaryrefslogtreecommitdiff
path: root/plugin/vim-options.vim
blob: 6f0634bfdfa717b03a0e364a3063b48fe0e4ca37 (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
" 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

" 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,html,htmldjango setlocal tabstop=2
au FileType sh,python setlocal tabstop=4
au FileType make setlocal tabstop=4 noexpandtab

" Setup colorscheme
syntax enable 
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

" 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 $HOME='/root/.vimcache'
  let $EditorDir='/root/.config/nvim/'
  let $SessionDir='.vimcache'
	silent! execute '!mkdir -p .vimcache/backup'
else
  let $EditorDir=$HOME.'/.vim/'
  let $SessionDir='.'
endif

" My Shorcuts
let mapleader="\<Space>"
" 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>
" New tab
nnoremap <C-w>t :tabnew<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 erros
nnoremap [q :lprev<CR>
nnoremap ]q :lnext<CR>
" Set breakpoint in python
noremap <leader>eb ofrom pudb import set_trace; set_trace()<ESC>
" Vertical split instead of horiztonal
noremap <c-w>f <c-w>f<c-w>H
" <c-w>] uses path not tags file? 
noremap <c-w>] <c-w>v<c-]><c-w>H
" Run isort on file
noremap <leader>ei :!isort %<CR>




"-----------------------------------------------------------------------------------------------------------------------
" Ack Searching
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/ack.vim/plugin/ack.vim'))
  nnoremap <leader>/ :call AckSearch()<CR>
  noremap <leader>ea :Ack <cword><cr>
  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
      Gstatus
    endif
  endfunction
  command ToggleGStatus :call ToggleGStatus()
  nnoremap <leader>gs :ToggleGStatus<CR>
  nnoremap <leader>gc :Gcommit --verbose<CR>
  nnoremap <leader>gd :Gdiff<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>
  " Enable C-N and C-P to go backwards in history
  let g:fzf_history_dir = $HOME.'.local/share/fzf-history'
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>er :call RenameTab()<CR>
endif
"-----------------------------------------------------------------------------------------------------------------------



"-----------------------------------------------------------------------------------------------------------------------
" Ale
"-----------------------------------------------------------------------------------------------------------------------
if !empty(glob($EditorDir.'plugged/ale/autoload/ale.vim'))
  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'))
  au VimEnter *.py RainbowParenthesesToggle
  au Syntax *.py RainbowParenthesesLoadRound
  au Syntax *.py RainbowParenthesesLoadSquare
  au Syntax *.py RainbowParenthesesLoadBraces
  let g:rbpt_colorpairs = [
    \ ['brown',         'RoyalBlue3'],
    \ ['darkblue',    'DarkOrchid3'],
    \ ['red',         'firebrick3'],
    \ ['magenta',     'SeaGreen3'],
    \ ['yellow', '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_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>n :Ranger<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
"-----------------------------------------------------------------------------------------------------------------------