-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
313 lines (291 loc) · 12.3 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
"
" You might need to install these on OSX:
"
" brew install ctags
" go get -u github.com/jstemmer/gotags
" npm install -g git+https://github.com/ramitos/jsctags.git
" npm install -g jshint
" https://github.com/ryanoasis/vim-devicons
"
" cd ~/.vim/bundle/YouCompleteMe
" ./install.py --clang-completer --gocode-completer --tern-completer
"
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
set rtp+=/usr/local/opt/fzf
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'itchyny/lightline.vim'
Plugin 'airblade/vim-gitgutter'
Plugin 'altercation/vim-colors-solarized'
Plugin 'tpope/vim-surround.git'
Plugin 'tpope/vim-fugitive.git'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'mklabs/grunt.vim'
Plugin 'fatih/vim-go'
Plugin 'vim-scripts/sessionman.vim'
Plugin 'vim-scripts/Auto-Pairs.git'
Plugin 'rking/ag.vim'
Plugin 'docunext/closetag.vim'
Plugin 'pangloss/vim-javascript'
Plugin 'jelera/vim-javascript-syntax'
Plugin 'scrooloose/syntastic'
Plugin 'scrooloose/nerdcommenter'
Plugin 'scrooloose/nerdtree'
Plugin 'mustache/vim-mustache-handlebars'
Plugin 'Shutnik/jshint2.vim'
Plugin 'majutsushi/tagbar'
Plugin 'othree/html5.vim'
Plugin 'ternjs/tern_for_vim'
Plugin 'cakebaker/scss-syntax.vim'
Plugin 'plasticboy/vim-markdown'
Plugin 'cespare/vim-toml'
call vundle#end()
filetype plugin on
filetype plugin indent on
syntax enable " enable as opposed to on (keeps theme colors)
"------------------------------------------------------------------------------
" General defaults
set encoding=utf-8
set showcmd " display incomplete commands
set nowrap " don't wrap lines
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set backspace=indent,eol,start " backspace through everything in insert mode
set colorcolumn=80
set number
set hlsearch " highlight matches
set incsearch " incremental searching
set ignorecase " searches are case insensitive...
set smartcase " ... unless they contain at least one capital letter
set history=1000
set showmatch " Show matching brackets.
set matchtime=5 " Bracket blinking.
set novisualbell " No blinking
set noerrorbells " No noise.
set laststatus=2 " Always show status line.
set vb t_vb= " disable any beeps or flashes on error
set viewoptions=folds,options,cursor,unix,slash " Better Unix / Windows compatibility
set virtualedit=onemore " Allow for cursor beyond last character
set history=1000 " Store a ton of history (default is 20)
set hidden " Allow buffer switching without saving
set iskeyword-=. " '.' is an end of word designator
set iskeyword-=# " '#' is an end of word designator
set iskeyword-=- " '-' is an end of word designator
set showmatch " Show matching brackets/parenthesis
set completeopt-=preview
set cmdheight=2
set showtabline=2
set guifont=Source\ Code\ Pro\ for\ Powerline:h15
set cursorline
set guioptions+=e
" this next line is now in .gvimrc
"set guitablabel=\[%N\]\ %t\ %M
set nobackup
set nowb
set noswapfile
set completeopt-=preview " dont show me preview/scratch window when auto-completing
set completeopt=longest,menuone
set wildmode=longest,list:longest
set sessionoptions-=options " never save any vim options with the session!
set sessionoptions-=help
set sessionoptions-=blank
set mouse=a
set scrolloff=5
" Multiple windows are equally sized and open in reading order.
set equalalways
set splitbelow splitright
" Set the working directory to wherever the open file lives
set autochdir
"------------------------------------------------------------------------------
" Auto-complete file types
set omnifunc=syntaxcomplete#Complete " enable autocomplete/syntax highlighting
set ofu=syntaxcomplete#Complete
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType phtml set omnifunc=phpcomplete#CompletePHP
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType c set omnifunc=ccomplete#Complete
" autocomplete selection improvements -- http://vim.wikia.com/wiki/Make_Vim_completion_popup_menu_work_just_like_in_an_IDE
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
inoremap <expr> <C-n> pumvisible() ? '<C-n>' : \ '<C-n><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
inoremap <expr> <M-,> pumvisible() ? '<C-n>' : \ '<C-x><C-o><C-n><C-p><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
let g:omni_sql_no_default_maps = 1
"------------------------------------------------------------------------------
" File type mappings
autocmd BufNewFile,BufReadPost *.md set filetype=markdown
autocmd BufNewFile,BufRead *.min.js set filetype=min.js
autocmd FileType min.js setlocal syntax=javascript
autocmd BufNewFile,BufRead *.less set filetype=less
autocmd FileType less set omnifunc=csscomplete#CompleteCSS
"------------------------------------------------------------------------------
" Golang
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_fmt_command = "gofmt"
let g:go_snippet_engine = "ultisnips"
let g:go_metalinter_deadline = "5s"
let g:go_gocode_unimported_packages = 1
let g:go_fmt_experimental = 1
"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'
"\ }C$,
"\ 'ctagsbin' : 'gotags',
"\ 'ctagsargs' : '-sort -silent'
"------------------------------------------------------------------------------
" CTRL-P
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,all.min.js,all.min.css,*/dist/*,*/dist-prod/*
let g:ctrlp_working_path_mode = 'r'
let g:ctrlp_by_filename = 0
let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.hg$\|\.svn$\|bower_components$\|dist$\|_uploads$\|_convert$\|tmp$\|_diffs$\|dist-prod$\|node_modules$\|project_files$\|test$',
\ 'file': '\.exe$\|\.so$\|\.dll$\|\.pyc$'
\ }
let g:ctrlp_clear_cache_on_exit = 1
let g:ctrlp_open_new_file = 'v'
let g:ctrlp_match_window = 'bottom,order:ttb'
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
"let g:ctrlp_user_command = 'ag %s -l -g ""'
let g:ctrlp_match_window = 'results:30'
"------------------------------------------------------------------------------
" Git
"let g:gitgutter_sign_column_always = 1
set signcolumn=yes
"------------------------------------------------------------------------------
" Snippets
let g:UltiSnipsExpandTrigger="<c-e>"
let g:UltiSnipsListSnippets="<c-l>"
"------------------------------------------------------------------------------
" Colors
" get rid of background color when highlighing brackets
hi MatchParen guibg=NONE guifg=YELLOW
set background=dark
colorscheme solarized
highlight SignColumn guibg=#073642
"remove search highlighting
nnoremap <silent> <esc> :noh<cr><esc>
"------------------------------------------------------------------------------
" Code folding
set foldcolumn=1
set foldmethod=manual "fold based on indent
set foldnestmax=10 "deepest fold is 10 levels
set nofoldenable "dont fold by default
"set foldlevel=1 "this is just what i use
function! NeatFoldText() "{{{2}}}"
let line = ' ' . substitute(getline(v:foldstart), '^\s*"\?\s*\|\s*"\?\s*{{' . '{\d*\s*', '', 'g') . ' '
let lines_count = v:foldend - v:foldstart + 1
let lines_count_text = '| ' . printf("%10s", lines_count . ' lines') . ' |'
let foldchar = matchstr(&fillchars, 'fold:\zs.')
let foldtextstart = strpart('+' . repeat(foldchar, v:foldlevel*2) . line, 0, (winwidth(0)*2)/3)
let foldtextend = lines_count_text . repeat(foldchar, 8)
let foldtextlength = strlen(substitute(foldtextstart . foldtextend, '.', 'x', 'g')) + &foldcolumn
return foldtextstart . repeat(foldchar, winwidth(0)-foldtextlength) . foldtextend
endfunction
set foldtext=NeatFoldText()
" }}}2
"------------------------------------------------------------------------------
" Syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_loc_list_height = 5
let g:syntastic_warning_symbol = '!'
let g:syntastic_style_error_symbol = '!'
let g:syntastic_style_warning_symbol = '!'
let g:syntastic_mode_map = { 'mode': 'active',
\ 'active_filetypes': ['js'],
\ 'passive_filetypes': ['html', 'min.js', 'go'] }
let g:syntastic_ignore_files = ['\.min\.js$', '\.min\.css$']
let g:syntastic_javascript_checkers = ['jshint']
let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck']
let g:syntastic_error_symbol = '✗'
let g:syntastic_warning_symbol = '!'
let g:syntastic_enable_signs=1
let g:syntastic_javascript_checkers=['eslint']
"------------------------------------------------------------------------------
" Status Line
let g:lightline = {
\ 'colorscheme': 'solarized',
\ }
"------------------------------------------------------------------------------
" NETRW
let g:netrw_liststyle=3 " tree
let g:netrw_banner=0 " no banner
let g:netrw_altv=1 " open files on right
let g:netrw_preview=1 " open previews vertically
nmap \e :NERDTreeToggle<CR>
"map <C-n> :NERDTreeToggle<CR>
"------------------------------------------------------------------------------
"" ripgrep
if executable('rg')
let g:ctrlp_user_command = 'rg --files %s'
let g:ctrlp_use_caching = 0
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_switch_buffer = 'et'
set grepprg=rg\ --vimgrep\ --no-heading
set grepformat=%f:%l:%c:%m,%f:%l:%m
endif
" --column: Show column number
" --line-number: Show line number
" --no-heading: Do not show file headings in results
" --fixed-strings: Search term as a literal string
" --ignore-case: Case insensitive search
" --no-ignore: Do not respect .gitignore, etc...
" --hidden: Search hidden files and folders
" --follow: Follow symlinks
" --glob: Additional conditions for search (in this case ignore everything in the .git/ folder)
" --color: Search color options
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --no-ignore --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>), 1, <bang>0)
"------------------------------------------------------------------------------
" Key mappings
nnoremap <Right> <C-w>l
nnoremap <Left> <C-w>h
nnoremap <Up> <C-w>k
nnoremap <Down> <C-w>j
nnoremap <Tab> :bnext<CR>
nnoremap <S-Tab> :bprevious<CR>
nnoremap <F2> :buffers<CR>:buffer<Space>
nnoremap <F3> :bdelete<CR>
nnoremap <F4> :sp<CR>
nnoremap <F5> :vs<CR>
nnoremap <F6> <C-w>w
nnoremap <F7> <C-w>q
nnoremap <F8> :TagbarToggle<CR>
nnoremap <F9> :Dash<CR>
au FileType go nmap <F10> :GoDef<CR>
au FileType go nmap <F11> :GoReferrers<CR>
au FileType go nmap <F12> <Plug>(go-rename)