-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
306 lines (253 loc) · 12.6 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
" prep general vim environment
" all these folders are accessible exclusively by user
if !isdirectory($HOME.'/.vim')
call mkdir($HOME.'/.vim', '', 0700)
endif
if !isdirectory($HOME.'/.vim/undodir')
call mkdir($HOME.'/.vim/undodir', '', 0700)
endif
" check if remote session
let g:remoteSession = !($SSH_TTY ==? '')
" NOTE: try :shell for in-vim shell stuff
" :term is cool too
if filereadable('/bin/fish')
set shell=/bin/fish\ --login
else
set shell=/bin/bash\ --login
endif
" visual settings
syntax enable " syntax highlighting for applicable buffers
set linebreak " wrap between words, not within
" NOTE: You can move the cursor inside display lines with g[hjkl]
set display+=lastline " always show last line of paragraph
set scrolloff=3 " show n lines above/below when scrolling
set sidescrolloff=5 " show n columns to sides when scrolling
" set colorcolumn=80 " highlight nth column
" set t_Co=256 " override TERM derived color capability
highlight CursorLineNr cterm=bold term=bold ctermfg=11 " ruler formatting
" error response settings
set noerrorbells
set novisualbell
" functional settings
set foldmethod=indent " fold based on indent level
set nofoldenable " no fold by default
" set nocompatible " disable vi compatability settings
set encoding=utf8 " always write utf-8 encoded files
set termencoding=utf8 " characters appear in utf-8
scriptencoding=utf8 " just for this file, since it has multibyte chars
set backspace=indent,eol,start " allow backspace across [chars]
set autoread " if file is changed outside vim, reload it
set autochdir " ensure working directory = directory of vim
set ttyfast " redraw faster
set undofile " enable preserved histories across sessions
set undodir=~/.vim/undodir " store histories in specific dir instead of same as file
set mouse=a " enable mouse
set ttymouse=sgr " change how vim understands mouse inputs
set splitbelow " Open :split buffers on bottom
set splitright " Open :vsplit buffers on right
" set conceallevel=1 " fold by default to maximum level
" set magic " grep regex instead of vim regex
" set ttimeout " after input, wait for more characters
" set ttimeoutlen=100 " wait 0.1s for more characters
filetype indent on " autoindent per filetype
" formatting settings
set autoindent " newlines inherit indent level
set smarttab " ... but only when sensible
set expandtab " replace tab with space
set tabstop=4 " n-width tabs
set softtabstop=4 " do not enforce tab width on existing tabs... essentially
set shiftwidth=4 " when moving text with [<>], move by n
set shiftround " round 'shift' to shiftwidth
set textwidth=80 " wrap to new buffer line based on column width.
" set wrapmargin=1 " wrap to new buffer line based on terminal size.
" NOTE: This setting is really jank in i3 and other wm, so I disabled
set formatoptions+=tc " enable auto-formatting based on textwidth
" same but for comments
set noendofline " disable automatically added newline
" most code formatters do this anyway
" search settings
set ignorecase " no case = any case
set smartcase " adding case = case sensitive
set hlsearch " highlight results
set incsearch " jump to nearest result as you search
" information settings
set ruler " display position on statusbar
set number " line numbers
set relativenumber " distances from cursor in line numbers
set showmatch " highlight matching paired symbol
set laststatus=2 " display statusline always
set wildmenu " enable command completion after :
set wildmode=longest:full,list " autocomplete to longest common string
set title " show vim status on title bar if applicable
set showcmd " show currently typed command
set history=1000 " preserve n changes
" vim efficiency settings
set lazyredraw " don't draw screen during command execution
" remaps
" let mapleader='' " TODO: choose a leader
" Easier buffer navigation
nnoremap <C-H> <C-W><C-H>
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
" these maps do not work for no reason
" nnoremap <C-Left> <C-W><C-H>
" nnoremap <C-Down> <C-W><C-J>
" nnoremap <C-Up> <C-W><C-K>
" nnoremap <C-Right> <C-W><C-L>
" disable arrow key navigation
" nnoremap <Left> :echoe "Use h to move left!"<CR>
" nnoremap <Right> :echoe "Use l to move right!"<CR>
" nnoremap <Up> :echoe "Use k to move up!"<CR>
" nnoremap <Down> :echoe "Use j to move down!"<CR>
" autocommands
" remember last edited location when reopening file, if valid
augroup remember_last_position
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
augroup autoformatters
autocmd BufWritePre <buffer> %s/\s\+$//e " clean whitespace at eol, always
augroup END
let otherTypes = ['c', 'cpp', 'java', 'ruby', 'html', 'css', 'js', 'javascript', 'haskell', 'vim', 'tex', 'plaintex', 'rkt', 'racket']
" keep track of alternative types for autoformat to run in
""""""""""""""""""""""""""""""""""""""""""""""""
" PLUGIN SETTINGS EXCLUSIVELY BELOW THIS POINT "
""""""""""""""""""""""""""""""""""""""""""""""""
if g:remoteSession " remote plugins
" colorscheme gruvbox
colorscheme darkblue
call plug#begin()
Plug 'vim-syntastic/syntastic' " linter w/o async
" common to local and remote sessions
Plug 'airblade/vim-gitgutter' " gitlens for vim
Plug 'tpope/vim-fugitive' " git information and commands
Plug 'vim-airline/vim-airline' " fancy status bar
Plug 'scrooloose/nerdtree' " file explorer inside vim
call plug#end()
else " local plugins
call plug#begin()
" local use
Plug 'dense-analysis/ale' " linter
Plug 'valloric/youcompleteme' " autocompletion engine
" NOTE: DO NOT ENABLE FOR TEX FILES! 500+ word buffers stress the CPU
" TODO: disable for tex/plaintex buffers automatically?
" Plug 'iamcco/markdown-preview.nvim', {'for': 'markdown'}
" NOTE: FIRST TIME SETUP FOR markdown-preview.nvim: call mkdp#util#install()
" TODO: Find a way to do this automatically?
" only for LaTeX
Plug 'lervag/vimtex', {'for': ['tex', 'plaintex']} " LaTeX previewer
Plug 'sirver/ultisnips', {'for': ['tex', 'plaintex']} " faster snippets completion
" formatters
Plug 'python/black', {'for': 'python'}
Plug 'rust-lang/rust.vim', {'for': 'rust'} " this comes with other cool things too
Plug 'wlangstroth/vim-racket', {'for': ['rkt', 'racket']}
Plug 'Chiel92/vim-autoformat', {'for': otherTypes}
Plug 'tpope/vim-unimpaired' " better bracket binds
" NOTE: you can :echo glob($VIMRUNTIME . '/ftplugin/*.vim') to see filetypes available
" NOTE: you can :PlugStatus to see running plugins
" not using currently
" Plug 'google/vim-codefmt', {'for': otherTypes}
" Plug 'tpope/vim-eunuch' " unix terminal commands in vim
" Plug 'jpalardy/vim-slime' " send buffer data to [session]
" Plug 'Konfekt/FastFold' " apparently folding = slow in vim
" Plug 'tpope/vim-surround' " surround selection with paired symbols
" common to local and remote sessions
Plug 'airblade/vim-gitgutter' " gitlens for vim
Plug 'tpope/vim-fugitive' " git information and commands
Plug 'vim-airline/vim-airline' " fancy status bar
Plug 'scrooloose/nerdtree' " file explorer inside vim
call plug#end()
endif
" remaps for plugins
nmap <C-n> :NERDTreeToggle<CR> " open NERDTree with Ctrl+n in normal mode
nmap <leader>1 <Plug>AirlineSelectTab1 " i3-style buffer selection while in normal mode
nmap <leader>2 <Plug>AirlineSelectTab2
nmap <leader>3 <Plug>AirlineSelectTab3
nmap <leader>4 <Plug>AirlineSelectTab4
nmap <leader>5 <Plug>AirlineSelectTab5
nmap <leader>6 <Plug>AirlineSelectTab6
nmap <leader>7 <Plug>AirlineSelectTab7
nmap <leader>8 <Plug>AirlineSelectTab8
nmap <leader>9 <Plug>AirlineSelectTab9
" autocommands for plugins
augroup autoformatters_plugins
autocmd FileType python autocmd BufWritePre <buffer> Black
autocmd FileType rust autocmd BufWritePre <buffer> RustFmt
autocmd FileType otherTypes autocmd BufWritePre <buffer> Autoformat " autoformatter using any installed formatter
augroup END
" NERDTree
let g:NERDTreeShowHidden=1
let g:NERDTreeShowBookmarks=1
let g:NERDTreeFileExtensionHighlightFullName = 1
let g:NERDTreeExactMatchHighlightFullName = 1
let g:NERDTreePatternMatchHighlightFullName = 1
let g:NERDTreeHighlightFolders = 1 " enables folder icon highlighting using exact match
let g:NERDTreeHighlightFoldersFullName = 1 " highlights the folder name
" air-line
let g:airline_powerline_fonts = 0 " do not use default symbols
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_left_sep = '' " omit for cleanliness
let g:airline_right_sep = ''
" let g:airline_left_sep = '▶'
" let g:airline_right_sep = '◀'
" let g:airline_left_alt_sep = '▶'
" let g:airline_right_alt_sep = '◀'
" let g:airline_symbols.linenr = '␊'
" let g:airline_symbols.linenr = ''
let g:airline_symbols.linenr = '¶'
let g:airline_symbols.maxlinenr = '' " no symbol for column num
" specific buffers/settings
let g:airline_symbols.readonly = ''
let g:airline_symbols.spell = '' " omit spell indicator; you'll know.
" let g:airline_symbols.paste = 'ρ'
" let g:airline_symbols.paste = 'Þ'
let g:airline_symbols.paste = '∥' " TODO: when are these three used
let g:airline_symbols.crypt = '⩐'
let g:airline_symbols.whitespace = 'Ξ'
" git specific symbols
let g:airline_symbols.branch = '𝌎' " tetragram for 'branch'
let g:airline_symbols.notexists = 'Ɇ' " buffer not tracked by git
let g:airline_symbols.dirty='*' " untracked changes; displays after branch name
" I use what matches my zsh prompt
let g:airline#extensions#tabline#enabled = 1 " display all open buffers on top bar
" let g:airline#extensions#tabline#tab_nr_type = 1 " how to format tab number type
" let g:airline#extensions#tabline#show_tab_nr = 1 " what # tab is this
" let g:airline#extensions#tabline#buffer_nr_show = 1 " what # buffer is this
let g:airline#extensions#tabline#nametruncate = 16 " max buffer name of 16 chars
let g:airline#extensions#tabline#fnamecollapse = 2 " max buffer name of 16 chars
let g:airline#extensions#tabline#formatter = 'default' " format top bar with [formatter]
" ALE
let g:ale_set_balloons = 1
" markdown-preview.nvim
let g:mkdp_auto_start = 1 " autostart when entering markdown buffer
let g:mkdp_auto_open = 1 " start buffer when editing markdown, even if closed
let g:mkdp_browser = 'chromium' " TODO: open in new window?
let g:mkdp_path_to_chrome = ''
let g:mkdp_open_to_the_world = 0 " can make preview visible on LAN
" vimtex
let g:tex_flavor = 'latex'
let g:vimtex_view_method = 'zathura'
let g:vimtex_view_general_viewer = 'zathura'
let g:vimtex_compiler_progname = 'tectonic'
let g:tex_conceal='abdmg'
let g:vimtex_quickfix_ignore_all_warnings = 1
let g:vimtex_quickfix_latexlog = {
\ 'overfull' : 0,
\ 'underfull' : 0,
\}
" UltiSnips
let g:UltiSnipsExpandTrigger = '<C-c>' " TODO: could be comfier
let g:UltiSnipsJumpForwardTrigger = '<C-b>'
let g:UltiSnipsJumpBackwardTrigger = '<C-z>'
" ycm extra conf for c and other compilation
let g:ycm_global_ycm_extra_conf = '~/.vim/.ycm_extra_conf.py'
" WSL yank support
let s:clip = 'clip.exe' " change this path according to your mount point
if executable(s:clip)
augroup WSLYank
autocmd!
autocmd TextYankPost * if v:event.operator ==# 'y' | call system(s:clip, @0) | endif
augroup END
endif