/
vimrc
311 lines (271 loc) · 7.69 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
" ############################################################################
" Complete re-work of my .vimrc
" All my old baggage has been thrown over board, and the .vimrc cleaned up.
" Thise file no longer contains any comments what each section does. The vim
" onlline help is all you need. But, if you're new to vim, here are a couple
" of hints to get you started:
"
" Folding
" -------
"
" This file uses folds to make it a bit more manageable. Type the following
" to get started on folding:
"
" :help folding
"
" If you just want to open everything up and start reading, type "zR"
"
" Finding help
" ------------
"
" You can open up the help by typing ":help" followed by a label. To read the
" vimrc, the following will be helpful:
"
" * If the line changes a setting (for example: 'set autoindent') you
" should surround the help label with single quotes:
"
" :help 'autodindent'
"
" * for everything else, you can prefix the label with a colon to get to
" the right page:
"
" :help :filetype
" ############################################################################
set encoding=utf-8
scriptencoding utf-8 " The encoding of *this* file
" Vundle {{{
filetype off " See https://github.com/gmarik/vundle/issues/176
set rtp+=~/.nvim/bundle/Vundle.vim/
call vundle#begin("~/.nvim/bundle")
Plugin 'gmarik/Vundle.vim'
Plugin 'Jinja'
Plugin 'MarcWeber/vim-addon-mw-utils'
Plugin 'NrrwRgn'
Plugin 'SirVer/ultisnips'
Plugin 'Yggdroot/indentLine'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'ervandew/supertab'
Plugin 'gitv'
Plugin 'itchyny/lightline.vim'
Plugin 'jelera/vim-javascript-syntax'
Plugin 'klen/python-mode'
Plugin 'mattn/emmet-vim'
Plugin 'molokai'
Plugin 'scrooloose/nerdtree'
Plugin 'tomtom/tlib_vim'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-surround'
Plugin 'unimpaired.vim'
call vundle#end()
" }}}
" UI style and 'core' behaviour {{{
filetype plugin indent on
syntax on
colorscheme molokai
set list
set listchars=tab:├─
set listchars+=trail:␣
set listchars+=extends:→
set listchars+=precedes:←
set listchars+=nbsp:◊
set title
set foldcolumn=5
set background=dark
set t_Co=256
set cmdheight=2
set scrolloff=7
set wildmenu
set wildignore=*.lnk,*~,*.bak,*.pyc
set wildignore+=*/.hg/*,*/.svn/*
set wildmode=longest:full,full
set viminfo=%,'50,<100,n~/.viminfo
set pastetoggle=<F3>
set modeline
set ignorecase
set smartcase
set hlsearch
set incsearch
set showmatch
set ruler
set showcmd
set timeout timeoutlen=1000 ttimeoutlen=100
set backspace=indent,eol,start
if has("patch-7.4.338")
set wrap
set breakindent
set breakindentopt=sbr
set showbreak=>
else
set nowrap
endif
if has('autocmd')
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
endif
if v:version >= 700
" Highlight the line containing the cursor
set cursorline
endif
if v:version >= 703
" Highlight the column where the text should wrap
set colorcolumn=+1
hi clear ColorColumn
hi link ColorColumn CursorLine
endif
" Custom colour for matching parentheses.
hi MatchParen term=reverse cterm=bold ctermbg=238 ctermfg=220
" Status line {{{
"Add the variable with the name a:varName to the statusline. Highlight it as {{{
"'error' unless its value is in a:goodValues (a comma separated string)
function! AddStatuslineFlag(varName, goodValues)
set statusline+=[
set statusline+=%#error#
exec "set statusline+=%{RenderStlFlag(".a:varName.",'".a:goodValues."',1)}"
set statusline+=%*
exec "set statusline+=%{RenderStlFlag(".a:varName.",'".a:goodValues."',0)}"
set statusline+=]
endfunction " }}}
"returns a:value or '' {{{
"
"a:goodValues is a comma separated string of values that shouldn't be
"highlighted with the error group
"
"a:error indicates whether the string that is returned will be highlighted as
"'error'
"
function! RenderStlFlag(value, goodValues, error)
let goodValues = split(a:goodValues, ',')
let good = index(goodValues, a:value) != -1
if (a:error && !good) || (!a:error && good)
return a:value
else
return ''
endif
endfunction " }}}
set statusline=
set statusline+=%2.3n " Buffer number
set statusline+=\ %< " Truncate here
set statusline+=%#Todo#\|%f\|%* " The filename
set statusline+=\ %y " filetype
call AddStatuslineFlag('&ff', 'unix') "fileformat
call AddStatuslineFlag('&fenc', 'utf-8') "file encoding
set statusline+=\ %m " modified flag
set statusline+=%r "
set statusline+=%= " Separator
set statusline+=\|\ Dec:\ %-3b\ Hex:\ 0x%2B " Character byte details
set statusline+=\ \|\ %20(%4l,%4c%V\ \|\ %3P%) " Cursor position
set laststatus=2 " Always show the status bar
" }}} End status line
" }}}
" Code quality {{{
set autoindent
set shiftround
set shiftwidth=4
set tabstop=4
set expandtab
" }}}
" Modified behaviour {{{
" Modifies a couple of default shortcuts.
nnoremap n nzz
nnoremap N Nzz
nnoremap * *zz
nnoremap # #zz
nnoremap g* g*zz
nnoremap g# g#zz
nnoremap j gj
nnoremap k gk
" }}}
" Print Settings {{{
" ----------------------------------------------------------------------------
set printoptions=header:3,number:y,left:10mm,right:10mm,top:10mm,bottom:10mm
if has("win32")
set printfont=Anonymous_Pro:h10
elseif has("unix")
set printfont=Anonymous\ Pro\ 10
endif " }}}
" Mappings {{{
let mapleader=','
inoremap jj <Esc>
nnoremap <leader><space> :noh<CR>
nnoremap <leader>n :NERDTreeToggle<CR>
nnoremap <leader>t :silent !ctags -R .<CR>:redraw!<CR>
nmap <space> <leader>
nmap <F4> a<C-R>=strftime("%Y-%m-%d %H:%M:%S")<CR><ESC>
imap <F4> <C-R>=strftime("%Y-%m-%d %H:%M:%S")<CR>
" Fix to make <C-PageUp/Down> work in tmux
nnoremap [5^ :tabprev<CR>
nnoremap [6^ :tabnext<CR>
" Abbreviation to instert a timestamp
iab <expr> dts strftime("%Y-%m-%d %H:%M:%S")
" Look up selected phrase in google
vnoremap ?? <Esc>:exec
\ ':!sensible-browser http://www.google.com/search?q="'
\ . substitute(@*,'\W\+\\|\<\w\>'," ","g")
\ . '"'<CR><CR>
" }}}
" Plugins {{{
" NERDTree {{{
let NERDTreeIgnore=['\.exe$', '\.tmp$', '\.pyc',
\ '\.sfv$', '\~$' ]
let NERDTreeWinSize=40
" }}}
" CtrlP {{{
let g:ctrlp_user_command = ['.git/', 'cd %s && git ls-files']
" }}}
" SQL {{{
let g:sql_type_default = 'pgsql'
let g:omni_sql_no_default_maps = 1
" }}}
" JavaScriptSyntax {{{
au FileType javascript call JavaScriptFold()
au FileType closure.javascript call JavaScriptFold()
" }}}
" UltiSnips {{{
let g:UltiSnipsEditSplit = 'vertical'
let g:UltiSnipsNoPythonWarning = 'true'
" }}}
" LightLine {{{
let g:lightline = {
\ 'colorscheme': 'molokai',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'fugitive', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component': {
\ 'readonly': '%{&readonly?"⭤":""}',
\ 'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}'
\ },
\ 'component_visible_condition': {
\ 'readonly': '(&filetype!="help"&& &readonly)',
\ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))',
\ 'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())'
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
" }}}
" SuperTab {{{
let g:SuperTabLongestEnhanced=1
" }}}
" Syntastic {{{
let g:syntastic_id_checkers = 1
let g:syntastic_error_symbol = '✗'
let g:syntastic_warning_symbol = '⚠'
let g:syntastic_auto_loc_list = 1
let g:syntastic_python_python_exe = 'python3'
" }}}
" python-syntax {{{
let python_highlight_all = 1
" }}}
" python-mode {{{
let g:pymode_folding = 1
let g:pymode_rope = 0
let g:pymode_rope_complete_on_dot = 0
" }}}
" {{{ emmet
let g:user_emmet_leader_key = '<c-y>'
" }}}
" vim: set shiftwidth=4 tabstop=4 expandtab:
" vim: set foldmethod=marker foldmarker={{{,}}} foldenable foldlevel=0: