-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.vim
403 lines (351 loc) · 12.7 KB
/
init.vim
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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
" ___ ___ _ __ / _| _ _ ___ ___
" / __/ _ \| '_ \ _____| |_ _____| | | / __|/ _ \
" | (_| (_) | | | |_____| _|_____| |_| \__ \ __/
" \___\___/|_| |_| |_| \__,_|___/\___|
"
if (has("nvim"))
if empty(glob('~/.local/share/nvim/site/autoload/plug.vim'))
echo "Downloading junegunn/vim-plug for neovim to manage plugins..."
silent !curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
endif
set number
set mouse=a
set clipboard=unnamedplus " use system clipboard
set history=10000 "Longer history
set undolevels=1000
let mapleader=';'
set wildignore+=*.pyc
set wildignore+=**/.git/*
call plug#begin('~/.vim/plugged')
" essential stuff
Plug 'tpope/vim-fugitive' " Git for vim
Plug 'junegunn/fzf.vim'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'neoclide/coc.nvim', {'branch': 'release'}
"Plug 'neoclide/coc.nvim', {'commit': 'cf651a31736fc36c441bf307d2babff78280dd59'}
"Plug 'tpope/vim-eunuch' " Unix command in vim
"Plug 'xolox/vim-misc' " Glue to make other xolox plugins work
Plug 'joshdick/onedark.vim' " Nice color theme for vim
Plug 'alfredodeza/pytest.vim'
Plug 'easymotion/vim-easymotion'
Plug 'chrisbra/matchit' " Makes % match more (e.g. if-else)
Plug 'vim-scripts/ReplaceWithRegister' " [count]["x]gr[r|motion] replates motion with register content
Plug 'machakann/vim-highlightedyank' " higlights what was yanked shortly
" Plug 'unblevable/quick-scope' " highlits unique letter for fFtT
if exists(':lua')
Plug 'nvim-lua/popup.nvim'
Plug 'nvim-lua/plenary.nvim'
"Plug 'nvim-telescope/telescope.nvim', { 'on': 'Telescope' }
Plug 'nvim-treesitter/nvim-treesitter' ", { 'commit': '47a4eadf4471af2b57fad405bd0a7b42cdf0fba6'}
Plug 'nvim-treesitter/nvim-treesitter-context', {'do': ':TSUpdate'} "https://github.com/nvim-treesitter/nvim-treesitter-context/issues/150 "run `TSInstall <language>` after!
Plug 'nvim-treesitter/nvim-treesitter-refactor'
Plug 'nvim-lualine/lualine.nvim'
Plug 'akinsho/nvim-bufferline.lua'
Plug 'Yggdroot/indentLine'
"Plug 'folke/which-key.nvim'
Plug 'norcalli/nvim-colorizer.lua'
endif
"Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-surround' " Surround text objects with stuff
Plug 'sbdchd/neoformat', { 'on': 'Neoformat' } " Code formatter
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-sleuth' " Autodetect indentation style
Plug 'kana/vim-textobj-user'
Plug 'kana/vim-textobj-function'
"Plug 'Yggdroot/indentLine' " Show vertical line for indent levels
Plug 'honza/vim-snippets'
" experimental stuff
"Plug 'ryanoasis/vim-devicons'
"Plug 'szw/vim-maximizer', { 'on': 'MaximizerToggle' }
"Plug 'dbeniamine/cheat.sh-vim', { 'on': 'Cheat' }
"Plug 'kassio/neoterm', { 'on': 'Ttoggle' }
Plug 'rhysd/vim-grammarous'
Plug 'preservim/tagbar', { 'on': 'Tagbar' }
Plug 'mhinz/vim-startify' " Fancy start screen
"Plug 'xolox/vim-notes' " Note taking plugin in vim
"Plug 'machakann/vim-highlightedyank'
Plug 'junegunn/goyo.vim', { 'on': 'Goyo' } " Centered buffer reading
Plug 'jiangmiao/auto-pairs'
Plug 'psliwka/vim-smoothie'
"Plug 'itchyny/lightline.vim'
"Plug 'mengelbrecht/lightline-bufferline'
Plug 'LnL7/vim-nix' " Nix syntax
"Plug 'lervag/vimtex'
call plug#end()
let g:lightline = {
\ 'component_function': {
\ 'filetype': 'MyFiletype',
\ 'fileformat': 'MyFileformat',
\ 'gitbranch': 'FugitiveHead'
\ },
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'colorscheme': 'onedark',
\ 'tabline': {
\ 'left': [ ['buffers'] ],
\ 'right': [ ['close'] ]
\ },
\ 'component_expand': {
\ 'buffers': 'lightline#bufferline#buffers'
\ },
\ 'component_type': {
\ 'buffers': 'tabsel'
\ },
\ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" },
\ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" }
\ }
function! MyFiletype()
return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype . ' ' . WebDevIconsGetFileTypeSymbol() : 'no ft') : ''
endfunction
function! MyFileformat()
return winwidth(0) > 70 ? (&fileformat . ' ' . WebDevIconsGetFileFormatSymbol()) : ''
endfunction
let g:netrw_liststyle=3
set showtabline=2
set lazyredraw
let g:netrw_banner = 0
set list lcs=tab:\|\
let g:fzf_layout = { 'window': { 'width': 0.8, 'height': 0.8 } }
let g:tex_flavor = 'latex'
let $FZF_DEFAULT_OPTS='--reverse --color=dark --color=fg:-1,bg:-1,hl:#c678dd,fg+:#ffffff,bg+:#4b5263,hl+:#d858fe --color=info:#98c379,prompt:#61afef,pointer:#be5046,marker:#e5c07b,spinner:#61afef,header:#61afef'
" somehow works in tmux now...
if has("termguicolors")
set termguicolors
endif
syntax on
" Transparaent OneDark!
let g:one_allow_italics = 1
if (empty($TMUX))
if (has("nvim"))
"For Neovim 0.1.3 and 0.1.4
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
endif
"For Neovim > 0.1.5 and Vim > patch 7.4.1799
if (has("termguicolors"))
set termguicolors
endif
endif
if (has("autocmd") && !has("gui_running"))
augroup colorset
autocmd!
let s:white = { "gui": "#ABB2BF", "cterm": "145", "cterm16" : "7" }
autocmd ColorScheme * call onedark#set_highlight("Normal", { "fg": s:white }) " `bg` will not be styled since there is no `bg` setting
augroup END
endif
colorscheme onedark
let s:black = { "gui": "#282C34", "cterm": "235", "cterm16": "0" }
let s:white = { "gui": "#ABB2BF", "cterm": "145", "cterm16" : "7" }
call onedark#set_highlight("Normal", { "fg": s:white }) " `bg` will not be styled since there is no `bg` setting
"call onedark#set_highlight("Normal", { "fg": s:white, "bg": s:black }) " normal text
colorscheme onedark
set hidden
set list " show invisible characters
set listchars=tab:»·,trail:·,nbsp:· " Display extra whitespace
let g:vim_json_conceal=0 " display quotes in json
if exists(":lua")
lua require'colorizer'.setup()
endif
set inccommand=split
command! -bang ProjectFiles call fzf#vim#files('~/devel', <bang>0)
" Most used
nnoremap <leader><SPACE> :Files<CR>
nnoremap <leader>b :Buffers<CR>
nnoremap <leader>r :Rg<CR>
nnoremap <leader>g :GitFiles<CR>
nnoremap <leader>l :Lines<CR>
nnoremap <leader>m :Marks<CR>
nnoremap <leader>n :Neoformat<CR>
nmap <leader>? <plug>(fzf-maps-n)
nnoremap <leader>o :ProjectFiles<CR>
nnoremap <leader>t :Tags<CR>
nnoremap <leader>z :Goyo<CR>
nnoremap <leader>P :Pytest project<CR>
nnoremap <leader>C :call CocAction('pickColor')<CR>
nnoremap <leader>d :cd %:p:h<CR>
nnoremap <leader>e :CocCommand explorer<CR>
nnoremap <leader>F :CocSearch -S
" nnoremap <leader>g :Gcd<CR>
nnoremap <leader>h :GitGutterPreviewHunk<CR>
"nnoremap <leader>j :.!nextline %:p 5<Enter>G'
nnoremap <leader>j :.!nextline de.md 5<Enter>G'
nnoremap <leader>s :G<CR>
nnoremap <leader>q :q<CR>
nnoremap <leader>p :vsplit<CR> \| :terminal git push<CR>i
nnoremap <leader>N :tabnew<CR>
nnoremap <leader>k :call <SID>show_documentation()<CR>
nnoremap <leader>. :bn<CR>
nnoremap <leader>, :bp<CR>
nnoremap <leader>dd :execute "normal \<Plug>Ysurroundiw\""<cr>
nnoremap <leader>bb :execute "normal \<Plug>Ysurroundiw)"<cr>
"Move to word
"map <Leader>/ <Plug>(easymotion"-prefix)
let g:EasyMotion_do_mapping = 0 " Disable default mappings
map <leader>w <plug>(easymotion-bd-w)
nmap <leader>w <plug>(easymotion-overwin-w)
map <leader>- <plug>(easymotion-s)
map <leader>/ <plug>(easymotion-bd-n)
"Y behave like D and P
nnoremap Y y$
"keep centered
nnoremap n nzzzv
nnoremap N Nzzzv
"nnoremap J mzJ`z
"Jumplist contains jumps larger 5 lines for Ctrl+o/i
nnoremap <expr> k (v:count > 5 ? "m'" . v:count : "") . 'k'
nnoremap <expr> j (v:count > 5 ? "m'" . v:count : "") . 'j'
autocmd FileType sh inoremap <leader>M if [ "$0" = "$BASH_SOURCE" ]; then<cr>fi<Esc>O
autocmd FileType python inoremap <leader>M if __name__ == "__main__":<cr> <Esc>O
" US-intl key dead key remappings
nmap à `a|nmap á 'a
nmap ć 'c
nmap è `e|nmap é 'e
nmap ǵ 'g
nmap ì `i|nmap í 'i
nmap ḱ 'k
nmap ĺ 'l
nmap ḿ 'm
nmap ǹ `n|nmap ń 'n
nmap ò `o|nmap ó 'o
nmap ṕ 'p
nmap ŕ 'r
nmap ś 's
nmap ù `u|nmap ú 'u
nmap ǜ `v|nmap ǘ 'v
nmap ẁ `w|nmap ẃ 'w
nmap ỳ `y|nmap ý 'y
nmap ź 'z
" Workaround bug https://sw.kovidgoyal.net/kitty/faq/#using-a-color-theme-with-a-background-color-does-not-work-well-in-vim
let &t_ut=''
" Faster global replace
nnoremap S :%s///gg<Left><Left><Left><Left>
if exists(':lua')
lua << EOF
require('lualine').setup{ options = { theme = 'onedark', icons_enabled = true }}
require'bufferline'.setup{}
require'nvim-treesitter.configs'.setup {
highlight = { enable = true },
zindex=300,
refactor = {
navigation = {
enable = true,
-- Assign keymaps to false to disable them, e.g. `goto_definition = false`.
keymaps = {
goto_definition = "gnd",
list_definitions = "gnD",
list_definitions_toc = "gO",
goto_next_usage = "<a-*>",
goto_previous_usage = "<a-#>",
},
},
},
}
EOF
endif
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
if executable('rg')
let g:rg_derive_root='true'
endif
autocmd CursorHold * silent call CocActionAsync('highlight')
set foldmethod=indent
set nofoldenable
nmap <leader>i <Plug>(coc-format)
nmap <leader><F2> <Plug>(coc-rename)
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
"Use <tab> and <S-tab> to navigate completion list: >
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction
" Insert <tab> when previous text is space, refresh completion if not.
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1):
\ <SID>check_back_space() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
"Use <c-space> to trigger completion:
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
"Use <CR> to confirm completion, use:
inoremap <expr> <cr> coc#pum#visible() ? coc#_select_confirm() : "\<CR>"
"To make <CR> to confirm selection of selected complete item or notify coc.nvim
"to format on enter, use: >
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#_select_confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
"inoremap <silent><expr> <TAB>
" \ pumvisible() ? "\<C-n>" :
" \ <SID>check_back_space() ? "\<TAB>" :
" \ coc#refresh()
"
"inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
"
"inoremap <silent><expr> <C-l>
" \ pumvisible() ? coc#_select_confirm() :
" \ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
" \ <SID>check_back_space() ? "\<TAB>" :
" \ coc#refresh()
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
let g:neoformat_enabled_python = ['black']
set tabstop=4 shiftwidth=4 expandtab
" additional mode switching
inoremap <special> kj <ESC>
cnoremap <special> kj <ESC>
inoremap <special> jk <ESC>:
tnoremap <special> jk <C-\><C-n>
map <leader><leader> <Esc>/<++<Enter>"_cf>
"noremap <leader>c <Esc>:silent execute "!xdg_open https://conserve.dynu.net/gitlab/jan/cheatsheets/-/blob/master/"
nnoremap <leader>c <Esc>:w<Enter>:vnew \| r!2>&1 ,run #<Enter>
inoremap <leader>c <Esc>:w<Enter>:vnew \| r!,run #<Enter>
" inoremap <leader>c <Esc>:w<Enter>:!,run #<Enter>
" maybe you want setxkbmap -option caps:escape int your (x-)profile
" Shortcutting split navigation, saving a keypress:
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>lA;
" Make accidental macro recording harder
nnoremap Q q
nnoremap q <Nop>
set tabline
set cursorline
set relativenumber
set smartcase
set ignorecase
set autoread
set scrolloff=6
set guifont=FiraCode\ Nerd\ Font\ Mono:h13
set encoding=UTF-8
set gdefault
set exrc
set secure
set title
set ruler
set colorcolumn=72
set spell
set spelllang=en,de
" set conceallevel=0
let g:indentLine_fileTypeExclude = ['json', 'markdown']
highlight ColorColumn ctermbg=233