-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc-minimal
318 lines (269 loc) · 10.9 KB
/
vimrc-minimal
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
" vimrc
" ----------------------------------------------------------------------------
" Summary: Payton's vimrc file
" URL: https://github.com/sirbrillig/dotfiles
" ----------------------------------------------------------------------------
" ----------------------------------------------------------------------------
" Set up vim-plug
" ----------------------------------------------------------------------------
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/bundle')
" ----------------------------------------------------------------------------
" Plugins
" ----------------------------------------------------------------------------
Plug 'EinfachToll/DidYouMean'
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'airblade/vim-gitgutter' " Adds git marks in the gutter
Plug 'bling/vim-bufferline'
Plug 'bronson/vim-trailing-whitespace'
Plug 'csscomb/vim-csscomb'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'garbas/vim-snipmate'
Plug 'iamcco/diagnostic-languageserver', { 'do': 'yarn install' }
Plug 'idanarye/vim-merginal'
Plug 'jiangmiao/auto-pairs'
Plug 'junegunn/vader.vim' " vimscript testing framework
Plug 'kshenoy/vim-signature' " Toggle and display marks in gutter
Plug 'moll/vim-bbye' " Allows truly deleting buffers
Plug 'prettier/vim-prettier', { 'do': 'yarn install', 'for': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'graphql'] }
Plug 'ruanyl/vim-gh-line' " type gh to open selected or current line in github
Plug 'ryanoasis/vim-devicons'
Plug 'scrooloose/nerdtree'
Plug 'tomtom/tcomment_vim' " Use gc to toggle comments or gcc for a single line
Plug 'tomtom/tlib_vim'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-sleuth' " Sets shiftwidth and expandtab automatically
Plug 'tpope/vim-surround'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'vim-scripts/AutoComplPop'
Plug 'vim-scripts/L9'
Plug 'vim-scripts/mru.vim'
Plug 'w0rp/ale'
Plug 'windwp/nvim-autopairs' " Adds autopopulating closing parens/brackets/braces/quotes
" Syntax plugins
Plug 'mxw/vim-jsx'
Plug 'elzr/vim-json'
Plug 'jelera/vim-javascript-syntax'
Plug 'pangloss/vim-javascript'
Plug 'moll/vim-node'
Plug 'cakebaker/scss-syntax.vim'
Plug 'hail2u/vim-css3-syntax'
" Search plugins
Plug 'jremmen/vim-ripgrep' " Requires ripgrep
call plug#end()
" ----------------------------------------------------------------------------
" Options
" ----------------------------------------------------------------------------
syntax on
set hlsearch "highlight search matches
set autoindent "use previous line's indent level
set background=dark "assume dark background.
set hidden "allow edited buffers to be hidden
set switchbuf=useopen "use existing buffer rather than opening a new one
set smarttab "pressing tab fixes indent.
set noet "use tabs to indent
set copyindent
set softtabstop=0
set shiftwidth=2
set tabstop=2
set showmatch "highlight matching braces, etc.
set ruler "show cursor position
set incsearch "do incremental searches
set ignorecase "case-insensitive searching
set smartcase "do case-sensitive if upper-case characters.
set gdefault "assume the /g flag on :s.
set formatoptions=crql "auto-format comments in code.
set textwidth=0 "for wrapping
set backspace=indent,eol,start "allow erasing previously entered characters in insert mode.
set wildmenu " show list instead of just completing
set scrolloff=3 " minimum lines to keep above and below cursor
set laststatus=2 " always show the status line
set cmdheight=2 " slightly more room for notices
let g:netrw_silent=1 " be quiet when using netrw
filetype on
filetype plugin on
filetype indent on
set cursorline " highlight the current cursor line number
set number " show line numbers
set path+=** " Allow recursive find
set completeopt=menuone,longest " Configure tab autocomplete
set iskeyword+=\- " Adds dash character to keyword characters
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set undodir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
" Allow copy/paste between MacOS and tmux
set clipboard=unnamed
" Open a new file (c-y) in the current window
let g:ctrlp_open_new_file = 'r'
" Show only MRU files in the current working directory
let g:ctrlp_mruf_relative = 1
let g:ctrlp_mruf_exclude_nomod = 1
" Use rg (ripgrep) for ctrlp indexing
if executable('rg')
let g:ctrlp_user_command = 'rg %s --files --color=never --glob ""'
let g:ctrlp_use_caching = 0
endif
" When pressing <CR> within a curly brace, add two lines and move up one.
let delimitMate_expand_cr = 1
" When pressing <SPACE> within a paren, add two spaces and move back one.
let delimitMate_expand_space = 1
" Display indentation guides
set list listchars=tab:\|\ ,trail:·,extends:»,precedes:<,nbsp:~
" Disable JSON quote concealing
let g:vim_json_syntax_conceal = 0
" ----------------------------------------------------------------------------
" vim-airline
" ----------------------------------------------------------------------------
let g:bufferline_fname_mod = ':p:.'
let g:bufferline_echo = 0
set t_Co=256
let g:airline_theme='wombat'
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#whitespace#enabled = 0
let g:airline#extensions#ale#enabled = 1
let g:airline_powerline_fonts = 1
" ----------------------------------------------------------------------------
" Keybindings
" ----------------------------------------------------------------------------
" quit with capital Q also
command! -bar -bang Q quit<bang>
command! -bar -bang Qa quit<bang>
command! Ccl ccl
" map CTRL-A and CTRL-E to home and end, respectively.
map <C-A> <Home>
map <C-E> <End>
map! <C-A> <Home>
map! <C-E> <End>
" reset the mapleader to ;
let mapleader = ";"
" Use leader-; as "repeat last f or t movement"
nnoremap <Leader>; ;
" map leader-q to clear the search highlight.
nnoremap <silent> <leader>q :nohlsearch<CR>
" map leader-S to start a global-replace.
nnoremap <Leader>S :%s///c<Left><Left><Left>
vnoremap <Leader>S :%s///c<Left><Left><Left>
" map leader-s to start a single-line-replace.
noremap <Leader>s :s///c<Left><Left><Left>
vnoremap <Leader>s :s///c<Left><Left><Left>
" map leader-o to insert a new line after the current.
nnoremap <Leader>o o^
" map backslash to save.
nnoremap \ :w<CR>
" map leader-w to wordwrap without newlines.
nnoremap <Leader>w gq
vnoremap <Leader>w gq
" map Leader-[ and Leader-] to buffer navigation.
nnoremap <Leader>[ :bp<CR>
nnoremap <Leader>] :bn<CR>
" map leader-p to toggle paste mode.
nnoremap <silent> <Leader>p :call Paste_on_off()<bar>:set paste?<CR>
set pastetoggle=
let paste_mode = 0 " 0 = normal, 1 = paste
function! Paste_on_off()
if g:paste_mode == 0
set paste
let g:paste_mode = 1
else
set nopaste
let g:paste_mode = 0
endif
endfunc
augroup comment_leaders
autocmd FileType haskell,vhdl,ada let b:comment_leader = '-- '
autocmd FileType vim let b:comment_leader = '" '
autocmd FileType c,cpp,java,php let b:comment_leader = '// '
autocmd FileType sh,make,ruby,perl,yaml,python let b:comment_leader = '# '
autocmd FileType let b:comment_leader = '% '
augroup END
" map Leader-n to toggle NERDTree
nnoremap <Leader>n :NERDTreeToggle<CR>
" Map leader-: to add a semicolon to the end of the line
nnoremap <Leader>: mqA;<esc>`q
" Map leader-, to add a comma to the end of the line
nnoremap <Leader>, mqA,<esc>`q
" Map leader-l to last buffer
nnoremap <Leader>l :b#<CR>
" Map leader-P to CtrlP without activation so a directory can be added
nnoremap <Leader>P :CtrlP<space>
" Map leader-m to the CtrlPMRU search
nnoremap <Leader>m :CtrlPMRU<CR>
" Map leader-b to the CtrlPBuffer search
nnoremap <Leader>b :CtrlPBuffer<CR>
" Map leader-x to close the current buffer
nnoremap <Leader>x :Bdelete<CR>
" Map leader-g to grep for the word under the cursor
nnoremap <Leader>g :Rg -w <cword>
" Map leader-G to begin a search
nnoremap <Leader>G :Rg
" ----------------------------------------------------------------------------
" Colors
" ----------------------------------------------------------------------------
" Set the theme
colorscheme elflord
" Modify some highlight colors to be less offensive to the eye.
hi IncSearch term=reverse,underline cterm=reverse,bold,underline ctermbg=NONE ctermfg=NONE
hi Search term=NONE cterm=reverse,bold ctermbg=NONE ctermfg=NONE
hi MatchParen term=NONE cterm=bold ctermbg=NONE ctermfg=DarkCyan
hi PmenuSel term=NONE cterm=NONE ctermfg=White ctermbg=Blue
hi Pmenu term=NONE cterm=NONE ctermfg=Black ctermbg=White
" Modify the cursorline colors to show just the line number highlighted
hi LineNr ctermfg=DarkGray
hi CursorLineNr ctermbg=3
hi CursorLine cterm=none ctermbg=none
" Modify the SignColumn to make it easier to read.
hi SignColumn ctermbg=NONE guibg=NONE
hi GitGutterAdd ctermfg=2 guifg=#009900 ctermbg=NONE guibg=NONE
hi GitGutterDelete ctermfg=1 ctermbg=NONE guifg=#ff2222 guibg=NONE
hi GitGutterChangeDefault ctermfg=3 ctermbg=NONE guifg=#bbbb00 guibg=NONE
" Modify the invisible characters colors (tabs)
hi SpecialKey ctermfg=DarkGray
" Highlight ES6 template strings
hi link javaScriptTemplateDelim String
hi link javaScriptTemplateVar Text
hi link javaScriptTemplateString String
" Simplify colors during vimdiff
highlight DiffAdd cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffDelete cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffChange cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffText cterm=bold ctermfg=10 ctermbg=88 gui=none guifg=bg guibg=Red
" Make it easier to see ALE errors
hi link ALEError Error
" ----------------------------------------------------------------------------
" Grep
" ----------------------------------------------------------------------------
" Use Rg to grep
if executable("rg")
set grepprg=rg\ --vimgrep\ --no-heading
set grepformat=%f:%l:%c:%m,%f:%l:%m
endif
command! -nargs=+ -complete=file Rg execute 'silent grep! <args>' | copen
" Default Rg to use smartcase
let g:rg_command = 'rg --vimgrep --smart-case'
let g:rg_highlight = 1
" ----------------------------------------------------------------------------
" ALE
" ----------------------------------------------------------------------------
let g:ale_lint_delay = 2000
"let g:ale_lint_on_text_changed = 'normal'
"let g:ale_php_phpcs_use_global = 1
let g:ale_echo_msg_format = '[%linter%] %s'
let g:ale_linters = {
\ 'javascript': ['standard','eslint'],
\ 'php': ['php', 'phpcs'],
\ 'html': [],
\}
" ----------------------------------------------------------------------------
" Prettier
" ----------------------------------------------------------------------------
" https://github.com/prettier/vim-prettier#overwrite-default-prettier-configuration
" Why can't it just use the project's prettier config?
" https://github.com/prettier/vim-prettier/pull/52
let g:prettier#config#bracket_spacing = 'true'