-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnvimrc
More file actions
448 lines (369 loc) · 14.1 KB
/
Copy pathnvimrc
File metadata and controls
448 lines (369 loc) · 14.1 KB
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
filetype off " required
set sidescroll=1 " Make side scrolling reasonable
set tabstop=4 " Set number of spaces that tabs count for
set shiftwidth=4 " Set autoindent level to 4 spaces
set expandtab " Change all tabs to spaces
set lazyredraw " Redraw screen only when typing
set ttyfast " Setting to ensure tmux is drawing quickly
set scrolloff=3 " keep 3 lines when scrolling
set ai " set auto-indenting on for programming
set showcmd " display incomplete commands
set nobackup " do not keep a backup file
set number " show line numbers
set relativenumber " line numbers are relative to current position
set ruler " show the current row and column
set colorcolumn=79 " Show the 79 character cutoff marker
set nowrap " Don't wrap lines by default
set hlsearch " highlight searches
set incsearch " do incremental searching
set showmatch " jump to matches when entering regexp
set ignorecase " ignore case when searching
set smartcase " no ignorecase if Uppercase char present
set visualbell t_vb= " turn off error beep/flash
set novisualbell " turn off visual bell
set wildignore+=*.pyc,*.swp " Filter these filetypes from the file search functions
set splitright " Vertical splits go to the right by default
set splitbelow " Horizontal splits go below by default
set virtualedit=block " Allow visual blocks to extend beyond end of text in lines
set t_Co=256 " Terminal colors
set backspace=indent,eol,start " make that backspace key work the way it should
syntax on " turn syntax highlighting on by default
filetype on " detect type of file
filetype indent on " load indent file for specific file type
match ErrorMsg '\s\+$'
" Fix backspace/delete key issues
set backspace=indent,eol,start " Setting backspace to behave in a sane fashion
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+ " Show visible characters for whitespace
set list " Also necessary for visible trailing whitespace
" Esc alternative for Dvorak users. QWERTY folks should use jk or kj
inoremap tn <Esc>
set timeoutlen=300
" Force `Y` behavior to match that of `C` and `D`
nnoremap Y y$
" Remap :W and :X to :w and :x because half the time I accidentally type them
ca W w
ca X x
" Move right 15 characters
nnoremap <C-l> 15zl
" Move left 15 characters
nnoremap <C-h> 15zh
function! FileOffset()
echo line2byte(line('.')) + col('.') - 1
endfunction
"""""""""""""""""""""""""""""""""""
""""""Neovim Specific Settings""""""
"""""""""""""""""""""""""""""""""""
function! Gf()
if &buftype ==# "terminal"
:e <cfile>
else
normal! gf
endif
endfunction
function! OpenDual(fl, fd)
let l:folder=a:fd . a:fl
exe 'tabe' . l:folder
exe 'tcd' . l:folder
vsp term://zsh
sp term://zsh
wincmd w
endfunction
function! OpenTrip(fl, fd)
let l:folder=a:fd . a:fl
exe 'tabe' . l:folder
exe 'tcd' . l:folder
exe 'vsp' . l:folder
vsp term://zsh
sp term://zsh
wincmd w
endfunction
function! OP(fs)
let l:gofolder=$HOME . '/go/src/github.com/'
let l:codefolder=$HOME . '/Code/'
let l:workspacefolder=$HOME . '/workspace/'
for fl in split(a:fs)
if !empty(glob(l:codefolder . fl))
call OpenTrip(fl, l:codefolder)
continue
endif
if !empty(glob(l:workspacefolder . fl))
call OpenTrip(fl, l:workspacefolder)
continue
endif
let l:ffolder=glob(l:gofolder . '*/' . fl)
if !empty(l:ffolder)
let l:p=split(l:ffolder, '/')
call OpenDual(join([l:p[-2], l:p[-1]], '/'), l:gofolder)
continue
endif
endfor
endfunction
function! JenkinsfileLint()
exe "!curl --user ". $JENKINS_USER . ":" . $JENKINS_TOKEN . " -X POST -F 'jenkinsfile=<" . expand("%:p") . "' " . $JENKINS_URL . "/pipeline-model-converter/validate"
endfunction
function! UmlDisplay()
exe "!java -jar " . $HOME . "/.config/nvim/plugged/vim-slumlord/plantuml.jar " . expand("%")
endfunction
" Increase terminal buffer 10x
let g:terminal_scrollback_buffer_size = 10000
let g:python_host_prog=$HOME . "/venvs/neovim2/bin/python" " Ensure neovim is always using its own virtualenv
let g:python3_host_prog=$HOME . "/venvs/neovim3/bin/python" " Ensure neovim is always using its own virtualenv
set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50
\,a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor
\,sm:block-blinkwait175-blinkoff150-blinkon175
" Workaround for bug #4299
nnoremap gf :call Gf()<CR>
" Neovim-remote for terminal buffers
let $GIT_EDITOR = 'nvr -cc split --remote-wait'
autocmd FileType gitcommit set bufhidden=delete
" Fixing Neovim Meta Character Terminal Word Jumping
tnoremap <A-b> <Esc>b
tnoremap <A-f> <Esc>f
tnoremap <A-.> <Esc>.
"""""""""""""""""""""""""""""""""""
vnoremap // y/\V<C-R>"<CR>
" Setting leader key based mappings
let mapleader=","
let maplocalleader=";"
" Easy buffer switching `,b<num>`
noremap <Leader>b :buffers<CR>:buffer<Space>
" Open loclist
noremap <Leader>l :lopen<CR>
" Next loclist
noremap <Leader>n :lnext<CR>
" Previous loclist
noremap <Leader>p :lprev<CR>
" Spellcheck shortcuts
" Quick spelling fix
noremap <Leader>f 1z=
" Toggle Highlighting
noremap <Leader>s :set spell!<CR>
" Quick Search
noremap <Leader>K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
" Delete all trailing whitespace
noremap <Leader>ds :try<CR> :%s/\s\+$//<CR> :let @/ = ''<CR> :catch<CR> :let @/ = ''<CR> :endtry<CR><CR>
" Easy Reload nvimrc
noremap <Leader>rv :source $MYVIMRC<CR>
" Easy Clear Last Search Highlight
noremap <Leader>c :let @/ = ''<CR>
" Easy Neovim Terminal Split
noremap <Leader>gt :vsp term://zsh<CR>
" Easy Split Switch From Neovim Terminal Insert Mode
tnoremap <Leader>e <C-\><C-n><C-w><C-w>
" Easy Pylinting mnemonic "Python Code"
noremap <Leader>,pc !pylint %
" Short UUID Generation in quotes
nnoremap <Leader>u mm:r!uuidgen\|cut -c 1-8<CR>dW"_dd`mi""<Esc>hp
""""
" Slimv keymappings
""""
noremap <LocalLeader>wp :emenu Slimv.Edit.Paredit-Wrap
" """""""""""""""""""""""""""""""""
" Auto install vim-plug for plugin management
if empty(glob('~/.config/nvim/autoload/plug.vim'))
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall
endif
""""""""""""""""""""""""""""""""""""""""
"""""""""" START PLUGINS """""""""""""""
""""""""""""""""""""""""""""""""""""""""
call plug#begin('~/.config/nvim/plugged')
Plug 'bling/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'easymotion/vim-easymotion'
"Mustache/Handlebars syntax"
Plug 'mustache/vim-mustache-handlebars'
"Powershell syntax"
Plug 'PProvost/vim-ps1'
" Easier Tabline Modification
Plug 'gcmt/taboo.vim'
let g:taboo_tab_format = ' %N : %P '
" Better python syntax highlighting
Plug 'msmith491/python-syntax'
let g:python_highlight_all = 1
" Plug 'Shougo/deoplete.nvim'
" let g:deoplete#enable_at_startup = 1
" let g:deoplete#enable_smart_case = 1
" let g:deoplete#auto_complete_start_length = 3
" inoremap <expr><tab> pumvisible() ? "\<c-n>" : "\<tab>"
" Plug 'deoplete-plugins/deoplete-jedi'
" let deoplete#sources#jedi#show_docstring = 0
"
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Enable tab completion for coc.nvim
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Forces preview window to close after completion
autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif
" Theme
Plug 'freeo/vim-kalisi'
set background=dark
" Shows git file changes to the left of line numbers
Plug 'airblade/vim-gitgutter'
set signcolumn=yes
let g:gitgutter_max_signs = 1000
" FuzzyFinder
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
let $FZF_DEFAULT_COMMAND = 'rg --files'
nnoremap <C-p> :FZF<CR>
Plug 'junegunn/fzf.vim'
nnoremap <C-h> :History<CR>
nnoremap <C-f> :Lines<CR>
nnoremap <C-b> :Buffers<CR>
nnoremap <C-s> :Rg<Space>
" Easy alignment of lines
Plug 'junegunn/vim-easy-align'
xmap ga <Plug>(EasyAlign)
nmap ga <Plug>(EasyAlign)
" Better file browser
Plug 'scrooloose/nerdtree'
map <C-n> :NERDTreeToggle<CR>
let NERDTreeIgnore = ['\.pyc$']
Plug 'Asheq/close-buffers.vim'
nnoremap <Leader>cc :Bdelete hidden<CR>
" Tag generation
Plug 'ludovicchabant/vim-gutentags'
let g:gutentags_cache_dir = $HOME . '/.gutencache'
" Function definitions in their own window
Plug 'majutsushi/tagbar', { 'on': 'TagbarToggle' }
" Accessible via `tb` shortcut
:nnoremap tb :TagbarToggle<CR>
" Autoinstalling exhuberent ctags so tagbar will function
if !executable('ctags')
silent !mkdir ~/ctags
silent !wget -O ~/ctags/ctags-5.8.tar.gz sourceforge.net/projects/ctags/files/ctags/5.8/ctags-5.8.tar.gz
silent !tar -xzvf ~/ctags/ctags-5.8.tar.gz
cd ~/ctags/ctags-5.8
silent !./configure
silent !make
silent !sudo make install
echo('You still need to run ./configure, make and sudo make install for ctags in your home directory')
echo("Otherwise tagbar won't work")
endif
let g:tagbar_ctags_bin='/usr/local/bin/ctags'
let g:tagbar_autofocus=1
" PlantUML
" This requries java
Plug 'scrooloose/vim-slumlord'
Plug 'aklt/plantuml-syntax'
nnoremap <Leader>cc :Bdelete hidden<CR>
""""""""""""""""""""""""""""""""""""""""
"""""""""" Hail To The Tpope """""""""""
""""""""""""""""""""""""""""""""""""""""
" Git integration
Plug 'tpope/vim-fugitive'
" Multiline comments via `gc` shortcut
Plug 'tpope/vim-commentary'
" Surround helper
Plug 'tpope/vim-surround'
" Date helper
Plug 'tpope/vim-speeddating'
"""""""""""""""""""""""""""""""""""""""
" Plug 'scrooloose/syntastic'
" set laststatus=2
" set statusline+=%f
" set statusline+=%#warningmsg#
" set statusline+=%{SyntasticStatuslineFlag()}
" set statusline+=%*
" let g:syntastic_always_populate_loc_list = 1
" let g:syntastic_auto_loc_list = 1
" let g:syntastic_check_on_open = 1
" let g:syntastic_check_on_wq = 0
" " Python checker settings
" let g:syntastic_python_checkers = ["pylint", "pyflakes", "flake8"]
" let g:syntastic_python_python_exec = '/usr/local/bin/python3'
" let g:syntastic_python_flake8_exe = 'python3 -m flake8'
" let g:syntastic_python_pylint_exe = 'python3 -m pylint'
" let g:syntastic_python_pyflakes_exe = 'python3 -m pyflakes'
" let g:syntastic_python_flake8_post_args = "--ignore=E501"
" let g:syntastic_yaml_checkers = ['yamllint']
" let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck']
" let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go', 'html'] }
" let g:syntastic_sh_checkers = ['shellcheck']
"
" Ale (Async Linting Engine)
Plug 'w0rp/ale'
" Rainbow parentheses
Plug 'luochen1990/rainbow'
let g:rainbow_active = 1
Plug 'Glench/Vim-Jinja2-Syntax'
Plug 'kshenoy/vim-signature'
Plug 'voldikss/vim-floaterm'
" Enable these when I work with these languages again
" Lisp plugin
" Plug 'kovisoft/slimv'
" let g:slimv_leader = \";"
" Scala
" Plug 'derekwyatt/vim-scala'
" Perl
" Plug 'vim-perl/vim-perl', { 'for': 'perl', 'do': 'make clean carp dancer highlight-all-pragmas moose test-more try-tiny' }
" Rust
Plug 'rust-lang/rust.vim'
let g:rustfmt_autosave = 1
autocmd FileType rust nnoremap gd :call CocActionAsync("jumpDefinition")<CR>
noremap <Leader>rp i println!("{:?}"
noremap <Leader>rf i .fold(0, \|acc, item\| acc + item)
Plug 'zah/nim.vim'
set tabstop=4
set shiftwidth=4
" Go
Plug 'fatih/vim-go'
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_fields = 1
let g:go_highlight_types = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_play_open_browser = 0
let g:go_bin_path = expand("~/.gotools")
let g:go_list_type = "quickfix"
let g:go_def_mode='gopls'
let g:go_info_mode='gopls'
call plug#end()
""""""""""""""""""""""""""""""""""""""""
"""""""""" END PLUGINS """"""""""""""""
""""""""""""""""""""""""""""""""""""""""
colorscheme kalisi
""""""""""""""""""""""""""""""""""
"""""" Python AutoCommands """"""
""""""""""""""""""""""""""""""""""
autocmd Filetype python setlocal indentkeys-=<:>
autocmd FileType python setlocal indentkeys-=:
" Jump to Python Definiton
autocmd FileType python nnoremap gd :call CocActionAsync("jumpDefinition")<CR>
""""""""""""""""""""""""""""""""""
"""""" Yaml AutoCommands """"""
""""""""""""""""""""""""""""""""""
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType yaml setlocal indentkeys-=:
""""""""""""""""""""""""""""""""""""""""
"""""" Golang Settings and Stuff """"""
""""""""""""""""""""""""""""""""""""""""
autocmd FileType go setlocal noexpandtab
autocmd FileType go setlocal listchars=tab:>·,trail:-,extends:>,precedes:<,nbsp:+ " Show visible characters for whitespace
autocmd FileType go setlocal nolist
autocmd FileType go setlocal colorcolumn=119
""""""""""""""""""""""""""""""""""""""""
""""""""" Mutt Email Settings """""""""
""""""""""""""""""""""""""""""""""""""""
autocmd BufRead,BufNewFile *mutt-* setfiletype markdown
" Add format option 'w' to add trailing white space, indicating that paragraph
" continues on next line. This is to be used with mutt's 'text_flowed' option.
autocmd FileType mail setlocal formatoptions+=w tw=72 fo=watqc nojs nosmartindent
""""""""""""""""""""""""""""""""""""""""
"""""""" Jenkinsfile Settings """""""""
""""""""""""""""""""""""""""""""""""""""
autocmd BufRead,BufNewFile *Jenkinsfile* setfiletype groovy
autocmd BufRead,BufNewFile *jenkinsfile* setfiletype groovy
autocmd BufRead,BufNewFile *Jenkinsfile* nnoremap gc :call JenkinsfileLint()<CR>
autocmd BufRead,BufNewFile *jenkinsfile* nnoremap gc :call JenkinsfileLint()<CR>
""""""""""""""""""""""""""""""""""""""""
"""""""" Dockerfile Settings """"""""""
""""""""""""""""""""""""""""""""""""""""
autocmd BufRead,BufNewFile *Dockerfile* setfiletype dockerfile
"""""""""""""""""""""""""""""""""
"""""""" UML Settings """"""""""
"""""""""""""""""""""""""""""""""
autocmd! BufWritePost *uml* :call UmlDisplay()