-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
292 lines (254 loc) · 9.85 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
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" plugs
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
call plug#begin('~/.vim/plugged')
" utilities
Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
Plug 'prabirshrestha/asyncomplete-file.vim'
Plug 'prabirshrestha/asyncomplete-tscompletejob.vim'
Plug 'mattn/vim-lsp-settings'
Plug 'runoshun/tscompletejob'
Plug 'majutsushi/tagbar'
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
Plug 'wikitopian/hardmode'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
Plug 'junegunn/fzf.vim'
" themes
Plug 'morhetz/gruvbox'
Plug 'vim-airline/vim-airline'
" syntax
Plug 'prettier/vim-prettier', { 'do': 'npm install -g', 'branch': 'release/1.x', 'for': [ 'javascript', 'typescript', 'css', 'less', 'scss', 'json', 'graphql', 'markdown', 'vue', 'lua', 'php', 'python', 'ruby', 'html', 'swift' ] }
Plug 'leafgarland/typescript-vim', { 'for': 'typescript' }
Plug 'Quramy/vim-js-pretty-template', { 'for': ['typescript', 'javascript'] }
Plug 'pangloss/vim-javascript', { 'for': ['typescript', 'javascript'] }
Plug 'mxw/vim-jsx', { 'for': ['typescript', 'javascript'] }
Plug 'mustache/vim-mustache-handlebars', { 'for': 'javascript' }
Plug 'StanAngeloff/php.vim', { 'for': 'php' }
Plug 'cakebaker/scss-syntax.vim', { 'for': 'scss' }
Plug 'jwalton512/vim-blade', { 'for': 'blade' }
Plug 'othree/html5.vim', { 'for': 'html' }
Plug 'tpope/vim-markdown', { 'for': 'markdown' }
call plug#end()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" key maps
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if &diff
nnoremap <silent><C-j> :diffget LOCAL<CR>
nnoremap <silent><C-.> :diffget BASE<CR>
nnoremap <silent><C-k> :diffget REMOTE<CR>
endif
nnoremap <C-\> :noh<CR>
nmap <C-p> :bprev<CR>
nmap <C-n> :bnext<CR>
map <F2> :%s/\s\+$//e<CR>
map <F3> :Gblame<CR>
map <F5> mzgg=G`z && retab!<CR>
map <F6> :PrettierAsync<CR>
map <F9> :set wrap!<Bar>set wrap?<CR>
map <F10> :set paste<CR>
nmap <F8> :TagbarToggle<CR>
" https://github.com/prabirshrestha/vim-lsp
nnoremap <C-]> :LspDefinition<CR>
nnoremap <ESC>[ :LspReferences<CR>
nnoremap <C-'> :LspRename<CR>
nnoremap <C-;> :LspDocumentFormat<CR>
nnoremap <ESC>s :Gstatus<CR>
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<cr>"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" global
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
syntax enable
filetype plugin indent on
set completeopt+=preview
set t_Co=256
let base16colorspace=256 " Access colors present in 256 colorspace
set number " Display line numbers
set timeoutlen=1 " Time to wait after ESC
set nobackup
set noswapfile
set nostartofline " cursor is kept in the same column
set tabstop=2 " Tabs are 2 spaces
set expandtab
set shiftwidth=2 " Define the width of a shift for the<< and>> commands. (Tabs under smart indent)
set autoindent " Automatically indent eache line like previous one
set smartindent " Automatically indent when adding a curly bracket, etc.
set backspace=2
set clipboard=unnamed
set hlsearch
set history=1000
set hidden
set magic
set showtabline=0
set incsearch
set ignorecase
set smartcase
set scrolloff=10
set statusline+=%#warningmsg#
set statusline+=%*
set colorcolumn=150
set mmp=10000
highlight ColorColumn ctermbg=232
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" color
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set background=dark
colorscheme gruvbox
let g:gruvbox_contrast_dark = 'soft'
let g:gruvbox_italic = 1
let g:gruvbox_termcolors = 256
let g:gruvbox_invert_signs = 1
let g:gruvbox_invert_selection = 1
let g:gruvbox_improved_strings = 1
let g:gruvbox_improved_warnings = 1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" search
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set tags=./tags;,tags;
set ofu=syntaxcomplete#Complete
set backupcopy=auto,breakhardlink
" Trailing or broken whitespace.
let c_space_errors=1
highlight WhitespaceEOL ctermbg=red guibg=red
match WhitespaceEOL /\s\+$/
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" airline
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols.space = "\ua0"
let g:airline#extensions#tabline#enabled = 0
set fillchars+=stl:\ ,stlnc:\
let g:airline_section_c = '%F'
let g:airline_section_y = '-%L-'
let g:bufferline_echo = 0
let g:airline_powerline_fonts = 1
let g:airline#extensions#ctrlp#color_template = 'visual'
let g:airline#extensions#tabline#show_tab_nr = 0
let g:airline#extensions#tabline#tab_nr_type = 0 " tab number
let g:airline#extensions#whitespace#enabled = 1
let g:airline#extensions#csv#enabled = 1
let g:airline#extensions#syntastic#enabled = 1
let g:airline#extensions#branch#empty_message = 'git it!!'
let g:airline_exclude_preview = 1
let g:airline#extensions#bufferline#enabled = 1
let g:airline#extensions#tabline#switch_buffers_and_tabs = 0
let g:airline#extensions#tabline#show_buffers = 1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" javascript
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:javascript_plugin_jsdoc = 1
let g:javascript_plugin_ngdoc = 1
let g:javascript_plugin_flow = 1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" fzf
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"[Buffers] Jump to the existing window if possible
let g:fzf_buffers_jump = 1
"[Tags] Command to generate tags file
"let g:fzf_tags_command = 'ctags --extra=+f -R'
" [Commands] --expect expression for directly executing the command
let g:fzf_commands_expect = 'alt-enter,ctrl-x'
let g:fzf_layout = { 'down': '~60%' }
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Clear'],
\ 'hl': ['fg', 'String'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
nmap <silent> <C-@> :Buffers<CR>
nmap <silent> / :BLines<CR>
nmap <silent> <C-f> :Rg<CR>
" meta key [ ALT ] mappings
nmap <ESC>f :GFiles<CR>
nmap <ESC>c :Commits<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" fzf functions
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --column --line-number --hidden --no-heading --color=always --smart-case '.shellescape(<q-args>), 1,
\ fzf#vim#with_preview(),
\ <bang>0)
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview(), <bang>0)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" gitgutter
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:gitgutter_escape_grep = 1
let g:gitgutter_enabled = 1
let g:gitgutter_signs = 1
let g:gitgutter_highlight_lines = 0
let g:gitgutter_realtime = 1
let g:gitgutter_eager = 1
let g:gitgutter_max_signs = 1500
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" prettier
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:prettier#autoformat = 0
let g:prettier#quickfix_enabled = 0
let g:prettier#exec_cmd_async = 1
let g:prettier#exec_cmd_path = "~/.node/bin/prettier"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" lsp
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
highlight link LspErrorText GruvboxRedSign
highlight clear LspWarningLine
let g:lsp_signs_enabled = 1
let g:lsp_diagnostics_echo_cursor = 1
let g:lsp_signs_error = {'text': '✗'}
let g:lsp_signs_warning = {'text': '‼'}
let g:asyncomplete_remove_duplicates = 1
let g:asyncomplete_auto_popup = 1
au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#file#get_source_options({
\ 'name': 'file',
\ 'whitelist': ['*'],
\ 'priority': 10,
\ 'completor': function('asyncomplete#sources#file#completor')
\ }))
"function PrettierPhpCursor()
" let save_pos = getpos(".")
" %! prettier --stdin --parser=php
" call setpos('.', save_pos)
"endfunction
"" define custom command
"command PrettierPhp call PrettierPhpCursor()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" misc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has('autocmd')
au VimEnter,BufNewFile,BufReadPost * silent! call HardMode()
au VimEnter * AirlineTheme gruvbox
"au BufwritePre *.php PrettierPhp
au BufNewFile,BufRead *.module,*.install set filetype=php
au BufRead,BufWritePre * if &modifiable | retab | endif
au BufRead,BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync
au BufWritePre <buffer> :call setline(1,map(getline(1,"$"),'substitute(v:val,"\\s\\+$","","")'))
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
au FileType php setlocal omnifunc=lsp#complete
" Don't automatically insert a comment command when entering insert mode with o
au FileType * setl formatoptions-=o
" " But do when hitting enter on a comment line, or when wrapping
au FileType * setl formatoptions+=rq
" Recognise numbered lists
au FileType * setl formatoptions+=n
" Don't automatically break lines when they are too long, unless they are comments
au FileType * setl formatoptions+=lc
" And try to remove comment leaders when joining lines
au FileType * setl formatoptions+=j"
" auto close preview window when completion is done
au! CompleteDone * if pumvisible() == 0 | pclose | endif
endif