-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
202 lines (166 loc) · 5.22 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
set nocompatible
" ---------------------------------------------------------------------------- "
" Plugins
" ---------------------------------------------------------------------------- "
call plug#begin('~/.vim/plugged')
Plug 'dylanaraps/wal.vim'
Plug 'junegunn/fzf.vim'
Plug 'liuchengxu/vista.vim'
Plug 'itchyny/lightline.vim'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'airblade/vim-gitgutter'
Plug 'romainl/vim-devdocs'
let languages = ['python', 'go', 'c', 'cpp', 'rust']
Plug 'prabirshrestha/vim-lsp', {'for': languages}
Plug 'prabirshrestha/async.vim', {'for': languages}
Plug 'prabirshrestha/asyncomplete.vim', {'for': languages}
Plug 'prabirshrestha/asyncomplete-lsp.vim', {'for': languages}
Plug 'prabirshrestha/asyncomplete-ultisnips.vim', {'for': languages}
call plug#end()
" ---------------------------------------------------------------------------- "
" General settings
" ---------------------------------------------------------------------------- "
filetype plugin indent on
colorscheme wal
if !exists("g:syntax_on")
syntax enable
endif
set background=dark
"set backspace=indent,eol,start
set laststatus=2
set number
set relativenumber
set clipboard=unnamedplus
set ruler
set ttyfast
set showcmd
set wildmenu
set wildmode=list:longest,full
set path+=**
set ttymouse=sgr
set tags=./tags;,~/.vimtags;
set completeopt+=preview
set splitright
set splitbelow
" Temp files
set nobackup
set noswapfile
set viminfo=""
" Search
set incsearch
set hlsearch
set ignorecase
set smartcase
" Indentation
set smartindent
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
" Folding
set foldmethod=indent
set nofoldenable
" ---------------------------------------------------------------------------- "
" Key mappings
" ---------------------------------------------------------------------------- "
" Clear search highlight
nnoremap <leader><space> :noh<CR>
" Search and replace
nnoremap <Leader>r :%s/\<<C-R><C-W>\>//gI<left><left><left>
" Vimdiff merging
nnoremap <leader>mr :diffg RE<CR>
nnoremap <leader>mb :diffg BA<CR>
nnoremap <leader>ml :diffg LO<CR>
" Toggle Vista
let g:vista#renderer#enable_icon = 1
nnoremap <leader>t :Vista!!<CR>
" Fzf
nnoremap <leader>f :Files<CR>
nnoremap <leader>g :Rg <C-R><C-W><CR>
nnoremap <leader>l :Lines <C-R><C-W><CR>
nnoremap <leader>b :Buffers<CR>
" Documentation
nnoremap <leader>K :DD <CR>
" Lsp bindings
nnoremap <leader>d :LspDefinition<CR>
nnoremap <leader>td :LspTypeDefinition<CR>
nnoremap <leader>df :LspDocumentFormat<CR>
nnoremap <leader>h :LspHover<CR>
nnoremap <leader>ref :LspReferences<CR>
nnoremap <leader>rn :LspRename<CR>
nnoremap <leader>dd :LspDocumentDiagnostics<CR>
" ---------------------------------------------------------------------------- "
" Plugin configuration
" ---------------------------------------------------------------------------- "
" ultisnips
let g:UltiSnipsExpandTrigger="<C-L>"
let g:UltiSnipsJumpForwardTrigger="<C-J>"
let g:UltiSnipsJumpBackwardTrigger="<C-K>"
" vim-lsp
let g:lsp_signs_enabled = 1
let g:lsp_diagnostics_echo_cursor = 1
if executable('gopls')
au User lsp_setup call lsp#register_server({
\ 'name': 'gopls',
\ 'cmd': {server_info->['gopls']},
\ 'whitelist': ['go'],
\ })
endif
if executable('pyls')
au User lsp_setup call lsp#register_server({
\ 'name': 'pyls',
\ 'cmd': {server_info->['pyls']},
\ 'whitelist': ['python'],
\ })
endif
if executable('rls')
au User lsp_setup call lsp#register_server({
\ 'name': 'rls',
\ 'cmd': {server_info->['rls']},
\ 'whitelist': ['rust'],
\ })
endif
if executable('clangd')
au User lsp_setup call lsp#register_server({
\ 'name': 'clangd',
\ 'cmd': {server_info->['clangd']},
\ 'whitelist': ['c', 'cpp', 'objc', 'objcpp'],
\ })
endif
" asyncomplete-ultisnips.vim
au Filetype cpp,c,python,rust call asyncomplete#register_source(
\ asyncomplete#sources#ultisnips#get_source_options({
\ 'name': 'ultisnips',
\ 'whitelist': ['*'],
\ 'completor': function('asyncomplete#sources#ultisnips#completor'),
\ }))
" vim-fzf
command! -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview(), <bang>0)
command! -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>), 1,
\ fzf#vim#with_preview(), <bang>0)
" vista
function! NearestMethodOrFunction() abort
return get(b:, 'vista_nearest_method_or_function', '')
endfunction
set statusline+=%{NearestMethodOrFunction()}
autocmd VimEnter * call vista#RunForNearestMethodOrFunction()
" lightline
let g:lightline = {
\ 'colorscheme': 'one',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'readonly', 'filename', 'modified', 'method' ] ]
\ },
\ 'component_function': {
\ 'method': 'NearestMethodOrFunction'
\ },
\ }
" ---------------------------------------------------------------------------- "
" Event handling
" ---------------------------------------------------------------------------- "
" Remove trailing whitespace on write
autocmd BufWritePre * if &filetype != 'markdown' | %s/\s\+$//e | endif