-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
233 lines (172 loc) · 4.33 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
" VimPlug {{{
call plug#begin()
" Defaults everyone can agree on
Plug 'tpope/vim-sensible'
" A solid language pack for Vim
Plug 'sheerun/vim-polyglot'
" Solarized, without the bullshit
Plug 'romainl/flattened'
" A light and configurable status line plugin for Vim
Plug 'itchyny/lightline.vim'
" Togglable syntax highlighting of tabs, nbsps and trailing spaces
Plug 'jpalardy/spacehi.vim'
" Work with several variants of a word at once
Plug 'tpope/vim-abolish'
" Fuzzy file, buffer, mru, tag, etc finder
Plug 'ctrlpvim/ctrlp.vim'
" Vim script for text filtering and alignment
Plug 'godlygeek/tabular'
" Vim files for the BitBake tool
Plug 'kergoth/vim-bitbake'
" Vim configuration for Rust
Plug 'rust-lang/rust.vim'
" Vim LSP support
Plug 'dense-analysis/ale'
call plug#end()
" }}}
" Basic configuration {{{
set confirm
set mouse=a
set number
" Terminals {{{
if &term =~# '^\(tmux\|screen\|alacritty\)'
" Better mouse support, see :help 'ttymouse'
set ttymouse=sgr
" Enable bracketed paste mode, see :help xterm-bracketed-paste
let &t_BE = "\<Esc>[?2004h"
let &t_BD = "\<Esc>[?2004l"
let &t_PS = "\<Esc>[200~"
let &t_PE = "\<Esc>[201~"
" Enable focus event tracking, see :help xterm-focus-event
let &t_fe = "\<Esc>[?1004h"
let &t_fd = "\<Esc>[?1004l"
execute "set <FocusGained>=\<Esc>[I"
execute "set <FocusLost>=\<Esc>[O"
" Enable modified arrow keys, see :help arrow_modifiers
execute "silent! set <xUp>=\<Esc>[@;*A"
execute "silent! set <xDown>=\<Esc>[@;*B"
execute "silent! set <xRight>=\<Esc>[@;*C"
execute "silent! set <xLeft>=\<Esc>[@;*D"
endif
" Undercurl & Underline {{{
" https://github.com/alacritty/alacritty/issues/4142#issuecomment-1078876187
" Enable undercurls in terminal
let &t_Cs = "\e[4:3m"
let &t_Ce = "\e[4:0m"
" Enable underline colors (ANSI), see alacritty #4660
let &t_AU = "\<esc>[58;5;%dm"
if !empty($DISPLAY) && $COLORTERM !~# '^rxvt'
" Enable true colors, see :help xterm-true-color
if &term =~# '^\(tmux\|screen\|alacritty\)'
let &t_8f = "\<esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<esc>[48;2;%lu;%lu;%lum"
endif
" Enable underline colors (RGB), see alacritty #4660
let &t_8u = "\<esc>[58;2;%lu;%lu;%lum"
" Use highlight-guibg and guifg attributes in terminal
set termguicolors
endif
" }}}
" }}}
" ColorScheme {{{
try
colorscheme flattened_dark
catch
colorscheme default
endtry
" }}}
" Buffer formatting {{{
set tabstop=8
set shiftwidth=8
set noexpandtab
set nofixeol
set textwidth=80
set colorcolumn=+1
" }}}
" Searches {{{
set hlsearch
set smartcase
" Make search result appear in the middle of the screen
nnoremap n nzzzv
nnoremap N Nzzzv
" }}}
" Spell checking {{{
set spell
set spelllang=en
" }}}
" Backup management {{{
set backup
set noswapfile
set noundofile
set backupdir=~/.vim/tmp/backup/
set directory=~/.vim/tmp/swap/
set undodir=~/.vim/tmp/undo/
if !isdirectory(expand(&backupdir))
call mkdir(expand(&backupdir), "p")
endif
if !isdirectory(expand(&directory))
call mkdir(expand(&directory), "p")
endif
if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir), "p")
endif
" }}}
" Tab page {{{
set tabpagemax=50
execute ":silent tab all"
" }}}
" Folding {{{
set foldmethod=marker
nnoremap <Space> za
vnoremap <Space> za
" }}}
" Keyword doc {{{
autocmd FileType rust set keywordprg=rustup\ doc
" }}}
" }}}
" Plugins configuration {{{
" LightLine {{{
set laststatus=2
set noshowmode
let g:lightline = {
\ 'colorscheme': 'flattened_dark',
\ 'active': {
\ 'left': [
\ [ 'mode', 'paste' ],
\ [ 'readonly', 'filename', 'modified' ]
\ ]
\ },
\ 'tabline': {
\ 'right': []
\ },
\ }
" }}}
" SPaceHi {{{
augroup spacehi
autocmd!
autocmd BufNewFile,BufRead * SpaceHi
autocmd BufNewFile,BufRead * syntax clear spacehiTab
augroup END
" }}}
" ALE {{{
" Enable completion
let g:ale_completion_enabled = 1
" Enable fixers
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'rust': ['rustfmt'],
\ 'sh': ['shfmt'],
\ }
let g:ale_fix_on_save = 1
let g:ale_fix_on_save_ignore = {
\ 'diff': ['trim_whitespace'],
\ }
" Configure go to definition
nnoremap <C-LeftMouse> :ALEGoToDefinition<CR>
" Rust options
let g:ale_rust_cargo_check_tests = 1
let g:ale_rust_cargo_check_examples = 1
" Shfmt options
let g:ale_sh_shfmt_options = '-s -p'
" }}}
" }}}