-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdot-vimrc
318 lines (261 loc) · 8.67 KB
/
dot-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
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
" This is MoniqueLive's .vimrc file
" vim:set ts=2 sts=2 sw=2 expandtab foldenable:
set nocompatible
filetype off
filetype plugin indent on
set sessionoptions-=options
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
"---------------------------------------------------------------- plugins {{{1
call plug#begin('~/.vim/plugged')
" startup
Plug 'ryanoasis/vim-devicons'
Plug 'mhinz/vim-startify'
" tpope fandom
Plug 'tpope/vim-characterize'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-rsi'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-vinegar'
" misc
Plug 'wincent/terminus'
"Plug 'tmux-plugins/vim-tmux-focus-events'
Plug 'bronson/vim-trailing-whitespace'
" coding
Plug 'AndrewRadev/splitjoin.vim'
Plug 'tommcdo/vim-lion'
Plug 'andymass/vim-matchup'
Plug 'editorconfig/editorconfig-vim'
Plug 'catppuccin/vim', { 'as': 'catppuccin' }
packadd! editexisting
" Initialize plugin system
call plug#end()
runtime ftplugin/man.vim
"-------------------------------------------------------- CYBERAMA - begin ---
augroup file_types " {
au!
au BufWritePost $MYVIMRC source $MYVIMRC
au BufRead,BufNewFile *.asm setlocal filetype=nasm
au BufRead,BufNewFile *.gohtml setlocal filetype=template
augroup END " }
let g:netrw_altfile = 1 " <C-6> returns to files
"-------------------------------------------------------- global defaults {{{1
set tabstop=2 softtabstop=2 shiftwidth=2 shiftround expandtab nowrap
\ noswapfile incsearch cursorline noshowmode
\ textwidth=0 colorcolumn=+1
\ ignorecase smartcase
\ number
\ signcolumn=yes
\ laststatus=2
\ showtabline=2
\ switchbuf=useopen
\ termencoding=utf-8 encoding=utf-8
\ visualbell noerrorbells
\ splitbelow splitright
\ tags^=./.git/tags;
\ autowriteall
\ scrolloff=1
\ backspace=indent,eol,start
\ showcmd
\ nojoinspaces
\ autoread
\ autoindent copyindent smartindent
\ mouse=a mousehide
\ viewoptions=folds,options,cursor,unix,slash
\ history=1000
\ iskeyword-=.
\ iskeyword-=#
\ iskeyword-=-
\ laststatus=3
\ equalalways
scriptencoding utf-8
"set clipboard+=unnamedplus
" Autosave on focus lost
autocmd FocusLost * silent! wa
" let terminal resize scale the internal windows
autocmd VimResized * :wincmd =
" Prevent Vim from clobbering the scrollback buffer. See
" http://www.shallowsky.com/linux/noaltscreen.html
set t_ti= t_te=
" Store temporary files in a central spot
set undodir=~/.vim/tmp/undo//
set backupdir=~/.vim/tmp/backup//
set directory=~/.vim/tmp/swap//
" set backup " Backups are nice ...
if has('persistent_undo')
set undofile " So is persistent undo ...
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
"---------------------------------------------------------------- helpers {{{1
""""""""""""""""""""""""""""""""""""""""""" RemoveFancyCharacters COMMAND {{{2
function! RemoveFancyCharacters()
let typo = {}
let typo["“"] = '"'
let typo["”"] = '"'
let typo["‘"] = "'"
let typo["’"] = "'"
let typo["–"] = '--'
let typo["—"] = '---'
let typo["…"] = '...'
:exe ":%s/".join(keys(typo), '\|').'/\=typo[submatch(0)]/ge'
endfunction
command! RemoveFancyCharacters :call RemoveFancyCharacters()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Reg COMMAND {{{2
function! Reg()
reg
echo "Register: "
let char = nr2char(getchar())
if char != "\<Esc>"
execute "normal! \"".char."p"
endif
redraw
endfunction
command! -nargs=0 Reg call Reg()
""""""""""""""""""""""""""""""""""""""""" create intermediary directories {{{2
fun! <SID>AutoMakeDirectory()
let s:directory = expand("<afile>:p:h")
if !isdirectory(s:directory)
call mkdir(s:directory, "p")
endif
endfun
autocmd BufWritePre,FileWritePre * :call <SID>AutoMakeDirectory()
cnoremap %% <C-R>=fnameescape(expand('%:h')).'/'<cr>
noremap Q !!sh<CR>
"----------------------------- Use 24-bit (true-color) mode in Vim/Neovim {{{2
if exists("$TMUX") || exists("$SSH_TTY")
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
else
let &t_ZH = "\<Esc>[3m"
let &t_ZR = "\<Esc>[23m"
endif
if has("termguicolors")
set termguicolors
endif
set background=dark " for the dark version
colorscheme catppuccin_mocha
"---------------------------------------------------------------- folding {{{2
nnoremap z0 :setlocal foldlevel=0<cr>
nnoremap z1 :setlocal foldlevel=1<cr>
nnoremap z2 :setlocal foldlevel=2<cr>
nnoremap z3 :setlocal foldlevel=3<cr>
nnoremap z4 :setlocal foldlevel=4<cr>
nnoremap z5 :setlocal foldlevel=5<cr>
if 0 " if 0 / endif HACK
i
" Folding rules {{{2
set nofoldenable " enable folding
set foldcolumn=2 " add a fold column
set foldmethod=marker " detect triple-{ style fold markers
set foldlevelstart=99 " start out with everything unfolded
set foldopen=block,hor,insert,jump,mark,percent,quickfix,search,tag,undo
" which commands trigger auto-unfold
function! MyFoldText()
let line = getline(v:foldstart)
let nucolwidth = &fdc + &number * &numberwidth
let windowwidth = winwidth(0) - nucolwidth - 3
let foldedlinecount = v:foldend - v:foldstart
" expand tabs into spaces
let onetab = strpart(' ', 0, &tabstop)
let line = substitute(line, '\t', onetab, 'g')
let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
let fillcharcount = windowwidth - len(line) - len(foldedlinecount) - 4
return line . ' …' . repeat(" ",fillcharcount) . foldedlinecount . ' '
endfunction
set foldtext=MyFoldText()
.
endif
" Subtle search highlights
highlight Search ctermbg=black ctermfg=yellow term=underline
highlight Comment cterm=italic gui=italic
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %
" Alternate buffer (easier than <C-^>)
nmap <leader><leader> <c-^>
" system clipboard's copy/paste
vnoremap <leader>y "+y
nnoremap <leader>y "+y
nnoremap <leader>Y "+Y
nnoremap <leader>p "+p
nnoremap <leader>P "+P
nnoremap <D-v> "+p
nnoremap <D-V> "+P
" See http://stevelosh.com/blog/2010/09/coming-home-to-vim
nnoremap / /\v
vnoremap / /\v
" Disable highlight when <leader><cr> is pressed
map <silent> <leader><cr> :noh<cr>
" Move around splits with <c-hjkl>
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
nnoremap <leader>w <C-w>v<C-w>l
nnoremap <leader>l <C-l>
" Resize splits
nnoremap <C-S-j> <c-w>+
nnoremap <C-S-k> <c-w>-
nnoremap <m-,> <c-w><
nnoremap <m-.> <c-w>>
" Open window below instead of above"
nnoremap <c-w>N :let sb=&sb<BAR>set sb<BAR>new<BAR>let &sb=sb<CR>
" Vertical equivalent of c-w-n and c-w-N"
nnoremap <c-w>v :vnew<CR>
nnoremap <c-w>V :let spr=&spr<BAR>set nospr<BAR>vnew<BAR>let &spr=spr<CR>
" Easier split resizing (shift - and shift +)
nnoremap _ <c-w>-
nnoremap + <c-w>+
" neovim, dont reinvent the wheel <3
nnoremap Y yy
set nohidden
"---------------------------------------------------------------- startify ---
let g:startify_change_to_dir = 0
let g:startify_change_to_vcs_root = 1
if has("gui_macvim") && has("gui_running")
xmap <D-/> <Plug>Commentary
imap <D-/> <Plug>Commentary
nmap <D-/> <Plug>CommentaryLine
else
nmap <leader>/ <Plug>CommentaryLine
xmap / <Plug>Commentary
endif
" Dont fold foldable files by default
if has("autocmd")
augroup Unfolding
autocmd!
autocmd BufRead * normal zR
augroup END
augroup GitCommitSpellCheck
" Spell checking for git commit messages
autocmd!
autocmd FileType gitcommit set spell
augroup END
augroup RubyFrozenStringLiteral
autocmd!
autocmd FileType ruby iabbrev fsl # frozen_string_literal: true
augroup END
augroup VimHelpNavigation
autocmd!
autocmd FileType help nnoremap <buffer> <CR> <C-]>
autocmd FileType help nnoremap <buffer> <BS> <C-T>
autocmd FileType help nnoremap <buffer> o /'\l\{2,\}'<CR>
autocmd FileType help nnoremap <buffer> O ?'\l\{2,\}'<CR>
autocmd FileType help nnoremap <buffer> s /\|\zs\S\+\ze\|<CR>
autocmd FileType help nnoremap <buffer> S ?\|\zs\S\+\ze\|<CR>
augroup END
if ! has('gui_running')
set ttimeoutlen=10 lazyredraw
augroup FastEscape
autocmd!
au InsertEnter * set timeoutlen=0
au InsertLeave * set timeoutlen=1000
augroup END
endif
endif