-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc.local
317 lines (261 loc) · 9.14 KB
/
vimrc.local
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
set background=dark
set colorcolumn=81
set completeopt=noinsert,menuone,noselect
set gdefault " Replace all matches on a line instead of just the first
set hidden " needed for coc
set hlsearch " highlight search results
set ignorecase " searches are case-insensitive
set matchtime=0 " Speed up escape after (){} chars
set nobackup " Don't make a backup before overwriting a file
set nofoldenable
set noshowmode
set nowrap
set nowritebackup " Don't make a backup before overwriting a file.
set number relativenumber " The best of both worlds
set redrawtime=1000 " Stop highlighting if it takes more than a second
set scrolloff=999
set shortmess+=c
set synmaxcol=250 " Don't try to highlight lines longer than 250 characters.
set smartcase " searches are case-sensitive if a capital is in term
set termguicolors " True color in neovim and vim 8
set ttimeout " Fast timeout
set undodir=$HOME/.undodir
set undofile
set undolevels=500
set undoreload=500
set wildmenu
set wildmode=longest:full,full
set winwidth=84
set winheight=10
set winminheight=5
autocmd BufRead,BufNewFile Dockerfile* set filetype=dockerfile
""
" Commands
""
command QA qa
command Qa qa
command Q q
command Wq wq
command WQ wq
command W w
cabbrev Bundle Dispatch bundle install
" vim-tmux-navigator overrides needed to allow Sublime Text-like <C-\> comments
let g:tmux_navigator_no_mappings = 1
let g:tmux_navigator_save_on_switch = 2
" Redefine the 4/5 mappings we'll use
nnoremap <silent> <C-h> :TmuxNavigateLeft<CR>
nnoremap <silent> <C-j> :TmuxNavigateDown<CR>
nnoremap <silent> <C-k> :TmuxNavigateUp<CR>
nnoremap <silent> <C-l> :TmuxNavigateRight<CR>
" Get dot command repeatability in visual mode
xnoremap . :normal.<CR>
" Up and down by visual lines, not literal lines
nnoremap gj j
nnoremap gk k
nnoremap j gj
nnoremap k gk
vnoremap gj j
vnoremap gk k
vnoremap j gj
vnoremap k gk
nnoremap Q :echoe "Disabled Ex mode"<CR>
nnoremap U :echoe "Disabled lowercasing"<CR>
vnoremap U :echoe "Disabled lowercasing"<CR>
let g:prettier#autoformat = 1
let g:prettier#autoformat_require_pragma = 0
""
" Appearance
""
" Palette-specific config
let g:nord_italic = 1
let g:nord_italic_comments = 1
let g:one_allow_italics = 1
colorscheme onedark
" Highlight VCS conflict markers
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
autocmd VimEnter * RainbowParentheses .
autocmd VimEnter * TroubleRefresh
""
" Code navigation, LSP, etc.
""
" Bind K to grep word under cursor
nnoremap <silent> K :Find <C-R><C-W><CR>
nnoremap \ :Find<Space>
nnoremap <C-P> :Files<CR>
set tags^=./.git/tags;
" Jump to the first result if only one tag match,
" otherwise show the candidates list
nnoremap <C-]> <Esc>:exe "tjump " . expand("<cword>")<Esc>
nnoremap <silent><C-]> <cmd>lua vim.lsp.buf.definition()<CR>
nmap <silent> <leader>d <Plug>DashSearch
" nnoremap gi <cmd>lua vim.lsp.buf.implementation()<CR>
nnoremap gh <cmd>lua vim.lsp.buf.hover()<CR>
nnoremap gr <cmd>lua vim.lsp.buf.references()<CR>
nnoremap gn <cmd>lua vim.lsp.buf.rename()<CR>
function! RipgrepFzf(query, fullscreen)
let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case -- %s || true'
let initial_command = printf(command_fmt, shellescape(a:query))
let reload_command = printf(command_fmt, '{q}')
let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen)
endfunction
let g:fzf_layout = {
\ 'window': {
\ 'width': 0.9,
\ 'height': 0.9,
\ 'relative': v:true
\ } }
let g:fzf_buffers_jump = 1
let g:fzf_tags_command = './.git/hooks/tags'
let g:fzf_colors = {
\ 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Exception'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
function! s:build_quickfix_list(lines)
call setqflist(map(copy(a:lines), '{ "filename": v:val }'))
copen
cc
endfunction
let g:fzf_action = {
\ 'ctrl-q': function('s:build_quickfix_list'),
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
let $FZF_DEFAULT_OPTS = '--bind ctrl-a:select-all'
" --column: Show column number
" --line-number: Show line number
" --no-heading: Do not show file headings in results
" --fixed-strings: Search term as a literal string
" --ignore-case: Case insensitive search
" --no-ignore: Do not respect .gitignore, etc...
" --hidden: Search hidden files and folders
" --follow: Follow symlinks
" --glob: Additional conditions for search (in this case ignore everything in the .git/ folder)
" --color: Search color options
command! -nargs=* -bang Find call RipgrepFzf(<q-args>, <bang>0)
" command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>), 1, <bang>0)
command! -bang -nargs=* FindAll call fzf#vim#grep('rg --column --line-number --no-ignore --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>), 1, <bang>0)
nnoremap <Leader>g :BCommit<CR>
vnoremap <Leader>g :BCommit<CR>
""
" Plugin settings
""
let g:splitjoin_trailing_comma=1
let g:splitjoin_curly_brace_padding=1
let g:splitjoin_ruby_options_as_arguments=1
let splitjoin_ruby_hanging_args=0
let splitjoin_ruby_curly_braces=0
" hlslens
noremap <silent> n <Cmd>execute('normal! ' . v:count1 . 'n')<CR>
\<Cmd>lua require('hlslens').start()<CR>
noremap <silent> N <Cmd>execute('normal! ' . v:count1 . 'N')<CR>
\<Cmd>lua require('hlslens').start()<CR>
noremap * *<Cmd>lua require('hlslens').start()<CR>
noremap # #<Cmd>lua require('hlslens').start()<CR>
noremap g* g*<Cmd>lua require('hlslens').start()<CR>
noremap g# g#<Cmd>lua require('hlslens').start()<CR>
""
" Testing
""
let test#ruby#minitest#executable = "bundle exec rake test"
" let g:test#javascript#runner = 'vitest'
let test#strategy = "dispatch"
let test#runner_commands = ['RSpec']
nnoremap <Leader>a :TestSuite<CR>
nnoremap <Leader>f :TestLast --only-failures<CR>
" Force headless spec execution for Capybara
nnoremap <Leader>S :execute "Dispatch NO_HEADLESS=true rspec ". expand("%") .":". line(".")<CR>
""
" Yanking and pasting
""
augroup highlight_yank
autocmd!
au TextYankPost * lua vim.highlight.on_yank {higroup="IncSearch", timeout=1000, on_visual=false}
augroup END
" Re-select prior selection in visual mode
nnoremap gv `[v`]
" When pasting over/replacing a region in visual mode,
" retain the pasted content rather than the replaced region.
vmap <silent> <expr> p paste#ReplaceVisualSelectionWithYankRegister()
" Paste system clipboard contents
nnoremap <Leader>p "*p
" Yank to system clipboard
vnoremap <Leader>y "*y
" Yank to end of line, like C, D
nnoremap Y y$
" Rehighlight after moving text in visual mode
vnoremap < <gv
vnoremap > >gv
" Comment/un-comment like Sublime
nnoremap <C-\> :TComment<CR>
vnoremap <C-\> :TComment<CR>
""
" Splits and moving files
""
" Edit another file in the same directory as the current file
" uses expression to extract path from current file's path
noremap <Leader>e :e <C-R>=expand("%:p:h") . '/'<CR>
noremap <Leader>v :vnew <C-R>=expand("%:p:h") . '/'<CR>
nnoremap <Leader>o <cmd>TroubleToggle document_diagnostics<CR>
nnoremap <Leader>m :w<CR>:Move <C-R>%
nnoremap <Leader>q :call quickfix#ToggleQuickfixList()<CR>
""
" Miscellaneous
""
let g:marked_app = 'Mark Text'
""
" Rails
""
let g:rails_projections = {
\ "app/admin/*.rb": { "command": "admin" },
\ "app/models/*.rb": {
\ "related": "spec/factories/{plural}.rb",
\ },
\ "app/controllers/*_controller.rb": {
\ "related": "spec/requests/{basename}_spec.rb",
\ },
\ "config/application.rb": {"command": "application"},
\ "config/locales/*.json": { "command": "locale" },
\ "Gemfile": {"command": "gemfile"},
\ "config/routes.rb": {"command": "routes"},
\ "lib/tasks/*.rake": {
\ "alternate": "spec/tasks/{basename}_spec.rb",
\ },
\ "spec/factories/*.rb": {
\ "command": "factory",
\ "related": "app/models/{singular}.rb",
\ },
\ "spec/requests/*_spec.rb": {
\ "related": "app/controllers/{basename}_controller.rb",
\ },
\ }
""
" Python
""
let g:python_host_prog = $HOME."/.asdf/shims/python2"
let g:python3_host_prog = $HOME."/.asdf/shims/python3"
""
" Command line
""
" Insert current file directory path (without file name)
cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'
" vint: -ProhibitAutocmdWithNoGroup
" Dockerfile
autocmd BufRead,BufNewFile [Dd]ockerfile set ft=Dockerfile
autocmd BufRead,BufNewFile [Dd]ockerfile* setfiletype Dockerfile
autocmd BufRead,BufNewFile *.[Dd]ockerfile set ft=Dockerfile
autocmd BufRead,BufNewFile *.dock set ft=Dockerfile
autocmd BufRead,BufNewFile [Dd]ockerfile.vim set ft=vim
" Containerfile
autocmd BufRead,BufNewFile [Cc]ontainerfile set ft=Dockerfile
autocmd BufRead,BufNewFile [Cc]ontainerfile* set ft=Dockerfile
autocmd BufRead,BufNewFile *.[Cc]ontainerfile set ft=Dockerfile