-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.vim
288 lines (237 loc) · 7.65 KB
/
init.vim
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
" # Requirements
"
" - dein.vim
" - Following variables
" - `dein_home_path`
" - `dein_plugin_base_path`
"
" ```
" let dein_home_path = '~/.config/dein.vim/repos/github.com/Shougo/dein.vim'
" let dein_plugin_base_path = '~/.config/dein.vim'
" source $HOME/projects/dotfiles/init.vim
" ```
"
" # File Locations for Windows
"
" - Word file (spell): `$VIM/share/nvim/runtime/spell`
" - Color scheme: `$HOME/.vim/colors`
" - Settings in Windows: `$HOME/AppData\Local\nvim\init.vim`
" ----------------------------------------------------------------
" Setting variables
if !exists('dein_home_path')
dein_home = ''
endif
if !exists('dein_plugin_base_path')
dein_home = ''
endif
" ----------------------------------------------------------------
" Basic Settings
" Editor
set autoindent
set ignorecase
set number
set shiftwidth=2
set smartcase
set tabstop=2
" Languages
set encoding=utf-8
set fileencoding=utf-8
set fileformat=unix
set fileformats=unix,dos,mac
set spell
set spelllang=en,cjk
" Colours
" colorscheme default
colorscheme japanesque
" Foldings
set foldmethod=indent
set foldlevelstart=999
set foldopen-=search
" ----------------------------------------------------------------
" Shortcuts
" Basics
imap <C-@> <C-[>
nnoremap <Space><Space> <Esc>
" Files
nnoremap <C-t> :NERDTreeToggle<CR>
nnoremap <Space><C-t> :NERDTreeFind<CR>
nnoremap <Space><C-p> :CtrlPMRUFiles<CR>
nnoremap <Space><C-b> :CtrlPBuffer<CR>
" Coding
nnoremap <S-Left> <iB
nnoremap <S-Right> >iB
vnoremap <S-S> :sort<cr>
" Visual
nnoremap <Space>s :SyntasticToggleMode<CR>
" Search
set inccommand=split
nnoremap <C-H> ^
vnoremap <C-H> ^
nnoremap <C-L> $
vnoremap <C-L> $
nnoremap <C-/> :noh<CR>
" Folding
function! ToggleSearchFromFoldings()
if (index(split(&foldopen, ","), "search") < 0)
set foldopen+=search
else
set foldopen-=search
endif
endfunction
nnoremap <C-Z> za
nnoremap <S-Z> :call ToggleSearchFromFoldings()<cr>
" Diff
nnoremap <Space><C-D> :diffupdate<CR>
nnoremap <Space><S-D> :diffoff!<CR>
nnoremap <Space>d :diffthis<CR>
" set diffopt+=vertical
" Tabs
nnoremap <C-W><C-T> :tabnew<CR>
nnoremap <C-Tab> :tabnext<CR>
nnoremap <C-S-Tab> :tabprevious<CR>
" Dealing with the host OS
nnoremap <C-N> :!start nvim-qt<CR>
" nnoremap <C-N> :!start nvim-qt --qwindowgeometry 1280x850<CR>
:command! W :set columns=80 lines=25
vnoremap <C-C> "+y
nnoremap <Space>p "+p
nnoremap <Space>P "+P
" Terminal
tnoremap <C-\><C-\> <C-\><C-n>
tnoremap <C-\>p <C-\><C-n>pa
tnoremap <C-\>P <C-\><C-n>"+Pa
tnoremap <S-Space> <Space>
command TB :terminal bash
tnoremap <C-Tab> <C-\><C-n>:tabnext<CR>
tnoremap <C-S-Tab> <C-\><C-n>:tabprevious<CR>
" tnoremap <C-W><C-T> <C-\><C-n>:tabnew<CR>
tnoremap <C-/> <C-\><C-n>:noh<CR>a
" ----------------------------------------------------------------
" Snippet
augroup filetype_javascript
autocmd!
autocmd FileType javascript inoremap <buffer> <C-F><C-L> console.log()<left>
autocmd FileType javascript inoremap <buffer> <C-F><C-D> console.debug('# ')<left><left>
autocmd FileType javascript inoremap <buffer> <C-F><C-F> function(
autocmd FileType javascript inoremap <buffer> <C-F><C-G> ) {<CR>}
autocmd FileType javascript vnoremap <buffer> <leader>B <esc>`<O{<esc>`>o}<esc>%viB>-i <left>| " surround with {}
augroup END
" ----------------------------------------------------------------
" dein.vim
" https://github.com/Shougo/dein.vim
if &compatible
set nocompatible
endif
" Required:
let &runtimepath .= ',' . dein_home_path
" Required:
if dein#load_state(dein_plugin_base_path)
call dein#begin(dein_plugin_base_path)
" Let dein manage dein
" Required:
call dein#add(dein_home_path)
" call dein#add('')
call dein#add('Lokaltog/vim-easymotion') " jump
call dein#add('Shougo/deoplete.nvim') " requires Python3
call dein#add('Shougo/neosnippet-snippets')
call dein#add('Shougo/neosnippet.vim')
call dein#add('airblade/vim-gitgutter') " show changed lines
call dein#add('ctrlpvim/ctrlp.vim') " filer
call dein#add('digitaltoad/vim-pug')
call dein#add('editorconfig/editorconfig-vim') " ?
call dein#add('isRuslan/vim-es6')
call dein#add('itchyny/lightline.vim') " bottom bar
call dein#add('itchyny/vim-cursorword') " underline a word
call dein#add('mattn/emmet-vim')
call dein#add('nathanaelkane/vim-indent-guides')
call dein#add('oblitum/rainbow')
call dein#add('posva/vim-vue')
call dein#add('scrooloose/nerdtree') " filer
call dein#add('tpope/vim-fugitive') " git
call dein#add('tyru/caw.vim') " toggle comment
call dein#add('tyru/open-browser.vim') " open URL
call dein#add('vim-syntastic/syntastic')
" Required:
call dein#end()
call dein#save_state()
else
echom 'Failed to start dein'
endif
" Required:
filetype plugin indent on
syntax enable
" If you want to install not installed plugins on startup.
if dein#check_install()
call dein#install()
endif
" call map(dein#check_clean(), "delete(v:val, 'rf')")
" ----------------------------------------------------------------
" Neosnippet
" Plugin key-mappings.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
" Do not turn on followings, or double quotations in JSON hide
"" " For conceal markers.
"" if has('conceal')
"" set conceallevel=2 concealcursor=niv
"" endif
let g:neosnippet#snippets_directory="$HOME/.config/neosnippet.vim"
" ----------------------------------------------------------------
" Ctrlp
" https://github.com/kien/ctrlp.vim
let g:ctrlp_custom_ignore = {
\ 'dir': 'node_modules\|vendor',
\ }
" ----------------------------------------------------------------
" deoplete.nvim
call deoplete#enable()
" ----------------------------------------------------------------
" EasyMotion
" https://github.com/Lokaltog/vim-easymotion
" http://mba-hack.blogspot.jp/2013/01/vim4.html
" let g:Eaotion_keys='hjklasdfgyuiopqwertnmzxcvbHJKLASDFGYUIOPQWERTNMZXCVB'
" let g:EasyMotion_leader_key=","
" let g:EasyMotion_grouping=1
" nmap <C-k><C-k> ,b
" nmap <C-k><C-j> ,w
nmap <C-j> <Plug>(easymotion-sn)
" ----------------------------------------------------------------
" encomment
" https://github.com/tyru/caw.vim
nmap <Space>k <Plug>(caw:hatpos:toggle)
vmap <Space>k <Plug>(caw:hatpos:toggle)
nmap <Space><S-k> <Plug>(caw:wrap:toggle)
vmap <Space><S-k> <Plug>(caw:wrap:toggle)
" ----------------------------------------------------------------
" https://github.com/tyru/open-browser.vim
nmap <Leader>o <Plug>(openbrowser-open)
" ----------------------------------------------------------------
" https://github.com/scrooloose/nerdtree
let NERDTreeShowBookmarks=0
let g:NERDTreeBookmarksSort=0
" ----------------------------------------------------------------
" Indent Guides
" https://github.com/nathanaelkane/vim-indent-guides
" https://github.com/nathanaelkane/vim-indent-guides/issues/31
let g:indent_guides_enable_on_vim_startup = 1
" ----------------------------------------------------------------
" Editorconfig
" https://github.com/editorconfig/editorconfig-vim
" Set following variable in first init.vim on current machine
" let g:EditorConfig_exec_path = "C:/Users/ginpei/app/editorconfig/bin/editorconfig.exe"
" ----------------------------------------------------------------
" Syntastic
" https://github.com/vim-syntastic/syntastic
" https://medium.com/@hpux/vim-and-eslint-16fa08cc580f
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_javascript_eslint_exec = 'npm run lint --'
" let g:syntastic_debug=3