-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
254 lines (229 loc) · 7.31 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
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" prepare environment and install plugin-manager for first use
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" auto install plugs in .vimrc
" https://github.com/junegunn/vim-plug/wiki/faq
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" create backupdirs
if empty(glob('~/.vim/backup_files'))
silent !mkdir ~/.vim/backup_files > /dev/null 2>&1
endif
if empty(glob('~/.vim/swap_files'))
silent !mkdir ~/.vim/swap_files > /dev/null 2>&1
endif
if empty(glob('~/.vim/undo_files'))
silent !mkdir ~/.vim/undo_files > /dev/null 2>&1
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" install Plugins with plugin-manger
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vim: set foldmarker={{{,}}} foldlevel=0 foldmethod=marker tabstop=4 shiftwidth=4:
" Environment {{{
set nocompatible " must be first line
set ttyfast " we have a fast tty
" }}}
" Plugins {{{
call plug#begin('~/.vim/plugged')
" General {{{
Plug 'scrooloose/nerdtree'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'majutsushi/tagbar'
Plug 'vim-scripts/a.vim'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'chriskempson/base16-vim'
Plug 'Rip-Rip/clang_complete'
Plug 'ervandew/supertab'
Plug 'Chiel92/vim-autoformat'
Plug 'tpope/vim-fugitive'
Plug 'easymotion/vim-easymotion'
Plug 'ngmy/vim-rubocop'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'bling/vim-bufferline'
Plug 'Townk/vim-autoclose'
Plug 'thaerkh/vim-workspace'
Plug 'mhinz/vim-startify'
Plug 'vim-syntastic/syntastic'
" Plugins inspired by yavide
"Plug 'vim-scripts/a.vim'
"Rip-Rip/clang_complete
"scrooloose/nerdcommenter
"vim-airline/vim-airline
"Townk/vim-autoclose
"ervandew/supertab
"tpope/vim-fugitive
"airblade/vim-gitgutter
"terryma/vim-multiple-cursors
" }}}
call plug#end()
" }}}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" visual appearance
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set number
set relativenumber
set colorcolumn=80
set wrap
set list listchars=tab:►\ ,trail:◆,eol:¬
syntax enable
syntax on
"let base16colorspace=256
"colorscheme base16-bright
set guioptions-=m "remove menu bar
set guioptions-=T "remove toolbar
set guioptions-=r "remove right-hand scroll bar
set guioptions-=L "remove left-hand scroll bar
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" behavior
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set history=1000
set mousehide
set cursorline
set ttyfast
filetype on
filetype plugin on
filetype indent on
"reload if file changed from outside
set autoread
"highlight search results
"set hlsearch
"show matching brackets
"set showmatch
"set blinktime for matching brackets
set mat=2
"spaces instead tabs
set expandtab
set shiftwidth=4
set tabstop=4
"undo
set undofile
set undolevels=1000
set undoreload=10000
set hidden
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" directories
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set directory=~/.vim/swap_files//
set backupdir=~/.vim/backup_files//
set undodir=~/.vim/undo_files//
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" settings for specific file types
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"filetype makefiles
autocmd FileType make set noexpandtab shiftwidth=8 softtabstop=0
autocmd FileType ruby,yaml set expandtab shiftwidth=2 softtabstop=2 tabstop=2
" auto save and reload .vimrc
autocmd BufWritePost .vimrc source $MYVIMRC
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"plugin settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"vim-autoformat
let b:formatdef_custom_c='"astyle --mode=c --style=1tbs"'
let b:formatters_c = ['custom_c']
"ultisnips
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<c-b>"
let g:UltiSnipsJumpBackwardTrigger = "<c-z>"
let g:UltiSnipsEditSplit = "vertical"
"airline
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#fnamemod = ':t'
set laststatus=2
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
"let g:airline_symbols
set guifont=Liberation\ Mono\ for\ Powerline\ 12
let g:airline_powerline_fonts = 1
let g:Powerline_symbols = 'fancy'
"vim-workspace
nnoremap <leader>s :ToggleWorkspace<CR>
let g:workspace_session_name = 'Session.vim'
let g:workspace_persist_undo_history = 1 " enabled = 1 (default), disabled = 0
let g:workspace_undodir='.undodir'
let g:workspace_autosave_always = 1
let g:workspace_autosave = 1
set updatetime=4000 " Default Vim setting (specifies CursorHold wait time).
let g:workspace_autosave_ignore = ['gitcommit']
"ctrl-p
let g:ctrlp_map = '<c-p>'
"nerdtree
nnoremap <leader>n :NERDTreeToggle<CR>
"startify
let g:startify_skiplist_server = [ 'GVIM' ]
"syntastic
let g:syntastic_cpp_compiler = 'clang++'
let g:syntastic_cpp_compiler_options = ' -std=c++11 -stdlib=libc++'
let g:syntastic_c_checkers=['make','clang-check','splint']
let g:syntastic_style_error_symbol = '⁉️'
let g:syntastic_warning_symbol = '⚠️'
let g:syntastic_style_warning_symbol = '💩'
let g:syntastic_error_symbol = '✗✗'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" keybindings
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap <silent> <F2> :NERDTreeToggle<CR>
nnoremap <silent> <F3> :CtrlPMixed<CR>
nnoremap <silent> <F4> :TagbarToggle<CR>
map <F5> :ls<CR>:b<Space>
noremap <F6> :Autoformat<CR>
"let mapleader = ","
" Copy and paste stuff
vmap <c-c> "+y
imap <c-p> <ESC>"+pa
" open .vimrc in split tab
nmap <leader>v :tabedit $MYVIMRC<CR>
"buffer behavior
" To open a new empty buffer
" This replaces :tabnew which I used to bind to this mapping
nmap <leader>T :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>
"make
nmap <leader>m :make
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" special functions
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Filebin
function! Filebin(start, end)
let range = a:start . "," . a:end
let name = expand("%:t")
if (name == "")
let name = "scratch"
endif
let extension = expand(&ft)
if (extension == "")
let extension = "text"
endif
let command = "w !fb -n '" . name . "' -e '" . extension . "'"
silent exe expand(range) . command
redraw!
endfunction
com! -nargs=0 -range=% Fb :call Filebin(<line1>, <line2>)
"latex ide made by jreinert.com
function! SynctexMake()
if v:servername == ""
throw "vim must be started with --servername"
endif
let position = line(".").':'.col(".").':'.expand("%:p")
let editor = 'vim --servername '.v:servername.' --remote +\%{line} \%{input}'
exe 'make view "SYNCTEX_FORWARD='.position.'" "SYNCTEX_EDITOR='.editor.'"'
endfunction
com! -nargs=0 SyncMake :call SynctexMake()
set wrap
if filereadable(expand("~/.vimrc_background"))
let base16colorspace=256
source ~/.vimrc_background
endif