-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
353 lines (294 loc) · 9.47 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
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
" plug.vim -> https://github.com/junegunn/vim-plug
call plug#begin()
" Plug 'mileszs/ack.vim'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'editorconfig/editorconfig-vim'
" Plug 'bubujka/emmet-vim'
Plug 'scrooloose/nerdcommenter'
" Plug 'vim-airline/vim-airline'
" Plug 'vim-airline/vim-airline-themes'
Plug 'itchyny/lightline.vim'
Plug 'kchmck/vim-coffee-script'
Plug 'ap/vim-css-color'
" Plug 'dag/vim-fish'
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
Plug 'chriseppstein/vim-haml'
Plug 'Yggdroot/indentLine'
" Plug 'nathanaelkane/vim-indent-guides'
" Plug 'digitaltoad/vim-jade'
Plug 'pangloss/vim-javascript'
Plug 'elzr/vim-json'
Plug 'tpope/vim-markdown'
Plug 'mustache/vim-mustache-handlebars'
" Plug 'tpope/vim-rails'
Plug 'vim-ruby/vim-ruby'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-abolish'
Plug 'dahu/vim-fanfingtastic'
Plug 'w0rp/ale'
Plug 'maximbaz/lightline-ale'
Plug 'othree/javascript-libraries-syntax.vim'
Plug 'luochen1990/rainbow'
Plug 'dracula/vim', { 'as': 'dracula' }
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'wellle/targets.vim'
Plug 'misterbuckley/vim-definitive'
Plug 'styled-components/vim-styled-components', { 'branch': 'main' }
call plug#end()
filetype plugin indent on
let g:dracula_colorterm = 0
let g:dracula_italic=0
colorscheme dracula
let g:lightline = {
\ 'colorscheme': 'Dracula',
\ 'active': {
\ 'right': [ [ 'lineinfo', 'percent' ],
\ [ 'filetype' ],
\ [ 'linter_errors', 'linter_warnings' ], ],
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'git_branch' ],
\ [ 'relativepath', 'modified', 'readonly' ], ]
\ },
\ 'component_function': {
\ 'git_branch': 'fugitive#head'
\ },
\ 'component_expand': {
\ 'linter_warnings': 'LightlineLinterWarnings',
\ 'linter_errors': 'LightlineLinterErrors',
\ },
\ 'component_type': {
\ 'linter_warnings': 'warning',
\ 'linter_errors': 'error',
\ },
\ }
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
if !has('gui_running')
set t_Co=256
endif
" Make Vim more useful
set nocompatible
" Use the OS clipboard by default (on versions compiled with `+clipboard`)
set clipboard=unnamed
" Enhance command-line completion
set wildmenu
" Allow cursor keys in insert mode
set esckeys
" Allow backspace in insert mode
set backspace=indent,eol,start
" Optimize for fast terminal connections
set ttyfast
" Add the g flag to search/replace by default
set gdefault
" Use UTF-8 without BOM
set encoding=utf-8 nobomb
" Change mapleader
let mapleader=","
" Don’t add empty newlines at the end of files
set binary
set eol
" Centralize backups, swapfiles and undo history
set backupdir=~/.vim/backups
set directory=~/.vim/swaps
if exists("&undodir")
set undodir=~/.vim/undo
endif
" Don’t create backups when editing files in certain directories
set backupskip=/tmp/*,/private/tmp/*
" Respect modeline in files
set modeline
set modelines=4
" Enable per-directory .vimrc files and disable unsafe commands in them
set exrc
set secure
" Highlight current line
set cursorline
" Make tabs as wide as two spaces
set tabstop=2
" Show “invisible” characters
set lcs=tab:▸\ ,trail:·,eol:¬,nbsp:_
set list
" Highlight searches
set hlsearch
" Ignore case of searches
set ignorecase
" Highlight dynamically as pattern is typed
set incsearch
" Always show status line
set laststatus=2
" Disable error bells
set noerrorbells
" Don’t reset cursor to start of line when moving around.
set nostartofline
" Show the cursor position
set ruler
" Don’t show the intro message when starting Vim
set shortmess=atI
" Don't show the current mode
set noshowmode
" Show the filename in the window titlebar
set title
" Show the (partial) command as it’s being typed
set showcmd
" Start scrolling three lines before the horizontal window border
set scrolloff=3
" Tab key -> 2 spaces
set expandtab
set shiftwidth=2
set softtabstop=2
" reload files when changed on disk, i.e. via `git checkout`
set autoread
" writing the swap file faster
set updatetime=100
" Splitting right and down feels more natural
set splitbelow
set splitright
" Save a file as root (,W)
noremap <leader>W :w !sudo tee % > /dev/null<CR>
" Automatic commands
if has("autocmd")
" Enable file type detection
filetype on
" Treat .json files as .js
autocmd BufNewFile,BufRead *.json setfiletype json syntax=javascript
autocmd User ALELint call lightline#update()
endif
" let g:EditorConfig_core_mode = 'external_command'
" let g:EditorConfig_exec_path = '/usr/local/bin/editorconfig'
let g:EditorConfig_exclude_patterns = ['fugitive://.\*']
"Enable code folding
set foldenable
"Hide mouse when typing
set mousehide
" slam escape / save
inoremap jk <Esc>
inoremap jkk <Esc>:w<CR>
nnoremap jkk <Esc>:w<CR>
inoremap kjj <Esc>:x<CR>
nnoremap kjj <Esc>:x<CR>
" this stuff needs to go into a black hole
nnoremap <silent> dd "_dd
nnoremap <silent> d "_d
nnoremap <silent> cc "_cc
nnoremap <silent> c "_c
nnoremap <silent> D "_D
nnoremap <silent> C "_C
nnoremap <silent> s "_s
nnoremap <silent> S "_S
" Use ctrl-[hjkl] to select the active split!
nmap <silent> <c-h> :wincmd h<CR>
nmap <silent> <c-j> :wincmd j<CR>
nmap <silent> <c-k> :wincmd k<CR>
nmap <silent> <c-l> :wincmd l<CR>
" Moving Lines
nnoremap ∆ :m .+1<CR>==
nnoremap ˚ :m .-2<CR>==
inoremap ∆ <Esc>:m .+1<CR>==gi
inoremap ˚ <Esc>:m .-2<CR>==gi
vnoremap ∆ :m '>+1<CR>gv=gv
vnoremap ˚ :m '<-2<CR>gv=gvV
nnoremap - :call Explore()<CR>
nnoremap <Leader>gb :Gblame<CR>
nnoremap <Leader>gc :Gcommit<CR>
nnoremap <Leader>gd :Gdiff<CR>
nnoremap <Leader>gl :sp<CR>:Glog<CR><CR>
nnoremap <Leader>gs :Gstatus<CR>
nnoremap <Leader>== =ip
nnoremap <silent> <Leader>/ :nohlsearch<CR>
" Fast editing and reloading of vimrc configs
map <leader>r :e! ~/.vimrc<cr>
autocmd! bufwritepost vimrc source ~/.vimrc
" Search for current visual selection
vnoremap // y/<C-R>"<CR>
nnoremap <Leader>c :tabnew<CR>
nnoremap <Leader>C :tabclose<CR>
nnoremap <silent> <Leader>X :tabnew<CR>:tabonly<CR>
nnoremap <Leader>V :spl<CR>
nnoremap <Leader>v :vsp<CR>
nnoremap <Leader>s :call OpenNextFile(1)<CR>
nnoremap <Leader>S :call OpenNextFile(-1)<CR>
nnoremap <Leader>a :vsp<CR>:call OpenNextFile(1)<CR>
nnoremap <Leader>A :spl<CR>:call OpenNextFile(1)<CR>
let g:indentLine_leadingSpaceEnabled=1
let g:javascript_plugin_jsdoc = 1
let g:used_javascript_libs = 'jquery, underscore, flux, react, handlebars'
let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
" Use compact syntax for prettified multi-line comments
let g:NERDCompactSexyComs = 1
" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'
" Set a language to use its alternate delimiters by default
let g:NERDAltDelims_java = 1
" Add your own custom formats or override the defaults
let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } }
" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1
" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1
augroup FiletypeGroup
autocmd!
au BufNewFile,BufRead *.jsx set filetype=javascript.jsx
augroup END
" nmap <silent> <C-n> <Plug>(ale_toggle)
nmap <silent> <C-S-n> <Plug>(ale_previous_wrap)
nmap <silent> <C-n> <Plug>(ale_next_wrap)
let g:ale_linter_aliases = {'jsx': ['css', 'javascript']}
let g:ale_fixers = {
\ 'javascript': ['eslint'],
\ 'scss': ['stylelint']
\}
let g:ale_linters = {
\ 'html': [],
\ 'ruby': [],
\ 'javascript': ['eslint', 'prettier'],
\ 'jsx': ['stylelint', 'eslint']
\}
let g:ale_fix_on_save = 1
let g:rainbow_active = 1
let g:rainbow_conf = {
\ 'ctermfgs': [ 'magenta', 'blue', 'yellow', 'red' ],
\ 'separately': {
\ 'html.handlebars': {
\ 'parentheses': [ 'start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold' ],
\ }
\ }
\}
let g:netrw_banner = 0
nnoremap <Leader>d :FindDefinition<CR>
function! Explore()
let last_file = expand('%:t')
exe 'Explore'
call search(last_file, 'wc')
endfunction
function! OpenNextFile(direction)
let current_dir = expand('%:p:h')
let current_file = expand('%:p')
let current_dir_files = globpath(current_dir, '*', 0, 1)
let current_file_index = index(current_dir_files, current_file)
let next_file_index = current_file_index + a:direction
while next_file_index != current_file_index
if next_file_index == len(current_dir_files)
let next_file_index = 0
endif
if filereadable(current_dir_files[next_file_index])
exe 'edit ' . current_dir_files[next_file_index]
break
endif
let next_file_index += a:direction
endwhile
endfunction