3 " Author: Samir Benmendil <samir.benmendil[at]gmail[dot]com>
7 set runtimepath=$XDG_CONFIG_HOME/vim,$VIMRUNTIME,$XDG_CONFIG_HOME/vim/after
11 set runtimepath+=$XDG_DATA_HOME/vim/vundle
12 call vundle#rc('$XDG_DATA_HOME/vim')
14 Bundle 'gmarik/vundle'
16 Bundle 'bling/vim-airline'
17 Bundle 'elzr/vim-json'
18 Bundle 'ervandew/ag.git'
19 Bundle 'http://git.code.sf.net/p/vim-latex/vim-latex'
20 Bundle 'kien/ctrlp.vim'
21 Bundle 'majutsushi/tagbar'
22 Bundle 'scrooloose/nerdtree'
23 Bundle 'scrooloose/syntastic'
24 Bundle 'sjl/gundo.vim'
25 Bundle 'tomtom/tcomment_vim'
26 Bundle 'tpope/vim-fugitive'
27 Bundle 'tpope/vim-surround'
28 Bundle 'tpope/vim-unimpaired'
29 Bundle 'valloric/youcompleteme'
30 Bundle 'zhaocai/goldenview.vim'
32 Bundle 'ompugao/ros.vim'
33 Bundle 'ompugao/ctrlp-ros'
35 Bundle 'derekwyatt/vim-fswitch'
36 Bundle 'jalcine/cmake.vim'
38 filetype plugin indent on
40 " moving around, searching and patterns {{{1
41 set incsearch " show match for partly typed search command
42 set ignorecase " ignore case when using a search pattern
43 set smartcase " override 'ignorecase' when pattern has upper case characters
44 set hlsearch " highlight all matches for the last used search pattern
46 " use leader-n to unhighlight search
47 nmap <silent> <Leader>n :silent nohl<CR>
48 " use leader-# to display the number of matches for the last search
49 nmap <Leader># :%s:<C-R>/::gn<CR>
50 " center cursor after search
56 inoremap <Right> <NOP>
62 set nostartofline " don't move the cursor to the first non-blank char of a line
63 set path=.,** " current + subdirectory search for :find, :grep:, ...
65 " displaying text {{{1
66 set scrolloff=5 " number of screen lines to show around the cursor
67 set nowrap " long lines wrap
68 set linebreak " wrap long lines at a character in 'breakat'
69 set showbreak=▒▒ " show these chars for wrapped lines
71 set lazyredraw " don't redraw while executing macros
73 set list " show chars defined in 'listchars'
74 set listchars=tab:»·,trail:· " list of strings used for list mode
76 set number " show the line number for each line
77 set relativenumber " show the relative line number for each line
78 " toggle relativenumber
79 nnoremap <silent> <Leader>u :exe "set relativenumber!"<CR>
82 " When editing a file, always jump to the last known cursor position.
83 " Don't do it when the position is invalid or when inside an event handler
84 " (happens when dropping a file on gvim).
85 " Also don't do it when the mark is in the first line, that is the default
86 " position when opening a file.
87 " blacklist certain filetype, you can get a file type with :echo &ft
88 let blacklist = ['gitcommit']
90 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
91 \ exe "normal! g`\"" |
96 " syntax, highlighting and spelling {{{1
97 set background=dark " Dark background, d'uh!
100 set spelllang=en_gb " list of accepted languages
101 set dictionary=spell " list of dictionary files for keyword completion
102 " Spell Check http://tex.stackexchange.com/a/52932
104 let g:myLangList=["en_gb","en_us","de","fr"]
106 function! ToggleSpell()
107 execute "setlocal spell!"
109 echo "setlocal spelllang=" g:myLangList[b:myLang]
112 nnoremap <silent> <Leader>s :call ToggleSpell()<CR>
114 function! SwitchSpell()
116 let b:myLang=b:myLang+1
117 if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
119 execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
120 echo "setlocal spelllang=" g:myLangList[b:myLang]
122 nnoremap <silent> <Leader>S :call SwitchSpell()<CR>
124 " fix spelling with first choice
125 nnoremap <Leader>f 1z=
129 \ if &omnifunc == "" | setl omnifunc=syntaxcomplete#Complete | endif
132 " multiple windows {{{1
133 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
135 set previewheight=20 " default height for the preview window
137 set splitright " a new window is put right of the current one
139 map <F1> :ls<CR>:b<space>
141 " using the mouse {{{1
142 set mouse=rnv " list of flags for using the mouse
143 set ttymouse=xterm " type of mouse
145 "xterm mouse with middleclick paste
146 nnoremap <MiddleMouse> i<MiddleMouse>
147 vnoremap <MiddleMouse> s<MiddleMouse>
149 " messages and info {{{1
150 set showcmd " Show (partial) command in status line.
151 set ruler " show the cursor position all the time
152 set confirm " Ask what to do when closing unsaved documents
153 set shortmess=filnxtoOI " don't show intro message
156 set backspace=indent,eol,start " allow backspacing over everything in insert mode
158 set showmatch " Show matching brackets.
160 set nojoinspaces " don't use two spaces after '.' when joining a line
161 set formatoptions+=j " remove comment leader when joining lines
163 set nrformats=hex " number formats recognized for CTRL-A and CTRL-X commands
165 " whether to use a popup menu for Insert mode completion
166 set completeopt=longest,menuone,preview
168 " Indent if we're at the beginning of a line. Else, do completion.
169 function! InsertTabWrapper()
170 let col = col('.') - 1
171 if !col || getline('.')[col - 1] !~ '\k'
177 inoremap <Tab> <C-R>=InsertTabWrapper()<CR>
178 inoremap <S-Tab> <C-P>
180 " fix legacy vi inconsistency
183 " allow repeat operator on visual
184 vnoremap . :normal .<CR>
186 " add line without changing position or leaving mode
187 map <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
188 map <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
190 " Don't use Ex mode, use Q for formatting
193 " allow undoing in insert-mode
194 inoremap <C-U> <C-G>u<C-U>
195 inoremap <C-W> <C-G>u<C-W>
197 " tabs and indent {{{1
198 set shiftwidth=4 " number of spaces used for each step of (auto)indent
199 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
200 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
201 set shiftround " round to 'shiftwidth' for "<<" and ">>"
202 set expandtab " expand <Tab> to spaces in Insert mode
204 set cindent " use smart C indenting (see :h C-indenting)
205 set cinoptions=l1,c4,(0,U1,w1,m1,j1,J1
207 set pastetoggle=<F11> " key sequence to toggle paste mode
209 nmap <Leader>b :set expandtab tabstop=4 shiftwidth=4 softtabstop=4<CR>
210 nmap <Leader>B :set expandtab tabstop=8 shiftwidth=8 softtabstop=4<CR>
211 nmap <Leader>M :set noexpandtab tabstop=8 softtabstop=4 shiftwidth=4<CR>
212 nmap <Leader>m :set expandtab tabstop=2 shiftwidth=2 softtabstop=2<CR>
215 set foldmethod=marker " folding type
216 set foldlevelstart=0 " value for 'foldlevel' when starting to edit a file
218 " space will toggle current fold in normal mode
219 nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
220 " create folds around visual selection
223 " save and restore folds
224 set viewoptions=folds,cursor " don't save local options
225 autocmd BufWinLeave *.* mkview
226 autocmd BufWinEnter *.* silent loadview
228 " reading and writing files {{{1
229 set writebackup " write a backup file before overwriting a file
230 set backup " keep a backup after owerwriting a file
231 set backupdir=$XDG_CACHE_HOME/vim
233 set undofile " persistent undo history
234 set undodir=$XDG_CACHE_HOME/vim
236 set autowrite " automatically write a file when leaving a modified buffer
239 cmap w!! w !sudo tee % > /dev/null
242 set directory=$XDG_CACHE_HOME/vim,.,/var/tmp
244 " command line editing {{{1
245 set history=500 " how many command lines are remembered
246 set wildmode=longest:full " specifies how command line completion works
247 set wildmenu " command-line completion shows a list of matches
250 set virtualedit=block " let cursor move past last char in <C-V> mode
251 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .vim
253 set viewdir=$XDG_CACHE_HOME/vim
257 let g:airline_detect_whitespace=2
258 let g:airline_whitespace_symbol = 'Ξ'
259 let g:airline_linecolumn_prefix = '␊ '
260 let g:airline_left_sep = '▶'
261 let g:airline_right_sep = '◀'
262 let g:airline#extensions#tabline#enabled = 1
265 let g:goldenview__enable_default_mapping = 0
266 nmap <silent> <C-N> <Plug>GoldenViewSplit
267 nmap <silent> <C-L> <Plug>GoldenViewNext
268 nmap <silent> <C-H> <Plug>GoldenViewPrevious
269 nmap <silent> <C-M> <Plug>GoldenViewSwitchMain
270 nmap <silent> <C-S-M> <Plug>GoldenViewPrevious
273 nnoremap <F7> :GundoToggle<CR>
275 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
278 " open/close NERDTree with \e
279 nmap <Leader>e :NERDTreeToggle<CR>
280 nmap <F6> :NERDTreeToggle<CR>
281 " <space> to open files/dirs
282 let NERDTreeMapActivateNode='<space>'
283 " close vim if only NERDTree is open
284 autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
287 let g:syntastic_enable_highlighting = 0
288 let g:syntastic_error_symbol='E'
289 let g:syntastic_style_error_symbol='S'
290 let g:syntastic_warning_symbol='W'
291 let g:syntastic_style_warning_symbol='S'
292 let g:syntastic_always_populate_loc_list=1
293 nmap <silent> <leader>y :SyntasticCheck<cr>
296 let g:syntastic_check_on_open=1
300 map <F5> :TagbarToggle<cr>
301 let g:tagbar_sort = 0
302 let g:tagbar_compact = 1
303 let g:tagbar_autoshowtag = 1
304 let g:tagbar_width = 25
305 let g:tagbar_iconchars = ['+', '-']
308 let g:ycm_extra_conf_globlist = ['/mnt/data/src/*']
311 let g:vim_json_syntax_conceal = 0
314 let g:tex_flavor='latex'
315 let g:Tex_DefaultTargetFormat='pdf'
318 " Convenient command to see the difference between the current buffer and the
319 " file it was loaded from, thus the changes you made.
320 " Only define it when not defined already.
321 if !exists(":DiffOrig")
322 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
323 \ | wincmd p | diffthis