-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.vim
468 lines (398 loc) · 15.3 KB
/
init.vim
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
let g:python_host_prog='/usr/local/bin/python'
let g:python3_host_prog='/usr/local/bin/python3'
call plug#begin('~/.config/nvim/plugged') " https://github.com/junegunn/vim-plug
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } " https://github.com/Shougo/deoplete.nvim
Plug 'benekastah/neomake' " https://github.com/benekastah/neomake
Plug 'nikvdp/ejs-syntax', { 'for': 'ejs' } " https://github.com/nikvdp/ejs-syntax
Plug 'chrisbra/csv.vim', { 'for': 'csv' } " https://github.com/chrisbra/csv.cim
Plug 'davidoc/taskpaper.vim' " https://github.com/davidoc/taskpaper.vim
Plug 'easymotion/vim-easymotion' " https://github.com/easymotion/vim-easymotion
Plug 'elzr/vim-json', { 'for': 'json' } " https://github.com/elzr/vim-json
Plug 'fatih/vim-go', { 'for': 'go' } " https://github.com/fatih/vim-go
Plug 'godlygeek/tabular' " https://github.com/godlygeek/tabular
Plug 'itchyny/lightline.vim' " https://github.com/itchyny/lightline.vim
Plug 'jelera/vim-javascript-syntax', { 'for': 'javascript' } " https://github.com/jelera/vim-javascript-syntax
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'kana/vim-textobj-line' " https://github.com/kana/vim-textobj-line
Plug 'kana/vim-textobj-user' " https://github.com/kana/vim-textobj-user
Plug 'kien/ctrlp.vim' " https://github.com/kien/ctrlp.vim
Plug 'kshenoy/vim-signature' " https://github.com/kshenoy/vim-signature
Plug 'lambdatoast/elm.vim' " https://github.com/lambdatoast/elm.vim
Plug 'mattn/emmet-vim', { 'for': ['html', 'htmldjango', 'ejs'] } " https://github.com/mattn/emmet-vim
Plug 'mhinz/vim-signify' " https://github.com/mhinz/vim-signify
Plug 'moll/vim-node', { 'for': 'javascript' } " https://github.com/moll/vim-node
Plug 'mxw/vim-jsx', { 'for': 'javascript' } " https://github.com/mxw/vim-jsx
Plug 'myhere/vim-nodejs-complete', { 'for': 'javascript' } " https://github.com/myhere/vim-nodejs-complete
Plug 'nathanaelkane/vim-indent-guides' " https://github.com/nathanaelkane/vim-indent-guides
Plug 'pangloss/vim-javascript', { 'for': 'javascript' } " https://github.com/pangloss/vim-javascript
Plug 'plasticboy/vim-markdown', { 'for': 'markdown' } " https://github.com/plasticboy/vim-markdown
Plug 'purpleP/python-syntax', { 'for': 'python' } " https://github.com/purpleP/python-syntax
Plug 'rizzatti/dash.vim' " https://github.com/rizzatti/dash.vim
Plug 'scrooloose/nerdtree' " https://github.com/scrooloose/nerdtree
Plug 'tpope/vim-rhubarb' " https://github.com/tpope/vim-rhubarb
Plug 'tpope/vim-characterize' " https://github.com/tpope/vim-characterize
Plug 'tpope/vim-commentary' " https://github.com/tpope/vim-commentary
Plug 'tpope/vim-dotenv' " https://github.com/tpope/vim-dotenv
Plug 'tpope/vim-eunuch' " https://github.com/tpope/vim-eunuch
Plug 'tpope/vim-fugitive' " https://github.com/tpope/vim-fugitive
Plug 'tpope/vim-repeat' " https://github.com/tpope/vim-repeat
Plug 'tpope/vim-surround' " https://github.com/tpope/vim-surround
Plug 'tpope/vim-unimpaired' " https://github.com/tpope/vim-unimpaired
Plug 'tweekmonster/braceless.vim', { 'for': ['python', 'coffee', 'yaml'] } " https://github.com/tweekmonster/braceless.vim
Plug 'vim-scripts/SyntaxAttr.vim' " https://github.com/vim-scripts/SyntaxAttr.vim
Plug 'vim-scripts/swap-parameters' " https://github.com/vim-scripts/swap-parameters
Plug 'zchee/deoplete-jedi' " https://github.com/zchee/deoplete-jedi
" colorschemes
Plug 'NLKNguyen/papercolor-theme'
" This modifies other plugins, so has to come last
Plug 'ryanoasis/vim-devicons'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
call plug#end()
filetype on
filetype plugin on
filetype indent on
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
set completeopt=menu,longest,preview
" set cursorline " didn't realize this makes vim slower
set fileencoding=utf-8 ff=unix " don't set encoding=utf-8... nvim sets it by default
" set exrc secure " enable per-directory .vimrc files
set grepprg=ag
set ignorecase smartcase
set iskeyword+=-
set mouse=a
set nobackup dir=~/.tmp/nvim
set noerrorbells visualbell t_vb=
set nofixeol
set nohlsearch incsearch
set nowrap linebreak
set number relativenumber
set pastetoggle=<F8>
set ruler laststatus=2 " one of these ensures each window contains a status line
set scrolloff=3
set synmaxcol=200 " disable syntax highlight after 200 chars for performance
set termguicolors " probably don't need this since $NVIM_TUI_ENABLE_TRUE_COLOR is set
set title
set ts=4 sw=4 ai expandtab
set ttyfast
set tw=79 colorcolumn=80,100
set wildignore=.svn,.git,.env,*.bak,*.pyc,*.DS_Store,*.db,venv
set wildmenu wildmode=list:longest
autocmd BufRead .bash* set filetype=sh
autocmd BufRead *.cls set filetype=apex
autocmd BufRead *.ejs set filetype=ejs
autocmd BufRead *.htm* set filetype=htmldjango omnifunc=htmlcomplete#CompleteTags
autocmd BufRead *.md set filetype=markdown
autocmd BufRead *.page set filetype=visualforce
autocmd BufRead *.py set filetype=python commentstring=#\ %s
autocmd BufRead *.scss set filetype=sass
autocmd BufRead *.sql set filetype=sql commentstring=--\ %s
autocmd BufRead *.txt set filetype=markdown
autocmd BufRead .zsh* set filetype=sh
autocmd BufRead requirements.txt set filetype=text sw=2 ts=2
autocmd BufRead requirements/*.txt set filetype=text sw=2 ts=2
autocmd FileType apex set ts=4 sw=4 foldmethod=indent commentstring=//\ %s
autocmd FileType cfg set ts=4 sw=4 tw=0 foldmethod=indent commentstring=#\ %s
autocmd FileType css set ts=2 sw=2 tw=0 foldmethod=indent
autocmd FileType ejs set ts=4 sw=4 tw=0 foldmethod=indent
autocmd FileType htmldjango set ts=2 sw=2 foldmethod=indent
autocmd FileType javascript set ts=2 sw=2 tw=120 colorcolumn=120 foldmethod=indent omnifunc=javascriptcomplete#CompleteJS
autocmd FileType javascript.jsx set ts=2 sw=2 tw=120 colorcolumn=120 foldmethod=indent omnifunc=javascriptcomplete#CompleteJS
autocmd FileType json set foldmethod=syntax
autocmd FileType mkd set tw=79 ts=2 sw=2
autocmd FileType markdown set tw=79 ts=2 sw=2
autocmd FileType python set ts=4 sw=4 foldmethod=indent omnifunc=pythoncomplete#Complete
autocmd FileType sass set ts=4 sw=4 foldmethod=indent sw=4
autocmd FileType yaml set foldmethod=indent sw=2 ts=2
" To avoid error 'crontab: temp file must be edited in place'
autocmd filetype crontab setlocal nobackup nowritebackup
" tabs in python are bad!
autocmd FileType python highlight Tabs ctermbg=red guibg=red
autocmd FileType python match Tabs /^\t+/
" Automatically chmod +x Shell scripts
autocmd BufWritePost *.sh silent !chmod +x %
" Open file at last edited location
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g'\"" | endif
" Title string
autocmd BufEnter * let &titlestring = 'δ ' . expand("%:t") . ' ∈ ' . FileDir()
" ------------------
" Theme
" ------------------
set background=dark
" these have to be in this order to work
source ~/.config/nvim/pcthemes/kyl.vim
let g:PaperColor_Theme = 'kyl'
colorscheme PaperColor
hi FunctionParameters guifg=#AAC4FF
" disable the annoying HTML link underlining
hi link htmlLink NONE
hi link htmlItalic NONE
" tweak colors
" ...this is a dumb way to do this
" ...i should create my own color scheme
hi htmlH1 ctermfg=225
hi htmlH2 ctermfg=218
hi htmlH3 ctermfg=182
hi htmlH4 ctermfg=139
hi htmlH5 ctermfg=96
hi htmlH6 ctermfg=239
hi mkdCode ctermfg=109
hi mkdLink ctermfg=105
hi mkdURL ctermfg=60
hi IndentGuidesOdd guibg=#233046
hi IndentGuidesEven guibg=#2F3648
hi SignColumn guibg=none ctermbg=none
" -------------
" Mappings
" -------------
:let mapleader='\'
nnoremap ,n :source ~/.config/nvim/init.vim<CR>
inoremap jk <Esc>
inoremap <TAB><TAB> <C-p>
tnoremap jk <C-\><C-n>
nnoremap <C-j> :wincmd j<CR>
nnoremap <C-k> :wincmd k<CR>
nnoremap <C-h> :wincmd h<CR>
nnoremap <C-l> :wincmd l<CR>
tnoremap <C-j> <C-\><C-n><C-w>h
tnoremap <C-k> <C-\><C-n><C-w>j
tnoremap <C-h> <C-\><C-n><C-w>k
tnoremap <C-l> <C-\><C-n><C-w>l
" <opt> = - . ,
nnoremap ≠ 10<C-W>+
nnoremap – 10<C-W>-
nnoremap ≥ 10<C-W>>
nnoremap ≤ 10<C-W><
" <opt> b f k j
nnoremap ∫ <C-W>H
nnoremap ƒ <C-W>L
nnoremap ˚ <C-W>K
nnoremap ∆ <C-W>J
" <opt> p o
nnoremap π :tabnext<CR>
nnoremap ø :tabprevious<CR>
" popup window - use Ctrl+j/k instead of Ctrl+n/p
inoremap <expr> <C-j> pumvisible() ? "\<C-n>" : "\<C-j>"
inoremap <expr> <C-k> pumvisible() ? "\<C-p>" : "\<C-k>"
" select just-pasted lines
nnoremap gp `[v`]
" insert space or newline and get back to normal mode
nnoremap <silent> gj o<Esc>
nnoremap <silent> gk O<Esc>
nnoremap <silent> gh i<Space><Esc>
nnoremap <silent> gl a<Space><Esc>
nnoremap <silent> gn i<CR><Esc>
" center search result
nnoremap N Nzz
nnoremap n nzz
" easier system clipboard access
noremap ,y "+y
noremap ,p "+p
" Common Command Typos
command! Q quit " converts ... :Q => :q
command! W write " converts ... :W => :w
command! Wq wq " converts ... :Wq => :wq
command! Wn wn " converts ... :Wn => :wn
command! WN wN " converts ... :WN => :wN
" don't show help when F1 is pressed
map <F1> <ESC>
" Remove trailing space without overwriting current search
nnoremap <silent> ,s :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>
" getting into terminal mode
nnoremap ,tv :vsp term://zsh -f<CR>i
nnoremap ,tx :sp term://zsh -f<CR>i
" folding
nnoremap <Leader>s :SignifyFold<CR>
" background toggle
map <Leader>bg :let &background = ( &background == "dark"? "light" : "dark" )<CR>
" ---------------------
" Plugin configuration
" ---------------------
" vim-go
let g:go_highlight_types = 1
let g:go_highlight_operators = 1
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
" vim-easymotion
let g:EasyMotion_do_mapping = 0 " Disable default mappings
"let g:EasyMotion_smartcase = 1
nmap ,z <Plug>(easymotion-overwin-f2)
map ,j <Plug>(easymotion-j)
map ,k <Plug>(easymotion-k)
" vim-jsx
let g:jsx_ext_required = 0
" vim-airline
let g:airline_theme = 'dark'
let g:airline_powerline_fonts = 1
" vim-signify
let g:signify_vcs_list = [ 'git' ]
" lightline
let g:lightline = {
\ 'colorscheme': 'PaperColor',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'fugitive', 'filedir', 'filename' ] ],
\ 'right': [ [ 'percent', 'lineinfo' ],
\ [ 'fileformat', 'fileencoding', 'filetype' ],
\ [ 'time'] ],
\ },
\ 'component': {
\ 'lineinfo': ' %2v:%-3l',
\ },
\ 'component_function': {
\ 'fugitive': 'LightlineFugitive',
\ 'readonly': 'LightlineReadonly',
\ 'modified': 'LightlineModified',
\ 'filedir': 'FileDir',
\ 'filename': 'LightlineFilename',
\ 'time': 'LightlineTime',
\ 'devicon': 'LightlineDevicon',
\ },
\ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" },
\ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" },
\ 'tab_component_function': {
\ 'devicon': 'LightlineDevicon',
\ 'modified': 'lightline#tab#modified',
\ 'readonly': 'lightline#tab#readonly',
\ 'tabnum': 'lightline#tab#tabnum'
\ },
\ 'tab': {
\ 'active': [ 'tabnum', 'devicon', 'filename', 'modified' ],
\ 'inactive': [ 'tabnum', 'devicon', 'filename', 'modified' ],
\ },
\ }
" python
let g:python_highlight_all = 1
let g:pyflakes_use_quickfix = 0
" CtrlP
map ,f :CtrlP<CR>
map ,m :CtrlPMRU<CR>
map ,g :CtrlPBuffer<CR>
map ,r :CtrlPClearCache<CR>
let g:ctrlp_match_window_bottom = 0
let g:ctrlp_match_window_reversed = 0
let g:ctrlp_dotfiles = 0
let g:ctrlp_map = '<C-q>'
let g:ctrlp_switch_buffer = 'Et'
let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|env'
let g:ctrlp_root_markers = ['.ctrlp']
" FZF
let g:fzf_layout = { 'down': '~40%' }
let g:fzf_command_prefix = 'Fzf'
" deoplete
let g:deoplete#enable_at_startup = 1
" indent-guides
let g:indent_guides_start_level = 2
let g:indent_guides_guide_size = 1
let g:indent_guides_auto_colors = 0
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_exclude_filetypes = ['help', 'nerdtree']
" NERDtree
map ,d :NERDTreeToggle<CR>
map ,e :NERDTreeFind<CR>
let NERDTreeIgnore = ['\.pyc$']
let NERDTreeWinSize = 45
let NERDTreeShowHidden=1
" vim-nerdtree-syntax-highlight
let s:brown = '905532'
let s:aqua = '3AFFDB'
let s:blue = '689FB6'
let s:darkBlue = '44788E'
let s:purple = '834F79'
let s:lightPurple = '834F79'
let s:red = 'AE403F'
let s:beige = 'F5C06F'
let s:yellow = 'F09F17'
let s:orange = 'D4843E'
let s:darkOrange = 'F16529'
let s:pink = 'CB6F6F'
let s:salmon = 'EE6E73'
let s:green = '8FAA54'
let s:lightGreen = '31B53E'
let s:white = 'FFFFFF'
let s:rspec_red = 'FE405F'
let s:git_orange = 'F54D27'
let g:NERDTreeExtensionHighlightColor = {}
let g:NERDTreeExtensionHighlightColor['py'] = s:green
let g:NERDTreeExtensionHighlightColor['md'] = s:purple
let g:NERDTreeExtensionHighlightColor['yml'] = s:pink
let g:NERDTreeExtensionHighlightColor['ini'] = s:pink
" neomake
autocmd BufWritePost * Neomake
autocmd! QuitPre * let g:neomake_verbose = 0
let g:neomake_go_enabled_makers = ['golint']
let g:neomake_javascript_enabled_makers = ['eslint']
let g:neomake_python_flake8_maker = { 'args': ['--ignore=E501,E731'] }
let g:neomake_python_enabled_makers = ['flake8']
" vim-json
let g:vim_json_syntax_conceal = 0
" -----------
" Functions
" -----------
function! FileDir()
let filedir = substitute(expand("%:p:h"), '/Users/kyl/', '', 'g')
let filedir = substitute(expand("%:p:h"), '/Users/kathleenlavalle/', '', 'g')
" Don't show common parent directories
let filedir = substitute(l:filedir, 'Code/', '', 'g')
let filedir = substitute(l:filedir, 'Work/', '', 'g')
" Shorten these a lot
let filedir = substitute(l:filedir, '.dotkyl/', '…', 'g')
" Shorten everything else a little by removing vowels
" (unless that vowel is the beginning of a word)
let filedir = substitute(l:filedir, '\(\<\)\@<![aeiou]', '', 'g')
" Then remove double letters
let filedir = substitute(l:filedir, '\([a-zA-Z]\)\1', '\1', 'g')
" Except these are better with vowels
let filedir = substitute(l:filedir, '\.rg/', '.org/', 'g')
return filedir
endfunction
function! LightlineModified()
if &filetype == "help"
return ""
elseif &modified
return "+"
elseif &modifiable
return ""
else
return ""
endif
endfunction
function! LightlineReadonly()
if &filetype == "help"
return ""
elseif &readonly
return "\ue0a2"
else
return ""
endif
endfunction
function! LightlineFugitive()
if exists("*fugitive#head")
let branch = fugitive#head()
return branch !=# '' ? ' '.branch : ''
endif
return ''
endfunction
function! LightlineFilename()
return ('' != LightlineReadonly() ? LightlineReadonly() . ' ' : '') .
\ ('' != expand('%:t') ? expand('%:t') : '[No Name]') .
\ ('' != LightlineModified() ? ' ' . LightlineModified() : '')
endfunction
function! LightlineTime()
return strftime('%H:%M')
endfunction
function! LightlineDevicon(n)
let buflist = tabpagebuflist(a:n)
let winnr = tabpagewinnr(a:n)
let fname = expand('#'.buflist[winnr - 1].':t')
return WebDevIconsGetFileTypeSymbol(fname)
endfunction
" ------------------------------
" Highlight trailing whitespace
" ------------------------------
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()