Blob


1 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2 " Lot of stuff is from the Internetz, especially from
3 " https://github.com/s3rvac/dotfiles/blob/master/vim/.vimrc
4 " and
5 " https://github.com/amix/vimrc/blob/master/vimrcs/basic.vim
6 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
7 " Vundle config
8 set nocompatible " be iMproved, required
9 filetype off " required
11 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
12 let g:netrw_banner = 0 " disable banner
13 let g:netrw_liststyle = 3 " tree view
15 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
17 call plug#begin('~/.vim/plugged')
19 Plug 'prabirshrestha/async.vim'
20 Plug 'prabirshrestha/vim-lsp'
21 Plug 'ajh17/vimcompletesme'
22 Plug 'itchyny/lightline.vim'
23 Plug 'Townk/vim-autoclose'
25 " Initialize plugin system
26 call plug#end()
28 if executable('clangd')
29 augroup lsp_clangd
30 autocmd!
31 autocmd User lsp_setup call lsp#register_server({
32 \ 'name': 'clangd',
33 \ 'cmd': {server_info->['clangd']},
34 \ 'whitelist': ['c', 'cpp', 'objc', 'objcpp'],
35 \ })
36 autocmd FileType c setlocal omnifunc=lsp#complete
37 autocmd FileType cpp setlocal omnifunc=lsp#complete
38 autocmd FileType objc setlocal omnifunc=lsp#complete
39 autocmd FileType objcpp setlocal omnifunc=lsp#complete
40 augroup end
41 endif
43 function! s:on_lsp_buffer_enabled() abort
44 setlocal omnifunc=lsp#complete
45 setlocal signcolumn=yes
46 if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
47 nmap <buffer> gd <plug>(lsp-definition)
48 nmap <buffer> gs <plug>(lsp-document-symbol-search)
49 nmap <buffer> gS <plug>(lsp-workspace-symbol-search)
50 nmap <buffer> gr <plug>(lsp-references)
51 nmap <buffer> gi <plug>(lsp-implementation)
52 nmap <buffer> gt <plug>(lsp-type-definition)
53 nmap <buffer> <leader>rn <plug>(lsp-rename)
54 nmap <buffer> [g <plug>(lsp-previous-diagnostic)
55 nmap <buffer> ]g <plug>(lsp-next-diagnostic)
56 nmap <buffer> K <plug>(lsp-hover)
57 inoremap <buffer> <expr><c-f> lsp#scroll(+4)
58 inoremap <buffer> <expr><c-d> lsp#scroll(-4)
60 let g:lsp_format_sync_timeout = 1000
61 autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync')
63 nnoremap <Esc>d :LspDefinition<cr>
64 nnoremap <Esc>h :LspHover<cr>
65 nnoremap <Esc>rn :LspRename<cr>
66 nnoremap <Esc>rf :LspReference<cr>
67 nnoremap <Esc>ne :LspNextError<cr>
68 nnoremap <Esc>e :LspNextError<cr>
69 nnoremap <Esc>pe :LspPreviousError<cr>
70 nnoremap <Esc>ne :LspNextError<cr> " refer to doc to add more commands
71 endfunction
73 " Bash like keys for the command line
74 cnoremap <C-A> <Home>
75 cnoremap <C-E> <End>
76 cnoremap <C-K> <C-U>
77 cnoremap <C-P> <Up>
78 cnoremap <C-N> <Down>
80 " Use j/k to move virtual lines instead of physical ones
81 noremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j')
82 noremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k')
83 " Stay in visual mode when indenting. You will never have to run gv after
84 " performing an indentation.
85 vnoremap < <gv
86 vnoremap > >gv
88 " Make Ctrl-e jump to the end of the current line in the insert mode. This is
89 " handy when you are in the middle of a line and would like to go to its end
90 " without switching to the normal mode.
91 inoremap <C-e> <C-o>$
93 " taglist plugin
94 "Toggle Tag list
95 nnoremap <silent> <F4> :TlistToggle<CR>
96 let Tlist_Exist_OnlyWindow = 1 " if you are the last, kill yourself
97 "let Tlist_Use_Right_Window = 1 " split to the right side of the screen
98 let Tlist_GainFocus_On_ToggleOpen = 1 " Jump to taglist window on open.
99 let Tlist_File_Fold_Auto_Close = 1
102 " Hitting space in normal/visual mode will make the current search disappear.
103 noremap <silent> <Space> :silent nohlsearch<CR>
105 " Disable arrows keys (I use exclusively h/j/k/l).
106 noremap <Up> <Nop>
107 noremap <Down> <Nop>
108 noremap <Left> <Nop>
109 noremap <Right> <Nop>
111 function! s:JoinWithoutSpaces()
112 normal! gJ
113 " Remove any whitespace.
114 if matchstr(getline('.'), '\%' . col('.') . 'c.') =~ '\s'
115 normal! dw
116 endif
117 endfunction
118 noremap <silent> J :call <SID>JoinWithoutSpaces()<CR>
120 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
121 set nocompatible " Disable vi compatibility.
122 set undolevels=200 " Number of undo levels.
123 set ttyfast " Improves redrawing for newer computers.
124 set nobackup " Disable backup files.
125 set noswapfile " Disable swap files.
127 " Splitting.
128 set splitright " Open new vertical panes in the right rather than left.
129 set splitbelow " Open new horizontal panes in the bottom rather than top.
131 set secure " Forbid loading of .vimrc under $PWD.
132 set nomodeline " Modelines have been a source of vulnerabilities.
134 set autoindent " Indent a new line according to the previous one.
135 set copyindent " Copy (exact) indention from the previous line.
136 set nopreserveindent " Do not try to preserve indention when indenting.
137 set nosmartindent " Turn off smartindent.
138 set nocindent " Turn off C-style indent.
139 set fo+=q " Allow formatting of comments with "gq".
140 set fo-=r fo-=o " Turn off automatic insertion of comment characters.
141 set fo+=j " Remove a comment leader when joining comment lines.
143 set gcr=n:blinkon0 " turn off blinking cursor
145 " Whitespace.
146 set tabstop=4 " Number of spaces a tab counts for.
147 set shiftwidth=4 " Number of spaces to use for each step of indent.
148 set shiftround " Round indent to multiple of shiftwidth.
149 set noexpandtab " Do not expand tab with spaces.
150 set path+=** " Enable recursive path
151 set wrapscan " Wrap search around
153 set go-=T " Hide the toolbar:
155 " Searching.
156 set hlsearch " Highlight search matches.
157 set incsearch " Incremental search.
158 " Case-smart searching (make /-style searches case-sensitive only if there
159 " is a capital letter in the search expression).
160 set ignorecase
161 set smartcase
163 " Show trailing whitespace
164 match ErrorMsg '\s\+$'
166 " When editing a file, always jump to the last cursor position
167 au BufReadPost *
168 \ if ! exists("g:leave_my_cursor_position_alone") |
169 \ if line("'\"") > 0 && line ("'\"") <= line("$") |
170 \ exe "normal g'\"" |
171 \ endif |
172 \ endif
174 set statusline=%<%1*(%M%R)%f(%F)%=\ [%n]%1*%-19(%2*\ %03lx%02c(%p%%)\ %1*%)%O'%3*%02b%1*'
175 " now set it up to change the status line based on mode
176 au InsertEnter * hi User1 term=inverse,bold ctermbg=darkblue ctermfg=cyan guibg=#18163e guifg=grey
177 au InsertLeave * hi User1 term=inverse,bold ctermbg=cyan ctermfg=darkblue guibg=grey guifg=#0d0c22
179 " Toggle copy and paste modus with <F2>
180 nnoremap <F2> :set invpaste paste?<CR>
181 imap <F2> <C-O><F2>
182 set pastetoggle=<F2>
184 colorscheme vombatidae
185 " set color scheme for GUI mode
186 if has("gui_running")
187 set guifont=Monospace\ 10 " use this font
188 set lines=30 " height = 50 lines
189 set columns=100 " width = 100 columns
190 "set selectmode=key,cmd
191 "set keymodel=
192 colorscheme torte
193 endif
194 " forget current search term
195 nmap <silent> <C-n> :noh<CR>
197 " rebuild cscope and tags db in current directory
198 map <C-X> <ESC>:!ectags -R<CR><CR>:!cscope -kcbqR<CR><CR>
199 map <C-Y> <ESC>:!ectags -R<CR><CR>
200 map <C-A> <ESC>:cs add ./cscope.out
202 set showmatch " Show matching brackets
203 set errorformat=%A%f:%l:\ %m,%-Z%p^,%-C%.%#
204 filetype plugin on
205 filetype indent on
206 set laststatus=2
208 " set dark background
209 set bg=dark
210 syntax on " Enable syntax highlighting
211 let sh_minlines=100
212 let sh_maxlines=600
213 set synmaxcol=300
214 set spellfile=~/.vim/spellfile.add
215 set wildmenu " Enable wildmenu
216 " Ignore compiled files
217 set wildignore=*.o,*~,*.pyc,*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
219 autocmd BufNewFile,BufRead COMMIT_EDITMSG set filetype=gitcommit
221 " Spell checking
222 map <F6> <Esc>:setlocal spell spelllang=en<CR>
223 map <F7> <Esc>:setlocal nospell<CR>
224 setlocal spell spelllang=en
226 " Set utf8 as standard encoding and en_US as the standard language
227 set encoding=utf8
229 " Disable highlight when <leader><cr> is pressed
230 map <silent> <leader><cr> :noh<cr>
232 " Absatz auf textwidth runterbrechen
233 map <Esc>a gqap
234 " Ganzes Dokument auf textwidth runterbrechen
235 map <Esc>q gggqG
237 map <leader>j gJ
239 hi SpellBad term=reverse ctermfg=white ctermbg=darkred guifg=#ffffff guibg=#7f0000 gui=underline
240 "hi SpellCap guifg=#ffffff guibg=#7f007f
241 "hi SpellRare guifg=#ffffff guibg=#00007f gui=underline
242 hi SpellLocal term=reverse ctermfg=black ctermbg=darkgreen guifg=#ffffff guibg=#7f0000 gui=underline
244 " Rechtschreibkorrektur mit <esc>-l zwischen en und de umschalten
245 let langcnt = 0
246 let spellst = ["de", "en"]
247 function Sel_lang()
248 let g:langcnt = (g:langcnt+1) % len(g:spellst)
249 let lang = g:spellst[g:langcnt]
250 echo "language " . lang . " selected"
251 exe "set spelllang=" . lang
252 exec "set spell"
253 endfunction
254 nmap <Esc>l :call Sel_lang()<CR>
255 " spell checking off by default
256 set nospell
258 nmap <Esc>o :set bg=dark<CR>
259 nmap <Esc>p :set bg=light<CR>
261 " Use silver_searcher with Ack
262 if executable('ag')
263 let g:ackprg = 'ag --vimgrep'
264 endif
266 set ruler
268 autocmd BufNewFile,BufRead ferm.conf setf ferm
269 autocmd BufNewFile,BufRead *.ferm setf ferm
271 hi mailHeader ctermfg=Gray
272 hi mailSubject ctermfg=Red
273 hi mailEmail ctermfg=Blue
274 hi mailSignature ctermfg=DarkRed
275 hi mailQuoted1 ctermfg=Darkyellow
276 hi mailQuoted2 ctermfg=Green
278 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
279 " Show line numbers
280 set number
281 " Show relative number
282 set relativenumber
283 " Show the current line
284 set cursorline
287 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
288 ab VG Viele GrĂ¼sse
289 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
290 " Jump to the previous/next tab.
291 noremap J gT
292 noremap K gt
293 " Close tabs with Ctrl + w
294 noremap <leader>w :tabclose<cr>
295 " Save all
296 noremap <leader>s :w<cr>
297 " Open new tab
298 noremap <leader>t :tabnew<cr>
299 " Quitall short
300 noremap <leader>q :quitall<cr>