-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvimrc
225 lines (198 loc) · 5.74 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
scriptencoding utf-8
packadd! matchit
runtime! ftplugin/man.vim
set nocompatible
set autoindent
set autoread
set autowrite
set backspace=indent,eol,start
set belloff=all
set cmdheight=2
set complete-=i
set completeopt=menuone,longest,preview
set cursorline
set dictionary+=/usr/share/dict/words
set display=truncate
set fillchars=vert:│,fold:·
set formatoptions+=1rj
set history=200
set hlsearch
set incsearch
set laststatus=2
set lazyredraw
set listchars=tab:▸\ ,trail:·,extends:⇢,precedes:⇠,nbsp:␠
set noequalalways
set nojoinspaces
set nolangremap
set nrformats-=octal
set number
set numberwidth=3
set report=0
set scrolloff=1
set sessionoptions-=options
set shiftround
set shortmess=aFIoOtT
set showcmd
set sidescroll=1
set sidescrolloff=5
set smarttab
set spellfile=~/.vim/spell/en.utf-8.add,~/.vim/spell/en-local.utf-8.add
set spelllang=en_us
set switchbuf=uselast
set tags+=./tags;
set thesaurus+=~/.vim/spell/mthesaur.txt
set timeoutlen=1200
set title
set ttimeout
set ttimeoutlen=50
set undodir^=~/.vim/_undo
set undofile
set viewoptions-=options
set viminfo+=n~/.vim/viminfo
set viminfo^=!
set virtualedit+=block
set wildignore+=*.[aos],*.aux,*.class,*.dSYM,*.dylib,*.out,*.py[co],*.so,.DS_Store
set wildignore+=*~,Session.vim,Sessionx.vim,[._]*.s[a-v][a-z],[._]*.sw[a-p],[._]s[a-v][a-z],[._]sw[a-p],[._]*.un~,tags
set wildmenu
set wildmode=longest:full,full
set winheight=10
set winminheight=10
set winwidth=80
set statusline=[%n] " buffer number
set statusline+=%(\ %.120f\ %) " relative path to file
set statusline+=%h%w%m%r%y " help|preview|modified|readonly|filetype
if exists('*FugitiveStatusline') | set statusline+=%{FugitiveStatusline()} | endif
set statusline+=%= " l-r separator
set statusline+=%-10.(0x%B%) " hex value of character under cursor
set statusline+=%-15.(%l,%c%V%)\ %P " line#,col#-vcol# %
set omnifunc=syntaxcomplete#Complete
set completefunc=syntaxcomplete#Complete
filetype plugin indent on
syntax enable
if $COLORTERM ==# 'truecolor'
if has('termguicolors')
set termguicolors
endif
silent! colorscheme deep-space
endif
if executable('rg')
set grepprg=rg\ --vimgrep
set grepformat^=%f:%l:%c:%m
else
set grepprg=grep\ -rnHI\ --exclude-dir=.git\ --exclude=tags
endif
" plugin settings
let g:ale_lint_on_insert_leave = 1
let g:ale_lint_on_text_changed = 'never'
let g:ale_linters = {
\ 'javascript': ['eslint']
\}
let g:ale_fixers = {
\ 'javascript': ['eslint']
\}
let g:ale_pattern_options = {
\ '/node_modules/': { 'ale_enabled': 0 },
\ '\.go$': { 'ale_enabled': 0 },
\}
let g:go_highlight_extra_types = 1
let g:html_indent_inctags = 'dd,dt,p'
let g:html_indent_script1 = 'inc'
let g:html_indent_style1 = 'inc'
let g:is_posix = 1
let g:markdown_fenced_languages = [
\ 'bash=sh',
\ 'css',
\ 'go',
\ 'html',
\ 'java',
\ 'javascript',
\ 'js=javascript',
\ 'json',
\ 'python',
\ 'ruby',
\ 'shell=sh',
\ 'sql',
\ 'swift',
\ 'terraform',
\ 'yaml',
\]
let g:no_default_tabular_maps = 1
let g:terraform_fmt_on_save = 1
let g:vim_indent_cont = 2
" mappings
let g:mapleader = ','
" make Q work like gq instead of switching to Ex mode
map Q gq
" make Y work like y$ instead of yy
nmap Y y$
" In insert mode, break the current undo sequence in sensible places. If <CR>
" is already mapped to include <C-G>u, then don't remap it. This preserves the
" endwise.vim <CR> mapping when re-sourcing this file.
if maparg('<CR>', 'i') !~# '<C-G>u<CR>'
inoremap <CR> <C-G>u<CR>
endif
inoremap <C-U> <C-G>u<C-U>
inoremap <C-W> <C-G>u<C-W>
" make & include flags
nnoremap & :&&<CR>
xnoremap & :&&<CR>
" make Ctrl-C check abbreviations, trigger InsertLeave, and preserve cursor
" position
inoremap <C-C> <Esc>`^
" continuous indentation
xnoremap > >gv
xnoremap < <gv
" clear search highlighting
nnoremap <silent> <C-L> :nohlsearch<CR><C-L>
function! s:sort_opfunc(...)
'[,']sort
endfunction
nnoremap <silent> gs :set operatorfunc=<SID>sort_opfunc<CR>g@
xnoremap <silent> gs :sort<CR>
noremap gy "*y
noremap gY "*y$
nnoremap [q :cprev<CR>
nnoremap ]q :cnext<CR>
nnoremap yol :setlocal invlist<CR>
nnoremap yow :setlocal invwrap<CR>
nnoremap <silent> cd
\ :if exists('*FugitiveGitDir') && !empty(FugitiveGitDir())<Bar>
\ Glcd<Bar>
\ else<Bar>
\ lcd %:h<Bar>
\ endif<Bar>
\ <CR>
nnoremap <silent> <C-W>z :wincmd z<Bar>pclose<Bar>cclose<Bar>lclose<Bar>helpclose<CR>
function! s:JumpToLastCursorPosition()
" If the last position is unset or past the end of the file, do nothing.
if line("'\"") == 0 || line("'\"") > line("$")
return
endif
" Jump to the last cursor position. If it is not in the bottom half of the
" last window, then re-center the window on the line.
if line("$") - line("'\"") > (line("w$") - line("w0")) / 2
return "g`\"zz"
else
return "g`\""
endif
endfunction
nnoremap <expr> gl <SID>JumpToLastCursorPosition()
augroup vimrc
autocmd!
autocmd BufNewFile,BufReadPost *.log{,.[0-9]*} setlocal readonly bufhidden=unload buftype=nowrite noundofile nowrap
autocmd BufNewFile,BufReadPost */.kube/config setlocal ft=yaml
autocmd BufNewFile,BufReadPost */node_modules/* setlocal readonly
autocmd BufNewFile,BufReadPost .npmignore setlocal ft=conf
autocmd BufWritePost */spell/*.add silent! mkspell! <afile>
autocmd BufWritePre /tmp/*,$TMPDIR/*,/{private,var,private/var}/tmp/*,/{var,private/var}/folders/* setlocal noundofile
autocmd CursorHoldI * silent! call feedkeys("\<C-G>u", "nt")
autocmd CursorHold,CursorHoldI,BufWritePost,BufReadPost,BufLeave *
\ if !empty(filter(split(&directory, ","), "isdirectory(expand(v:val))")) |
\ let &swapfile = &modified |
\ endif
autocmd FocusGained * silent! checktime
autocmd FocusLost * silent! wall
augroup END
if filereadable(expand('~/.vimrc.local'))
source ~/.vimrc.local
endif