-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvim.vimrc
235 lines (194 loc) · 5.95 KB
/
vim.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
" color scheme
syntax on
colorscheme pablo
set bg=dark
set history=1000
" general
set backspace=indent,eol,start
set nocursorline
set nocompatible
set nolist
set nowrap
set numberwidth=5
set ruler
set scrolloff=5
set showcmd
set showmatch
set showmode
set laststatus=2
set autoread
set viminfo=""
" filetype support
filetype plugin indent on
" colorcolumn
set colorcolumn=80
" highlight
hi ColorColumn ctermfg=150 ctermbg=236
hi LineNr ctermfg=111 ctermbg=256
hi DiffAdd ctermfg=NONE ctermbg=22 cterm=BOLD
hi DiffDelete ctermfg=NONE ctermbg=52 cterm=BOLD
hi DiffChange ctermfg=NONE ctermbg=23 cterm=BOLD
hi DiffText ctermfg=NONE ctermbg=23 cterm=BOLD
" trun off annoyed swap files
set noswapfile
set nobackup
set nowritebackup
" indention
set autoindent
set smartindent
set cindent
" tabs
set expandtab
set shiftwidth=4
set softtabstop=4
set tabstop=4
" search
set nohlsearch
set ignorecase
set incsearch
set smartcase
" misc
set noerrorbells
set novisualbell
set clipboard=unnamed
" encoding
set fileencoding=utf-8
set fileencodings=ucs-bom,utf-8,big5,latin1,euc-jp,gbk,euc-kr,utf-bom,iso8859-1
set encoding=utf-8
set tenc=utf-8
" always treat *.md as markdown file
autocmd BufNewFile,BufReadPost *.md set filetype=markdown
" always treat Dockerfile.* as Dockerfile
autocmd BufNewFile,BufReadPost Dockerfile* set filetype=dockerfile
" always treat Jenkinsfile as groovy
autocmd BufNewFile,BufReadPost Jenkinsfile* set filetype=groovy
" always treat */{playbooks/roles}/*.y[a]ml as ansible
autocmd BufNewFile,BufReadPost */playbooks/*.yml set filetype=yaml.ansible
autocmd BufNewFile,BufReadPost */playbooks/*.yaml set filetype=yaml.ansible
autocmd BufNewFile,BufReadPost */roles/*.yml set filetype=yaml.ansible
autocmd BufNewFile,BufReadPost */roles/*.yaml set filetype=yaml.ansible
" always treat *.tf{vars,state} as terraform
autocmd BufNewFile,BufReadPost *.tf set filetype=terraform
autocmd BufNewFile,BufReadPost *.tfvars set filetype=terraform
autocmd BufNewFile,BufReadPost *.tfstate set filetype=terraform
autocmd BufNewFile,BufReadPost .terraform.lock.hcl set filetype=terraform
" always treat *.{pkr,pkrvars}.hcl as terraform
autocmd BufNewFile,BufReadPost *.pkr.hcl set filetype=terraform
autocmd BufNewFile,BufReadPost *.pkvars.hcl set filetype=terraform
" always treat *.ts as javascript file
autocmd BufNewFile,BufReadPost *.ts set filetype=javascript
" always treat *.jsonnet as terraform
autocmd BufNewFile,BufReadPost *.jsonnet set filetype=jsonnet
autocmd BufNewFile,BufRead *.libsonnet set filetype=jsonnet
" always treat Makefile* as make file
autocmd BufNewFile,BufReadPost Makefile* set filetype=make
" don't expand tab for filetype = make
autocmd FileType make set noexpandtab
" ignore files
set wildignore+=*.so,*.swp,*.zip,*.exe,*.pyc,*.pyo
" setting up vundle
let vundle_readme=expand('~/.vim/bundle/Vundle.vim/README.md')
if !filereadable(vundle_readme)
echo "Installing Vundle.."
echo ""
silent !mkdir -p ~/.vim/bundle
silent !git clone https://github.com/VundleVim/Vundle.vim ~/.vim/bundle/Vundle.vim
!vim +BundleInstall +qall
endif
set rtp+=~/.vim/bundle/Vundle.vim
" setup plugins
call vundle#begin()
" basic
Plugin 'VundleVim/Vundle.vim'
" theme
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
" git
Plugin 'airblade/vim-gitgutter'
Plugin 'mhinz/vim-signify'
Plugin 'tpope/vim-endwise'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-git'
" useful plugins
Plugin 'Xuyuanp/nerdtree-git-plugin'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'tomtom/tcomment_vim'
Plugin 'ervandew/supertab'
Plugin 'junegunn/vim-easy-align'
" syntax highlighting
Plugin 'fatih/vim-go'
Plugin 'hashivim/vim-terraform'
Plugin 'hashivim/vim-packer'
Plugin 'hdima/python-syntax'
Plugin 'nvie/vim-flake8'
Plugin 'pearofducks/ansible-vim'
Plugin 'plasticboy/vim-markdown'
Plugin 'vim-ruby/vim-ruby'
Plugin 'google/vim-jsonnet'
Plugin 'rust-lang/rust.vim'
call vundle#end()
set pastetoggle=<F9>
" <Ctrl-N> NERDTREE Toggle
" <Ctrl-w-w> to switch between panels
" - https://stackoverflow.com/a/25254470
:map <silent> <C-n> :NERDTreeToggle<CR>
" <F6>: toggle on/off syntax highlighting
:map <silent> <F6> :if exists("g:syntax_on") <Bar>
\ syntax off <Bar>
\ else <Bar>
\ syntax on <Bar>
\ hi ColorColumn ctermbg=7 <Bar>
\ endif <CR>
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
nmap <silent> gb :Git blame<CR>
" format json with "python -m json.tool"
nmap =j :%!python -m json.tool<CR>
" gs: toggle for turn ignore whitespace on/off for vimdiff
if &diff
map gs :call IwhiteToggle()<CR>
function! IwhiteToggle()
if &diffopt =~ 'iwhite'
set diffopt-=iwhite
else
set diffopt+=iwhite
endif
endfunction
endif
" manual setup required (macOS):
" 1. open https://github.com/powerline/fonts
" 2. download and install 'DejaVu Sans Mono for Powerline'
" 3. setup non-ASCII font
"
" reference:
" - https://powerline.readthedocs.io/en/latest/installation.html#fonts-installation
let g:airline_powerline_fonts = 0
" Ctrl-P
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](\.git|\.hg|\.svn|node_modules|\.terraform)$',
\ 'file': '\v\.(exe|so|dll|pyc|DS_Store)$',
\ }
" NertTree
let NERDTreeIgnore = ['\.pyc$', '\.pyo$']
let NERDTreeShowHidden = 1
" vim-go
"
" reference:
" - https://github.com/fatih/vim-go/wiki/Tutorial
" - https://github.com/golang/tools/blob/master/gopls/doc/vim.md#vimgo
let g:go_def_mode='gopls'
let g:go_info_mode='gopls'
let g:go_fmt_command = "goimports"
let g:go_textobj_include_function_doc = 1
" ansible
let g:ansible_name_highlight = 'b'
let g:ansible_attribute_highlight = "ob"
let g:ansible_unindent_after_newline = 1
let g:ansible_extra_keywords_highlight = 1
" Terraform
let g:terraform_align=1
let g:terraform_completion_keys = 1
let g:terraform_fmt_on_save=1