-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
408 lines (325 loc) · 8.96 KB
/
vimrc
File metadata and controls
408 lines (325 loc) · 8.96 KB
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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
""" Reload vimrc on save of vimrc
au BufLeave $MYVIMRC :source $MYVIMRC
""" Change VIm root if we're using neovim (and handle custom settings)
if has('nvim')
let s:editor_root=expand('~/.nvim')
let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1
set termguicolors
else
set t_Co=256
let s:editor_root=expand('~/.vim')
endif
filetype off
call plug#begin(s:editor_root . '/plugged')
""" For Plugin documentation visit the respective GitHub pages
if has('nvim')
Plug 'shougo/deoplete.nvim'
else
Plug 'Valloric/YouCompleteMe'
endif
Plug 'tpope/vim-fugitive'
Plug 'scrooloose/nerdtree'
Plug 'klen/python-mode'
Plug 'vim-scripts/utl.vim'
Plug 'airblade/vim-gitgutter'
Plug 'bling/vim-airline'
Plug 'vim-scripts/a.vim'
Plug 'scrooloose/nerdcommenter'
Plug 'Raimondi/delimitMate'
Plug 'vimoutliner/vimoutliner'
Plug 'wincent/command-t'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-dispatch'
Plug 'vim-scripts/lucius'
Plug 'vim-scripts/pyte'
Plug 'google/vim-ft-bzl'
Plug 'rust-lang/rust.vim'
call plug#end()
map <F2> :NERDTreeToggle<CR>
nnoremap <space>ga :Git add %:p<CR><CR>
nnoremap <space>gs :Gstatus<CR>
nnoremap <space>gc :Gcommit -v -q<CR>
nnoremap <space>gt :Gcommit -v -q %:p<CR>
nnoremap <space>gd :Gdiff<CR>
nnoremap <space>ge :Gedit<CR>
nnoremap <space>gw :Gwrite<CR><CR>
nnoremap <space>gl :silent! Glog<CR>:bot copen<CR>
nnoremap <space>gp :Ggrep<Space>
nnoremap <space>gm :Gmove<Space>
nnoremap <space>gb :Git branch<Space>
nnoremap <space>go :Git checkout<Space>
nnoremap <space>gps :Dispatch! git push<CR>
nnoremap <space>gpl :Dispatch! git pull<CR>
let g:gitgutter_realtime = 1
let g:gitgutter_eager = 1
set updatetime=750
let g:airline#extension#tabline#enabled = 1
let g:airline_powerline_fonts = 1
let g:Powerline_symbols = 'fancy'
let g:Tex_DefaultTargetFormat = 'pdf'
let g:Tex_MultipleCompileFormats = 'pdf, aux'
let g:Tex_flavor='latex'
let g:Tex_ViewRule_pdf = 'zathura'
""" VIm Settings
set showtabline=1
set wildmenu
set laststatus=2
set ruler
""" Setup colorscheme
if has("gui_running")
set guifont=DejaVu\ Sans\ Mono\ for\ Powerline\ 9
colorscheme pyte
else
let g:lucius_style = 'light'
set background=light
silent! colorscheme lucius
endif
if has('nvim')
highlight Normal guifg=White guibg=None
endif
set laststatus=2
let g:gitgutter_highlight_lines = 0 "prevent gitgutter from actually highlighting
syntax on
filetype plugin on
filetype indent on
filetype on
set autoread "doesn't work very well, but useful for external commands"
set so=7 "scroll to middle of file"
set wildignore=*.o,*~,*.pyc "ignore compiled files
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
set lazyredraw
set magic
""" Blink matching parentheses
set showmatch
set mat=2
set autoindent
set copyindent
set shiftround
cmap w!! w !sudo tee % >/dev/null
set encoding=utf8
set termencoding=utf-8
set number
set list
""" Define characters to show when you show formatting
" Stolen from https://github.com/tpope/vim-sensible
if &listchars ==# 'eol:$'
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
if &termencoding ==# 'utf-8' || &encoding ==# 'utf-8'
let &listchars = "tab:\u21e5,trail:\u2423,extends:\u21c9,precedes:\u21c7,nbsp:\u26ad"
endif
endif
set nolist
nmap <silent> <leader>s :set nolist!<CR>
set hidden
set history=1000
set undolevels=1000
set nobackup
set noswapfile
set nowb
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>
nnoremap ; :
set splitbelow
set splitright
set smarttab
set expandtab
set hlsearch
set incsearch
set smartcase
set ignorecase
set wrap
set tabstop=4
set shiftwidth=2
let mapleader = ","
set wildmenu
set wildmode=list:longest
set title
"""""""""""""""""""""""
""" Python-mode
" Keys:
" K Show python docs
" <Ctrl-Space> Rope autocomplete
" <Ctrl-c>g Rope goto definition
" <Ctrl-c>d Rope show documentation
" <Ctrl-c>f Rope find occurences
" <Leader>b Set, unset breakpoint
" [[ Jump on previous class
" ]] Jump on next class
" [M Jump on previous class or method
" ]M Jump on next class or method
"""""""""""""""""""""""
let g:pymode_rope = 1
let g:pymode_doc = 1
let g:pymode_doc_key = 'K'
let g:pymode_lint = 1
let g:pymode_lint_checker = "pyflakes,pep8"
let g:pymode_lint_write = 1
let g:pymode_virtualenv = 1
let g:pymode_breakpoint = 1
let g:pymode_breakpoint_bind = '<leader>b'
let g:pymode_syntax = 1
let g:pymode_syntax_all = 1
let g:pymode_syntax_indent_errors = g:pymode_syntax_all
let g:pymode_syntax_space_errors = g:pymode_syntax_all
let g:pymode_folding = 0
""""""""""""""""""""""""
" Visual mode
""""""""""""""""""""""""
"
" Pressing * or # searches for the current selection
vnoremap <silent> * :call VisualSelection('f')<CR>
vnoremap <silent> # :call VisualSelection('b')<CR>
map j gj
map k gk
map <space> /
map <c-space> ?
map <silent> <leader><cr> :noh<cr>
map <leader>bd :Bclose<cr>
map <leader>ba :1,1000 bd!<cr>
map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove<cr>
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
map <leader>cd :cd %:p:h<cr>:pwd<cr>
try
set switchbuf=useopen,usetab,newtab
set stal=2
catch
endtry
""" Return to last position when editing
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
set viminfo^=%
map 0 ^
nmap <M-j> mz:m+<cr>`z
nmap <M-k> mz:m-2<cr>`z
vmap <M-j> :m'm+<cr>`<my`>mzgv`yo`z
vmap <M-k> :m`<-2<cr>`>my`<mzgv`yo`z
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc
autocmd BufWrite *.py :call DeleteTrailingWS()
""""""""""""""""""""""""
" vimgrep searching and cope displaying
""""""""""""""""""""""""
" gv vimgreps to selected text
vnoremap <silent> gv :call VisualSelection('gv')<CR>
" open vimgrep and place cursor
map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left>
" vimgrep in current file
map <leader><space> :vimgrep // <C-R>%<C-A><left><left><left><left><left><left><left><left><left><left>
" <leader>r search and replace selected text
vnoremap <silent> <leader>r :call VisualSelection('replace')<CR>
" Display results of vimgrep in cope using <leader>cc
"
" Use <leader>n for next result
"
" Use <leader>p for previous result
map <leader>co :bot cope<cr>
map <leader>n :cn<cr>
map <leader>p :cp<cr>
"""""""""""""""""""""""""
" Spell checking
"""""""""""""""""""""""""
"Pressing <leader>ss toggles spell checking
map <leader>ss :setlocal spell!<cr>
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>s? z=
syntax spell toplevel
"""""""""""""""""""""""""
" Helper functions
"""""""""""""""""""""""""
function! CmdLine(str)
exe "menu Foo.Bar :" . a:str
emenu Foo.Bar
unmenu Foo
endfunction
function! VisualSelection(direction) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'b'
execute "normal ?" . l:pattern . "^M"
elseif a:direction == 'gv'
call CmdLine("vimgrep " . '/' . l:pattern . '/' . ' **/*.')
elseif a:direction == 'replace'
call CmdLine("%s" . '/' . l:pattern . '/')
elseif a:direction == 'f'
execute "normal /" . l:pattern . "^M"
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
function! HasPaste()
if &paste
return 'PASTE MODE '
endif
return ''
endfunction
command! Bclose call <SID>BufcloseCloseIt()
function! <SID>BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
if buflisted(l:alternateBufNum)
buffer #
else
bnext
endif
if bufnr("%") == l:currentBufNum
new
endif
if buflisted(l:currentBufNum)
execute("bdelete! " . l:currentBufNum)
endif
endfunction
noremap <silent> <leader>w :call ToggleWrap()<CR>
function WrapOn()
setlocal wrap linebreak nolist
set virtualedit=
setlocal display+=lastline
noremap <buffer> <silent> <Up> g<Up>
noremap <buffer> <silent> <Down> g<Down>
noremap <buffer> <silent> <Home> g<Home>
noremap <buffer> <silent> <End> g<End>
inoremap <buffer> <silent> <Up> <C-o>gk
inoremap <buffer> <silent> <Down> <C-o>gj
inoremap <buffer> <silent> <Home> <C-o>g<Home>
inoremap <buffer> <silent> <End> <C-o>g<End>
endfunction
function WrapOff()
setlocal nowrap
set virtualedit=all
silent! nunmap <buffer> <Up>
silent! nunmap <buffer> <Down>
silent! nunmap <buffer> <Home>
silent! nunmap <buffer> <End>
silent! iunmap <buffer> <Up>
silent! iunmap <buffer> <Down>
silent! iunmap <buffer> <Home>
silent! iunmap <buffer> <End>
endfunction
function ToggleWrap()
if &wrap
echo "Wrap OFF"
call WrapOff()
else
echo "Wrap ON"
call WrapOn()
endif
endfunction
call WrapOn()
function SetXeTex()
let g:Tex_CompileRule_pdf = 'xelatex -aux-directory=F:/Vim/my_latex_doc/temp --synctex=-1 -src-specials -interaction=nonstopmode $*'
endfunction
map <Leader>lx :<C-U>call SetXeTex()<CR>