-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.vim
More file actions
344 lines (270 loc) · 7.88 KB
/
init.vim
File metadata and controls
344 lines (270 loc) · 7.88 KB
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
" Install Vim Plug if not installed
if empty(glob('~/.config/nvim/autoload/plug.vim'))
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall
endif
" Specify a directory for plugins
let g:pymode_python = 'python3'
"" Vim settings
set nu
syntax on
set re=0
set clipboard=unnamedplus
set cursorline
set nohlsearch
" Map leader key
let mapleader = " "
"set color
set termguicolors
" set t_Co=256
" show the cursor position all the time
set ruler
" display incomplete commands
set showcmd
" do incremental searching
set incsearch
if has('mouse')
set mouse=a
endif
set autoread
set autowrite
"" Set no backup
set nobackup
set nowb
set noswapfile
" Undo
set hidden
" Set folding
set foldmethod=indent
set foldlevel=99
set autoindent
set si "smart indent
" set tabs size
set tabstop=2 softtabstop=0 expandtab shiftwidth=2 smarttab
" ignore case when searching
set ignorecase
" Ignore
set wildignore+=*/node_modules/*,*.so,*.swp,*.zip
call plug#begin('~/.vim/plugged')
" Make sure you use single quotes
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
" Plug 'junegunn/vim-easy-align'
"" Persional Plugins
" On-demand loading
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'scrooloose/nerdcommenter'
" Git
Plug 'tpope/vim-fugitive'
" UI
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'terryma/vim-multiple-cursors'
Plug 'ryanoasis/vim-devicons'
Plug 'Yggdroot/indentLine'
" Elixir
Plug 'elixir-editors/vim-elixir'
" Search
set rtp+=~/.fzf
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
" Syntax
Plug 'pangloss/vim-javascript'
Plug 'maxmellon/vim-jsx-pretty'
Plug 'HerringtonDarkholme/yats.vim'
let g:vim_jsx_pretty_disable_tsx = 1
Plug 'cakebaker/scss-syntax.vim'
Plug 'hail2u/vim-css3-syntax'
" Editor
Plug 'ternjs/tern_for_vim', { 'do': 'npm install && npm install -g tern' }
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'alvan/vim-closetag'
Plug 'jiangmiao/auto-pairs'
Plug 'christoomey/vim-tmux-navigator'
" Plug 'autozimu/LanguageClient-neovim', {
" \ 'branch': 'next',
" \ 'do': 'bash install.sh',
" \ }
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Plug 'neoclide/coc-tsserver', {'do': 'npm i package.json && npm i'}
" Go
" Plug 'fatih/vim-go'
" Plug 'sebdah/vim-delve'
" Plug 'SirVer/ultisnips'
" Plug 'ludovicchabant/vim-gutentags'
" let g:gutentags_cache_dir = get(g:, 'gutentags_cache_dir', expand('~/.cache/tags'))
" Initialize plugin system
call plug#end()
"" Vim-airline
" airline config
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#show_buffers = 1
let g:airline#extensions#tabline#buffer_idx_mode = 1
"" Set theme
colorscheme neodark_custom
let g:airline_theme='badwolf'
" vim-javascript
let g:javascript_plugin_jsdoc = 1
let g:javascript_plugin_ngdoc = 1
" let g:javascript_conceal_arrow_function = "⇒"
set conceallevel=1
"" Map key
" close buffer
nmap qq :q<cr>
" New buffer
map <c-t> :new<cr>
" New vertical buffer
map <c-v> :vsplit<cr>
" New horizontal buffer
map <c-b> :split<cr>
" Quit all
nmap qa :qa<cr>
" Save
nmap ss :w<cr>
" Save without format
" nmap <leader>f <Plug>(coc-format-selected)
" Ag
" nmap <leader>ag :rg<cr>
nmap <leader>f :Rg<cr>
" jumpDefinition
nmap gd :call CocAction('jumpDefinition', 'drop')<cr>
" Map syntastic
map <leader>ep :lprev<cr>
map <leader>en :lnext<cr>
" refml
map <leader>r :!refmt --in-place %<cr>
" Fast moving tab airline
nmap <leader>1 <Plug>AirlineSelectTab1
nmap <leader>2 <Plug>AirlineSelectTab2
nmap <leader>3 <Plug>AirlineSelectTab3
nmap <leader>4 <Plug>AirlineSelectTab4
nmap <leader>5 <Plug>AirlineSelectTab5
nmap <leader>6 <Plug>AirlineSelectTab6
nmap <leader>7 <Plug>AirlineSelectTab7
nmap <leader>8 <Plug>AirlineSelectTab8
nmap <leader>9 <Plug>AirlineSelectTab9
nmap <leader>0 <Plug>AirlineSelectTab10
nmap <leader>- <Plug>AirlineSelectPrevTab
nmap <leader>= <Plug>AirlineSelectNextTab
" NERDTreeToggle
map <Tab> :NERDTreeToggle<CR>
" NERDTreeFind
map nf :NERDTreeFind<CR>
" Gblame
map gb :Git blame<CR>
" copy current path
map fp :let @+ = expand("%")<CR>
" nerdcommenter
let g:NERDSpaceDelims = 1
" Persistent undo
" Don't forget mkdir folder $HOME/.vim/undo
set undofile
set undodir=$HOME/.vim/undo
set undolevels=1000
set undoreload=10000
" Closetag
" filenames like *.xml, *.html, *.xhtml, ...
let g:closetag_filenames = '*.html,*.xhtml,*.phtml, *.js, *.jsx, *.vue, *.ts, *.tsx'
let g:closetag_regions = {
\ 'typescript.tsx': 'jsxRegion,tsxRegion',
\ 'javascript.jsx': 'jsxRegion',
\ }
" Advanced customization using autoload functions
inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'left': '15%'})
" command! -bang -nargs=* Ag
" \ call fzf#vim#ag(<q-args>,
" \ <bang>0 ? fzf#vim#with_preview('up:60%')
" \ : fzf#vim#with_preview('right:50%:hidden', '?'),
" \ <bang>0)
" Prevent FZF open file in NERDTree
autocmd VimEnter * nnoremap <silent> <expr> <C-p> (expand('%') =~ 'NERD_tree' ? "\<c-w>\<c-w>" : '').":Files\<cr>"
" This is the default extra key bindings
" let g:fzf_action = {
" \ 'ctrl-v': 'vsplit' }
" Default fzf layout
" - down / up / left / right
let g:fzf_layout = { 'down': '~30%' }
" Enable per-command history.
" CTRL-N and CTRL-P will be automatically bound to next-history and
" previous-history instead of down and up. If you don't like the change,
" explicitly bind the keys to down and up in your $FZF_DEFAULT_OPTS.
let g:fzf_history_dir = '~/.local/share/fzf-history'
let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -l -g ""'
" Set italic
hi htmlArg gui=italic
hi htmlArg cterm=italic
hi Comment gui=italic
hi Comment cterm=italic
hi Type gui=italic
hi Type cterm=italic
" reasonml
let g:LanguageClient_serverCommands = {
\ 'reason': ['~/Downloads/rls-macos/reason-language-server.exe'],
\ }
nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
" Floating Window
function! OpenFloatTerm()
let height = float2nr((&lines - 2) / 1.5)
let row = float2nr((&lines - height) / 2)
let width = float2nr(&columns / 1.5)
let col = float2nr((&columns - width) / 2)
" Border Window
let border_opts = {
\ 'relative': 'editor',
\ 'row': row - 1,
\ 'col': col - 2,
\ 'width': width + 4,
\ 'height': height + 2,
\ 'style': 'minimal'
\ }
let border_buf = nvim_create_buf(v:false, v:true)
let s:border_win = nvim_open_win(border_buf, v:true, border_opts)
" Main Window
let opts = {
\ 'relative': 'editor',
\ 'row': row,
\ 'col': col,
\ 'width': width,
\ 'height': height,
\ 'style': 'minimal'
\ }
let buf = nvim_create_buf(v:false, v:true)
let win = nvim_open_win(buf, v:true, opts)
terminal
startinsert
" Hook up TermClose event to close both terminal and border windows
autocmd TermClose * ++once :q | call nvim_win_close(s:border_win, v:true)
endfunction
function! FloatCurrent()
let buf = bufnr('%')
let height = float2nr((&lines - 2) / 1.5)
let row = float2nr((&lines - height) / 2)
let width = float2nr(&columns / 1.5)
let col = float2nr((&columns - width) / 2)
let opts = {
\ 'relative': 'editor',
\ 'row': row,
\ 'col': col,
\ 'width': width,
\ 'height': height,
\ }
let win = nvim_open_win(buf, v:true, opts)
hi FloatTermNormal term=None guibg=#2d3d45
call setwinvar(win, '&winhl', 'Normal:FloatTermNormal')
endfunction
map ft :call OpenFloatTerm()<CR>
map fb :call FloatCurrent()<CR>
" Navigate buffer
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" coc-prettier
map <leader>p :Prettier<CR>
command! -nargs=0 Prettier :CocCommand prettier.formatFile
" stylelintplus
let g:coc_global_extensions = ['coc-stylelintplus']
let g:loaded_perl_provider = 0
let g:loaded_ruby_provider = 0