-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
192 lines (174 loc) · 5.77 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
vim9script
&t_SI = "\<Esc>[6 q"
&t_SR = "\<Esc>[4 q"
&t_EI = "\<Esc>[2 q"
:packadd! comment
:packadd! editorconfig
:runtime ftplugin/man.vim
filetype plugin indent on
syntax on
g:mapleader = " "
augroup ColorschemeCustom
au!
au Colorscheme * {
:highlight Normal ctermbg=NONE guibg=NONE
:highlight link Normal NonText
}
augroup END
:colorscheme retrobox
nnoremap <leader>l <C-^>
nnoremap <leader>n <cmd>bn<cr>
nnoremap <leader>p <cmd>bp<cr>
nnoremap <leader>o o<esc>
nnoremap <leader>O O<esc>
nnoremap <leader>m <cmd>ls<CR>:b<Space>
nnoremap <leader>M <cmd>ls<CR>:bd<Space>
noremap <leader>/ <cmd>set hlsearch!<cr>
noremap <C-l> <C-l><cmd>nohlsearch<cr><cmd>match<cr><cmd>diffupdate<cr>
nnoremap <S-Tab> <C-o>
noremap <C-j> <C-d>
noremap <C-k> <C-u>
noremap j gj
noremap k gk
noremap gj j
noremap gk k
noremap <leader>f <cmd>FZF<cr>
tnoremap <C-n> <C-\><C-n>
noremap <leader>q <cmd>stop<cr>
noremap <leader>e <cmd>wqa<cr>
noremap <C-S-Left> <C-W>>
noremap <C-S-Right> <C-W><
noremap <C-S-Up> <C-W>+
noremap <C-S-Down> <C-W>-
map <leader>s "+
noremap <leader>r <cmd>registers<cr>
noremap <leader>ww <cmd>w<cr>
noremap <leader>wa <cmd>wa<cr>
noremap <leader>co <cmd>copen<cr>
noremap <leader>cw <cmd>cwindow<cr>
noremap <leader>cc <cmd>cclose<cr>
noremap <leader>cl <cmd>cc<cr>
noremap <leader>cn <cmd>cnext<cr>
noremap <leader>cp <cmd>cprev<cr>
noremap <leader>cb <cmd>cabove<cr>
noremap <leader>cu <cmd>cbelow<cr>
inoremap <expr> <CR> pumvisible() ? "\<C-Y>" : "\<CR>"
inoremap <expr> <C-Y> pumvisible() ? "\<CR>" : "\<C-Y>"
vnoremap <leader>gr "hy:%s/<C-r>h//gc<left><left><left>
nnoremap <silent> <F5> <cmd>call <SID>PreciseTrimWhiteSpace()<cr>
set laststatus=2 number relativenumber ruler cursorline showcmd mouse=a title background=dark
set wildmenu completeopt=menuone,popup,fuzzy,longest wildignorecase wildoptions=pum pumheight=25 keywordprg=:Man
set expandtab tabstop=4 softtabstop=4 shiftwidth=4 shiftround smarttab smartindent autoindent
set nohlsearch incsearch ignorecase smartcase
set lazyredraw termguicolors signcolumn=number omnifunc=syntaxcomplete#Complete
set linebreak scrolloff=10 wrap nostartofline cpoptions+=n nofoldenable foldlevelstart=99 foldmethod=syntax showbreak=>>>\
set autoread autowrite backspace=indent,eol,start
set backupcopy=auto backup writebackup undofile
set hidden history=1000 sessionoptions-=options sessionoptions-=folds viewoptions-=cursor
set encoding=utf8 ffs=unix,dos,mac nrformats-=octal
set showmatch matchtime=1 matchpairs+=<:> ttimeoutlen=0 wrapmargin=15
set spelllang=en_ca,en_us,en_gb spelloptions=camel spellsuggest=best,20 dictionary+=/usr/share/dict/words complete+=k
&statusline = " %f%m%r%h %w%y %= CWD: %{pathshorten(substitute(getcwd(winnr()),$HOME,'~',''),4)} (%l,%c) [%p%%,%P]"
g:c_no_curly_error = 1 # disable error highlight for c compound literals
g:ft_man_no_sect_fallback = 1
g:local_vimrc = {cache_file: $HOME .. "/.cache/vim/local_vimrc_cache"}
g:vimsyn_folding = "afhHlmpPrt"
var LspServers = [{name: 'clangd',
filetype: ['c', 'cpp'],
path: '/bin/clangd',
args: [
'--background-index',
'--clang-tidy',
'--pch-storage=memory',
'--malloc-trim',
'--background-index-priority=background',
'--completion-style=detailed'
]
}]
var LspOptions = {
autoComplete: v:false,
useBufferCompletion: v:true,
filterCompletionDuplicates: v:true,
}
augroup Custom
au!
au FileType * setlocal formatoptions+=j formatoptions-=cro
autocmd BufRead,BufNewFile *.h setlocal filetype=c
au FileType qf Use_q_AsExit()
au CmdWinEnter * Use_q_AsExit()
au BufReadPost * {
var line = line("'\"")
if line >= 1 && line <= line("$") && &filetype !~# 'commit'
&& index(['xxd', 'gitrebase'], &filetype) == -1
:execute "normal! g`\""
endif
}
au Filetype c,cpp ++once {
:packadd lsp
call LspOptionsSet(LspOptions)
call LspAddServer(LspServers)
augroup LspAttach
au User LspAttached OnLspAttach()
augroup END
}
au VimResume * :silent! checktime
au VimResized * :wincmd =
au VimLeavePre * {
if v:this_session != ""
execute ':mksession! ' .. v:this_session
endif
}
au BufWinLeave ?* :mkview!
au SessionLoadPost * {
augroup LoadView
au!
au BufWinEnter ?* :silent! loadview
augroup END
}
augroup END
command! DiffOrig DiffOrig()
command -nargs=* -complete=file Make make! <args>
def OnLspAttach()
setlocal tagfunc=lsp#lsp#TagFunc
augroup LspCustom
au!
au BufWritePre <buffer> {
:execute "LspFormat"
}
augroup END
noremap <buffer> <leader>g <cmd>LspDiag current<cr>
noremap <buffer> <leader>= <cmd>LspFormat<cr>
noremap <buffer> <leader>i <cmd>LspHover<cr>
noremap <buffer> <leader>sh <cmd>LspSwitchSourceHeader<cr>
noremap <buffer> <leader>hh <cmd>LspHighlight<cr>
noremap <buffer> <leader>hc <cmd>LspHighlightClear<cr>
noremap <buffer> <leader>a <cmd>LspCodeAction<cr>
noremap <buffer> <leader>dd <cmd>LspGotoDeclaration<cr>
noremap <buffer> <leader>de <cmd>LspGotoDefinition<cr>
enddef
def PreciseTrimWhiteSpace()
var saved_view = winsaveview()
:keepjumps exe ":%s/\\s\\+$//ge"
winrestview(saved_view)
enddef
def Use_q_AsExit()
nnoremap <nowait> <buffer> q <cmd>quit<cr>
nnoremap <nowait> <buffer> <C-q> q
enddef
export def DiffOrig()
var prev_file = bufnr()
:vertical new
var scratch_buf = bufnr()
set bt=nofile
:execute 'read ++edit ' .. bufname(prev_file)
deletebufline(scratch_buf, 1)
:diffthis
:wincmd p
:diffthis
g:__diffoff_buf = scratch_buf
command DiffOff {
execute 'bdelete ' .. g:__diffoff_buf
unlet g:__diffoff_buf
delc DiffOff
}
enddef