-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvimrc
More file actions
343 lines (248 loc) · 8.08 KB
/
vimrc
File metadata and controls
343 lines (248 loc) · 8.08 KB
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
set nocompatible
" Set term settings to xterm-256
if &term == "xterm"
set term=xterm-256color
endif
" Set terminal font encoding
set encoding=utf-8
set termencoding=utf-8
"{{{ General settings
" Turn on syntax highlighting
syntax on
" Set colorscheme to our custom color
colorscheme desert256m
" Disable JSON concealment
let g:vim_json_conceal = 0
" Save up to 200 commands executed
set history=200
" enable filetype detection:
filetype on
filetype plugin on
filetype indent on
" Set the leader for the whole file
let mapleader = ","
" Fold by marker by default '{{{' and '}}}'
set foldmethod=marker
" Cool tab completion stuff
set wildmenu
"set wildmode=list:longest,full
set wildmode=list:list:longest
set wildignore+=*.swp,*.zip,*.tar,*.gz,*.class,*.o
" Allow backspace over newlines
set backspace=2
" Allow buffers to move to the background without
" complaining about needing to be saved
set hidden
" Define the location of our exuberant ctags file
set tags=./tags;/
"}}}
"{{{ Display settings
" Show matching parens, brackets, etc
set showmatch
" Show commands as you're typing them
set showcmd
" Show the cursor position ruler at the bottom
set ruler
" Display nonprintable characters
"set list
" Display tabs as dot-space instead of ^I
"set listchars=tab:»\ ,trail:·,nbsp:·
" Scroll offset of 3
set scrolloff=3
" Turn on line numbers
"set nu
" Display a line at column 81 to let us know not to enter or cross it.
set colorcolumn=80
" Change the background color the hightlight menu from ugly pink to nice blue
:highlight Pmenu ctermbg=DarkBlue ctermfg=white gui=bold
:highlight PmenuSel ctermbg=LightBlue ctermfg=red gui=bold
" Highlight trailing whitespace with a red background
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/ " This will not match trailing whitespace when typing on a line
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
" }}}
"{{{ Spacing and tabbing
set shiftwidth=2
set tabstop=2
set expandtab
set smarttab
set nowrap
set smartindent
" }}}
" {{{ Search, replace, and paste
" Ignore case in search - except...
set ignorecase
" Only do case-sensitive search when a capital has been typed
set smartcase
" Search right when you start typing
set incsearch
" Highlight the found search
set hlsearch
" Toggle paste mode
set pastetoggle=<F10>
"}}}
"{{{ Mouse options
set mouse=a
"set mousemodel=popup
if !has('nvim')
set ttymouse=xterm2
endif
" set up command mode abbreviations for mouseoff and mouseon
cabbrev mouseoff set mouse=<CR>
cabbrev mouseon set mouse=a<CR>
"}}}
"{{{ User Interface
" Status line settings
set laststatus=2 "Always have a status line
set statusline=%-3.3n\ %f%(\ %r%)%(\ %%m%0*%)%=%{LinterStatus()}\ (%l,\ %c)\ %P\ [%{&encoding}%{&fileformat}]%(\ %w%)\ %y
set shortmess+=aI "Use nice short status notices
hi StatusLine term=inverse cterm=NONE ctermfg=white ctermbg=black
hi StatusLineNC term=none cterm=NONE ctermfg=darkgray ctermbg=black
"}}}
"{{{ Auto Commands
" When editing a file, always jump to the last cursor position
au BufReadPost *
\ if ! exists("g:leave_my_cursor_position_alone") |
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif |
\ endif
" }}}
" {{{ Git settings
" Go to the top of git commit files, do not remember where we left off
autocmd BufReadPost COMMIT_EDITMSG exe "normal gg"
autocmd BufReadPost COMMIT_EDITMSG exe "normal $a"
" Enable spell-checking for commit messages
autocmd BufNewFile,BufReadPost COMMIT_EDITMSG set spell
" Wrap commit messages at 72 chars
autocmd BufNewFile,BufReadPost COMMIT_EDITMSG set tw=72
" }}}
"{{{ Mappings
" disable stop/quit (only works with stty -ixon)
:map <C-s> :"stop/quit disabled!<CR>
:map <C-q> :"stop/quit disabled!<CR>
" disable suspend
:map <C-z> :"suspending disabled!<CR>
" Space will toggle folds. Very helpful.
nnoremap <space> za
" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
map N Nzz
map n nzz
map * *zz
map # #zz
" Left/Right arrows to previous/next buffer
map <left> :bp<CR>
map <right> :bn<CR>
" Tab/Shift-tab to previous/next buffer
nmap <S-tab> :bp<CR>
nmap <tab> :bn<CR>
" Control arrows move tabs
map <C-l> :tabn<CR>
map <C-h> :tabp<CR>
" Tab commands
map <leader>tc :tabnew<cr>
map <leader>td :tabclose<cr>
map <leader>tm :tabmove
map <leader>tn :tabnext<cr>
map <leader>tp :tabprevious<cr>
nmap <F6> :call ToggleList()<CR>
" Load/Source the vimrc quickly
nmap <leader>s :source $MYVIMRC<CR>
nmap <leader>e :e $MYVIMRC<CR>
" Quickly delete a buffer
nmap <leader>d :b#<bar>bd#<CR>
" Quickly toggle spellcheck
nmap <leader>l :set spell!<CR>
" Mapping to remove all trailing whitespace on lines
nmap <leader>w :%s/\s\+$//<CR>:let @/=''<CR>
" Change to current file directory upon request
nmap <silent> <Leader>cd :cd %:p:h<CR>
nmap <leader>fw :set autoindent cindent shiftwidth=2 tabstop=2 expandtab smarttab<CR>
" Make horizontal scrolling faster
nnoremap zh 20zh
nnoremap zl 20zl
" This is totally awesome - remap jj to escape in insert mode. You'll never type jj anyway, so it's great!
inoremap jj <Esc>
" Use Tab and Shift Tab to go through autocomplete options
inoremap <expr> <TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
inoremap <expr> <S-TAB> pumvisible() ? "\<C-p>" : "\<TAB>"
" }}}
"{{{ Backup settings
set writebackup " We want to write a backup file
set backupdir=~/.vim/backup,.,~/tmp,~/ " Store the backup file outside the current directory if it exists
set directory=~/.vim/tmp,.,~/tmp,/var/tmp,/tmp " Store the swap file outside the current directory if it exists
if version >= 703
" Set persistent undo within files
set undodir=~/.vim/undodir
set undofile
set undolevels=1000 "maximum number of changes that can be undone
set undoreload=10000 "maximum number lines to save for undo on a buffer reload
endif
" }}}
"{{{ Testbed
" Ignore diff whitespace
set diffopt+=iwhite
" Test out omnicompletion
"set ofu=ale#completion#OminFunc
" Search the current file for what's currently in the search register and display matches
nmap <silent> ,gs :vimgrep /<C-r>// %<CR>:ccl<CR>:cwin<CR><C-W>J:nohls<CR>
" Search the current file for the word under the cursor and display matches
nmap <silent> ,gw :vimgrep /<C-r><C-w>/ %<CR>:ccl<CR>:cwin<CR><C-W>J:nohls<CR>
" Search the current file for the WORD under the cursor and display matches
nmap <silent> ,gW :vimgrep /<C-r><C-a>/ %<CR>:ccl<CR>:cwin<CR><C-W>J:nohls<CR>
" }}}
" Plugin settings {{{
" Specify directory for plugins
call plug#begin('~/.vim/plugged')
let g:ale_completion_enabled = 1
Plug 'Yggdroot/indentLine'
Plug 'dense-analysis/ale'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Plug 'leafOfTree/vim-svelte-plugin'
Plug 'leafgarland/typescript-vim', { 'do': '~/.vim/bundle/typescript-vim' }
Plug 'tpope/vim-dadbod'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-haml'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-liquid'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'thoughtbot/vim-rspec'
Plug 'martinda/Jenkinsfile-vim-syntax'
" Initialize plugin system
call plug#end()
" {{{ vim-svelte-plugin
let g:vim_svelte_plugin_use_typescript = 1
" }}}
" {{{ fugitive
nnoremap <Leader>gb :Gblame<Enter>
nnoremap <Leader>gd :Gdiff<Enter>
nnoremap <Leader>gl :Glog<Enter>
nnoremap <Leader>gs :Gstatus<Enter>
" }}}
" {{{ ale
let g:ale_set_balloons = 1
let g:ale_ruby_rubocop_executable = 'bundle'
let g:ale_ruby_standardrb_executable = 'bundle'
let g:ale_fix_on_save = 1
let g:ale_linters = {
\ 'go': ['gopls'],
\}
let g:ale_fixers = {
\ 'svelte': ['prettier'],
\ 'javascript': ['prettier'],
\ 'css': ['prettier'],
\}
function! LinterStatus() abort
let l:counts = ale#statusline#Count(bufnr(''))
let l:ok_msg = '⬥ ok'
let l:count_msg = '⨉ %d, ⚠ %d'
let l:all_errors = l:counts.error + l:counts.style_error
let l:all_non_errors = l:counts.total - l:all_errors
return l:counts.total == 0 ? ok_msg : printf(count_msg, all_errors, all_non_errors)
endfunction
" }}}