-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimrc
More file actions
204 lines (170 loc) · 5.86 KB
/
.vimrc
File metadata and controls
204 lines (170 loc) · 5.86 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
" become ~*~modern~*~
set nocompatible
set encoding=utf-8
set exrc
set secure
" file highlighting
syntax enable
" file-specific indenting
filetype plugin indent on
" On Windows, use Unix line endings
set fileformats=unix,dos
set fileformat=unix
" persistent-undo
set undofile
autocmd BufWritePre /tmp/* setlocal noundofile
" tab settings
set smarttab
augroup vimrc
autocmd!
autocmd BufWritePre /tmp/* setlocal noundofile
" extra filetype detection
autocmd BufNewFile,BufRead *.asm set filetype=nasm
autocmd BufNewFile,BufRead *.{mjs,cjs} set filetype=javascript
autocmd BufNewFile,BufRead *.{mts,cts} set filetype=typescript
autocmd BufNewFile,BufRead *.{gohtml,html.jinja,html.j2} set filetype=html
" default tab settings (needs to be autocmd b/c these are buffer-local)
autocmd FileType * setlocal tabstop=8 softtabstop=2 expandtab shiftwidth=2 autoindent copyindent
" language-specific settings
autocmd Filetype glsl setlocal tabstop=4 softtabstop=0 noexpandtab shiftwidth=4
autocmd Filetype go setlocal tabstop=8 softtabstop=0 noexpandtab shiftwidth=8
autocmd Filetype make setlocal tabstop=4 softtabstop=0 noexpandtab shiftwidth=4
autocmd Filetype markdown setlocal spell textwidth=79
autocmd Filetype python setlocal tabstop=4 softtabstop=4 expandtab shiftwidth=4
autocmd Filetype rust setlocal tabstop=4 softtabstop=4 expandtab shiftwidth=4
autocmd Filetype tex setlocal spell
" tex keybindings (up arrow goes into wrap)
autocmd Filetype tex noremap <silent> <Up> gk
autocmd Filetype tex noremap <silent> <Down> gj
autocmd Filetype tex inoremap <silent> <Up> <C-o>gk
autocmd Filetype tex inoremap <silent> <Down> <C-o>gj
augroup END
" Commands to specifically use tabs/spaces for a given file
command! -nargs=0 Tabs :setlocal tabstop=8 softtabstop=0 noexpandtab shiftwidth=8
command! -nargs=0 Spaces :setlocal tabstop=8 softtabstop=2 expandtab shiftwidth=2
" see tabs
set list
set listchars=tab:▶·
" natural backspace, linewrap settings
set backspace=indent,eol,start
set whichwrap=<,>,[,]
" Open all folds by default (use zM to close all folds)
set foldlevel=99
set foldlevelstart=99
" column to not go over
set colorcolumn=+1
highlight ColorColumn ctermbg=darkgray
" searching
set wildmenu
set hlsearch
set incsearch
set showmatch
set smartcase
" left side
set number
set ruler
set hidden
" allows using <Esc> when in terminal windows
tnoremap <Esc> <C-\><C-n>
" allows use of mouse
set mouse=a
" makes it so colors show up correctly in tmux
set background=dark
" make it so colors show up correctly in cmd.exe
set termguicolors
" Maybe I'll do per-filetype colorschemes someday? For the most popular
" filetypes.
let g:normal_colorschemes = [
\ 'base24-espresso',
\ 'base16-da-one-gray',
\ 'base16-decaf',
\ 'base16-eighties',
\ 'base16-precious-dark-eleven',
\ 'base16-tomorrow-night',
\ 'base16-solarflare',
\ ]
" I _don't_ want my nvim panes to be the same color as normal panes
" actually
" \ 'base16-helios',
command Colo execute 'colorscheme' normal_colorschemes[rand() % len(normal_colorschemes)]
let g:light_colorschemes = [
\ 'base16-da-one-white',
\ 'base16-equilibrium-light',
\ ]
" \ 'base16-ia-light',
" \ 'base16-precious-light-white',
command ColoLight execute 'colorscheme' light_colorschemes[rand() % len(light_colorschemes)]
let bad_colorschemes = [
\ 'base16-horizon-dark',
\ 'base24-borland',
\ 'base24-ic-green-ppl',
\ 'base24-ic-orange-ppl',
\ 'blue',
\ 'habamax',
\ 'sorbet',
\ 'unokai',
\ 'wildcharm',
\ ]
command ColoBad execute 'colorscheme' bad_colorschemes[rand() % len(bad_colorschemes)]
" Set the color scheme
if !exists('g:colors_name')
" This is my definite favorite, though others in :Colo are nice too
colorscheme base24-espresso
endif
" Don't pass messages to |ins-completion-menu|
set shortmess+=c
" Allow copy with Ctrl+Shift+C
vnoremap <C-S-c> "+y
" Allow copy with Super+C
vnoremap <D-c> "+y
" Default OS paste support (at least for Kitty) includes Ctrl+Shift+V and
" Super+V. Configure these in the terminal, and they _should_ "just work" here.
" Pasting in WSL is a bit trickier, however:
if $DOTFILES_WSL != ""
" First, we have to set up the correct keyboard handlers
let g:clipboard = {
\ 'name': 'WslClipboard',
\ 'copy': {
\ '+': 'clip.exe',
\ '*': 'clip.exe',
\ },
\ 'paste': {
\ '+': 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
\ '*': 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
\ },
\ 'cache_enabled': 0,
\ }
" Then, because the above shortcuts are incompatible, we need to use others:
" Allow copy with Alt+Shift+C
vnoremap <M-C> "+y
" Allow paste with Alt+Shift+V
noremap <M-V> <cmd>norm "+p<cr>
inoremap <M-V> <cmd>norm "+p<cr>
endif
" Open file from OS clipboard. Only works in normal mode due to restrictions
" of <cmd>
nnoremap <leader>po :tabedit <C-r>+<cr>
" Open file from default clipboard
nnoremap <leader>pp :tabedit <C-r>"<cr>
" better tab navigation commands (from vim-unimpaired)
noremap [<Tab> <cmd>tabprevious<cr>
noremap ]<Tab> <cmd>tabnext<cr>
" better window navigation commands (my own invention)
noremap [w <C-w>W
noremap ]w <C-w>w
" better hunk navigation (like vim-unimpaired but respects count)
function! s:Context(reverse, count) abort
let i = 0
let count = a:count > 0 ? a:count : 1
while i < count
call search('^\(@@ .* @@\|[<=>|]\{7}[<=>|]\@!\)', a:reverse ? 'b' : '')
let i += 1
endwhile
endfunction
" TODO: document these somehow
noremap [n <cmd>call <SID>Context(1, v:count)<cr>
noremap ]n <cmd>call <SID>Context(0, v:count)<cr>
" quickly open current window in new tab
noremap <C-w>n <cmd>tab split<cr>
" ocamlformat
set rtp^="$HOME/.opam/default/share/ocp-indent/vim"