-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc~
148 lines (136 loc) · 5.46 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
let &t_SI = "\<Esc>[6 q"
let &t_SR = "\<Esc>[4 q"
let &t_EI = "\<Esc>[2 q"
packadd! comment
" packadd! editorconfig
runtime ftplugin/man.vim
filetype plugin indent on
syntax on
let mapleader = " "
set viminfo+=n~/.config/vim/viminfo
augroup ColorschemeCustom
au!
au Colorscheme * hi Normal ctermbg=NONE guibg=NONE | hi default 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>-
noremap <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>"
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 nolazyredraw termguicolors signcolumn=number omnifunc=syntaxcomplete#Complete
set linebreak scrolloff=10 wrap nostartofline cpoptions+=n nofoldenable foldlevelstart=99 foldmethod=manual showbreak=>>>\
set autoread autowrite backspace=indent,eol,start
set backupcopy=auto backup writebackup backupdir=~/.cache/vim/backup dir=~/.cache/vim/swap
set undofile undodir=~/.cache/vim/undo
set hidden history=1000 sessionoptions-=options,folds
set encoding=utf8 ffs=unix,dos,mac nrformats-=octal
let &statusline=" %f%m%r%h %w%y %= CWD: %{pathshorten(substitute(getcwd(winnr()),$HOME,'~',''),4)} (%l,%c) [%p%%,%P]"
set showmatch matchtime=1 matchpairs+=<:> ttimeoutlen=0
let 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'
\]
\ }])
let LspOptions = (#{
\autoComplete: v:false,
\useBufferCompletion: v:true,
\filterCompletionDuplicates: v:true,
\semanticHighlight: v:true,
\usePopupInCodeAction: v:true,
\})
function! s: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>h <cmd>LspSwitchSourceHeader<cr>
noremap <buffer> <leader>a <cmd>LspCodeAction<cr>
endfunction
let c_no_curly_error = 1 " disable error highlight for c compound literals
let g:ft_man_no_sect_fallback = 1
let g:local_vimrc = {'cache_file': $HOME."/.cache/vim/local_vimrc_cache"}
command! -nargs=* -complete=file Make make! <args>
command! DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
augroup Custom
au!
au FileType * set formatoptions+=j formatoptions-=cro
au FileType c,cpp set matchpairs+==:;
au FileType c,cpp ++once if !exists('g:termdebug_loaded') | packadd termdebug | packadd lsp | endif
au FileType qf
\if &buftype ==? "quickfix" |
\ nnoremap <buffer> q <cmd>quit<cr> |
\ nnoremap <buffer> <C-q> q |
\endif
au CmdWinEnter * nnoremap <nowait> <buffer> q <cmd>quit<cr> | nnoremap <nowait> <buffer> <C-q> q
" au BufEnter * if &buftype !=?
au User LspSetup ++once
\call LspOptionsSet(LspOptions) |
\call LspAddServer(LspServers) |
\au User LspAttached call <SID>OnLspAttach()
" restore last cursor position (taken from defaults.vim)
au BufReadPost *
\ let line = line("'\"")
\ | if line >= 1 && line <= line("$") && &filetype !~# 'commit'
\ && index(['xxd', 'gitrebase'], &filetype) == -1
\ | execute "normal! g`\""
\ | endif
\ | unlet line
au BufRead,BufNewFile *.h set filetype=c
au VimResume * checktime
au VimResized * wincmd =
autocmd VimLeave * if v:this_session != "" | mksession! | endif
au TextYankPost * if v:event.regname ==? "-" |
\call job_start(['sh', '-c',
\'xclip -i -rmlastnl -selection clipboard <<< "' . @- . '"']) |
\endif
augroup END