-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc
347 lines (288 loc) · 10.4 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
" _ _ _ __
"| | ___ __ _ __| | ___ _ __ | |/ /___ _ _
"| | / _ \/ _` |/ _` |/ _ \ '__| | ' // _ \ | | |
"| |__| __/ (_| | (_| | __/ | | . \ __/ |_| |
"|_____\___|\__,_|\__,_|\___|_| |_|\_\___|\__, |
" |___/
let mapleader=" "
" _ _
"__ _(_)_ __ ___ _ __ | |_ _ __ _
"\ \ / / | '_ ` _ \ _____| '_ \| | | | |/ _` |
" \ V /| | | | | | |_____| |_) | | |_| | (_| |
" \_/ |_|_| |_| |_| | .__/|_|\__,_|\__, |
" |_| |___/
if empty(glob('~/.vim/autoload/plug.vim')) && empty(glob('~/.config/nvim/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 | source $MYVIMRC
endif
set nocompatible " Be iMproved
call plug#begin('~/.vim/plugged')
Plug 'tomasr/molokai'
" harden
Plug 'ciaranm/securemodelines'
" Make Vim Powerful
Plug 'jiangmiao/auto-pairs'
Plug 'kien/ctrlp.vim'
Plug 'scrooloose/nerdtree'
Plug 'PhilRunninger/nerdtree-buffer-ops'
Plug 'jistr/vim-nerdtree-tabs'
Plug 'ervandew/supertab'
Plug 'majutsushi/tagbar'
Plug 'junegunn/vim-easy-align'
Plug 'terryma/vim-multiple-cursors'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'triglav/vim-visual-increment'
Plug 'andymass/vim-matchup'
Plug 'fs111/pydoc.vim'
" disable following plugins for better performance
if filereadable(expand('~/.vimenv.fastcomputer'))
Plug 'airblade/vim-gitgutter'
"Plug 'SirVer/ultisnips'
"Plug 'honza/vim-snippets'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
endif
" Syntax
Plug 'chr4/nginx.vim'
Plug 'PProvost/vim-ps1' "ps1
Plug 's3rvac/vim-syntax-yara'
Plug 'cespare/vim-toml'
" only load these web front-end related plugins when we need them
if filereadable(expand('~/.frontend.vimenv'))
" syntax
Plug 'othree/html5.vim'
Plug 'cakebaker/scss-syntax.vim'
Plug 'hail2u/vim-css3-syntax'
Plug 'othree/yajs.vim'
Plug 'posva/vim-vue'
Plug 'slim-template/vim-slim'
Plug 'digitaltoad/vim-pug'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'neoclide/coc-vetur'
" other
" Everyone uses template engine, but you can add it into .frontend.vimenv
"Plug 'mattn/emmet-vim'
source ~/.frontend.vimenv
endif
" Command Tool
Plug 'mileszs/ack.vim'
" Misc
Plug 'editorconfig/editorconfig-vim'
let local_Vimrc=expand('~/.vimrc.local')
if filereadable(local_Vimrc)
source ~/.vimrc.local
endif
call plug#end()
filetype plugin indent on
" _____ _
"|_ _| |__ ___ _ __ ___ ___
" | | | '_ \ / _ \ '_ ` _ \ / _ \
" | | | | | | __/ | | | | | __/
" |_| |_| |_|\___|_| |_| |_|\___|
let g:rehash256 = 1
if !empty(glob('~/.vim/plugged/molokai/colors/molokai.vim'))
color molokai
endif
" ____ _ ____ __ _
"| __ ) __ _ ___(_) ___ / ___|___ _ __ / _(_) __ _
"| _ \ / _` / __| |/ __| | | / _ \| '_ \| |_| |/ _` |
"| |_) | (_| \__ \ | (__ | |__| (_) | | | | _| | (_| |
"|____/ \__,_|___/_|\___| \____\___/|_| |_|_| |_|\__, |
" |___/
set autoindent " 自動縮排
set backspace=indent,eol,start " 統一 backsapce 功能
set colorcolumn=100 " 換行提示線
set cursorline " 目前游標所在這行反白
set fileencodings=utf-8,default,big5,ucs-bom,latin1
set hlsearch " 顏色標記被搜尋的文字
set ignorecase " 搜尋忽略大小寫
set incsearch " 往後搜尋
set nobackup " 關閉備份檔案
set noswapfile " 不使用 swapfile
set nowritebackup " 關閉備份檔案
set number " 顯示行數
set ruler " 游標位置資訊
set scrolloff=3 " 游標距離上下 N 行開始捲動螢幕
set shiftwidth=4 " tab 寬度
set showcmd " 顯示命令按鍵
set smartcase " 搜尋時自動判斷是否區分大小寫
set smartindent " 自動縮排
set splitright " :vsplit on right side
set t_Co=256 " 啟用256色彩空間
set tabpagemax=100 " 一次最多可以開多少tab
set tabstop=4 " tab寬度
set timeoutlen=300 " escape delay
set wildmenu " 自動補完選單
set termguicolors
syntax on
filetype plugin indent on
" _____ _ _ _____ ____ _ _ _
"| ___(_) | __|_ _| _ _ __ ___ | _ \ ___| | __ _| |_ ___ __| |
"| |_ | | |/ _ \| || | | | '_ \ / _ \ | |_) / _ \ |/ _` | __/ _ \/ _` |
"| _| | | | __/| || |_| | |_) | __/ | _ < __/ | (_| | || __/ (_| |
"|_| |_|_|\___||_| \__, | .__/ \___| |_| \_\___|_|\__,_|\__\___|\__,_|
" |___/|_|
autocmd FileType python setlocal et sw=4 sts=4 cc=80
autocmd FileType html setlocal et sw=2 sts=2
autocmd FileType ruby setlocal noet sw=2 sts=2
autocmd FileType php setlocal et
" _ __ __ __ _
"| |/ /___ _ _ | \/ | __ _ _ __ _ __ (_)_ __ __ _
"| ' // _ \ | | | | |\/| |/ _` | '_ \| '_ \| | '_ \ / _` |
"| . \ __/ |_| | | | | | (_| | |_) | |_) | | | | | (_| |
"|_|\_\___|\__, | |_| |_|\__,_| .__/| .__/|_|_| |_|\__, |
" |___/ |_| |_| |___/
imap jk <esc>
" clear search result
nnoremap <c-l> :noh<CR>
inoremap <c-l> <c-o>:noh<CR>
" tagbar
nmap <F8> :TagbarToggle<CR>
" NERDTree
inoremap <F10> <ESC>:NERDTreeTabsToggle<CR>
nnoremap <silent> <F10> :NERDTreeTabsToggle<CR>
let g:NERDTreeWinSize=22
let NERDTreeIgnore=['__pycache__', '\.o$', '\.pyc$', '\~$', 'node_modules', '\.dSYM$', '\.class$']
" EasyAlign
vmap <Enter> <Plug>(EasyAlign)
" tabs
nmap <Tab> gt
nmap <S-Tab> gT
nmap <A-]> gt
nmap <A-[> gT
" ctags
nmap g<enter> <c-]>
" move in panels
nmap <leader>h <c-w>h
nmap <leader>j <c-w>j
nmap <leader>k <c-w>k
nmap <leader>l <c-w>l
" integration with system clipboard
map <leader>p "*p
map <leader>y "*y
" _____ _ _
"| ____|_ _____ ___ _ _| |_(_) ___ _ __
"| _| \ \/ / _ \/ __| | | | __| |/ _ \| '_ \
"| |___ > < __/ (__| |_| | |_| | (_) | | | |
"|_____/_/\_\___|\___|\__,_|\__|_|\___/|_| |_|
autocmd filetype c nnoremap <leader>r :w <bar> exec '!gcc '.shellescape('%').' -std=c99 -O2 && ./a.out'<CR>
autocmd filetype cs nnoremap <leader>r :w <bar> exec '!mcs '.shellescape('%').' && mono '.shellescape('%:r').'.exe'<CR>
autocmd filetype cpp nnoremap <leader>r :w <bar> exec '!g++ '.shellescape('%').' -std=c++17 -O2 && ./a.out'<CR>
autocmd filetype php nnoremap <leader>r :w <bar> exec '!php -f '.shellescape('%') <CR>
autocmd filetype java nnoremap <leader>r :w <bar> exec '!javac '.shellescape('%').'&&java '.shellescape('%:r') <CR>
autocmd filetype lisp nnoremap <leader>r :w <bar> exec '!clisp '.shellescape('%') <CR>
autocmd filetype perl nnoremap <leader>r :w <bar> exec '!perl '.shellescape('%') <CR>
autocmd filetype ruby nnoremap <leader>r :w <bar> exec '!ruby '.shellescape('%') <CR>
autocmd filetype shell nnoremap <leader>r :w <bar> exec '!bash '.shellescape('%') <CR>
autocmd filetype python nnoremap <leader>r :w <bar> exec '!python3 '.shellescape('%')<CR>
autocmd filetype javascript nnoremap <leader>r :w <bar> exec '!nodejs '.shellescape('%') <CR>
" ____ _ _ ____ __ _
"| _ \| |_ _ __ _(_)_ __ ___ / ___|___ _ __ / _(_) __ _
"| |_) | | | | |/ _` | | '_ \/ __| | | / _ \| '_ \| |_| |/ _` |
"| __/| | |_| | (_| | | | | \__ \ | |__| (_) | | | | _| | (_| |
"|_| |_|\__,_|\__, |_|_| |_|___/ \____\___/|_| |_|_| |_|\__, |
" |___/ |___/
" Ctags
let g:ctags_statusline = 1
" CtrlP
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](\.(git|hg|svn)|node_modules)$',
\ 'file': '\v\.(exe|so|dll|swp|zip|7z|rar|gz|xz|apk|dmg|iso|jpg|png|pdf)$',
\ }
" python-syntax
let python_highlight_all = 1
" vim-css3-syntax
augroup VimCSS3Syntax
autocmd!
autocmd FileType css setlocal iskeyword+=-
augroup END
" vim-surround
let g:surround_45="<% \r %>" " -
let g:surround_61="<%= \r %>" " =
let g:surround_33="<!-- \r -->" "!
let g:surround_42="/* \r */" "*
" ack.vim
if executable('ag') || executable('ag.exe')
let g:ackprg = 'ag --vimgrep'
endif
" pydoc.vim
let g:pydoc_open_cmd = 'vsplit'
let g:pydoc_cmd = 'python3 -m pydoc'
" ultisnips
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
let g:UltiSnipsEditSplit="vertical"
" coc.nvim
if has_key(plugs, 'coc.nvim')
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
nmap <leader>rn <Plug>(coc-rename)
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
inoremap <silent><expr> <m-j>
\ coc#pum#visible() ? coc#pum#next(1) :
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr><m-k> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm() : "\<CR>"
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
endif
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }
" ___ _ _
" / _ \| |_| |__ ___ _ __
"| | | | __| '_ \ / _ \ '__|
"| |_| | |_| | | | __/ |
" \___/ \__|_| |_|\___|_|
" Highlight trailing spaces
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
hi Search ctermfg=16 ctermbg=226
if executable('win32yank.exe')
let g:clipboard = {
\ 'name': 'win32yank-wsl',
\ 'copy': {
\ '*': 'win32yank.exe -i --crlf',
\ },
\ 'paste': {
\ '*': 'win32yank.exe -o --lf',
\ },
\ 'cache_enabled': 0,
\ }
endif