forked from jferris/config_files
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
274 lines (213 loc) · 6.48 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
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
set nobackup
set nowritebackup
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
set exrc " enable per-directory .vimrc files
set secure " disable unsafe commands in local .vimrc files
set clipboard=unnamed " share clipboard with the system
set encoding=utf-8
filetype on " without this vim emits a zero exit status, later, because of :ft off
filetype off
call plug#begin('~/.vim/plugged')
" install vim plugs
if filereadable(expand("~/.vimrc.plugs"))
source ~/.vimrc.plugs
endif
call plug#end()
" Don't use Ex mode, use Q for formatting
map Q gq
" Make sure we're recognizing 256 color terminals
if $TERM == "xterm-256color" || $TERM == "screen-256color" || $COLORTERM == "gnome-terminal"
set t_Co=256
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if (&t_Co > 2 || has("gui_running")) && !exists("syntax_on")
syntax on
set hlsearch
endif
set tabstop=4
set shiftwidth=2
set smartindent
set smarttab
filetype plugin indent on
if has("folding")
set nofoldenable
endif
map <silent><C-,> :bn
map <silent><C-.> :bp
map <silent><C-/> :b#
set hidden
" \ is the leader character
let mapleader = "\\"
" Hide search highlighting
map <Leader>h :set invhls <CR>
" NERD Tree
map <Leader>ls :NERDTreeToggle <CR>
" Opens an edit command with the path of the currently edited file filled in
" Normal mode: <Leader>e
map <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
" Opens a tab edit command with the path of the currently edited file filled in
" Normal mode: <Leader>t
" map <Leader>te :tabe <C-R>=expand("%:p:h") . "/" <CR>
" Set debugging
map <Leader>p Iimport pdb;pdb.set_trace()<CR><ESC>
map <Leader>d Idebugger;<CR><ESC>
" Semantic gd with golang
au FileType go nmap gd <Plug>(go-def)
" Go rename variable
au FileType go nmap <Leader>n <Plug>(go-rename)
" Open up go definitions in different splits
au FileType go nmap <Leader>ds <Plug>(go-def-split)
au FileType go nmap <Leader>dv <Plug>(go-def-vertical)
au FileType go nmap <Leader>dt <Plug>(go-def-tab)
" Go tools
au FileType go nmap <Leader>gr <Plug>(go-run)
au FileType go nmap <Leader>gb <Plug>(go-build)
au FileType go nmap <Leader>gt <Plug>(go-test)
au FileType go nmap <Leader>gc <Plug>(go-coverage)
" Go docs in a browser
au FileType go nmap <Leader>gb <Plug>(go-doc-browser)
" Interface inspection
au FileType go nmap <Leader>s <Plug>(go-implements)
" Type inspection
au FileType go nmap <Leader>i <Plug>(go-info)
let g:go_fmt_command = "goimports"
" Inserts the path of the currently edited file into a command
" Command mode: Ctrl+P
cmap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
" Maps autocomplete to tab
imap <C-Tab> <C-N>
" Duplicate a selection
" Visual mode: D
vmap D y'>p
" No Help, please
nmap <F1> <Esc>
" Press ^F from insert mode to insert the current file name
imap <C-F> <C-R>=expand("%")<CR>
" Display extra whitespace
set list listchars=tab:»·,trail:·
" Local config
if filereadable(".vimrc.local")
source .vimrc.local
endif
" Numbers
set number
set numberwidth=5
" case only matters with mixed case expressions
set ignorecase
set smartcase
"less highlighting
au BufNewFile,BufRead *.less set filetype=less
" Color scheme
colorscheme vividchalk
highlight NonText guibg=#060606
" Highlight everything that overflows 80 chars
highlight OverLength ctermbg=red ctermfg=white guibg=#FCA08D
au FileType markdown highlight OverLength none
match OverLength /\%81v.*/
set laststatus=2
" show a navigable menu for tab completion
set wildignore=log/**,node_modules/**,target/**,tmp/**,*.rbc,*.pyc
set wildmenu
set wildmode=longest,list,full
"Use locally installed flow if available
let local_flow = finddir('node_modules', '.;') . '/.bin/flow'
if matchstr(local_flow, "^\/\\w") == ''
let local_flow= getcwd() . "/" . local_flow
endif
if executable(local_flow)
let g:syntastic_javascript_flow_exe = local_flow
endif
" let g:syntastic_go_checkers = []
let g:syntastic_javascript_checkers = ['flow', 'eslint']
" Disable flow on save, since syntastic will do that
let g:flow#enable = 0
" automatically rebalance windows on vim resize
autocmd VimResized * :wincmd =
" Use Ack instead of Grep when available
if executable("ack")
set grepprg=ack\ -H\ --nogroup\ --nocolor
endif
" Use The Silver Searcher https://github.com/ggreer/the_silver_searcher
if executable('ag')
let g:ackprg = 'ag --nogroup --column'
" Use Ag over Grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
endif
" Use ripgrep
if executable('rg')
let g:ackprg = 'rg --vimgrep'
" Use rg over ag
set grepprg=rg\ --vimgrep
endif
" Enable basic mouse behavior such as resizing buffers.
set mouse=a
if (!has('nvim') && exists('$TMUX')) " Support resizing in tmux
set ttymouse=xterm2
endif
" NeoComplete config
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplete.
let g:neocomplete#enable_at_startup = 1
" Use smartcase.
let g:neocomplete#enable_smart_case = 1
" Set minimum syntax keyword length.
let g:neocomplete#sources#syntax#min_keyword_length = 3
"ale config
let g:ale_fixers = {
\ 'javascript': ['eslint'],
\}
let g:ale_linters_ignore = {
\ 'javascript': ['tsserver'],
\}
let g:ale_fix_on_save = 1
" Tagbar config for go
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }
" FZF config
set rtp+=/usr/local/bin/fzf
let g:fzf_action = {
\ 'ctrl-s': 'split',
\ 'ctrl-v': 'vsplit'
\ }
nnoremap <c-p> :FZF<cr>
" Do jsx highlighting even on .js files
let g:jsx_ext_required = 0
let g:javascript_plugin_flow = 1
let g:javascript_plugin_jsdoc = 1