-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
273 lines (238 loc) · 7.06 KB
/
.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
set nocompatible
filetype off
" List of plugins --- {{{
call plug#begin()
Plug 'tpope/vim-sensible'
Plug 'tmux-plugins/vim-tmux-focus-events'
Plug 'pangloss/vim-javascript'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'airblade/vim-gitgutter'
Plug 'dracula/vim', { 'as': 'dracula' }
Plug 'editorconfig/editorconfig-vim'
Plug 'flowtype/vim-flow'
Plug 'heavenshell/vim-jsdoc'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'ternjs/tern'
Plug 'moll/vim-node'
Plug 'w0rp/ale'
Plug 'rizzatti/dash.vim'
Plug 'scrooloose/nerdtree'
Plug 'tpope/vim-fugitive'
Plug 'itchyny/lightline.vim'
Plug 'vim-scripts/tComment'
Plug 'jremmen/vim-ripgrep'
Plug 'duganchen/vim-soy'
Plug 'mattn/emmet-vim'
Plug 'galooshi/vim-import-js'
call plug#end()
" }}}
filetype plugin on
" pangloss/vim-javascript --- {{{
let g:javascript_plugin_jsdoc = 1
let g:javascript_plugin_flow = 1
" }}}
" nathanaelkane/vim-indent-guides --- {{{
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_guide_size = 1
let g:indent_guides_auto_colors = 0
let g:indent_guides_exclude_filetypes = ['help', 'nerdtree']
"
" see
" 1. https://github.com/dracula/vim/blob/master/colors/dracula.vim
" 2. https://commons.wikimedia.org/wiki/File:Xterm_256color_chart.svg
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd ctermbg=237
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=237
" }}}
" flowtype/vim-flow --- {{{
let g:flow#enable = 1
let g:flow#autoclose = 1
" }}}
" junegunn/fzf.vimw --- {{{
" This is the default extra key bindings
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
" Default fzf layout
" - down / up / left / right
let g:fzf_layout = { 'down': '~40%' }
" In Neovim, you can set up fzf window using a Vim command
" let g:fzf_layout = { 'window': 'enew' }
" let g:fzf_layout = { 'window': '-tabnew' }
" let g:fzf_layout = { 'window': '10split enew' }
" Customize fzf colors to match your color scheme
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'border': ['fg', 'Ignore'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
" Enable per-command history.
" CTRL-N and CTRL-P will be automatically bound to next-history and
" previous-history instead of down and up. If you don't like the change,
" explicitly bind the keys to down and up in your $FZF_DEFAULT_OPTS.
let g:fzf_history_dir = '~/.local/share/fzf-history'
" }}}
" moll/vim-node --- {{{
autocmd User Node
\ if &filetype == "javascript" |
\ nmap <buffer> <C-w>f <Plug>NodeVSplitGotoFile |
\ nmap <buffer> <C-w><C-f> <Plug>NodeVSplitGotoFile |
\ endif
" }}}
" w0rp/ale --- {{{
let g:ale_fix_on_save = 0
let g:ale_lint_on_text_changed = 'never'
let g:ale_javascript_prettier_use_local_config = 1
nmap <silent>]e :ALENext<cr>
nmap <silent>[e :ALEPrevious<cr>
nmap <silent>ff :ALEFix<cr>
nmap <silent>ar :ALEDisable<cr>:ALEEnable<cr>
let g:ale_fixers = {
\ 'javascript': [
\ 'prettier',
\ 'eslint',
\ 'importjs',
\ ],
\ 'css': [
\ 'prettier',
\ ],
\ 'less': [
\ 'prettier',
\ ]
\}
" }}}
" itchyny/lightline.vim --- {{{
let g:lightline = {
\ 'colorscheme': 'Dracula',
\ 'active': {
\ 'left': [['mode', 'paste'], ['filename', 'gitbranch', 'filetype', 'modified']],
\ 'right': [['fileformat', 'fileencoding'], ['lineinfo'], ['percent'], ['readonly', 'linter_warnings', 'linter_errors', 'linter_ok']]
\ },
\ 'component_expand': {
\ 'linter_warnings': 'LightlineLinterWarnings',
\ 'linter_errors': 'LightlineLinterErrors',
\ 'linter_ok': 'LightlineLinterOK'
\ },
\ 'component_type': {
\ 'readonly': 'error',
\ 'linter_warnings': 'warning',
\ 'linter_errors': 'error'
\ },
\ 'component_function': {
\ 'gitbranch': 'fugitive#head'
\ },
\ }
function! LightlineLinterWarnings() abort
let l:counts = ale#statusline#Count(bufnr(''))
let l:all_errors = l:counts.error + l:counts.style_error
let l:all_non_errors = l:counts.total - l:all_errors
return l:counts.total == 0 ? '' : printf('%d ◆', all_non_errors)
endfunction
function! LightlineLinterErrors() abort
let l:counts = ale#statusline#Count(bufnr(''))
let l:all_errors = l:counts.error + l:counts.style_error
let l:all_non_errors = l:counts.total - l:all_errors
return l:counts.total == 0 ? '' : printf('%d ✗', all_errors)
endfunction
function! LightlineLinterOK() abort
let l:counts = ale#statusline#Count(bufnr(''))
let l:all_errors = l:counts.error + l:counts.style_error
let l:all_non_errors = l:counts.total - l:all_errors
return l:counts.total == 0 ? '✓ ' : ''
endfunction
autocmd User ALELint call s:MaybeUpdateLightline()
" Update and show lightline but only if it's visible (e.g., not in Goyo)
function! s:MaybeUpdateLightline()
if exists('#lightline')
call lightline#update()
end
endfunction
" }}}
" mattn/emmet-vim --- {{{
let g:user_emmet_install_global = 0
autocmd FileType html,css EmmetInstall
" }}}
" Settings --- {{{
syntax enable
set showtabline=0
set synmaxcol=256
set ttyfast
set termencoding=utf-8
set colorcolumn=119
set tabstop=4
set shiftwidth=4
set expandtab
set smartindent
set hlsearch
set noshowmode
set title
set list
set showmatch
set number
set cursorline
set linebreak
set foldlevelstart=99
set foldmethod=manual
let &t_8f="\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b="\<Esc>[48;2;%lu;%lu;%lum"
let &t_Co=256
set termguicolors
set background=dark
colorscheme dracula
" }}}
" Mappings --- {{{
let mapleader=' '
nmap <silent><leader>gb :.Gblame<cr>
vmap <silent><leader>gb :Gblame<cr>
nmap <silent><leader>gd :Gdiff<cr>
nmap <silent><leader>gst :Gstatus<cr>
nmap <silent><leader>gc :Gcommit<cr>
nmap <silent><leader>td :TernDef<cr>
nmap <silent><leader>tr :TernRefs<cr>
" nmap <silent><leader>nt :tabnew<cr>
nmap <silent><leader>q :bd<cr>
nmap <silent>]b :bnext<cr>
nmap <silent>[b :bprev<cr>
nmap <silent>' :!jest %<cr>
nmap <silent><leader>f :NERDTreeFind<cr>
" let g:NERDTreeWinSize=50
nmap <silent><leader>h :Dash<cr>
nmap <silent>q :cclose<cr>
nmap <silent>]q :cnext<cr>
nmap <silent>[q :cprev<cr>
nnoremap <silent><cr> :nohlsearch<cr><cr>
nmap <silent><C-p> :Files<cr>
nmap ; :Buffers<CR>
" }}}
" Autocommands for filetypes --- {{{
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal foldmethod=marker
autocmd FileType vim execute "normal zM"
augroup END
augroup filetype_javascript
autocmd!
autocmd BufNewFile,BufReadPost *.flow set ft=javascript
autocmd FileType javascript setlocal foldmethod=syntax
augroup END
" }}}
" Cursor in tmux --- {{{
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
" }}}
nmap \r :!tmux send-keys -t 0 C-p C-j <CR><CR>