-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
370 lines (303 loc) · 9.89 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
" If you don't understand a setting in here, just type ':h setting'.
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
set encoding=utf-8
" Leader
let mapleader = " "
" set backspace=2 " Backspace deletes like most programs in insert mode
set backspace=indent,eol,start " Make backspace behave in a sane manner.
set nobackup
set nowritebackup
set noswapfile " http://robots.thoughtbot.com/post/18739402579/global-gitignore#comment-458413287
set history=50
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
set laststatus=2 " Always display the status line
set autowrite " Automatically :write before running commands
set modelines=0 " Disable modelines as a security precaution
set nomodeline
" Switch syntax highlighting on
syntax on
if filereadable(expand("~/.vimrc.bundles"))
source ~/.vimrc.bundles
endif
" Enable file type detection and do language-dependent indenting.
filetype plugin indent on
" Softtabs, 2 spaces
set tabstop=2
set shiftwidth=2
set shiftround
set expandtab
" Display extra whitespace
set list listchars=tab:»·,trail:·,nbsp:·
" Use one space, not two, after punctuation.
set nojoinspaces
filetype off " required
filetype plugin indent on
augroup vimrcEx
autocmd!
" When editing a file, always jump to the last known cursor position.
" Don't do it for commit messages, when the position is invalid, or when
" inside an event handler (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" Set syntax highlighting for specific file types
autocmd BufRead,BufNewFile *.md set filetype=markdown
autocmd BufRead,BufNewFile .{jscs,jshint,eslint}rc set filetype=json
autocmd BufRead,BufNewFile aliases.local,zshrc.local,*/zsh/configs/* set filetype=sh
autocmd BufRead,BufNewFile gitconfig.local set filetype=gitconfig
autocmd BufRead,BufNewFile tmux.conf.local set filetype=tmux
autocmd BufRead,BufNewFile vimrc.local set filetype=vim
augroup END
" ALE linting events
augroup ale
autocmd!
if g:has_async
autocmd VimEnter *
\ set updatetime=1000 |
\ let g:ale_lint_on_text_changed = 0
autocmd CursorHold * call ale#Queue(0)
autocmd CursorHoldI * call ale#Queue(0)
autocmd InsertEnter * call ale#Queue(0)
autocmd InsertLeave * call ale#Queue(0)
else
echoerr "The thoughtbot dotfiles require NeoVim or Vim 8"
endif
augroup END
" When the type of shell script is /bin/sh, assume a POSIX-compatible
" shell for syntax highlighting purposes.
let g:is_posix = 1
" Make it obvious where 80 characters is
set textwidth=80
set colorcolumn=+1
" Line numbers
set relativenumber
if v:version > 703
set number " hybrid relative and absolute for current line
endif
" Colorscheme
lua << EOF
require('neosolarized').setup({
comment_italics = true,
background_set = false,
})
EOF
colorscheme neosolarized
highlight ColorColumn ctermbg=DarkCyan
set guifont=Mnlo\ Regular:h14
" Use The Silver Searcher https://github.com/ggreer/the_silver_searcher
if executable('ag')
" Use Ag over Grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in fzf for listing files. Lightning fast and respects .gitignore
let $FZF_DEFAULT_COMMAND = 'ag --literal --files-with-matches --nocolor --hidden -g ""'
if !exists(":Ag")
command -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw!
nnoremap \ :Ag<SPACE>
endif
endif
" Map Ctrl + p to open fuzzy find (FZF)
nnoremap <c-p> :Files<cr>
" ctrlp
" =====
" Make CtrlP use ag for listing the files. Way faster and no useless files.
" Without --hidden, it never finds .travis.yml since it starts with a dot
" let g:ctrlp_user_command = 'ag %s -l --hidden --nocolor -g ""'
" let g:ctrlp_use_caching = 0
"
" Enable MRU for CtrlP
" let g:ctrlp_cmd = 'CtrlP'
" Tab completion
" will insert tab at beginning of line,
" will use completion if not at beginning
set wildmode=list:longest,list:full
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<Tab>"
else
return "\<C-p>"
endif
endfunction
inoremap <Tab> <C-r>=InsertTabWrapper()<CR>
inoremap <S-Tab> <C-n>
" Switch between the last two files
nnoremap <Leader><Leader> <C-^>
" Get off my lawn
nnoremap <Left> :echoe "Use h"<CR>
nnoremap <Right> :echoe "Use l"<CR>
nnoremap <Up> :echoe "Use k"<CR>
nnoremap <Down> :echoe "Use j"<CR>
" Treat <li> and <p> tags like the block tags they are
let g:html_indent_tags = 'li\|p'
" Set tags for vim-fugitive
set tags^=.git/tags
" Open new split panes to right and bottom, which feels more natural
set splitbelow
set splitright
" Quicker window movement
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
" Move between linting errors
nnoremap ]r :ALENextWrap<CR>
nnoremap [r :ALEPreviousWrap<CR>
" Set spellfile to location that is guaranteed to exist, can be symlinked to
" Dropbox or kept in Git and managed outside of thoughtbot/dotfiles using rcm.
set spellfile=$HOME/.vim-spell-en.utf-8.add
" Autocomplete with dictionary words when spell check is on
set complete+=kspell
" Always use vertical diffs
if &diff
set diffopt-=internal
set diffopt+=iwhite
endif
" vim-rspec
" ==========
" Use iTerm instea of Terminal for vim-rspec
" let g:rspec_runner = "os_x_iterm"
" vim-test
" ========
"
" Use iTerm to execute test commands
if has("gui_running")
let test#strategy = "iterm"
let g:test#preserve_screen = 1
else
let test#strategy = "kitty"
" let test#strategy = "neoterm"
" let g:neoterm_default_mod = "botright"
" let g:neoterm_keep_term_open = 0 " when buffer closes, exit the terminal too.
" let g:neoterm_autoscroll = 1 " autoscroll to the bottom when entering insert mode
" let g:neoterm_size = 10
" let test#strategy = "neovim"
" let test#neovim#term_position = "botright 10"
" if $IN_NIX_SHELL
" let test#strategy = "neoterm"
" let g:neoterm_default_mod = "botright"
" let g:neoterm_keep_term_open = 0 " when buffer closes, exit the terminal too.
" let g:neoterm_autoscroll = 1 " autoscroll to the bottom when entering insert mode
" let g:neoterm_size = 10
" else
" let test#strategy = "neovim"
" let test#neovim#term_position = "botright 10"
" endif
end
let test#javascript#jest#file_pattern = '\v(__tests__/.*|(spec|test))\.(js|jsx|coffee|ts|tsx|es6)$'
" direnv
" ======
" let g:direnv_auto = 1
" RSpec.vim mappings
" map <Leader>t :call RunCurrentSpecFile()<CR>
" map <Leader>r :call RunNearestSpec()<CR>
" map <Leader>l :call RunLastSpec()<CR>
" map <Leader>a :call RunAllSpecs()<CR>
" vim-test mappings
nmap <silent> <leader>r :TestNearest<CR>
nmap <silent> <leader>rr :Tclose<CR>
nmap <silent> <leader>t :TestFile<CR>
nmap <silent> <leader>a :TestSuite<CR>
nmap <silent> <leader>l :TestLast<CR>
nmap <silent> <leader>gt :TestVisit<CR>
" vim-rubytest mappings
" map <Leader>r <Plug>RubyTestRun
" map <Leader>t <Plug>RubyFileRun
" map <Leader>l <Plug>RubyTestRunLast
" vim-run-interactive mappings
nnoremap <leader>ri :RunInInteractiveShell<space>
" Key mappings
" :inoremap ii <Esc>
" split term mappings
nmap <silent> <leader>f :10Term<CR>
" vim-fugitive Git mappings
nnoremap <leader>gb <cmd>Git blame<cr>
" Telescope mappings
nnoremap <leader>ff <cmd>Telescope find_files hidden=true<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fgg <cmd>Telescope git_commits<cr>
nnoremap <leader>fgs <cmd>Telescope git_status<cr>
nnoremap <leader>fgb <cmd>Telescope git_bcommits<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
" File Explorer
" nnoremap <leader>b <cmd>NERDTree<cr>
nnoremap <leader>bb <cmd>NvimTreeToggle<cr>
nnoremap <leader>bf <cmd>NvimTreeFindFile<cr>
nnoremap <leader>bc <cmd>NvimTreeCollapse<cr>
" Run elixir formatter on save
let g:mix_format_on_save = 1
let g:mix_format_options = '--check-equivalent'
let g:mix_format_silent_errors = 1
" Go formatter
let g:go_fmt_command = "gofmt"
" Spell checking
set spellfile=$HOME/.vim-spell-en.utf-8.add
autocmd BufRead,BufNewFile *.md setlocal spell
" Autocomplete with dictionary words when spell check is on
set complete+=kspell
set mouse=a
set clipboard=unnamed
set nohlsearch
" Telescope Setup
lua << EOF
-- disable netrw at the very start of your init.lua
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
-- set termguicolors to enable highlight groups
-- vim.opt.termguicolors = true
require('nvim-web-devicons').setup {
-- your personal icons can go here (to override)
-- you can specify color or cterm_color instead of specifying both of them
-- DevIcon will be appended to `name`
-- Found icon at https://www.nerdfonts.com/cheat-sheet
override = {
rb = {
icon = "",
color = "#701516",
cterm_color = "52",
name = "Rb"
}
};
}
-- empty setup using defaults
require("nvim-tree").setup({
renderer = {
icons = {
glyphs = {
folder = {
arrow_closed = "",
}
}
}
}
})
require('telescope').setup{
defaults = {
-- Default configuration for telescope goes here:
-- config_key = value,
path_display={"smart"}, -- can also consider "shorten" or "truncate"
mappings = {
i = {
-- map actions.which_key to <C-h> (default: <C-/>)
-- actions.which_key shows the mappings for your picker,
-- e.g. git_{create, delete, ...}_branch for the git_branches picker
["<C-j>"] = "move_selection_next",
["<C-k>"] = "move_selection_previous",
}
},
layout_config = {
horizontal = {
preview_cutoff = 0,
},
},
},
}
-- To get fzf loaded and working with telescope, you need to call
-- load_extension, somewhere after setup function:
require('telescope').load_extension('fzf')
EOF