-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
229 lines (182 loc) · 6.41 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
syntax on
filetype plugin on
nnoremap Q :echo "The “Q” normal command is disabled because it’s annoying and useless"<CR>
"enable per-directory .vimrc files
set exrc
set secure
set foldmethod=manual
" display all matches on tab completion
set wildmenu
set nomodeline
set autoindent
set ruler
set number
set backspace=indent,eol,start
set history=1000
set scrolloff=2
set noerrorbells
set encoding=utf-8
set tabstop=4
set cursorline
highlight CursorLine term=bold cterm=bold guifg=NONE guibg=#121212 gui=NONE ctermfg=NONE ctermbg=236
set hlsearch
highlight Search term=NONE cterm=NONE ctermfg=11 ctermbg=239 guifg=#ffff00 guibg=#808000 gui=NONE
highlight mySpacesBeforeTab ctermbg=red guibg=lightgreen
highlight myTrailingWhitespace ctermbg=red guibg=lightgreen
highlight myTabsNotAtTheStartOfLine ctermbg=red guibg=lightgreen
highlight mySpacesForIndentingAfterTabs ctermbg=red guibg=lightgreen
highlight myOnlyWhitespace ctermbg=red guibg=lightgreen
function! RestoreCursorPosition()
if line("'\"") > 0
if line("'\"") <= line("$")
execute "norm '\""
else
execute "norm $"
endif
endif
endfunction
augroup my
autocmd BufReadPost * call RestoreCursorPosition()
"Show trailing whitepace and spaces before a tab:
autocmd Syntax * syntax match mySpacesBeforeTab / \+\ze\t/
autocmd Syntax * syntax match myTrailingWhitespace /\s\+$/
"Show tabs that are not at the start of a line:
autocmd Syntax * if &filetype != "help"
\|syntax match myTabsNotAtTheStartOfLine /[^\t]\zs\t\+/
"Show spaces used for indenting (so you use only tabs for indenting).
autocmd Syntax * syntax match mySpacesForIndentingAfterTabs /^\t*\zs \+/
autocmd Syntax * syntax match mySpacesForIndenting /^ \+/
autocmd Syntax * syntax match myOnlyWhitespace /^[ \t]\+$/
autocmd BufRead,BufNewFile .bashrc.my setlocal filetype=bash
autocmd BufRead,BufNewFile nginx.* set filetype=nginx
autocmd BufRead,BufNewFile */nginx.conf.d/*.conf set filetype=nginx
autocmd BufRead,BufNewFile */bind/zones/*.db set tabstop=8
autocmd BufRead,BufNewFile Capfile,Gemfile,*.ru,*.rb.* set filetype=ruby
autocmd BufRead,BufNewFile *.json set nospell
autocmd BufRead,BufNewFile *.env.* set filetype=sh
autocmd BufRead,BufNewFile * silent execute (getline(1) =~ '[^ ]\+/\(env \)\?node\>' ? "set filetype=javascript" : "")
autocmd BufRead,BufNewFile *.md setlocal textwidth=72
autocmd BufRead,BufNewFile *.as,*.js.esm set filetype=javascript
autocmd BufRead,BufNewFile ~/.aws/credentials set filetype=dosini
autocmd BufRead,BufNewFile *.my.cnf set filetype=dosini
autocmd BufRead,BufNewFile .crontab set filetype=crontab
autocmd BufRead,BufNewFile .gitignore set filetype=config
" Underscore templates
autocmd BufRead,BufNewFile *.html._ set filetype=html
" For files in /private/etc/sudoers.d/, e. g. vlad.sudoers
autocmd BufRead,BufNewFile *.sudoers set filetype=sudoers
autocmd BufRead,BufNewFile *.html._ set syntax=underscore_template
"remove line numbers for log files
autocmd BufNewFile,BufRead *.log set nonu
autocmd BufNewFile,BufRead *.html,*.php let b:unaryTagsStack="none"
augroup END
let g:netrw_list_hide='.*\.swp$'
let g:netrw_banner=0
execute pathogen#infect()
function! Eatchar(pat)
let c = nr2char(getchar(0))
return (c =~ a:pat) ? '' : c
endfunc
source ~/.vim/colors/diff.vim
source ~/.vim/colors/comments.vim
source ~/.vim/ftplugin/common.vim
"select the just-pasted text
nnoremap gp `[v`]
" let every line be considered a change in the undo history
inoremap <CR> <C-G>u<CR>
" let ^Z suspend vim even if in insert mode
inoremap <silent> <C-Z> <ESC>:stop<CR>
cnoremap <silent> <C-Z> <ESC>:stop<CR>
" let ^L clear search highlighting
noremap <silent> <C-l> :nohlsearch<CR>:redraw!<CR>:GitGutterAll<CR>
" Capture inside slashes. Useful for paths and regular expressions.
" Thanks to Dhruva Sagar @ http://stackoverflow.com/a/23668360/227167
onoremap <silent> i/ :<C-U>normal! T/vt/<CR>
onoremap <silent> i* :<C-U>normal! T*vt*<CR>
onoremap <silent> i+ :<C-U>normal! T+vt+<CR>
" IRB templates
onoremap <silent> i% :<C-U>normal! T%vt%<CR>
" Capture inside double smart quotes.
onoremap <silent> i” :<C-U>normal! T“vt”<CR>
" Capture Ruby lambda’s argument list
onoremap <silent> i\| :<C-U>normal! T\|vt\|<CR>
set showcmd
command W write
command Wq wq
command Wqa wqa
command Q quit
command Hexdump %!xxd
set signcolumn=yes
let g:closetag_filenames = "*.xml,*.html"
"let g:tsuquyomi_use_vimproc = 1
let g:elm_format_autosave = 1
call plug#begin()
Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'
Plug 'elmcast/elm-vim'
Plug 'mitermayer/vim-prettier', {
\ 'tag': '0.0.15',
\ 'do': 'npm install',
\ 'for': ['javascript', 'typescript', 'css', 'less', 'scss']
\ }
Plug 'metakirby5/codi.vim'
Plug 'heavenshell/vim-tslint'
Plug 'michaeljsmith/vim-indent-object'
Plug 'othree/xml.vim'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-liquid'
Plug 'cakebaker/scss-syntax.vim'
Plug 'chase/vim-ansible-yaml'
Plug 'groenewege/vim-less'
Plug 'leafgarland/typescript-vim'
Plug 'Quramy/tsuquyomi'
Plug 'Shougo/vimproc.vim', { 'do': 'make' }
Plug 'ElmCast/elm-vim'
Plug 'alvan/vim-closetag'
Plug 'airblade/vim-gitgutter'
Plug 'hail2u/vim-css3-syntax'
Plug 'w0rp/ale'
Plug 'elzr/vim-json'
Plug 'digitaltoad/vim-pug'
Plug 'jiangmiao/auto-pairs'
Plug 'vim-ruby/vim-ruby'
call plug#end()
"fzf
cnoremap <C-T> :GFiles<CR>
cnoremap <C-R> :History:<CR>
cnoremap <C-O> :Buffers<CR>
cnoremap <C-F> Ag<Space>
set spellfile=$HOME/.vim/spell/en.utf-8.add
set dictionary+=/usr/share/dict/words
" ALE begin https://github.com/w0rp/ale
let g:ale_fixers = {
\ 'css': ['stylelint', 'prettier'],
\ 'javascript': ['prettier'],
\ 'typescript': ['tslint', 'prettier'],
\ 'typescript.tsx': ['tslint', 'prettier'],
\}
let g:ale_fix_on_save = 1
autocmd User ALEFixPost GitGutterAll
nmap <C-A><C-F> :ALEFix<CR>
nmap <C-A><C-L> :ALELint<CR>
"TODO: disable when &diff == 1
" ALE end
let g:vim_json_syntax_conceal = 0
" auto-pairs
let g:AutoPairs = {
\ '`': '`',
\ '"': '"',
\ '{': '}',
\ '''': '''',
\ '(': ')',
\ '[': ']',
\}
"TODO: have ft-specific pair-sets, e.g. <> is unwanted in most cases
" Disabling this because it messes up my typing: I can’t type î any more.
let g:AutoPairsShortcutJump=''
" When the filetype is FILETYPE then make AutoPairs only match for parenthesis
"autocmd Filetype FILETYPE let b:AutoPairs = {"(": ")"}
" auto-pairs end