Blame


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