3 " Author: Samir Benmendil <samir.benmendil[at]gmail[dot]com>
8 set runtimepath& " reset rtp
10 set runtimepath+=$XDG_DATA_HOME/vim/vundle
11 call vundle#rc('$XDG_DATA_HOME/vim')
13 Bundle 'gmarik/vundle'
15 Bundle 'bling/vim-airline'
16 Bundle 'elzr/vim-json'
17 Bundle 'ervandew/ag.git'
18 Bundle 'http://git.code.sf.net/p/vim-latex/vim-latex'
19 Bundle 'kien/ctrlp.vim'
20 Bundle 'majutsushi/tagbar'
21 Bundle 'scrooloose/nerdtree'
22 Bundle 'scrooloose/syntastic'
23 Bundle 'sjl/gundo.vim'
24 Bundle 'tomtom/tcomment_vim'
25 Bundle 'tpope/vim-fugitive'
26 Bundle 'tpope/vim-surround'
27 Bundle 'tpope/vim-unimpaired'
28 Bundle 'valloric/youcompleteme'
29 "Bundle 'zhaocai/goldenview.vim'
31 Bundle 'ompugao/ros.vim'
32 Bundle 'ompugao/ctrlp-ros'
34 Bundle 'firef0x/pkgbuild.vim'
35 Bundle 'derekwyatt/vim-fswitch'
36 " seems to have problems right now... may be add later?
37 "Bundle 'jalcine/cmake.vim'
40 " remove entries first
41 set runtimepath -=$HOME/.vim
42 set runtimepath -=$HOME/.vim/after
43 set runtimepath -=$XDG_CONFIG_HOME/vim
44 set runtimepath -=$XDG_CONFIG_HOME/vim/after
45 " then prepend and append them
46 set runtimepath ^=$XDG_CONFIG_HOME/vim
47 set runtimepath +=$XDG_CONFIG_HOME/vim/after
49 filetype plugin indent on
51 " moving around, searching and patterns {{{1
52 set incsearch " show match for partly typed search command
53 set ignorecase " ignore case when using a search pattern
54 set smartcase " override 'ignorecase' when pattern has upper case characters
55 set hlsearch " highlight all matches for the last used search pattern
57 " use leader-n to unhighlight search
58 nmap <silent> <Leader>n :silent nohl<CR>
59 " use leader-# to display the number of matches for the last search
60 nmap <Leader># :%s:<C-R>/::gn<CR>
61 " center cursor after search
67 inoremap <Right> <NOP>
73 set nostartofline " don't move the cursor to the first non-blank char of a line
74 set path=.,include/,../include/,/usr/include/c++/*,/opt/ros/hydro/include
76 " displaying text {{{1
77 set scrolloff=5 " number of screen lines to show around the cursor
78 set nowrap " long lines wrap
79 set linebreak " wrap long lines at a character in 'breakat'
80 set showbreak=▒▒ " show these chars for wrapped lines
82 set lazyredraw " don't redraw while executing macros
84 set list " show chars defined in 'listchars'
85 set listchars=tab:»·,trail:· " list of strings used for list mode
87 set number " show the line number for each line
88 set relativenumber " show the relative line number for each line
89 " toggle relativenumber
90 nnoremap <silent> <Leader>u :exe "set relativenumber!"<CR>
93 " When editing a file, always jump to the last known cursor position.
94 " Don't do it when the position is invalid or when inside an event handler
95 " (happens when dropping a file on gvim).
96 " Also don't do it when the mark is in the first line, that is the default
97 " position when opening a file.
98 " blacklist certain filetype, you can get a file type with :echo &ft
99 let blacklist = ['gitcommit']
100 autocmd BufReadPost *
101 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
102 \ exe "normal! g`\"" |
107 " syntax, highlighting and spelling {{{1
111 set dictionary=spell " list of dictionary files for keyword completion
112 " Spell Check http://tex.stackexchange.com/a/52932
114 let g:myLangList=["en_gb","en_us","de","fr"]
116 function! ToggleSpell()
117 execute "setlocal spell!"
119 echo "setlocal spelllang=" g:myLangList[b:myLang]
122 nnoremap <silent> <Leader>s :call ToggleSpell()<CR>
124 function! SwitchSpell()
126 let b:myLang=b:myLang+1
127 if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
129 execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
130 echo "setlocal spelllang=" g:myLangList[b:myLang]
132 nnoremap <silent> <Leader>S :call SwitchSpell()<CR>
134 " fix spelling with first choice
135 nnoremap <Leader>f 1z=
139 \ if &omnifunc == "" | setl omnifunc=syntaxcomplete#Complete | endif
142 " multiple windows {{{1
143 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
145 set previewheight=20 " default height for the preview window
147 set splitright " a new window is put right of the current one
149 map <F1> :ls<CR>:b<space>
154 " using the mouse {{{1
155 set mouse=rnv " list of flags for using the mouse
156 set ttymouse=xterm " type of mouse
158 "xterm mouse with middleclick paste
159 nnoremap <MiddleMouse> i<MiddleMouse>
160 vnoremap <MiddleMouse> s<MiddleMouse>
162 " messages and info {{{1
163 set showcmd " Show (partial) command in status line.
164 set ruler " show the cursor position all the time
165 set confirm " Ask what to do when closing unsaved documents
166 set shortmess=filnxtoOI " don't show intro message
169 set backspace=indent,eol,start " allow backspacing over everything in insert mode
171 set showmatch " Show matching brackets.
173 set nojoinspaces " don't use two spaces after '.' when joining a line
174 set formatoptions+=j " remove comment leader when joining lines
176 set nrformats=hex " number formats recognized for CTRL-A and CTRL-X commands
178 " whether to use a popup menu for Insert mode completion
179 set completeopt=longest,menuone,preview
181 " Indent if we're at the beginning of a line. Else, do completion.
182 function! InsertTabWrapper()
183 let col = col('.') - 1
184 if !col || getline('.')[col - 1] !~ '\k'
190 inoremap <Tab> <C-R>=InsertTabWrapper()<CR>
191 inoremap <S-Tab> <C-P>
193 " fix legacy vi inconsistency
196 " allow repeat operator on visual
197 vnoremap . :normal .<CR>
199 " add line without changing position or leaving mode
200 map <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
201 map <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
203 " Don't use Ex mode, use Q for formatting
206 " allow undoing in insert-mode
207 inoremap <C-U> <C-G>u<C-U>
208 inoremap <C-W> <C-G>u<C-W>
210 " tabs and indent {{{1
211 set shiftwidth=4 " number of spaces used for each step of (auto)indent
212 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
213 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
214 set shiftround " round to 'shiftwidth' for "<<" and ">>"
215 set expandtab " expand <Tab> to spaces in Insert mode
217 set cindent " use smart C indenting (see :h C-indenting)
218 set cinoptions=l1,c4,(0,U1,w1,m1,j1,J1
220 set pastetoggle=<F11> " key sequence to toggle paste mode
222 nmap <Leader>b :set expandtab tabstop=4 shiftwidth=4 softtabstop=4<CR>
223 nmap <Leader>B :set expandtab tabstop=8 shiftwidth=8 softtabstop=4<CR>
224 nmap <Leader>M :set noexpandtab tabstop=8 softtabstop=4 shiftwidth=4<CR>
225 nmap <Leader>m :set expandtab tabstop=2 shiftwidth=2 softtabstop=2<CR>
228 set foldmethod=marker " folding type
229 set foldlevelstart=0 " value for 'foldlevel' when starting to edit a file
231 " space will toggle current fold in normal mode
232 nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
233 " create folds around visual selection
236 " save and restore folds
237 set viewoptions=folds,cursor " don't save local options
238 autocmd BufWinLeave *.* mkview
239 autocmd BufWinEnter *.* silent loadview
241 " reading and writing files {{{1
242 set writebackup " write a backup file before overwriting a file
243 set backup " keep a backup after owerwriting a file
244 set backupdir=$XDG_CACHE_HOME/vim
246 set undofile " persistent undo history
247 set undodir=$XDG_CACHE_HOME/vim
249 set autowrite " automatically write a file when leaving a modified buffer
252 cmap w!! w !sudo tee % > /dev/null
255 set directory=$XDG_CACHE_HOME/vim,.,/var/tmp
257 " command line editing {{{1
258 set history=500 " how many command lines are remembered
259 set wildmode=longest:full " specifies how command line completion works
260 set wildmenu " command-line completion shows a list of matches
263 set virtualedit=block " let cursor move past last char in <C-V> mode
264 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache
266 set viewdir=$XDG_CACHE_HOME/vim
270 let g:airline_detect_whitespace=2
271 let g:airline#extensions#tabline#enabled = 1
272 let g:airline_powerline_fonts = 1
275 "let g:goldenview__enable_default_mapping = 0
276 "nmap <silent> <C-N> <Plug>GoldenViewSplit
277 "nmap <silent> <C-L> <Plug>GoldenViewNext
278 "nmap <silent> <C-H> <Plug>GoldenViewPrevious
279 "nmap <silent> <C-M> <Plug>GoldenViewSwitchMain
280 "nmap <silent> <C-S-M> <Plug>GoldenViewPrevious
283 nnoremap <F7> :GundoToggle<CR>
285 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
286 " delete fugitive buffers when closed
287 autocmd BufReadPost fugitive://* set bufhidden=delete
290 " open/close NERDTree with \e
291 nmap <Leader>e :NERDTreeToggle<CR>
292 nmap <F6> :NERDTreeToggle<CR>
293 " <space> to open files/dirs
294 let NERDTreeMapActivateNode='<space>'
295 " close vim if only NERDTree is open
296 autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
299 let g:syntastic_enable_highlighting = 0
300 let g:syntastic_error_symbol='E'
301 let g:syntastic_style_error_symbol='S'
302 let g:syntastic_warning_symbol='W'
303 let g:syntastic_style_warning_symbol='S'
304 let g:syntastic_always_populate_loc_list=1
305 nmap <silent> <leader>y :SyntasticCheck<cr>
308 let g:syntastic_check_on_open=1
312 map <F5> :TagbarToggle<cr>
313 let g:tagbar_sort = 0
314 let g:tagbar_compact = 1
315 let g:tagbar_autoshowtag = 1
316 let g:tagbar_width = 25
317 let g:tagbar_iconchars = ['+', '-']
320 let g:ycm_extra_conf_globlist = ['~/src/*']
323 let g:vim_json_syntax_conceal = 0
326 let g:tex_flavor='latex'
327 let g:Tex_DefaultTargetFormat='pdf'
330 " auto source vimrc when saved
331 autocmd bufwritepost vimrc source $MYVIMRC
332 nmap <leader>v :tabedit $MYVIMRC<CR>
334 " Convenient command to see the difference between the current buffer and the
335 " file it was loaded from, thus the changes you made.
336 " Only define it when not defined already.
337 if !exists(":DiffOrig")
338 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
339 \ | wincmd p | diffthis