-
Notifications
You must be signed in to change notification settings - Fork 2
/
.vimrc
355 lines (292 loc) · 10.3 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
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
343
344
345
346
347
348
349
350
351
352
353
354
355
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
call plug#begin("~/.vim/plugged")
" Better status bar
Plug 'vim-airline/vim-airline'
" Clock for the status bar
Plug 'enricobacis/vim-airline-clock'
" Themes for that status bar
Plug 'vim-airline/vim-airline-themes'
" Commenting lines
Plug 'tpope/vim-commentary'
" Git for vim
Plug 'tpope/vim-fugitive'
" Paper color theme
Plug 'NLKNguyen/papercolor-theme'
" NERD tree will be loaded on the first invocation of NERDTreeToggle command
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
" Add git flags to nerdtree
Plug 'Xuyuanp/nerdtree-git-plugin'
" Add git gutter to files
if has('nvim') || has('patch-8.0.902')
Plug 'mhinz/vim-signify'
else
Plug 'mhinz/vim-signify', { 'branch': 'legacy' }
endif
" Requirement for bash server
Plug 'prabirshrestha/vim-lsp'
if executable('bash-language-server')
au User lsp_setup call lsp#register_server({
\ 'name': 'bash-language-server',
\ 'cmd': {server_info->['bash-language-server', 'start']},
\ 'allowlist': ['sh', 'bash'],
\ })
endif
if executable('rustup')
au User lsp_setup call lsp#register_server({
\ 'name': 'rust-analyzer',
\ 'cmd': {server_info->['rustup', 'run', 'stable', 'rust-analyzer']},
\ 'allowlist': ['rust'],
\ })
endif
" rust vim is the official plugin for rust
Plug 'rust-lang/rust.vim'
" webapi connection to help with rust playground
Plug 'mattn/webapi-vim'
" NvimR is the ESS of vim
Plug 'jalvesaq/Nvim-R' ", {'branch': 'stable'}
" Plugin to work with Nvim-R that includes devtools
Plug 'mllg/vim-devtools-plugin'
" Pandoc syntax for Rmarkdown
Plug 'vim-pandoc/vim-pandoc-syntax'
" SuperCollider Audio Synthesis vim integration
Plug 'supercollider/scvim'
" Aligning assignment operators
" https://stackoverflow.com/q/16522235/2752888
Plug 'vim-scripts/Align'
" hybrid relative line numbers
" https://jeffkreeftmeijer.com/vim-number/
Plug 'jeffkreeftmeijer/vim-numbertoggle'
" context-aware scrolling for looooong nested elements
Plug 'wellle/context.vim'
" zen mode for vim
Plug 'junegunn/goyo.vim'
" dim all but current section when writing
Plug 'junegunn/limelight.vim'
" editorconfig file support
Plug 'editorconfig/editorconfig-vim'
" View ANSI colors in vim
Plug 'chrisbra/Colorizer'
" Indentation guides
Plug 'nathanaelkane/vim-indent-guides'
call plug#end()
" Global options
" ===============================================
set hidden " Allows for hidden buffers in the background
set cursorline " Highlights the current line
set number relativenumber " Number all the lines relative to cursor
set expandtab " Use spaces for tabs
set cc=81 " Set the color column at 81
set tabstop=2
set shiftwidth=2
set formatoptions=tcqr
" t auto-wrap text
" c auto-wrap commetns
" q allow comments to wrap
" r auto-continue comment lines
" https://stackoverflow.com/a/11560415/2752888
set list " Display unprintable characters f12 - switches
set listchars=tab:<->,trail:•,extends:»,precedes:« " Unprintable chars mapping
set backspace=indent,eol,start " more powerful backspacing
" To change the hellacious CTRL-W to a much more wrist-friendly alternative
" https://vi.stackexchange.com/a/3729/18729
:nnoremap <Leader>w <C-w>
" Give me a testthat snippet
autocmd Filetype r :iabbrev tt <CR>test_that("", {<CR><CR>})<CR><UP><UP><UP><esc>wll
" Move visual selection
" J will move lines down, K will move lines up
vnoremap J :m '>+1<cr>gv=gv
vnoremap K :m '<-2<cr>gv=gv
" have vim save the backups in the /tmp/ directory, remembering the
" file path of the files
" https://stackoverflow.com/a/4824781/2752888
set backupdir=~/.vim/tmp//
set directory=~/.vim/tmp//
augroup pandoc_syntax
au! BufNewFile,BufFilePre,BufRead *.qmd set filetype=markdown.pandoc
au! BufNewFile,BufFilePre,BufRead *.Rmd set filetype=markdown.pandoc
au! BufNewFile,BufFilePre,BufRead *.md set filetype=markdown.pandoc
au! BufNewFile,BufFilePre,BufRead *.markdown set filetype=markdown.pandoc
augroup END
" Copy to clipboard
" https://stackoverflow.com/a/15971506/2752888
if has('mac')
vnoremap <C-c> :w !pbcopy<CR><CR>
let g:rust_clip_command = 'pbcopy'
else
vnoremap <C-C> :w !xclip -i -sel c<CR><CR>
let g:rust_clip_command = 'xclip -selection clipboard'
endif
" Use Ctrl+Space to do omnicompletion:
if has('nvim') || has('gui_running')
inoremap <C-Space> <C-x><C-o>
else
inoremap <Nul> <C-x><C-o>
endif
" https://stackoverflow.com/a/33358103/2752888
set mouse=a
" Airline options
" ===============================================
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#whitespace#enabled = 0
let g:airline#extensions#clock#format = '%b%d %H:%M'
let g:airline#parts#ffenc#skip_expected_string='utf-8[unix]'
let g:airline#extensions#wordcount#formatter#default#fmt = 'W:%s'
let g:airline#extensions#wordcount#formatter#default#fmt_short = 'W:%s'
"
" Color Scheme Options
" ===============================================
set termguicolors " needed for ayucolor to work
let g:indent_guides_start_level = 3
let g:indent_guides_enable_on_vim_startup = 1
let g:PaperColor_Theme_Options = {
\ 'theme': {
\ 'default': {
\ 'transparent_background': 1,
\ 'allow_bold': 1,
\ 'allow_italic': 1,
\ }
\ }
\ }
" ChangeBackground changes the background mode based on macOS's `Appearance`
" setting. We also refresh the statusline colors to reflect the new mode.
function! SyncSignColumn()
let sccolor = system("(kitty @ get-colors | grep '^background ' | sed -e 's/^background *'//) || echo NONE")
if sccolor != 'NONE'
execute 'highlight SignColumn guibg='.sccolor
endif
endfunction
function! ChangeBackground()
if system("black_cat") =~ '1'
set background=light " for the light version of the theme
else
set background=dark " for the dark version of the theme
endif
colorscheme PaperColor
try
execute "AirlineRefresh"
catch
endtry
try
call SyncSignColumn()
catch
endtry
endfunction
let g:airline_theme="sol"
" initialize the colorscheme for the first run
call ChangeBackground()
" change the color scheme if we receive a SigUSR1
" autocmd SigUSR1 * call ChangeBackground()
" Alignment options
" ===============================================
" align arrows in R
vnoremap <leader>tar :Align <-<CR><CR>
" align comments in bash/r/python/etc
vnoremap <leader>tac :Align #<CR><CR>
" vim-signify options
" ===============================================
if has('nvim') || has('patch-8.0.902')
set updatetime=100
endif
" DistractFree options
" ===============================================
let g:distractfree_width = '90' " 80 columns
" Editorconfig options
" ===============================================
" allows EditorConfig work well with fugitive
let g:EditorConfig_exclude_patterns = ['fugitive://.*']
" context.vim options
" ===============================================
let g:context_add_mappings = 0
" NERD Tree options
" ===============================================
" Mapping ctrl+n to toggle file tree
map <cr> :NERDTreeToggle<CR>
" Show Hidden files
let NERDTreeShowHidden=1
" setings :: rust.vim plugin
let g:rustfmt_autosave = 1
" settings :: Nvim-R plugin
" ===============================================
" This searches if radian (an enhanced client for R) is installed
" https://github.com/randy3k/radian
if executable('radian')
let R_app = "radian"
let R_cmd = "R"
let R_hl_term = 0
let R_args = []
let R_bracketed_paste = 1
else
" Default arguments on start
let R_args = ['--no-save', '--no-restore']
endif
" Let me have my snake case :}~~<
let R_assign = 0
" R output is highlighted with current colorscheme
let g:rout_follow_colorscheme = 1
"
" R commands in R output are highlighted
let g:Rout_more_colors = 1
" set a minimum source editor width
let R_min_editor_width = 80
" set the working directory to be vim's working directory
let R_nvim_wd = 1
" control the size of the R console
let R_rconsole_width = winwidth(0) / 2
let R_rconsole_height = 10
autocmd VimResized * let R_rconsole_width = winwidth(0) / 2
" Don't expand a dataframe to show columns by default
let R_objbr_opendf = 0
" disable annoying arg indent
let r_indent_align_args = 0
" Press the space bar to send lines and selection to R console
vmap <Space> <Plug>RDSendSelection
nmap <Space> <Plug>RDSendLine
" Switch between file and test
function! SwitchTestBuddy()
let f = expand('%:t')
if expand('%:p:h:t') == 'testthat'
execute ':edit R/'..substitute(f, 'test-', '', '')
else
execute ':edit tests/testthat/test-'..f
endif
endfunction
" Mappings for devtools vim
map <c-L> :RLoadPackage<CR>
map <c-D> :RDocumentPackage<CR>
map <c-T> :RTestPackage<CR>
map <tab> :call devtools#test_file()<CR>
map <c-O> :call SwitchTestBuddy()<CR>
map <c-E> :RCheckPackage<CR>
" Grep options
:let Grep_Skip_Dirs = '.git .Rproj.user'
if executable("rg")
set grepprg=rg\ --vimgrep\ --smart-case\ --hidden
set grepformat=%f:%l:%c:%m
endif
" SuperCollider Options
" =====================================
" Highlight the evaluated line
let g:scFlash = 1
" Remap the F5 and F6 to ones that work better for my keyboard since it's kind
" of awkward for me to type both fn and F{5,6} keys at the same time. I'm
" copying these directly from
" https://github.com/supercollider/scvim/blob/master/plugin/supercollider.vim
au Filetype supercollider nnoremap <leader>sc :call SClangStart()<CR>
au Filetype supercollider nnoremap <leader>b :call SendToSC('s.boot;')<CR>
au Filetype supercollider nnoremap <leader>t :call SendToSC('s.plotTree;')<CR>
au Filetype supercollider nnoremap <leader>m :call SendToSC('s.meter;')<CR>
" Sending a block of sc code <leader>f(eans)
" au Filetype supercollider inoremap <leader>f :call SClang_block()<CR>a
au Filetype supercollider nnoremap <leader>f :call SClang_block()<CR>
au Filetype supercollider vnoremap <leader>f :call SClang_send()<CR>
" Sending a single line is <Space>
au Filetype supercollider vnoremap <buffer> <Space> :call SClang_line()<CR>
au Filetype supercollider nnoremap <buffer> <Space> :call SClang_line()<CR>
" au Filetype supercollider inoremap <buffer> <Space> :call SClang_line()<CR>a
" Hardstop is <leader>x
au Filetype supercollider nnoremap <leader>x :call SClangHardstop()<CR>