-
Notifications
You must be signed in to change notification settings - Fork 2
/
vimrc
322 lines (288 loc) · 10.7 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
if has('python3')
silent! python3 1
endif
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'gmarik/vundle'
Plugin 'scrooloose/nerdtree'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'scrooloose/nerdcommenter'
Plugin 'Valloric/YouCompleteMe'
Plugin 'bling/vim-airline'
Plugin 'technosophos/drupal-snippets'
Plugin 'sirver/ultisnips'
Plugin 'honza/vim-snippets'
Plugin 'sniphpets/sniphpets'
Plugin 'sniphpets/sniphpets-common'
Plugin 'sniphpets/sniphpets-phpunit'
Plugin 'dahu/SearchParty'
Plugin 'xolox/vim-misc'
Plugin 'xolox/vim-session'
Plugin 'flazz/vim-colorschemes'
Plugin 'tpope/vim-fugitive'
Plugin 'ntpeters/vim-better-whitespace'
Plugin 'lumiliet/vim-twig'
Plugin 'joonty/vdebug'
Plugin 'tpope/vim-haml'
Plugin 'ap/vim-css-color'
Plugin 'valloric/MatchTagAlways'
Plugin 'majutsushi/tagbar'
Plugin 'tpope/vim-surround'
Plugin 'jiangmiao/auto-pairs'
Plugin 'pangloss/vim-javascript'
Plugin 'mxw/vim-jsx'
Plugin 'digitaltoad/vim-pug'
Plugin 'embear/vim-localvimrc'
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'mileszs/ack.vim'
Plugin 'w0rp/ale'
Plugin 'ludovicchabant/vim-ctrlp-autoignore'
Plugin 'shawncplus/phpcomplete.vim'
call vundle#end() " required
filetype plugin indent on " required
" ---------------------------
" Default Vim settings begin
" ---------------------------
" Vim settings
set mouse=a " Enable mouse
set number " Show line numbers
set showmatch " Show matching brackets
set smartcase " Do smart case matching
set smarttab " Enable smarttab
set incsearch " Incremental search
set noswapfile " Do not create swp file
set cursorline " highlight current line
set laststatus=2 " Airline
set backspace=indent,eol,start " Backspace for dummies
set ignorecase " Case insensitive search
set smartcase " Case sensitive when uc present
set wildmenu " Show list instead of just completing
set wildmode=list:longest,full " Command <Tab> completion, list matches, then longest common part, then all.
set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace
set fileformat=unix " UNIX fileformat
set endofline " Newline at the end of file
set autoread " Autoreload changes to file
set noundofile " Do not create undo files
set undodir=~/vimtmp " Store undo files in a directory
set tabstop=2 " Two space indentation
set shiftwidth=2 " Number of space during (auto)indent
set expandtab " Use spaces for tabs
set autoindent " Copies indent from current line to next line
set smartindent " Copies indent from current line to next line
set guifont=Monaco:h16 " Default font settings
set background=dark " Defaults to dark background
" TODO figure out why we have to set this explicitly
autocmd FileType * setlocal smartindent
autocmd FileType * setlocal autoindent
augroup filetypedetect
" Drupal files should be identified as PHP files.
au! BufRead,BufNewFile *.module setfiletype php
au! BufRead,BufNewFile *.install setfiletype php
au! BufRead,BufNewFile *.test setfiletype php
au! BufRead,BufNewFile *.inc setfiletype php
au! BufRead,BufNewFile *.profile setfiletype php
au! BufRead,BufNewFile *.view setfiletype php
au! BufRead,BufNewFile *.theme setfiletype php
" markdown syntax highlighting
au! BufRead,BufNewFile *.md set filetype=markdown
augroup END
" remove trailing whitespace on save
augroup removetrailingspace
au! BufWritePre * :%s/\s\+$//e
augroup END
" tab navigation like firefox
nnoremap <C-S-tab> :tabprevious<CR>
nnoremap <C-tab> :tabnext<CR>
nnoremap <C-n> :tabnew<CR>
nnoremap <A-1> 1gt
nnoremap <A-2> 2gt
nnoremap <A-3> 3gt
nnoremap <A-4> 4gt
nnoremap <A-5> 5gt
nnoremap <A-6> 6gt
nnoremap <A-7> 7gt
nnoremap <A-8> 8gt
nnoremap <A-9> :tablast<CR>
inoremap <C-S-tab> <Esc>:tabprevious<CR>
inoremap <C-tab> <Esc>:tabnext<CR>
inoremap <C-n> <Esc>:tabnew<CR>
inoremap <A-1> <Esc>1gt
inoremap <A-2> <Esc>2gt
inoremap <A-3> <Esc>3gt
inoremap <A-4> <Esc>4gt
inoremap <A-5> <Esc>5gt
inoremap <A-6> <Esc>6gt
inoremap <A-7> <Esc>7gt
inoremap <A-8> <Esc>8gt
inoremap <A-9> <Esc>:tablast<CR>
" for Mac
nnoremap <D-1> 1gt
nnoremap <D-2> 2gt
nnoremap <D-3> 3gt
nnoremap <D-4> 4gt
nnoremap <D-5> 5gt
nnoremap <D-6> 6gt
nnoremap <D-7> 7gt
nnoremap <D-8> 8gt
nnoremap <D-9> :tablast<CR>
inoremap <D-1> <Esc>1gt
inoremap <D-2> <Esc>2gt
inoremap <D-3> <Esc>3gt
inoremap <D-4> <Esc>4gt
inoremap <D-5> <Esc>5gt
inoremap <D-6> <Esc>6gt
inoremap <D-7> <Esc>7gt
inoremap <D-8> <Esc>8gt
inoremap <D-9> <Esc>:tablast<CR>
" easy indentation
nnoremap <tab> a<C-t><Esc>
nnoremap <S-tab> a<C-d><Esc>
vnoremap <tab> :><CR>gv
vnoremap <S-tab> :<<CR>gv
" color column
if exists('+colorcolumn')
set colorcolumn=80
else
au! BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
endif
" Move tabs with alt + left|right (Also makes sure that this keymap is set in
" the end)
autocmd VimEnter * nnoremap <silent> <A-Left> :execute 'silent! tabmove ' . (tabpagenr()-2)<CR>
autocmd VimEnter * nnoremap <silent> <A-Right> :execute 'silent! tabmove ' . (tabpagenr()+1)<CR>
" Store backups in separate directory
" Make sure you do `mkdir ~/vimtmp` before using this setting
set backupdir=~/vimtmp
" Instead of reverting the cursor to the last position in the buffer, we
" set it to the first line when editing a git commit message
au! FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0])
" Shortcut to open quickfix list
nnoremap <leader>q :copen<CR>
" ---------------------------
" Default Vim settings end
" ---------------------------
" ---------------------------
" Plugin settings begin
" ---------------------------
" Tagbar settings
nnoremap <leader>tt :TagbarToggle<CR>
" nerdtree/vim-nerdtree-tabs settings
let g:nerdtree_tabs_open_on_gui_startup=0
nnoremap <leader>ntt :NERDTreeTabsToggle<CR>
nnoremap <leader>ntf :NERDTreeFind<CR>
let NERDTreeShowHidden=1
" ctrlp settings
let g:ctrlp_by_filename = 1
let g:ctrlp_match_window = 'bottom,order:ttb,min:1,max:20,results:20'
let g:ctrlp_open_new_file = 't'
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn)$',
\ 'file': '\v\.(jpg|jpeg|png|gif)$',
\ }
let g:ctrlp_mruf_case_sensitive = 0
" ignore files in .gitignore
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . -co --exclude-standard', 'find %s -type f']
let g:ctrlp_working_path_mode = 0
let g:ctrlp_max_files = 0
let g:ctrlp_switch_buffer = 'et'
let g:ctrlp_regexp = 1
let g:ctrlp_extensions = ['autoignore']
" Enable omni completion.
augroup onmicompletion
au! FileType css setlocal omnifunc=csscomplete#CompleteCSS
au! FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
au! FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
au! FileType php setlocal omnifunc=phpcomplete#CompletePHP
augroup END
" vim-session settings
let g:session_directory = "~/.vimsessions" " Store vim sessions in another location. Make sure you do `mkdir ~/.vimsessions` before using this setting
let g:session_default_to_last = 1 " Restore last session
let g:session_autoload = 'yes' " Restore last session
let g:session_autosave = 'yes' " Session will be saved manually
let g:session_default_overwrite = 0 " Do not override default session
nnoremap <C-A-p> :OpenSession<CR> " sublime text like project switch
" vim-airline settings
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#whitespace#enabled = 1
let g:airline#extensions#whitespace#symbol = '!'
let g:airline#extensions#whitespace#checks = [ 'indent', 'trailing' ]
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_left_sep = '▶'
let g:airline_right_sep = '◀'
let g:airline_symbols.linenr = ''
let g:airline_symbols.branch = '⎇'
let g:airline_symbols.paste = 'ρ'
" vdebug settings
" If you are using VM, make sure you have the following settings:
" - If your VM file path is in sync with your host path, you have to configure
" `path_maps` like this:
" 'path_maps': {
" '<VM_PATH_1>': '<HOST_PATH_1>',
" '<VM_PATH_2>': '<HOST_PATH_2>',
" }
" Thanks to https://github.com/AshishThakur
" -----------------------------------------------------------------------------
let g:vdebug_options= {
\ 'break_on_open': 1,
\ 'debug_file_level': 2,
\ 'debug_file': '/tmp/vdebug.log',
\ 'path_maps': {
\ '/var/www/drupalvm': '/var/www/drupalvm',
\ },
\ 'idekey': 'vdebug',
\}
nnoremap <F8> :BreakpointRemove *<CR>
inoremap <F8> <Esc>:BreakpointRemove *<CR>
" MatchTagAlways settings
" enable match tags in php template files
let g:mta_filetypes = {
\ 'html' : 1,
\ 'xhtml' : 1,
\ 'xml' : 1,
\ 'jinja' : 1,
\ 'php' : 1,
\}
" ack.vim settings
let g:ackhighlight = 1
let g:ack_default_options = " --ignore-dir=vendor"
nnoremap <Leader>a :Ack!<Space>
nnoremap K :Ack! "\b<C-R><C-W>\b"<CR>:cw<CR> " bind K to grep word under cursor
" The Silver Searcher + mileszs/ack.vim
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
" embear/vim-localvimrc settings
let g:localvimrc_ask=0
" ale settings
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 0
let g:ale_lint_on_enter = 0
let g:ale_open_list = 1
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 1
let g:ale_php_phpcs_standard = 'Drupal' " See https://www.drupal.org/node/1419988
let g:ale_linters = {
\ 'php': ['php', 'phpcs'],
\ 'javascript': [],
\}
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-j> <Plug>(ale_next_wrap)
" ultisnips settings
let g:UltiSnipsExpandTrigger="<c-k>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" Default colorscheme
augroup colorscheme
au! BufWinEnter * :colorscheme solarized
augroup END
" vim-fugitive settings
cnoreabbrev git Git
" ---------------------------
" Plugin settings end
" ---------------------------
" End of vimrc-install additions.
source $VIMRUNTIME/vimrc_example.vim