-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
387 lines (286 loc) · 9.89 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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
syntax on
filetype plugin indent on
set nocompatible
set shell=/bin/bash
set termguicolors
set hidden
" Bracket pairs
set showmatch
set matchtime=10
set scrolloff=4
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set autoindent
set nostartofline
set mouse=a
" Searching
set ignorecase
set smartcase
" display numbers
set relativenumber
set number
" display pum when tabbing
set wildmode=longest,full
" appearance
set background=dark
color everforest
" no mode indicator
"set noshowmode
" limit popup height
set pumheight=15
" don't show completion preview popup
"set completeopt=menuone
" Neovide
if exists("g:neovide")
set guifont=Ubuntu\ Mono:h13
let g:neovide_cursor_trail_size = 0.4
let g:neovide_position_animation_length = 0.01
let g:neovide_scroll_animation_length = 0.15
let g:neovide_cursor_vfx_mode = "pixiedust"
endif
" ------------ My commands -----------------------
command! SandboxFind Ack! <cword> $SANDBOX
command! EditVimRC e ~/.vim/vimrc
command! RemoveTrailingWhitespace %s/\s\+$
" ------------ Auto nohlsearch -----------------------
augroup vimrc-incsearch-highlight
autocmd!
autocmd CmdlineEnter /,\? :set hlsearch
autocmd CmdlineLeave /,\? :set nohlsearch
augroup END
" ------------ Custom Highlighting -----------------------
autocmd BufRead Jamroot,Jamfile,*.jam set syntax=bbv2
autocmd BufRead *.qrc set filetype=xml
" ------------ Mappings -----------------------
let mapleader = ","
let maplocalleader = ","
" Search with Space
nmap <Space> /
" Quicker save
noremap <Leader>w :update<CR>
" Alternate buffer
nnoremap <BS> :buffer #<CR>
" Comfortable window switching
nnoremap <C-w>c :bp\|bd #<CR>
nnoremap <C-c> :bd<CR>
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
imap öö (
imap ää {
imap üü [
vmap öö S)
vmap ää S}
vmap üü S]
inoremap ,, <Esc>A;<Esc>
" leave various insert modes
inoremap jk <ESC>
cnoremap jk <C-c>
tnoremap jk <C-\><C-n>
" far better mapping for german layout
map ü <C-]>
" fast ag search
nnoremap <leader>a :Ack<Space>
" split line at coursor in normal mode
"nnoremap K i<CR><Esc>
" switch current dir to buffer's dir
nmap <leader>cd :cd %:p:h<CR>
"noremap <Leader>h :nohl<CR>
" quick g/s on buffer
nnoremap S :%<Space>
" quick command mode
nnoremap ä :
" finder
if executable('fzf')
nnoremap <Leader>f :FZF $PROTOS_ROOT<CR>
else
nnoremap <Leader>f :Telescope find_files cwd=$PROTOS_ROOT<CR>
endif
nnoremap <Leader>g :Telescope live_grep cwd=$SANDBOX<CR>
" Alternate source <-> header
nnoremap <Leader>q :A<CR>
nnoremap <F3> :Gitsigns toggle_signs<CR>
" dispatch / make / quickfix
"nnoremap <Leader>m :Make!<CR>
function! MyMakeOpen()
Copen
nnoremap <buffer> o <CR>
nnoremap <buffer> q :bd<CR>
"nnoremap <buffer> n :cnext<CR>
"nnoremap <buffer> p :cprevious<CR>
nnoremap <buffer> n /error<CR>
"buftype quickfix
endfunction
nnoremap <F5> :Make<CR>
nnoremap <F6> :wa<CR>:Make<CR>
inoremap <F6> <Esc>:wa<CR>:Make<CR>
nnoremap <Leader>mc :call MyMakeOpen()<CR>
nnoremap <Leader>mn :cnext<CR>
nnoremap <Leader>mp :cprevious<CR>
function! CppSettings()
setlocal cindent
setlocal cinoptions=(0,w1
endfunction
autocmd FileType cpp call CppSettings()
" ------- Plugins ---------------
"---------------------------------------------------------------------------
" Simple Bookmarks
"---------------------------------------------------------------------------
let g:bookmark_show_warning = 1
let g:bookmark_save_per_working_dir = 0
let g:bookmark_manage_per_buffer = 0
"---------------------------------------------------------------------------
" Buffer Explorer
"---------------------------------------------------------------------------
"let g:bufExplorerSplitOutPathName = 0
let g:bufExplorerReverseSort=1
nnoremap ö :ToggleBufExplorer<CR>
"---------------------------------------------------------------------------
" Tagbar
"---------------------------------------------------------------------------
nmap <F8> :TagbarToggle<CR>
let g:tagbar_sort = 0
let g:tagbar_compact = 1
"let g:tagbar_show_data_type = 1
"---------------------------------------------------------------------------
" Ultisnips
"---------------------------------------------------------------------------
"let g:UltiSnipsExpandTrigger="<CR>"
let g:UltiSnipsExpandTrigger="<C-j>"
let g:UltiSnipsJumpForwardTrigger="<C-j>"
let g:UltiSnipsJumpBackwardTrigger="<C-k>"
let g:UltiSnipsSnippetsDir=$HOME .. "/.vim/Ultisnips"
let g:UltiSnipsSnippetDirectories=["Ultisnips"]
"---------------------------------------------------------------------------
" Fugitive mapping
"---------------------------------------------------------------------------
nnoremap <Leader>gg :Git<Space>
nnoremap <Leader>gs :Git<CR>
nnoremap <Leader>gd :Gdiff<CR>
nnoremap <Leader>gl :Git log<CR>
nnoremap <Leader>ge :Gedit<CR>
nnoremap <Leader>gr :Gread<CR>
nnoremap <Leader>gw :Gwrite<CR>
nnoremap <Leader>gb :Git blame<CR>
"---------------------------------------------------------------------------
" LSP
"---------------------------------------------------------------------------
lua require("config.lsp")
"---------------------------------------------------------------------------
" nvim-cmp
"---------------------------------------------------------------------------
lua require("config.cmp")
"---------------------------------------------------------------------------
" a.vim (alternate)
"---------------------------------------------------------------------------
let g:alternateNoDefaultAlternate = 1
" append to script default
let g:alternateSearchPath = 'sfr:../source,sfr:../src,sfr:../include,sfr:../inc'
\ . ',sfr:../src,sfr:../public_include'
\ . ',sfr:../../src,sfr:../../public_include'
\ . ',reg:/src/public_include/g'
\ . ',reg:/public_include/src/g'
"---------------------------------------------------------------------------
" Sessions
"---------------------------------------------------------------------------
set sessionoptions=buffers,curdir,resize,terminal,winpos,winsize
let g:default_session_file = ""
function! SessionRestore()
let l:started_with_stdin = len(getbufinfo({'bufmodified':1})) > 0
if !argc() && !l:started_with_stdin && empty(v:this_session)
let g:default_session_file = expand("~/.vim/sessions/default.vim")
if filereadable(g:default_session_file)
execute "source" g:default_session_file
endif
endif
endfunction
function! SessionSave()
if len(g:default_session_file)
execute "mksession!" g:default_session_file
endif
endfunction
augroup sessions
autocmd!
autocmd VimEnter * nested call SessionRestore()
autocmd VimLeave,BufAdd * call SessionSave()
augroup END
"---------------------------------------------------------------------------
" Telescope
"---------------------------------------------------------------------------
nnoremap <leader>y :lua require("telescope.builtin").registers({initial_mode="normal"})<cr>
nnoremap <leader>t :lua require("telescope.builtin").lsp_document_symbols({initial_mode="insert"})<cr>
"---------------------------------------------------------------------------
" Sneak
"---------------------------------------------------------------------------
nmap f <Plug>Sneak_s
nmap F <Plug>Sneak_S
xmap f <Plug>Sneak_s
xmap F <Plug>Sneak_S
omap f <Plug>Sneak_s
omap F <Plug>Sneak_S
let g:sneak#s_next = 1
"---------------------------------------------------------------------------
" fzf
"---------------------------------------------------------------------------
set runtimepath+=~/Programme/fzf
autocmd FileType fzf set laststatus=0 noshowmode noruler | autocmd BufLeave <buffer> set laststatus=2 showmode ruler
"---------------------------------------------------------------------------
" Ack / Ag
"---------------------------------------------------------------------------
if executable('rg')
let g:ackprg = 'rg --vimgrep --smart-case'
elseif executable('ag')
let g:ackprg = 'ag --vimgrep --smart-case'
endif
"let g:ack_use_dispatch = 1
"---------------------------------------------------------------------------
" Dirvish
"---------------------------------------------------------------------------
command! Shell Dirvish ~/bin/
command! Utils Dirvish ~/bin_dev/
"---------------------------------------------------------------------------
" Fugitive
"---------------------------------------------------------------------------
augroup fugitive_config
autocmd!
autocmd FileType fugitive map <buffer><silent> q gq
augroup END
"---------------------------------------------------------------------------
" Dispatch
"---------------------------------------------------------------------------
let g:dispatch_tmux_height = 6
let g:dispatch_quickfix_height = 16
"---------------------------------------------------------------------------
" Lualine
"---------------------------------------------------------------------------
lua require("config.lualine")
"---------------------------------------------------------------------------
" gitsigns
"---------------------------------------------------------------------------
lua require("config.gitsigns")
"---------------------------------------------------------------------------
" Gen
"---------------------------------------------------------------------------
lua require("config.gen")
"---------------------------------------------------------------------------
" Diagnostics
"---------------------------------------------------------------------------
lua << EOF
vim.diagnostic.config({
signs = {
text = {
[vim.diagnostic.severity.ERROR] = "🔥",
[vim.diagnostic.severity.WARN] = "👀",
[vim.diagnostic.severity.INFO] = "💡",
[vim.diagnostic.severity.HINT] = "H"
}
}
})
EOF
"---------------------------------------------------------------------------
" Plugins
"---------------------------------------------------------------------------
lua require("packages")