-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
242 lines (194 loc) · 7.28 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
"-- Plugs {{{ ----------------------------------------------------------------
call plug_helper#install_plug_vim_if_needed()
call plug#begin('~/.vim/plugged')
Plug 'prabirshrestha/vim-lsp'
Plug 'mattn/vim-lsp-settings' " |vim_lsp_settings|
Plug 'Shougo/ddc.vim'
Plug 'shun/ddc-vim-lsp'
Plug 'LumaKernel/ddc-file'
Plug 'MattesGroeger/vim-bookmarks' " |vim_bookmarks|
Plug 'Shougo/ddc.vim' " |ddc_vim|
Plug 'Shougo/ddc-filter-matcher_head'
Plug 'Shougo/ddc-filter-sorter_rank'
Plug 'Shougo/ddc-source-around'
Plug 'Shougo/ddc-ui-native'
Plug 'Shougo/neomru.vim'
Plug 'Shougo/unite.vim' " |unite_vim|
Plug 'Yggdroot/indentLine' " |indentline|
Plug 'airblade/vim-gitgutter' " |vim_gitgutter|
Plug 'bkad/CamelCaseMotion' " |camelcasemotion|
Plug 'christoomey/vim-tmux-navigator' " |vim_tmux_navigator|
Plug 'easymotion/vim-easymotion' " |vim_easymotion|
Plug 'elzr/vim-json' " |vim_json|
Plug 'itchyny/lightline.vim'
Plug 'junegunn/fzf'
Plug 'rhysd/committia.vim'
Plug 'preservim/nerdcommenter' " |nerdcommenter|
Plug 'preservim/nerdtree' " |nerdtree|
Plug 'sheerun/vim-polyglot' " |vim_polyglot|
Plug 'slack/vim-l9'
Plug 'terryma/vim-expand-region' " |vim_expand_region|
Plug 'thinca/vim-quickrun' " |vim_quickrun|
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-fugitive' " |vim_fugitive|
Plug 'tpope/vim-sleuth'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
Plug 'vim-denops/denops.vim'
Plug 'vim-scripts/Align'
Plug 'vim-scripts/sudo.vim'
Plug 'digitaltoad/vim-pug', {'for': 'pug'}
Plug 'elixir-lang/vim-elixir', {'for': 'elixir'}
Plug 'kchmck/vim-coffee-script', {'for': 'coffee'}
Plug 'leafgarland/typescript-vim', {'for': 'typescript'}
Plug 'rust-lang/rust.vim', {'for': 'rust'}
Plug 'slim-template/vim-slim', {'for': 'slim'}
call plug#end()
" See ~/.vim/plugin/plugged/*.vim for settings of plugins.
" See ~/.vim/etc/unused_settings.vim for unused plugins.
" Define commands to create/remove empty settings file for each plugin.
command! PlugStub call plug_helper#stub()
command! PlugUnstub call plug_helper#unstub()
" Remap gf to open a plug in the browser.
function! PlugOpen()
exec 'silent ! open https://github.com/' . expand('<cfile>')
call feedkeys("\<C-l>") " Refresh screen wiped by the command above.
endfunction
au BufEnter .vimrc nmap <buffer> <silent> gf :call PlugOpen()<CR>
"-- Plugs }}} ----------------------------------------------------------------
"-- Vim settings {{{ ---------------------------------------------------------
" Always use en_US.
language en_US
" Suppress deprecation warning from Python 3.7.
" Fixed in 8.1.201.
" See https://github.com/vim/vim/issues/3117#issuecomment-402622616
if has('python3') && !has('patch-8.1.201')
silent! python3 pass
endif
set encoding=utf-8 " Set default encoding. Otherwise it would be latin1.
set ignorecase " Ignore case in the search pattern.
set smartcase " Override ignorecase if the search pattern contains uppercase characters.
set laststatus=2 " Always show status-line.
set foldmethod=marker " Automatically fold by markers.
set backspace=indent,eol,start " Allow backspacing over these items.
set synmaxcol=256 " Limit maximum column upto witch Vim tries to parse syntax.
set number " Show line number.
set mouse=a " Enable mouse for *a*ll modes.
set visualbell t_vb= " Silence beep sound.
set hidden " Hide buffer when it is abonedoned.
set scrolloff=2 " Set minimum number of lines to keep visible around the cursor.
set nofixeol " Do not fix missing EOL.
" Enable incremental search with highlight.
set hlsearch
set incsearch
" Enhance command-line completion.
set wildmenu
set wildmode=longest,full
" Show tabs and trailing whitespaces.
set list
set listchars=tab:>-,trail:_
" Set position of a new split window.
set splitbelow
set splitright
" Make wrapped line continue visually indented.
set breakindent
let &breakindentopt = 'sbr'
let &showbreak = '> '
" Set local leader character.
let maplocalleader = '_'
" Extend '%' motion.
packadd matchit
" Prepare my data directory.
let $VIM_DATA_DIR = $HOME . '/.local/share/vim'
if !isdirectory($VIM_DATA_DIR)
call mkdir($VIM_DATA_DIR, 'p')
endif
" Add a tags file to jump around my vim settings.
set tags+=$VIM_DATA_DIR/vimrc_tags
" Enable backup.
set backup
set backupdir=$VIM_DATA_DIR/backup
if !isdirectory(&backupdir)
call mkdir(&backupdir)
endif
" Set swapfile directory.
set directory=$VIM_DATA_DIR/swap
if !isdirectory(&directory)
call mkdir(&directory)
endif
" Enable undofile.
set undofile
set undodir=$VIM_DATA_DIR/undo
if !isdirectory(&undodir)
call mkdir(&undodir)
endif
"-- Vim settings }}} ---------------------------------------------------------
"-- Mappings {{{ -------------------------------------------------------------
""" Extended moves
" First/last changed/yanked
nnoremap Ki '[
nnoremap Ji ']
" First/last selected
nnoremap Kv '<
nnoremap Jv '>
" Move around windows and tabs
nnoremap T :tab
nnoremap <silent> <Right> :tabnext<CR>
nnoremap <silent> <Left> :tabprevious<CR>
nnoremap <silent> <Tab> :<C-U>wincmd w<CR>
nnoremap <silent> <S-Tab> :<C-U>wincmd W<CR>
" Emacs-like motion in command mode
cnoremap <C-A> <Home>
cnoremap <C-F> <Right>
cnoremap <C-B> <Left>
" Unhilight search results by double-tapping <Esc>
" Yanked from http://d.hatena.ne.jp/viver/20070612/p1
nnoremap <silent> <Esc><Esc> :noh<CR><Esc>
" Insert current file's path and it's base directory, respectively
cnoremap <C-X> <c-r>=expand('%:p:h')<cr>/
cnoremap <C-Z> <c-r>=expand('%:p:r')<cr>
" Map omni-completion to Ctrl-B which is unused
inoremap <C-B> <C-X><C-O>
" Search selected string by * in visual mode
" Yanked from http://labs.timedia.co.jp/2014/09/learn-about-vim-in-the-workplace.html
vnoremap * "zy:let @/ = @z<CR>n
" Miscellany
cnoremap w!! w !sudo tee > /dev/null %
inoremap <C-J> <Esc>o
noremap Y y$
"-- Mappings }}} -------------------------------------------------------------
"-- Abbereviations {{{ -------------------------------------------------------
" Correct common typos.
iab erorr error
iab imoprt import
iab improt import
iab labmda lambda
iab retrn return
iab retunr return
iab reqiure require
iab slef self
"-- Abbreviations }}} --------------------------------------------------------
"-- Autocmds {{{ -------------------------------------------------------------
" Set group for the following autocmds
augroup vimrc
" Unregister autocmds in the vimrc group first so that the following autocmds
" will not be registered twice when reloading .vimrc
autocmd!
au BufWritePost .vimrc :exec 'silent ! ~/.vim/bin/generate_vimrc_tags.pl'
" Automatically open QuickFix window
au QuickfixCmdPost make,grep,grepadd,vimgrep cwindow
" End the vimrc group
augroup END
"-- Autocmds }}} -------------------------------------------------------------
"-- Commands {{{ -------------------------------------------------------------
command -nargs=* -complete=file New tabnew
"-- Commands }}} -------------------------------------------------------------
"-- Highlight {{{ ------------------------------------------------------------
hi Folded ctermbg=NONE
hi LineNr ctermfg=darkgray
" Highlight TabLine
" Stolen from http://d.hatena.ne.jp/teramako/20070318/vim7_tab
hi TabLine term=reverse cterm=reverse,underline ctermfg=white ctermbg=blue
hi TabLineSel term=bold cterm=bold ctermfg=5
hi TabLineFill term=reverse cterm=reverse,underline ctermfg=white ctermbg=blue
"-- Highlight }}}-------------------------------------------------------------