-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
259 lines (220 loc) · 6.45 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
" Setting up Vundle
let VundleInstalled=1
let vundle_readme=expand($HOME.'/.vim/bundle/Vundle.vim/README.md')
if !filereadable(vundle_readme)
echo "Installing Vundle ..."
echo ""
silent !mkdir -p $HOME/.vim/bundle
silent !git clone https://github.com/VundleVim/Vundle.vim $HOME/.vim/bundle/Vundle.vim
let VundleInstalled=0
endif
set nocompatible
filetype off
set rtp+=$HOME/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-vinegar'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-commentary'
Plugin 'airblade/vim-gitgutter'
Plugin 'mileszs/ack.vim'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'tobyS/pdv'
Plugin 'tobyS/vmustache'
Plugin 'editorconfig/editorconfig-vim'
Plugin 'pbrisbin/vim-mkdir'
Plugin 'posva/vim-vue'
Plugin 'othree/html5.vim'
Plugin 'gabrielelana/vim-markdown'
if v:version >= 704
if has('python')
Plugin 'SirVer/ultisnips'
endif
endif
if VundleInstalled == 0
echo "Installing Plugins, please ignore key map error messages"
echo ""
:PluginInstall
endif
call vundle#end()
" Colors
syntax enable
set background=dark
colorscheme hemisu
highlight Normal ctermbg=none
highlight NonText ctermbg=none
au InsertEnter * highlight StatusLine cterm=bold ctermbg=235
au InsertLeave * highlight StatusLine cterm=bold ctermbg=none
" Editor Config
set hidden
set number
set ttyfast
set autoread
set ttimeout
set noshowmode
set splitbelow
set splitright
set scrolloff=3
set laststatus=2
set nojoinspaces
set shortmess+=I
set spelllang=en
set encoding=utf-8
set updatetime=250
set ttimeoutlen=100
set formatoptions+=j
set virtualedit+=onemore
set backspace=indent,eol,start
" Statusline
set statusline=
" current filename
set statusline+=%*%t
" file flags
set statusline+=\ %m%r%w
" git status
set statusline+=\ %{fugitive#statusline()}
" column and line
set statusline+=%=\ %c:%l/%L\ %3.p%%
" Tabs and Spaces
set smarttab
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
filetype plugin indent on
" Searching
set hlsearch
set incsearch
set smartcase
set ignorecase
" Backup
set backup
set writebackup
set backupskip=/tmp/*,/private/tmp/*
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
" Undo
if exists("+undofile")
if isdirectory($HOME . '/.vim/undodir') == 0
:silent !mkdir -p ~/.vim/undodir > /dev/null 2>&1
endif
set undofile
set undolevels=5000
set undoreload=10000
set undodir=~/.vim/undodir//
endif
" Settigs for certain filetypes
augroup configgroup
autocmd!
autocmd BufReadPost *
\ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
au BufWritePre *.php,*.py,*.js,*.txt,*.hs,*.java :call <SID>StripTrailingWhitespaces()
au FileType php setlocal commentstring=//\ %s
au FileType apache setlocal commentstring=#\ %s
au FileType css,scss,sass setlocal iskeyword+=-
au FileType gitcommit startinsert
au Filetype gitcommit setlocal spell textwidth=72
au BufNewFile,BufRead *.md set ft=markdown
au BufRead,BufNewFile *.blade.php set filetype=html
au BufWritePost .vimrc source %
au BufEnter *.js syn match ErrorMsg /console.log/
augroup END
" ack-vim
let g:ackhighlight = 1
let g:ack_default_options = " -s --with-filename"
" Set space as leader key
let mapleader = "\<space>"
" Activate syntax completion
set omnifunc=syntaxcomplete#Complete
" Improve completion menu
set completeopt=longest,menuone
" keep menu item always highlighted in completion
inoremap <expr> <C-n> pumvisible() ? '<C-n>' :
\ '<C-n><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
inoremap <expr> <C-p> pumvisible() ? '<C-p>' :
\ '<C-p><C-r>=pumvisible() ? "\<lt>Up>" : ""<CR>'
" Save file with sudo
cnoremap w!! w !sudo tee % >/dev/null
" Move visual block
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
" move vertically by visual line
nnoremap j gj
nnoremap k gk
" Keep visual selection on indent
vnoremap < <gv
vnoremap > >gv
" emacs style key mappings for start/end of line
imap <C-a> <C-o>^
imap <C-e> <C-o>$
map <C-a> ^
map <C-e> $
" highlight last inserted text
nnoremap gV `[v`]
" Map Ctrl-J to insert line break (opposite of J)
nnoremap <NL> i<CR><ESC>
" Map ESC to jk
:imap jk <ESC>
" Remap Q to disable search highlighting
nnoremap <silent>Q :nohlsearch<CR>
" Toggle line numbering
nnoremap <silent> <Leader>n :silent set number!<CR>
" Copy to system clipboard
map <leader>c "*y
" Paste from system clipboard
map <silent><Leader>p :set paste<CR>o<esc>"*]p:set nopaste<cr>
" Edit word and repeat on next occurence with .
nnoremap <leader>r *``cgn
" TAB and S-TAB to switch buffers
nnoremap <silent><TAB> :bp<CR>
nnoremap <silent><S-TAB> :bn<CR>
" Open CtrlP for buffers and MRU
nmap <silent> <Leader>b :CtrlPBuffer<CR>
nmap <silent> <Leader>m :CtrlPMRU<CR>
" Dont search here with CtrlP
set wildignore+=*/vendor/**,node_modules
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
" Show hidden files/dirs in CtrlP
let g:ctrlp_show_hidden = 1
" Always show current file in CtrlP
let g:ctrlp_match_current_file = 1
" Unclutter CtrlP item listing
let g:ctrlp_line_prefix = ''
" Function to strip trailing whitespace
function! <SID>StripTrailingWhitespaces()
let _s=@/
let l = line(".")
let c = col(".")
%s/\s\+$//e
let @/=_s
call cursor(l, c)
endfunction
" Prettyprint for JSON, HTML & XML
command! PrettyPrintJSON %!python -m json.tool
command! PrettyPrintHTML !tidy -mi -html -wrap 0 %
command! PrettyPrintXML !tidy -mi -xml -wrap 0 %
" See difference between current buffer changes you made
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
" Make 'gf' useful in PHP files on class names
set includeexpr=substitute(v:fname,'\\\','/','g')
set suffixesadd+=.php
set path+=$PWD/vendor/**
set path+=$PWD/app/**
" page facing view: side-by-side view of same buffer scrollbound
nnoremap <leader>vs :<C-u>let @z=&so<cr>:set so=0 noscb<cr>:bo vs<cr>Ljzt:setl scb<cr><C-w>p:setl scb<cr>:let &so=@z<cr>
" Ultisnips / PHP Documentor
let g:pdv_template_dir = $HOME ."/.vim/bundle/pdv/templates_snip"
nnoremap <leader>d :call pdv#DocumentWithSnip()<CR>
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
" Markdown
let g:markdown_enable_spell_checking = 0
let g:markdown_fenced_languages = ['html', 'python', 'bash=sh', 'php', 'sql']