-
Notifications
You must be signed in to change notification settings - Fork 5
/
vimrc
317 lines (255 loc) · 7.94 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
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PLUGINS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
call plug#begin('~/.vim/plugged')
Plug 'itchyny/lightline.vim'
Plug 'bling/vim-bufferline'
Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] }
" Navigation
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'scrooloose/nerdtree'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'ryanoasis/vim-devicons'
Plug 'junegunn/vim-peekaboo'
" Language specific
" -- Go
Plug 'fatih/vim-go'
let g:go_version_warning = 0
" -- Markdown
Plug 'jtratner/vim-flavored-markdown'
" -- Clojure
" ---- Connection to nREPL
Plug 'guns/vim-sexp', {'for': 'clojure'}
Plug 'liquidz/vim-iced', {'for': 'clojure'}
" ---- Linting
Plug 'borkdude/clj-kondo'
" -- TOML
Plug 'cespare/vim-toml'
" -- Fennel
Plug 'bakpakin/fennel.vim'
" Git
Plug 'tpope/vim-fugitive'
" -- Adds :Gbrowse
Plug 'tpope/vim-rhubarb'
" -- Adds :GV to browse history
Plug 'junegunn/gv.vim'
" Misc
Plug 'scrooloose/nerdcommenter'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" THEMES/UI
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Themes
Plug 'morhetz/gruvbox'
call plug#end()
" Color scheme
:syntax enable
:set background=dark
:silent! colorscheme gruvbox
" Set background and font in gVim
if has("gui_running")
set background=light
if has("gui_gtk2")
set guifont=Inconsolata\ 11
elseif has("gui_win32")
set guifont=Consolas:h10:cANSI
endif
endif
" Use local config if it exists
if filereadable($HOME . "/.vimrc.local")
source ~/.vimrc.local
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" VISUAL/LAYOUT
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Highlight trailing whitespace and spaces touching tabs
" Lines ending with spaces:
" Mixed spaces and tabs (in either order):
"
"
:highlight TrailingWhitespace ctermbg=darkred guibg=darkred
:let w:m2=matchadd('TrailingWhitespace', '\s\+$\| \+\ze\t\|\t\+\ze ')
" Remap <leader>
" I tend to use leader a lot, so I try to namespace commands under leader
" using a simple mnemonic:
" <leader>e_ -> Edit stuff
" <leader>g_ -> Git stuff
" <leader>m_ -> 'localleader': Filetype specific stuff
" <leader>f_ -> File stuff, some [fuzzy] find stuff
" <leader>t_ -> Toggleable settings
" <leader>w_ -> Window stuff
" Though some that don't fit aren't yet put behind a namespace
:let mapleader="\<Space>"
:let maplocalleader="\<Space>m"
" Use WhichKey to show my prefix mappings
:nnoremap <silent> <leader> :WhichKey '<Space>'<CR>
" Read configurations from files
:set modeline
:set modelines=5
" Setup tags file
:set tags=./tags,tags;
" Set path to include the cwd and everything underneath
:set path=**3
:set wildmenu
" Show the normal mode command as I type it
:set showcmd
" Lazily redraw: Make macros faster
:set lazyredraw
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" NAVIGATION
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Jump to last cursor position unless it's invalid or in an event handler
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" Disable arrow keys for navigation
:nnoremap <up> <nop>
:nnoremap <down> <nop>
:nnoremap <left> <nop>
:nnoremap <right> <nop>
" Make j and k move up and down better for wrapped lines
:noremap k gk
:noremap j gj
:noremap gk k
:noremap gj j
" Ctrl-<hjkl> to change splits
:noremap <C-h> <C-w>h
:noremap <C-j> <C-w>j
:noremap <C-k> <C-w>k
:noremap <C-l> <C-w>l
" <Tab> to cycle through splits
:noremap <Tab> <C-w>w
" Jumping between buffers
:noremap <C-n> :bnext<CR>
:noremap <C-p> :bprev<CR>
:noremap <C-e> :b#<CR>
" Let <C-n> and <C-p> also filter through command history
:cnoremap <C-n> <Down>
:cnoremap <C-p> <Up>
" Start scrolling before my cursor reaches the bottom of the screen
set scrolloff=4
" Improve search
:set ignorecase
:set smartcase
:set infercase
:set hlsearch
:set noincsearch " Default on neovim, and I hate it
" Turn off swap files
:set noswapfile
:set nobackup
:set nowritebackup
" Open new split panes to right and bottom
:set splitbelow
:set splitright
" allow hidden buffers
:set hidden
" always show the status bar
:set laststatus=2
" hide mode so it shows on the statusbar only
:set noshowmode
" short ttimeoutlen to lower latency to show current mode
:set ttimeoutlen=50
" Consistent backspace on all systems
:set backspace=2
" When tabbing on lines with extra spaces, round to the next tab barrier
:set shiftround
" Enable indent folding, but have it disabled by default
:set foldmethod=indent
:set foldlevel=99
" Use braces to determine when to auto indent
:set smartindent
" Make Y act like D and C
nnoremap Y y$
" Make joins keep the cursor at the same spot in the window
nnoremap J mzJ`z
" Make searching keep the cursor in thei same spot in the window
nnoremap n nzzzv
nnoremap N Nzzzv
" Unmap ex mode
nnoremap Q <nop>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" GLOBAL MAPPINGS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Clear trailing whitespace
:nnoremap <leader>eW :%s/\s\+$//<CR><C-o>
" Convert tabs to spaces
:nnoremap <leader>eT :%s/\t/ /g<CR>
" Select whole buffer
nnoremap vag ggvGg_
" Open commonly edited files
:nmap <leader>fev :edit $MYVIMRC<CR>
:nmap <leader>fet :edit $HOME/.tmux.conf<CR>
:nmap <leader>feb :edit $HOME/.bash_aliases<CR>
:nmap <leader>feg :edit $HOME/.gitaliases<CR>
" Reload vimrc
:nmap <leader>frv :source $MYVIMRC<CR>
" Close the current buffer
:nmap <leader>bd :bp\|bd #<CR>
" Save
:nmap <leader>fs :w<CR>
" Quit
:nmap <leader>qq :qa<CR>
" Add 'DELETEME' comment using nerdcommenter
nmap <leader>dm mx<leader>cA DELETEME<ESC>`x
" Delete all DELETEME lines
nmap <leader>dd :keepp :g/DELETEME/d<CR><C-o>
" Toggle search highlighting
:nmap <leader>th :set hlsearch!<CR>
" Show relative line numbers
:nmap <leader>tl :set number! relativenumber!<CR>
" Toggle cursor highlighting
:nmap <leader>tx :set cursorline! cursorcolumn!<CR>
" Toggle signcolumn (gutter) to make copy and paste easier
:nmap <leader>tg :call Toggle_sign_column()<CR>
function! Toggle_sign_column()
if &signcolumn == "yes"
set signcolumn=no
else
set signcolumn=yes
endif
endfunction
" Toggle showing listchars
:nnoremap <leader>t<TAB> :set list!<CR>
if &encoding == "utf-8"
exe "set listchars=eol:\u00ac,nbsp:\u2423,conceal:\u22ef,tab:\u25b8\u2014,precedes:\u2026,extends:\u2026"
else
set listchars=eol:$,tab:>-,extends:>,precedes:<,conceal:+
endif
" Toggle paste
:nmap <leader>tp :set paste!<CR>
" Window (split) management
:nmap <leader>wv :vsp<CR>
:nmap <leader>ws :sp<CR>
:nmap <leader>wd :close<CR>
:nmap <leader>wo :only<CR>
" NERDTree
:nnoremap <leader>ft :NERDTreeToggle<CR>
" Fugitive (git)
:nmap <leader>gb :Git blame<CR>
:nmap <leader>gd :Git diff<CR>
:nmap <leader>gs :Git status<CR>
:nmap <leader>gl :GV<CR>
" fzf.vim
" -- Find files in 'project' (repo)
:nmap <leader>pf <cmd>GFiles<CR>
:nmap <leader>ff <cmd>Files<CR>
:nmap <leader>bb :Buffers<CR>
:nmap <leader>ss :BLines<CR>
:nmap <leader>f* :Lines<CR>
:nmap <leader>frg :Rg<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Specific language settings
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Special settings for some filetypes
:au Filetype ruby setl expandtab smarttab tabstop=4 shiftwidth=4 softtabstop=4
:au Filetype yaml setl expandtab smarttab tabstop=4 shiftwidth=4 softtabstop=4
" Use github-flavored markdown
:aug markdown
:au!
:au BufNewFile,BufRead *.md,*.markdown setlocal filetype=ghmarkdown
:aug END
" vim-iced (Clojure)
let g:iced_default_key_mapping_leader = "<LocalLeader>"
let g:iced_enable_default_key_mappings = v:true
let g:iced_enable_clj_konda_analysis = v:true