-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
337 lines (271 loc) · 8.08 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
" Prevent d / x from overriding yank buffer.
nnoremap x "_x
nnoremap d "_d
" Paste without updating the default register.
vnoremap p "_dP
let mapleader = ","
" Disable scratchpad
set completeopt-=preview
imap <M-Space> <Esc>
" Remove delay between modes.
set timeoutlen=500 ttimeoutlen=0
set encoding=utf-8
" To open a new empty buffer
" This replaces :tabnew which I used to bind to this mapping
nmap <leader>n :enew<cr>
" Move to the next buffer
nmap <leader>l :bnext<CR>
" Move to the previous buffer
nmap <leader>h :bprevious<CR>
" Close the current buffer and move to the previous one
" This replicates the idea of closing a tab
nmap <leader>bq :bp <BAR> bd #<CR>
" Show all open buffers and their status
nmap <leader>bl :ls<CR>
" Disable arrows for navigating
map <Left> <Nop>
map <Right> <Nop>
map <Up> <Nop>
map <Down> <Nop>
nmap <silent> <Up> :wincmd k<CR>
nmap <silent> <Down> :wincmd j<CR>
nmap <silent> <Left> :wincmd h<CR>
nmap <silent> <Right> :wincmd l<CR>
" bind - to /
nmap - /
nnoremap K <Nop>
nnoremap <C-n> <C-]>
" Autocomplete braces and apostrophes and move cursor between them.
""inoremap ( ()<Esc>i
""inoremap [ []<Esc>i
""inoremap { {<CR>}
""inoremap ' ''<Esc>i
""inoremap " ""<Esc>i
"nnoremap j gj
"nnoremap k gk
" w!! will save file as sudo.
cmap w!! %!sudo tee > /dev/null %
" Create new / change buffer
map <C-Left> :tabp<CR>
map <C-Right> :tabn<CR>
" Bigger block size for faster scrolling
set ttyfast
" Undo history between sessions
set undodir=~/.vim/undodir
set undofile
set undolevels=1000 "maximum number of changes that can be undone
set undoreload=10000 "maximum number lines to save for undo on a buffer reload
" Colored column (to see line size violations)
" set colorcolumn=80
" Source .vimrc after saving .vimrc
" autocmd bufwritepost .vimrc source $MYVIMRC
" Highlight current line in insert mode.
autocmd InsertLeave * set nocursorline
autocmd InsertEnter * set cursorline
" Bundle thingie
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle
" required!
Plugin 'gmarik/Vundle.vim'
" My Plugins here:
"
" original repos on github
" Plugin 'tpope/vim-fugitive'
" Plugin 'Lokaltog/vim-easymotion'
" Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Plugin 'tpope/vim-rails.git'
" vim-scripts repos
" Plugin 'L9'
" Plugin 'FuzzyFinder'
" non github repos
" Plugin 'git://git.wincent.com/command-t.git'
" ...
Plugin 'tpope/vim-unimpaired'
Plugin 'mattn/webapi-vim'
Plugin 'mattn/gist-vim'
Plugin 'Shougo/unite.vim'
Plugin 'Shougo/vimproc.vim'
Plugin 'Raimondi/delimitMate'
Plugin 'mattn/emmet-vim'
" Plugin 'gregsexton/MatchTag'
Plugin 'scrooloose/nerdcommenter'
Plugin 'Shougo/neocomplete.vim'
"Plugin 'pangloss/vim-javascript'
"Plugin 'stephpy/vim-php-cs-fixer'
"Plugin 'scrooloose/syntastic'
"Plugin 'joonty/vim-sauce.git'
"Plugin 'evidens/vim-twig'
Plugin 'bling/vim-airline'
Plugin 'tpope/vim-surround'
"Plugin 'morhetz/gruvbox'
Plugin 'tpope/vim-fugitive'
Plugin 'jamessan/vim-gnupg'
"Plugin 'Shougo/deoplete.nvim'
Plugin 'arnaud-lb/vim-php-namespace'
"Plugin 'padawan-php/padawan.vim'
"Plugin 'padawan-php/deoplete-padawan'
"Plugin 'roxma/nvim-yarp'
"Plugin 'roxma/vim-hug-neovim-rpc'
"Plugin 'lvht/phpcd.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'iandwelker/rose-pine-vim'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - list configured plugins
" :PluginInstall(!) - install (update) plugins
" :PluginSearch(!) foo - search (or refresh cache first) for foo
" :PluginClean(!) - confirm (or auto-approve) removal of unused plugins
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
"
set background=dark
" Color settings
set t_Co=256
"let g:gruvbox_italic=1
"let g:gruvbox_contrast_dark='medium'
colorscheme rose-pine-dark
set go=aegirL
" use filetype plugins, e.g. for PHP
" filetype plugin on
" old vim thingies continue
syntax on
"set scrolljump=5
set scrolloff=5
" repair wired terminal/vim settings
set backspace=start,eol,indent
" toggle paste
set pastetoggle=§
set wrap
" show nice info in ruler
set ruler
set laststatus=2
" set standard setting for pear coding standards
set tabstop=2
set shiftwidth=2
" auto expand tabs to spaces
set expandtab
" auto indent after a {
set autoindent
set smartindent
" show (relative) line numbers by default
set relativenumber
" use incremental searching
set incsearch
" Search hilighting
set hlsearch
" Clear hlsearch on insert mode
for key in ['i','I','o','O','a','A']
exe 'nnoremap <silent>' key ':noh<CR>'.key
endfor
autocmd BufEnter * lcd %:p:h
au BufRead,BufNewFile *.install set filetype=php
au BufRead,BufNewFile *.theme set filetype=php
au BufRead,BufNewFile *.module set filetype=php
au BufRead,BufNewFile *.inc set filetype=php
au BufRead,BufNewFile *.test set filetype=php
au BufRead,BufNewFile *.twig set filetype=html
" Disable pastemode when leaving insert mode.
au InsertLeave * set nopaste
" Search files with unite.vim
if has('nvim')
nnoremap <space>p :Unite -start-insert file_rec/neovim:!<cr>
else
nnoremap <space>p :Unite -start-insert file_rec/async:!<cr>
endif
nnoremap <leader>s :Unite -start-insert buffer<cr>
" Search from yank history.
let g:unite_source_history_yank_enable = 1
nnoremap <space>y :Unite history/yank<cr>
" Search content with unite.vim
nnoremap <space>c :Unite grep:.<cr>
" Search buffer with unite.vim
nnoremap <space>b :Unite -quick-match buffer<cr>
"nmap ; :CtrlPBuffer<CR>
" Autocenter on ggG
nmap <silent> ggG ggGzz
" Reselect visual block after indent/outdent
vnoremap < <gv
vnoremap > >gv
" Keep search pattern at the center of the screen.
nnoremap <silent> n nzz
nnoremap <silent> N Nzz
nnoremap <silent> * *zz
nnoremap <silent> # #zz
nnoremap <silent> g* g*zz
nnoremap <silent> g# g#zz
" keep page up/down at the center of the screen
nnoremap <silent> <C-d> <C-d>zz
nnoremap <silent> <C-u> <C-u>zz
" Toggle tagbar and auto resize existing spit windows to use exactly same
" amount of space
nmap <F8> :TagbarToggle<CR><C-w>=
" Resize tagbar to use 30 chars instead of 40
let g:tagbar_width = 30
" Leave mode handling for airline.vim
"set noshowmode
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline_theme = 'raven'
let g:airline_left_sep=''
let g:airline_right_sep=''
let g:airline#extensions#whitespace#trailing_format = '[%s]'
" Unimpaired: Move line up/down
map <S-Up> [e
map <S-Down> ]e
" fix mistype :W and :Q
command! -bang -range=% -complete=file -nargs=* WQ <line1>,<line2>wq<bang> <args>
command! -bang -complete=file -nargs=* Qa qa<bang>
command! -bang -complete=file -nargs=* QA qa<bang>
command! -bang -range=% -complete=file -nargs=* Wq <line1>,<line2>wq<bang> <args>
command! -bang -range=% -complete=file -nargs=* W <line1>,<line2>w<bang> <args>
command! -bang Q quit<bang>
" Smart case search
set smartcase
function! TrimWhiteSpace()
%s/\s\+$//e
endfunction
function! RemoveHtml()
%s#<[^>]\+>##g
endfunction
autocmd FileWritePre * :call TrimWhiteSpace()
autocmd FileAppendPre * :call TrimWhiteSpace()
autocmd FilterWritePre * :call TrimWhiteSpace()
autocmd BufWritePre * :call TrimWhiteSpace()
" Disable ex mode.
nnoremap Q <nop>
nnoremap <leader>q <c-v>
" Ctrl+q to visual block
"nnoremap <c-q> <c-v>
let g:syntastic_mode_map = { 'mode': 'passive', 'active_filetypes': [],'passive_filetypes': [] }
if has('nvim')
tnoremap <C-j> <c-\><c-n><c-w>j
tnoremap <C-k> <c-\><c-n><c-w>k
tnoremap <C-h> <c-\><c-n><c-w>h
tnoremap <C-l> <c-\><c-n><c-w>l
au WinEnter *pid:* call feedkeys('i')
endif
function! NumberToggle()
if(&relativenumber == 1)
set number
else
set relativenumber
endif
endfunc
nnoremap <F2> :call NumberToggle()<CR>
function! Copy()
%w !xclip -i -sel c
endfunc
let g:GPGUseAgent = 0
let g:GPGPreferSymmetric = 1
let g:deoplete#enable_at_startup = 1
let g:deoplete#ignore_sources = get(g:, 'deoplete#ignore_sources', {})
let g:deoplete#ignore_sources.php = ['omni']