-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
418 lines (358 loc) · 13.4 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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
" ~./.vimrc
"
runtime! debian.vim
" sets 'nocompatible'
set nocompatible
filetype off
call plug#begin()
Plug 'Valloric/YouCompleteMe'
Plug 'vim-syntastic/syntastic'
Plug 'jalvesaq/Nvim-R'
Plug 'tyru/open-browser.vim'
Plug 'airblade/vim-gitgutter'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'edkolev/tmuxline.vim'
Plug 'jimhester/lintr'
Plug 'mkitt/tabline.vim'
Plug 'kannokanno/previm'
"Plug 'suan/vim-instant-markdown'
Plug 'wesQ3/vim-windowswap'
Plug 'vim-pandoc/vim-pandoc'
Plug 'vim-pandoc/vim-pandoc-syntax'
"Plug 'vim-pandoc/vim-rmarkdown'
Plug 'vim-scripts/matchit.zip'
Plug 'craigemery/vim-autotag'
"Plug 'junegunn/fzf'
"Plug 'soywod/himalaya'
"colorschemes (see https://vimcolors.com/):
Plug 'altercation/vim-colors-solarized'
"Plug 'atahabaki/archman-vim'
Plug 'sickill/vim-monokai'
Plug 'jdsimcoe/hyper.vim'
Plug 'megantiu/true.vim'
Plug 'cormacrelf/vim-colors-github'
"Plug 'jreybert/vimagit'
Plug 'preservim/tagbar'
"Plug 'jupyter-vim/jupyter-vim'
"Plug 'pangloss/vim-javascript'
Plug 'Exafunction/codeium.vim'
call plug#end()
filetype plugin indent on
"execute pathogen#infect()
if has("syntax")
syntax on
endif
"if has ('gui_running')
" set background=light
"else
" set background=dark
"endif
set t_Co=16
let g:solarized_termcolors=16
set background=dark
"colorscheme github "light
"colorscheme monokai "dark
colorscheme true "dark
if has("autocmd")
" Jump to the last position when reopening a file
"au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
" Load indentation rules and plugins according to the detected filetype.
" Note these are essential for r-plugin!
filetype plugin on
" filetype indent on " set above for vundle
endif
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set ignorecase " Do case insensitive matching
set smartcase " Do smart case matching
set incsearch " Incremental search
"set autowrite " Automatically save before commands like :next and :make
set hidden " Hide buffers when they are abandoned
" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
" Extra config lines
set modelines=0
set tabstop=4
set shiftwidth=4
set softtabstop=4
"set noexpandtab " noexpand needed for Makevars files to properly insert tabs
set expandtab
set autoindent
set ruler
"set relativenumber
set nu "line numbering
set wrap
set textwidth=80
set colorcolumn=84
set undofile
"global searches, so :%s/foo/bar/g automatically becomes :%s/foo/bar
set gdefault
"automatically highlight searching
set hlsearch
" Height of the command bar
set cmdheight=1
set backspace=indent,eol,start
" rename window to current file
" https://vi.stackexchange.com/questions/3897/how-to-label-tmux-tabs-with-the-name-of-the-file-edited-in-vim
"if exists('$TMUX')
" autocmd BufReadPost,FileReadPost,BufNewFile,BufEnter * call system("tmux rename-window '" . expand("%:r") . "'")
" autocmd VimLeave * call system("tmux setw automatic-rename")
"endif
"------------------------------------
" Behavior
"------------------------------------
let maplocalleader = ","
let mapleader = ";"
"let g:mapleader = ","
"set foldenable
"------------------------------------
" Remaps
"------------------------------------
nnoremap <C-L> :nohls<cr>
noremap <C-m> :!make<cr>
nmap <leader>w :w!<cr>
nmap <C-x> :qa<cr>
" Codeium
let g:codeium_map_no_tab = v:true
imap <C-n> <Cmd>call codeium#CycleCompletions(1)<CR>
imap <C-b> <Cmd>call codeium#CycleCompletions(-1)<CR>
imap <script><silent><nowait><expr> <C-a> codeium#Accept()
" syntastic
nmap [l :lprev<cr>
nmap ]l :lnext<cr>
" openbrowser maps:
nmap gx <Plug>(openbrowser-smart-search)
vmap gx <Plug>(openbrowser-smart-search)
nmap gw <Plug>(openbrowser-open)
vmap gw <Plug>(openbrowser-open)
" Next 2 lines make tab match brackets instead of %
nnoremap <tab> %
vnoremap <tab> %
" edit and source .vimrc
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
nnoremap <leader>sv :source $MYVIMRC<cr>
" paste from clipboard
map <F4> :r!xclip -o<CR>
" copy to clipboard
map <F5> :r!xclip -sel c<CR>
"------------------------------------
" Showmarks
"------------------------------------
let Tlist_Ctags_Cmd = '/usr/bin/ctags-exuberant'
let marksCloseWhenSelected = 0
let showmarks_include="abcdefghijklmnopqrstuvwxyz"
"------------------------------------
" ExploreMode (instead of NERDTree) mapped to F2
" Note that help doesn't work, but just search "vim netrw" or see here:
" https://medium.com/@mozhuuuuu/vimmers-you-dont-need-nerdtree-18f627b561c3
"------------------------------------
function! MyExplore()
tabnew
Explore
nmap <buffer> <leader>q :q<cr>
endfunction
nmap <F2> :call MyExplore()<cr>
"----------------------------------------
"------------- airline ---------------
"----------------------------------------
set laststatus=2
" configure vim-airline
let g:airline_theme='term'
"let g:airline_theme='solarized'
"let g:airline_theme='sol'
" show all open buffers on top
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#tab_nr_type = 1
" nice looking things
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline#extensions#tabline#left_sep = ''
let g:airline#extensions#tabline#left_alt_sep = '|'
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
set wildmenu
set wildmode=list:full
"----------------------------------------
"--------- soywod/himalaya ----------
"----------------------------------------
let g:himalaya_mailbox_picker = 'native'
"----------------------------------------
"------------- Nvim-R ---------------
"----------------------------------------
" Set color schemes with `colorout` package in `.Rprofile`
"omni-completion
set omnifunc=syntaxcomplete#Complee
let R_source = '/home/smexus/tmux_split.vim'
" https://github.com/jcfaria/Vim-R-plugin/issues/204
let g:ScreenImpl = 'Tmux'
let g:ScreenShellInitialFocus = 'shell'
" send selection to R with space bar
vmap <Space> <Plug>RDSendSelection
" send line to R with space bar
nmap <Space> <Plug>RDSendLine
" stop the plugin remapping underscore to '->':
let R_assign = 0
let g:R_external_term = 0
let g:R_applescript = 0
"let g:R_tmux_split = 1
let g:R_rconsole_height = winheight(0)
let g:R_rconsole_width = winwidth(0) / 2
"let g:R_rconsole_width = 0
"autocmd VimResized * let R_rconsole_width = winwidth(0) / 2
let g:R_nvimpager = "horizontal"
let R_args = ['--no-save', '--quiet']
"let R_tmux_title = 'automatic'
let R_tmux_title = 'R-'.split(getcwd(),'/')[-1]
"let g:R_notmuxconf = 1 "use my .tmux.conf, not the Nvim-r one
let r_syntax_folding = 1
"-------------------------------------------
"--------------- Tagbar ----------------
"-------------------------------------------
nmap <F8> :TagbarToggle<CR>
"-------------------------------------------
"--------------- previm ----------------
"-------------------------------------------
augroup PrevimSettings
autocmd!
autocmd BufNewFile,BufRead *.{md,mdwn,mkd,mkdn,mark*} set filetype=markdown
augroup END
nnoremap <leader>m :PrevimOpen<cr>
"Manual markdown render with <leader>p
"inoremap <buffer> <F4> <ESC>:call Markdown_Preview()<cr>
"function! Markdown_Preview()
" let b:curr_file = expand('%:p')
" call system('pandoc --standalone "' . b:curr_file . '" >/tmp/vim-markdown-preview.html')
" call system('xdg-open /tmp/vim-markdown-preview.html 1>/dev/null 2>/dev/null &')
"endfunction
"noremap <leader>mp :call Markdown_Preview()<cr> " currently `;mp`
"nmap <leader>p :call Markdown_Preview()<cr>
"nmap <buffer> <F4> :call Markdown_Preview()<cr>
"-------------------------------------------
"------------- syntastic ---------------
"-------------------------------------------
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
set encoding=utf-8
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 0
let g:syntastic_check_on_w = 0
let g:syntastic_check_on_wq = 0
"let b:syntastic_mode = 0 " disable
" http://stackoverflow.com/questions/20030603/vim-syntastic-how-to-disable-the-checker
let g:syntastic_mode_map = {
\ 'mode': 'active',
\ 'active_filetypes': [],
\ 'passive_filetypes': [] }
nnoremap <C-w>E :SyntasticCheck<CR> :SyntasticToggleMode<CR>
"let g:syntastic_debug = 1
" - open .cpp and :mes, :SyntasticInfo to get debug info
" see https://github.com/vim-syntastic/syntastic/issues/1246 and
" https://github.com/Valloric/YouCompleteMe#user-content-the-gycm_show_diagnostics_ui-option
let g:ycm_show_diagnostics_ui = 0
let g:syntastic_cpp_compiler = 'clang++'
let g:syntastic_cpp_compiler_options = ' -std=c++14 -std=libc++'
let g:syntastic_enable_cpp_check_header = 1
let g:syntastic_enable_cpp_lint_checker = 1
let g:syntastic_enable_cpp_clang_check = 1
let g:syntastic_enable_cpp_clang_tidy = 1
let g:syntastic_cpp_checkers = ['gcc', 'clang_check', 'clang_tidy', 'cpp_lint']
let g:syntastic_cpp_clang_check_quiet_messages = {"regex":
\ ['file not found']}
" jimhester/lintr:
let g:syntastic_enable_r_lintr_checker = 1
let g:syntastic_r_checkers = ['lintr']
let g:syntastic_r_lintr_linters = "linters_with_defaults(indentation_linter=indentation_linter(4))"
let g:syntastic_enable_rmd_lintr_checker = 1
let g:syntastic_rmd_checkers = ['lintr']
let g:syntastic_rmd_lintr_linters = "linters_with_defaults(indentation_linter=indentation_linter(4))"
function! SyntasticCheckHook(errors)
if !empty(a:errors)
let g:syntastic_loc_list_height = min([len(a:errors), 10])
endif
endfunction
let g:syntastic_r_lintr_quiet_messages = {"regex":
\ ['Commented code should be removed',
\ 'Remove spaces before the left parenthesis']}
let g:syntastic_rmd_lintr_quiet_messages = {"regex":
\ ['Commented code should be removed',
\ 'Remove spaces before the left parenthesis']}
"let g:syntastic_r_lintr_quiet_messages = {"regex":
" \ ['Only use double-quotes.', 'Opening curly braces should never',
" \ 'No visible global function definition', 'Commented code should be removed',
" \ 'Remove spaces before the left parenthesis']}
"let g:syntastic_rmd_lintr_quiet_messages = {"regex":
" \ ['Only use double-quotes.', 'Opening curly braces should never',
" \ 'No visible global function definition', 'Commented code should be removed',
" \ 'Remove spaces before the left parenthesis']}
" syntastic has :Error, so this is required for :E to work again
" (https://github.com/vim-syntastic/syntastic/issues/164)
command! E Ex
"-------------------------------------------
"------------- vim-latex ---------------
"-------------------------------------------
" Set grep program to always generate a file-name.
set grepprg=grep\ -nH\ $*
" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to
" 'plaintex' instead of 'tex', which results in vim-latex not being loaded.
" The following changes the default filetype back to 'tex':
let g:tex_flavor='latex'
autocmd BufRead,BufNewFile *.tex call CheckFileType()
function! CheckFileType()
set textwidth=144
set colorcolumn=150
set syntax=context " or tex, latex, plaintex
endfunction
" set same widths for text files too
autocmd BufNewFile,BufRead *.txt set textwidth=144 | set colorcolumn=150
"-------------------------------------------
"------------ jupyter-vim --------------
"-------------------------------------------
if has('nvim')
let g:python3_host_prog = '/path/to/python/bin/python3'
else
set pyxversion=3
endif
" =============== WORD COUNT FUNCTION =============
" From http://stackoverflow.com/questions/2974954/correct-word-count-of-a-latex-document
" with modifications from:
" http://tex.stackexchange.com/questions/534/is-there-any-way-to-do-a-correct-word-count-of-a-latex-document
" NOTE that this is globally defined for ALL filetypes, and may muck up other <F3> mappings!
:map <F3> :call WC()<CR>
function! WC()
let filename = expand("%")
"let cmd = "detex " . filename . " | wc -w | perl -pe 'chomp; s/ +//;'"
let cmd = "detex " . filename . " | wc -w | tr -d [:space:]"
let result = system(cmd)
echo result . " words"
endfunction
" g<C-g> just counts words of a selection, but does not detex.
" NOTE that the above WC() function seems to give really rubbish estimates.
" A superior alternative is texcount, gives far more detail, for which see
" http://app.uio.no/ifi/texcount/howto.html
" To run it, just type :!texcount %<CR>
" It takes a while, but is far more accurate. It is nevertheless not really
" accurate, because it still counted far more words that those remaining when all
" major environments were excised. This is nevertheless possibly just because of
" \itemize, lists, and so on, so it seems to be the best way for the moment.
" =============== SPELL CHECKING =============
" NOTE that spell stopped working with .tex at some stage, and can be fixed by
" entering :syn spell toplevel. To avoid having to manually enter this every
" time, follow the instructions in ":h mysyntaxfile-add":
" Make a new directory in /.vim/after/sytax, with "tex.vim" holding this syn
" command.
" Add a word to the `spellfile` with `zg`
" The mysyntaxfile-add instructions also have lots of details about custom
" colour highlight schemes and the likes.
set spell spelllang=en_gb
set spellfile=~/dictionary.utf-8.add
set nospell