-
Notifications
You must be signed in to change notification settings - Fork 0
/
new_vimrc
353 lines (288 loc) · 10.4 KB
/
new_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
" Install YouCompleteMe !!!!
" Other things to install:
" QFEnter/ Vundle.vim/ YouCompleteMe/ syntastic/ ultisnips/
" vim-codefmt/ vim-flake8/ vim-fugitive/ vim-glaive/ vim-maktaba/
" vim-snippets/
" sensible/ unimpaired/
" Figure out tmux pasting
scriptencoding utf-8
set encoding=utf-8
" set rtp+=~/.vim/bundle/Vundle.vim
" call vundle#begin()
" Plugin 'something.vim'
" call vundle#end()
"
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
set mouse=v " r
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
"
Plugin 'Valloric/YouCompleteMe.vim'
" Plugin 'YouCompleteMe'
" " The following are examples of different formats supported.
" " Keep Plugin commands between vundle#begin/end.
" " plugin on GitHub repo
" Plugin 'tpope/vim-fugitive'
" " plugin from http://vim-scripts.org/vim/scripts.html
" " Plugin 'L9'
" " Git plugin not hosted on GitHub
" Plugin 'git://git.wincent.com/command-t.git'
" " git repos on your local machine (i.e. when working on your own plugin)
" Plugin 'file:///home/gmarik/path/to/plugin'
" " The sparkup vim script is in a subdirectory of this repo called vim.
" " Pass the path to set the runtimepath properly.
" Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" " Install L9 and avoid a Naming conflict if you've already installed a
" " different version somewhere else.
" " Plugin 'ascenator/L9', {'name': 'newL9'}
"
" All of your Plugins must be added before the following line
" Add maktaba and codefmt to the runtimepath.
" (The latter must be installed before it can be used.)
Plugin 'google/vim-maktaba'
Plugin 'google/vim-codefmt'
" Also add Glaive, which is used to configure codefmt's maktaba flags. See
" `:help :Glaive` for usage.
Plugin 'google/vim-glaive'
" Track the engine.
Plugin 'SirVer/ultisnips'
" Snippets are separated from the engine. Add this if you want them:
Plugin 'honza/vim-snippets'
" Quickfix changes
Plugin 'yssl/QFEnter'
" colorscheme
Plugin 'morhetz/gruvbox'
" nerdtree
Plugin 'scrooloose/nerdtree'
call vundle#end() " required
" the glaive#Install() should go after the "call vundle#end()"
call glaive#Install()
" Optional: Enable codefmt's default mappings on the <Leader>= prefix.
" Glaive codefmt plugin[mappings]
" Glaive codefmt google_java_executable="java -jar /path/to/google-java-format-VERSION-all-deps.jar"
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
let g:ycm_collect_identifiers_from_tags_files = 1 " Let YCM read tags from Ctags file
let g:ycm_use_ultisnips_completer = 1 " Default 1, just ensure
let g:ycm_seed_identifiers_with_syntax = 1 " Completion for programming language's keyword
let g:ycm_complete_in_comments = 1 " Completion in comments
let g:ycm_complete_in_strings = 1 " Completion in string
nnoremap <c-n> :YcmCompleter GoToReferences<CR>
let g:UltiSnipsExpandTrigger = "<c-j>"
let g:UltiSnipsJumpForwardTrigger = "<c-j>"
let g:UltiSnipsJumpBackwardTrigger = "<c-p>"
let g:UltiSnipsListSnippets = "<c-k>" "List possible snippets based on current file
" let g:UltiSnipsExpandTrigger="<c-j>"
" let g:UltiSnipsJumpForwardTrigger="<c-b>"
" let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%{FugitiveStatusline()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 0 " 1
let g:syntastic_check_on_wq = 0
let g:syntastic_python_pylint_args = "--load-plugins pylint_django"
augroup autoformat_settings
autocmd FileType bzl AutoFormatBuffer buildifier
autocmd FileType c,cpp,proto,javascript AutoFormatBuffer clang-format
autocmd FileType dart AutoFormatBuffer dartfmt
autocmd FileType go AutoFormatBuffer gofmt
autocmd FileType gn AutoFormatBuffer gn
autocmd FileType html,css,sass,scss,less,json AutoFormatBuffer js-beautify
autocmd FileType java AutoFormatBuffer google-java-format
" autocmd FileType python AutoFormatBuffer yapf
" Alternative: autocmd FileType python AutoFormatBuffer autopep8
autocmd FileType vue AutoFormatBuffer prettier
augroup END
" autocmd BufWritePost *.py call Flake8()
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
"
execute pathogen#infect()
filetype plugin indent on
set wildmode=list:full
set wildmenu
set ignorecase
set smartcase
set hlsearch
set incsearch
set number
set relativenumber
set matchpairs+=<:>,':',":"
set nowrap
set undofile
set undodir=~/.vimlocal/undo
set dir=~/.vimlocal/swap
set scrolloff=4
set sidescrolloff=8
set virtualedit=onemore,block
set title
set tabstop=4
" No Ex mode
map q: <Nop>
nnoremap Q <Nop>
"other
set colorcolumn=+1
highlight ColorColumn ctermbg=darkgrey
let mapleader=','
let g:mapleader=','
if &diff
set cursorline
" map ] ]c
" map [ [c
map <leader>1 :diffget LOCAL<CR>
map <leader>2 :diffget BASE<CR>
map <leader>1 :diffget REMOTE<CR>
endif
vnoremap / /\v
nnoremap / /\v
vnoremap ? ?\v
nnoremap ? ?\v
imap jk <Esc>
" Splits
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
set splitbelow
set splitright
" open tags in split
" map <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR>
" map <A-]> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
map <C-\> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
" Use Ag for grep
" The Silver Searcher
if executable('ag')
" 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 ""'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
" bind K to grep word under cursor
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
" bind \ (backward slash) to grep shortcut
command -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw!
nnoremap \ :Ag<SPACE>
" Edit the path
" set path+=**
set path=**
let g:netrw_banner=0 " disable banner
let g:netrw_browse_split=4 " open in prior window
let g:netrw_altv=1 " open splits to the right
let g:netrw_listtype=3 " tree view
let g:netrw_list_hide=netrw_gitignore#Hide()
let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S+'
" Snippets
nnoremap ,html :-1read $HOME/.vim/snippet/skeleton.html<CR>
nnoremap ,cpp :-1read $HOME/.vim/snippet/skeleton.cpp<CR>
nnoremap ,cfor :-1read $HOME/.vim/snippet/skeleton.cfor<CR>
nnoremap Y $y
" colorscheme liquidcarbon
"
" nnoremap ]l :lnext<CR>
" nnoremap [l :lprevious<CR>
" From otherss
" Operate on screen line instead of file lines
nnoremap j gj
nnoremap k gk
map <F2> :mksession! ~/vim_session <cr> " Quick write session with F2
map <F3> :source ~/vim_session <cr> " And load session with F3
" Press * or # to search for current selection
vnoremap <silent> * y:let @/ = @"<CR>n:set hlsearch<CR>
vnoremap <silent> # y:let @? = @"<CR>n:set hlsearch<CR>
" replay @q for each line of visual selection
vnoremap Q :normal @q<CR>
" qq to record Q to replay
nnoremap Q @q
" easier indent visual blocks
vnoremap > >gv
vnoremap < <gv
" use system clipboard
set clipboard=
" case insensitive filename completion
set wic
" set list " show whitespace
" set listchars=trail:·,tab:··
set statusline=[%n\|%{winnr()}] " buffer number and window index
set statusline+=\ %<%.99f " tail of filename
set statusline+=\ %m " modified flag
set statusline+=[
set statusline+=%{&ff} " file format
set statusline+=%R " read only flag
set statusline+=%Y " filetype
set statusline+=]
set statusline+=%= " left right separator
" set statusline+=%-16(%{fugitive#statusline()}%) " git branch
set statusline+=%l/%LL " cursor line/total lines
set statusline+=\ %c%VC " cursor column
set statusline+=\ %P " percent through file
set laststatus=2 " always show status line
set ai " auto indent
set si " smart indent
set smarttab " use shiftwidth to tab at beginning of line
set cindent " c style indenting
set tabstop=2 " tab spaciing (next setting for unity)
set softtabstop=2
set shiftwidth=2
set autowrite " save file when shell/cmd are run
set autoread
set wildmenu
set wildmode=full " zsh style command completion
set autoread " no prompt for file change outside vim
set swapfile " keep swap files
set wildignore+=tags " ignore tabs when globbing
set wildignore+=tmp/** " also tmp file
set wildignore+=public/uploads/**
set wildignore+=public/images/**
set wildignore+=vendor/**
set isk+=_,$,@,%,# " none of these should be word dividers
set wildignore+=.git,*.o,tmp/**,vendor/rails/**
nnoremap <left> <c-w>>
nnoremap <right> <c-w><
nnoremap <up> <c-w>+
nnoremap <down> <c-w>-
let g:AutoPairs={'(':')','[':']','{':'}',"'":"'",'"':'"'}
imap {<CR> {<ESC>o}<ESC>%a<CR>
set foldmethod=indent
nnoremap <Space> za
vnoremap <Space> za
nnoremap Y y$
" nnoremap <c-m> :noh<cr>
set mouse=a
nnoremap <C-LeftMouse> <LeftMouse>:YcmCompleter GoToReferences<CR>
:vmap <C-C> "+y
map <F2> :mksession! ~/vim_session <cr> " Quick write session with F2
map <F3> :source ~/vim_session <cr> " And load session with F3
map <F7> :NERDTreeToggle<CR>
" autocmd vimenter * NERDTree
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") && v:this_session == "" | NERDTree | endif
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
com! FormatJSON %!python -m json.tool
""""""""""""""""""""""""""""""""""""
" all plugins before these lines:
"
filetype plugin indent on
syntax on