-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_vimrc
414 lines (343 loc) · 11.9 KB
/
dot_vimrc
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
scriptencoding 'utf-8'
" turn off mouse mode
" set mouse=c
" tabs to 2 spaces
set expandtab
set shiftwidth=2
set softtabstop=2
filetype plugin indent on
" live reload files if it changes on disk
set autoread
" word wrap more excellently
" nnoremap <expr> j v:count ? 'j' : 'gj'
" nnoremap <expr> k v:count ? 'k' : 'gk'
" relative line numbers
" set relativenumber
set number
" search options
set incsearch
set hlsearch
set ignorecase
set smartcase
" Install and apply vim plug when needed
" https://github.com/junegunn/vim-plug/wiki/tips#automatic-installation
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
augroup plug
au!
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
augroup END
endif
" Run PlugInstall if there are missing plugins
augroup plug
autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
\| PlugInstall --sync | source $MYVIMRC
\| endif
augroup END
call plug#begin(data_dir . 'plugged')
" #plugins
Plug 'junegunn/vim-plug'
" Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
" Plug 'junegunn/fzf.vim'
" Plug 'tpope/vim-fugitive'
" Plug 'airblade/vim-gitgutter'
" Plug 'sheerun/vim-polyglot'
" Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
" Plug 'tpope/vim-markdown'
" Plug 'tpope/vim-commentary'
" Plug 'tpope/vim-eunuch' " Common shell helpers like mkdir, rename, sudo write, etc
" Plug 'dense-analysis/ale'
" Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile', 'branch': 'release'}
" Plug 'neomake/neomake'
" Plug 'editorconfig/editorconfig-vim'
" Plug 'vim-ruby/vim-ruby'
" Plug 'mgedmin/test-on-save.vim'
" Plug 'sonph/onehalf', { 'rtp': 'vim' }
" Plug 'rktjmp/lush.nvim'
" Plug 'tjdevries/colorbuddy.nvim'
" Plug 'flazz/vim-colorschemes'
" Plug 'ishan9299/modus-theme-vim', {'branch': 'stable'}
" Plug 'sainnhe/everforest'
" Plug 'preservim/vim-colors-pencil'
call plug#end()
" Colorscheme / Theme
" set t_Co=256
" if exists('+termguicolors')
" let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
" let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
" set termguicolors
" endif
" let &t_ut=''
set cursorline
" colorscheme
" colorscheme desert
" colorscheme onehalfdark
" colorscheme pencil
" colorscheme everforest
" let g:pencil_terminal_italics = 1
" let g:pencil_gutter_color = 1
" colorscheme modus-vivendi
" let g:modus_faint_syntax=1
" let g:modus_moody_enable=1
" let g:modus_yellow_comments=1
" let g:modus_cursorline_intense=1
" let g:modus_termtrans_enable=1
" augroup coc
" highlight NormalFloat ctermbg=Black ctermfg=White
" " hi Pmenu ctermfg=White ctermbg=Black
" " hi PmenuSel ctermfg=White ctermbg=Black
" " hi FgCocInfoFloatBgCocFloating ctermfg=White ctermbg=Black guifg=White guibg=Black
" " hi FgCocErrorFloatBgCocFloating ctermfg=White ctermbg=Black guifg=White guibg=Black
" " hi FgCocWarningFloatBgCocFloating ctermfg=White ctermbg=Black guifg=White guibg=Black
" augroup END
" Ruby language features
" https://github.com/vim-ruby/vim-ruby/wiki/VimRubySupport
" augroup mine
" au!
" autocmd FileType ruby compiler ruby
" augroup END
" YAML / YML support
" augroup yaml
" au! BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml " foldmethod=indent
" autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" augroup END
" syntax highlight .envrc and .env
" augroup dotenv
" autocmd BufRead,BufNewFile *.{sh,envrc,env} set filetype=sh
" augroup END
" See whitespace
set list
" custom leader commands
let mapleader = ','
let maplocalleader = ','
map <leader>vr :tabedit ~/.vimrc<CR>
map <leader>vn :tabedit $MYVIMRC<CR>
map <leader>vl :source $MYVIMRC<CR>
" map <Esc><Esc> :noh<CR>:set nopaste<CR>
" map <leader>r :!resize<CR><CR>
" map <leader>f :set paste<CR>mmggi# frozen_string_literal: true<CR><CR><Esc>`m:set nopaste<CR>
" map <leader>c :!ctags -R --languages=ruby --exclude=.git --exclude=log --tag-relative=yes -f .tags . $(bundle list --paths)<CR>
" map <leader>co mmgg"+yG`m
" map <leader>' cs"'
" map <leader>" cs'"
" map <Leader>o :w<cr>:call RunNearestSpec()<CR>
" fzf file fuzzy search
" nnoremap <C-p> :FZF<CR>
" nnoremap <silent> <Leader>f :Rg<CR>
" ALE Asynchronous Lint Engine Config
" set omnifunc=ale#completion#OmniFunc
" let g:ale_sign_column_always = 1
" fixer configurations
" let g:ale_fixers = {
" \ '*': ['remove_trailing_lines', 'trim_whitespace'],
" \}
" linter configurations
" let g:ale_linters = {}
" let g:ale_linters.typescript = [
" \ 'prettier',
" \ 'eslint',
" \ 'tsserver',
" \]
" let g:ale_linters.javascript = [
" \ 'prettier',
" \ 'eslint',
" \ 'flow-language-server'
" \]
" let g:ale_linters.yaml = [
" \ 'yamllint',
" \ 'yaml-language-server'
" \]
" if filereadable(expand(".rubocop.yml"))
" let g:ale_linters.ruby = [
" \ 'rubocop',
" \]
" let g:ale_fixers.ruby = [
" \ 'rubocop',
" \ 'solargraph'
" \]
" else
" let g:ale_linters.ruby = [
" \ 'standardrb',
" \]
" let g:ale_fixers.ruby = [
" \ 'standardrb',
" \ 'solargraph'
" \]
" endif
" let g:ale_fixers = {}
" let g:ale_fixers.typescript = [
" \ 'prettier',
" \ 'eslint',
" \ 'tsserver',
" \]
" let g:ale_fixers.javascript = [
" \ 'prettier',
" \ 'eslint',
" \ 'flow-language-server'
" \]
" let g:ale_typescript_prettier_use_local_config = 1
" let g:ale_lint_on_save = 1
" let g:ale_fix_on_save = 1
" lint after 1000ms after changes are made both on insert mode and normal mode
" let g:ale_lint_on_text_changed = 'always'
" " let g:ale_lint_delay = 1000
" let g:ale_lint_delay = 100
" use explicitly configured linters, not all possible linters
" let g:ale_linters_explicit = 1
" use nice symbols for errors and warnings
" let g:ale_sign_error = '✗\ '
" let g:ale_sign_warning = '⚠\ '
" COC completion servers
" ref https://thoughtbot.com/blog/modern-typescript-and-react-development-in-vim
" Give more space for displaying messages.
" set cmdheight=5
" set cmdheight=2
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=50
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
" inoremap <silent><expr> <TAB>
" \ pumvisible() ? \"\<C-n>" :
" \ <SID>check_back_space() ? \"\<TAB>" :
" \ coc#refresh()
" inoremap <expr><S-TAB> pumvisible() ? \"\<C-p>" : \"\<C-h>"
" function! s:check_back_space() abort
" let col = col('.') - 1
" return !col || getline('.')[col - 1] =~# '\s'
" endfunction
" Use <c-space> to trigger completion.
" if has('nvim')
" inoremap <silent><expr> <c-space> coc#refresh()
" else
" inoremap <silent><expr> <c-@> coc#refresh()
" endif
" Make <CR> auto-select the first completion item and notify coc.nvim to
" format on enter, <cr> could be remapped by other vim plugin
" inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
" \: \"\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
" nmap <silent> [g <Plug>(coc-diagnostic-prev)
" nmap <silent> ]g <Plug>(coc-diagnostic-next)
" GoTo code navigation.
" nmap <silent> gd <Plug>(coc-definition)
" nmap <silent> gy <Plug>(coc-type-definition)
" nmap <silent> gi <Plug>(coc-implementation)
" nmap <silent> gr <Plug>(coc-references)
" Use K to show documentation in preview window.
" nnoremap <silent> K :call <SID>show_documentation()<CR>
" function! s:show_documentation()
" if (index(['vim','help'], &filetype) >= 0)
" execute 'h '.expand('<cword>')
" elseif (coc#rpc#ready())
" silent call CocActionAsync('doHover')
" else
" execute '!' . &keywordprg . " " . expand('<cword>')
" endif
" endfunction
" nmap <leader>K <Plug>(coc-diagnostic-info)
" Highlight the symbol and its references when holding the cursor.
" autocmd CursorHold * silent call CocActionAsync('highlight')
" Symbol renaming.
" nmap <leader>rn <Plug>(coc-rename)
" Formatting selected code.
" xmap <leader>fmt <Plug>(coc-format-selected)
" nmap <leader>fmt <Plug>(coc-format-selected)
" augroup cocformatting
" autocmd!
" " Setup formatexpr specified filetype(s).
" autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" " Update signature help on jump placeholder.
" autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
" augroup end
" Applying codeAction to the selected region.
" Example: `<leader>aap` for current paragraph
" xmap <leader>a <Plug>(coc-codeaction-selected)
" nmap <leader>a <Plug>(coc-codeaction-selected)
" Map function and class text objects
" NOTE: Requires 'textDocument.documentSymbol' support from the language server.
" xmap if <Plug>(coc-funcobj-i)
" omap if <Plug>(coc-funcobj-i)
" xmap af <Plug>(coc-funcobj-a)
" omap af <Plug>(coc-funcobj-a)
" xmap ic <Plug>(coc-classobj-i)
" omap ic <Plug>(coc-classobj-i)
" xmap ac <Plug>(coc-classobj-a)
" omap ac <Plug>(coc-classobj-a)
" Add `:Format` command to format current buffer.
" command! -nargs=0 Format :call CocAction('format')
" Add `:Fold` command to fold current buffer.
" command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Add `:OR` command for organize imports of the current buffer.
" command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
" Add (Neo)Vim's native statusline support.
" NOTE: Please see `:h coc-status` for integrations with external plugins that
" provide custom statusline: lightline.vim, vim-airline.
" set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
" set shortmess+=a
" let g:ale_disable_lsp = 1
" let g:coc_global_extensions = [
" \ 'coc-tsserver',
" \]
" if isdirectory('./node_modules') && isdirectory('./node_modules/prettier')
" let g:coc_global_extensions += ['coc-prettier']
" endif
" if isdirectory('./node_modules') && isdirectory('./node_modules/eslint')
" let g:coc_global_extensions += ['coc-eslint']
" endif
" function! ShowDocIfNoDiagnostic(timer_id)
" if (coc#float#has_float() == 0 && CocHasProvider('hover') == 1)
" silent call CocActionAsync('doHover')
" endif
" endfunction
" function! s:show_hover_doc()
" silent call timer_start(500, 'ShowDocIfNoDiagnostic')
" endfunction
" autocmd CursorHoldI * :call <SID>show_hover_doc()
" autocmd CursorHold * :call <SID>show_hover_doc()
" https://github.com/iamcco/vim-language-server
" let g:markdown_fenced_languages = [
" \ 'vim',
" \ 'help'
" \]
" Add (Neo)Vim's native statusline support.
" NOTE: Please see `:h coc-status` for integrations with external plugins that
" provide custom statusline: lightline.vim, vim-airline.
" set statusline=
" set statusline+=%f
" set statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
" set statusline+=%f%r
" set statusline+=%{coc#status()}
" set statusline+=%{get(b:,'coc_current_function','')}
" https://vimawesome.com/plugin/test-on-save-vim
" set laststatus=2
" GitGutter Config
" if exists('&signcolumn')
" set signcolumn=yes
" else
" let g:gitgutter_sign_column_always = 1
" endif
" let g:gitgutter_highlight_lines = 0 " don't highlight full lines, it messes with syntax highlighting
" Line Length Guide
set textwidth=120
set colorcolumn=+1
" No local swp and ~ files
set directory=/tmp
augroup mine
" Spellcheck on by default for markdown
autocmd BufRead,BufNewFile *md setlocal spell
" Syntax concealment on by default for markdown
autocmd BufRead,BufNewFile *md set conceallevel=1
augroup END
" Use project-local vim config overrides where present
if filereadable(expand('.git/safe/../../.vimrc.local'))
source ./.vimrc.local
set secure " disable unsafe commands in local .vimrc files
endif
" if filereadable(expand(".git/safe/../../.nvimrc"))
" set exrc " enable per-directory .vimrc / .nvimrc / .exrc files
" source ./.nvimrc
" endif