-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
executable file
·223 lines (185 loc) · 6 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
"""""""""""""""""""
" VIM-PLUG CONFIG "
"""""""""""""""""""
set nocompatible
filetype off
" Map leader to space
let mapleader ="g"
set shell=/bin/bash
call plug#begin('~/.vim/plugged')
" PLUGINS "
Plug 'arcticicestudio/nord-vim'
Plug 'honza/vim-snippets'
Plug 'sheerun/vim-polyglot'
Plug 'terryma/vim-multiple-cursors'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-sleuth'
Plug 'tpope/vim-surround'
Plug 'wincent/terminus'
Plug 'airblade/vim-gitgutter'
nmap <C-h> <Plug>(GitGutterNextHunk)
nmap <C-g> <Plug>(GitGutterPrevHunk)
Plug 'kergoth/vim-bitbake'
" Bitbake syntax highlighting
au BufRead,BufNewFile *.bb set filetype=bitbake
au BufRead,BufNewFile *.bbclass set filetype=bitbake
au BufRead,BufNewFile *.bbappend set filetype=bitbake
au BufRead,BufNewFile *.inc set filetype=bitbake
au BufRead,BufNewFile local.conf.sample set filetype=bitbake
au BufRead,BufNewFile bblayers.conf.sample set filetype=bitbake
Plug 'ctrlpvim/ctrlp.vim'
let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:10,results:0'
let g:ctrlp_cache_dir = $HOME . '/.cache/ctrlp'
if executable('ag')
let g:ctrlp_user_command = 'rg %s --files --color=never --glob ""'
endif
Plug 'scrooloose/nerdtree'
nnoremap <C-e> :NERDTreeToggle<cr>
let NERDTreeMinimalUI=1
let NERDTreeAutoDeleteBuffer=1
Plug 'Xuyuanp/nerdtree-git-plugin'
let g:NERDTreeGitStatusIndicatorMapCustom = {
\ 'Modified' :'✹',
\ 'Staged' :'+',
\ 'Untracked' :'*',
\ 'Renamed' :'→',
\ 'Unmerged' :'═',
\ 'Deleted' :'✖',
\ 'Dirty' :'✗',
\ 'Ignored' :'☒',
\ 'Clean' :'✔︎',
\ 'Unknown' :'?',
\ }
Plug 'SirVer/ultisnips'
let g:UltiSnipsSnippetsDir=$HOME.'/.vim/bundle/vim-snippets/UltiSnips'
let g:UltiSnipsSnippetDirectories=["UltiSnips"]
let g:UltiSnipsExpandTrigger="<c-z>"
let g:UltiSnipsJumpForwardTrigger="<c-z>"
let g:UltiSnipsJumpBackwardTrigger="<c-b>"
let g:UltiSnipsListSnippets="<c-l>"
let g:UltiSnipsEditSplit="vertical"
Plug 'vim-airline/vim-airline'
let g:airline_powerline_fonts = 1
let g:airline_section_y=''
call plug#end()
filetype plugin indent on
"""""""""""""""
" VIM RELATED "
"""""""""""""""
colorscheme nord
cd %:p:h
" Set delay
set timeoutlen=1000 ttimeoutlen=0
" Syntax and filetype
syntax on
" make backspace work like most other programs
set backspace=2
" Colorscheme
" Line length
" set tw=80
" Tabs
set tabstop=4
set sw=4
set expandtab
" " Line numbering
set number relativenumber
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
augroup END
" Copy visual selection to clipboard
vnoremap <C-c> "+y
"Vim splits navigation
nnoremap <C-Down> <C-W><C-J>
nnoremap <C-Up> <C-W><C-K>
nnoremap <C-Right> <C-W><C-L>
nnoremap <C-Left> <C-W><C-H>
set splitbelow
set splitright
" Vim tabs navigation
nnoremap <A-Right> gt
nnoremap <A-Left> gT
nnoremap <Esc>t :tabnew<cr> :NERDTreeToggle<cr>
" VHDL
" autocmd FileType vhdl setlocal comments=:--
" autocmd FileType vhdl setlocal formatoptions+=cro
" au BufNewFile,BufRead *.pkg set filetype=vhdl
" Enable folding
set foldmethod=indent
set foldlevel=99
set nofoldenable
nmap <leader><f> za
" Enable word highlighting
set hlsearch
nnoremap * :let @/ = '\<'.expand('<cword>').'\>'\|set hlsearch<C-M>
" Clear hightlights
nnoremap <Leader>8 :let @/=""<cr>
" undo hidtory
set undofile
" Saving
nnoremap <C-s> :w<cr>
inoremap <C-s> :w<cr>
nnoremap <C-q> :wqa<cr>
" nnoremap <C-w> :wq<cr>
" Italic font
hi Italic cterm=italic
hi Comment cterm=italic
" Modeline magic
set modeline
set modelines=5
function! AppendModeline()
let l:modeline = printf(" vim: set ts=%d sw=%d tw=%d %set :",
\ &tabstop, &shiftwidth, &textwidth, &expandtab ? '' : 'no')
let l:modeline = substitute(&commentstring, "%s", l:modeline, "")
call append(line("$"), printf(""))
call append(line("$"), l:modeline)
endfunction
nnoremap <silent> <Leader>ml :call AppendModeline()<CR>
autocmd FileType tex set spell
autocmd FileType tex set spelllang=fr
" Spell correction
" imap <C-l> <Esc>[s1z=`]a
nmap <leader>q gqap
function! CleverTab()
if strpart( getline('.'), 0, col('.')-1 ) =~ '^\s*$'
return "\<Tab>"
else
return "\<C-N>"
endif
endfunction
inoremap <Tab> <C-R>=CleverTab()<CR>
" Cscope
function! CscopeLoad()
if has("cscope")
" Look for a 'cscope.out' file starting from the current directory,
" going up to the root directory.
let s:dirs = split(getcwd(), "/")
while s:dirs != []
let s:path = "/" . join(s:dirs, "/")
if (filereadable(s:path . "/cscope.out"))
execute "cs add " . s:path . "/cscope.out " . s:path . " -v"
break
endif
let s:dirs = s:dirs[:-2]
endwhile
set csto=0 " Use cscope first, then ctags
set cst " Only search cscope
set csverb " Make cs verbose
nmap <C-c>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-c>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-c>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-c>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-c>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-c>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-c>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-c>d :cs find d <C-R>=expand("<cword>")<CR><CR>
nmap <C-c>q :cs find a <C-R>=expand("<cword>")<CR><CR>
nmap <F6> :cnext <CR>
nmap <F5> :cprev <CR>
" Open a quickfix window for the following queries.
set cscopequickfix=s-,c-,d-,i-,t-,e-,g-
endif
endfunction
call CscopeLoad()