-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathideavimrc
401 lines (328 loc) · 10.4 KB
/
ideavimrc
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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
" {{{ Vundle and basic settings
set nocompatible " be iMproved, required
filetype off " required
" Vim Plug (vim-plug)
call plug#begin('~/.vim/plugged')
" Plugins
" Plug 'w0ng/vim-hybrid'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
"Plug 'einars/js-beautify'
Plug 'joonty/vim-phpqa'
"Plug 'majutsushi/tagbar'
"Plug 'maksimr/vim-jsbeautify'
"Plug 'rking/ag.vim'
"Font for windows tree terminal I picked Droid sans
"https://github.com/ryanoasis/nerd-fonts#patched-fonts
Plug 'preservim/nerdtree'
Plug 'preservim/nerdcommenter'
Plug 'shawncplus/phpcomplete.vim'
Plug 'Shougo/neocomplete.vim'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'elzr/vim-json'
Plug 'tobyS/vmustache'
Plug 'tobyS/pdv'
Plug 'dense-analysis/ale'
"Plug 'lumiliet/vim-twig'
Plug 'ryanoasis/vim-devicons'
Plug 'lambdalisue/glyph-palette.vim'
"Plug 'prettier/vim-prettier', { 'do': 'yarn install' }
Plug 'editorconfig/editorconfig-vim'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'ervandew/supertab'
Plug 'ludovicchabant/vim-gutentags'
"Plug 'rstacruz/sparkup', {'rtp': 'vim/'}
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'neoclide/coc-css', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-lists', {'do': 'yarn install --frozen-lockfile'} " mru and stuff
Plug 'neoclide/coc-highlight', {'do': 'yarn install --frozen-lockfile'} " color highlighting
Plug 'neoclide/coc-html', {'do': 'yarn install --frozen-lockfile'} " html
Plug 'marlonfan/coc-phpls', {'do': 'yarn install --frozen-lockfile'} " php linter
Plug 'christoomey/vim-tmux-navigator'
Plug 'tmux-plugins/vim-tmux-focus-events'
" All of your Plugins must be added before the following line
call plug#end()
" {{{ Functions
function! NumberToggle()
if(&relativenumber == 1)
set nonumber
set norelativenumber
elseif(&relativenumber == 0 && &number == 0)
set number
elseif(&relativenumber == 0 && &number == 1)
set relativenumber
endif
endfunc
function! AleFixOnSaveToggle()
if (g:ale_fix_on_save == 1)
let g:ale_fix_on_save = 0
else
let g:ale_fix_on_save = 1
endif
endfunc
" }}}
" {{{ Window and editor setup
" Display line numbers and rulers.
set number
set relativenumber
set ruler
syntax on
" Set encoding
set encoding=utf-8
set termencoding=utf-8
set fileencodings=utf-8,latin1
set ff=unix
" Whitespace features
set tabstop=4
set shiftwidth=4
set softtabstop=4
set noeol
set autoindent
" Enable formatting of comments, and one letter words.
" see :help fo-table
set formatoptions=qrc1
" Allow backspacing over everything in insert mode
set backspace=indent,eol,start
" Window settings
set wrap
set lbr
set textwidth=0
" Don't redraw when macros are executing.
set lazyredraw
" Use modeline overrides
set modeline
set modelines=10
" Status bar
set laststatus=2
" Use the system clipboard
set clipboard+=unnamed
" No swap file, undofile
set noswapfile
set undofile
set undodir=~/.vim/undo
" Tab completion for filenames and other command line features.
set wildmenu
set wildmode=list:longest,list:full
set wildignore+=*.o,*.obj,.git,*.rbc,*.class,.svn,vendor/gems/*,*.pyc,node_modules/*
" ctags optimization
set tags=tags;
" fix for slow vim, syntax
set synmaxcol=1000
" required for parceljs HMR
set backupcopy=yes
" window preview size
set previewheight=30
" mouse tty
set mouse=a
set ttymouse=xterm2
" }}}
" {{{ Colors
set background=dark
let g:solarized_termcolors=256
colorscheme solarized
" {{{ Plugins config
" NeoComplete
"let g:acp_enableAtStartup = 0
"let g:neocomplete#enable_at_startup = 1
"let g:neocomplete#enable_smart_case = 1
"let g:neocomplete#enable_auto_close_preview = 1
"if !exists('g:neocomplete#force_omni_input_patterns')
"let g:neocomplete#force_omni_input_patterns = {}
"endif
"let g:neocomplete#force_omni_input_patterns.php = '[^. \t]->\%(\h\w*\)\?\|\h\w*::\%(\h\w*\)\?'
"let g:neocomplete#force_omni_input_patterns.php = '\h\w*\|[^. \t]->\%(\h\w*\)\?\|\h\w*::\%(\h\w*\)\?'
"set completeopt=longest,menuone
" PHP QA
let g:phpqa_messdetector_autorun = 0
" PHP Code Sniffer binary
let g:phpqa_codesniffer_autorun = 0
let g:phpqa_codesniffer_args = "--standard=CakePHP"
let g:phpqa_codesniffer_cmd = $HOME . "~/.composer/vendor/bin/phpcs"
" PDV settings
let g:pdv_template_dir = $HOME . "/.vim/pdv-templates"
" higlight search
:set hlsearch
" horizontal split styling
:set t_Co=1024
let g:airline_theme='sol'
let g:airline_extensions = []
" nerdtree color
:hi Directory guifg=#FF0000 ctermfg=148 "https://vim.fandom.com/wiki/Xterm256_color_names_for_console_Vim
" devicons config
augroup my-glyph-palette
autocmd! *
autocmd FileType fern call glyph_palette#apply()
autocmd FileType nerdtree,startify call glyph_palette#apply()
augroup END
if exists("g:loaded_webdevicons")
call webdevicons#refresh()
endif
" FZF
" export FZF_DEFAULT_OPTS="--history=$HOME/.fzf_history"
set rtp+=~/.fzf
nnoremap <C-f> :Files<Cr>
"nnoremap <C-l> :Lines<Cr>
nnoremap <C-a> :Ag<Cr>
nnoremap <C-g> :Rg<Cr>
"nnoremap <C-h> :History<Cr>
" Gutentags
set statusline+=%{gutentags#statusline()}
" Auto Pairs
let g:AutoPairsShortcutToggle = '<p>'
" vim-tmux-focus-events
set autoread
" tmux fix for cursor
let &t_SI="\<Esc>[1 q"
let &t_SR="\<Esc>[1 q"
let &t_EI="\<Esc>[3 q"
" dbui
let g:db_ui_win_position = 'left'
let g:db_ui_show_database_icon = 1
let g:db_ui_use_nerd_fonts = 1
let g:db_ui_auto_execute_table_helpers = 1
" to include headrs in export query, find answer here https://stackoverflow.com/questions/5941809/include-headers-when-using-select-into-outfile
" easier to use union than fetching fields from information schema
let g:db_ui_export_query = "
\SET @outfile = DATE_FORMAT(NOW(),\"'/var/lib/mysql-export/{table}_%Y%m%d%H%i%s.csv'\");\n
\SET @s = CONCAT(\"SELECT * FROM `{table}` INTO OUTFILE \", @outfile, \" FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n'\");\n
\/* Replace sample fields with real for export with headers */\n
\/* https://stackoverflow.com/questions/5941809/include-headers-when-using-select-into-outfile */\n
\/* SET @s = CONCAT(\"SELECT 'id', 'first_name', 'last_name' UNION SELECT id, first_name, last_name FROM `{table}` INTO OUTFILE \", @outfile, \" FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n'\"); */\n
\PREPARE stmt FROM @s;\n
\EXECUTE stmt;\n
\SELECT @outfile;\n"
let g:db_ui_table_helpers = {
\ 'mysql': {
\ 'Export': g:db_ui_export_query
\ }
\ }
" }}}
" {{{ Filetypes
" Cakephp ctp as php file
au BufNewFile,BufRead *.ctp set filetype=php
" make uses real tabs
au FileType make setl noexpandtab
" Make ruby,scss,sass use 2 spaces for indentation.
au FileType {yaml,sass,scss,ruby,eruby,less,css,javascript,json} setl softtabstop=2 shiftwidth=2 tabstop=2 expandtab colorcolumn=80
" php settings
au FileType php setl textwidth=120 softtabstop=4 shiftwidth=4 tabstop=4 expandtab colorcolumn=120
" Javascript settings
"au FileType javascript setl textwidth=120 softtabstop=4 shiftwidth=4 tabstop=4 expandtab colorcolumn=120
"sparkup
augroup sparkup_types
" Remove ALL autocommands of the current group.
autocmd!
" Add sparkup to new filetypes
autocmd FileType mustache,php,javascript,jsx runtime! ftplugin/html/sparkup.vim
augroup END
" }}}
" {{{ Mapping
let mapleader = ','
" jj as escape in insert mode
imap jj <Esc>
" NeoComplete
"imap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
"imap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
" Leader mapping
map <Leader>h :nohl<CR>
map <Leader>p :set paste!<BAR>:set paste?<CR>
map <Leader>n :call NumberToggle()<CR>
map <Leader>a :call AleFixOnSaveToggle()<CR>
" NERDTree
map <Leader>t :NERDTreeToggle<CR>
let g:NERDTreeDirArrowExpandable = '+'
let g:NERDTreeDirArrowCollapsible = '-'
au BufEnter * if bufname('#') =~ 'NERD_tree' && bufname('%') !~ 'NERD_tree' && winnr('$') > 1 | b# | exe "normal! \<c-w>\<c-w>" | :blast | endif " prevent files to open in nerdtree eg with fzf
" Prettier
let g:prettier#config#config_precedence = 'file-override'
" PHP QA
map <Leader>qf :%!phpcbf --standard=psr2<CR>
" PDV settings
map <Leader>d :call pdv#DocumentCurrentLine()<CR>
" Tabs
map th :tabfirst<CR>
map tj :tabnext<CR>
map tk :tabprev<CR>
map tl :tablast<CR>
map tn :tabnew<CR>
map tc :tabclose<CR>
" Git fugitive
map gs :Git<CR>
map gd :Git diff<CR>
map gw :Gwrite<CR>
map gr :Gread<CR>
map gl :Git log<CR>
map gb :Git blame<CR>
map gm :Gmove<CR>
map ge :Gedit<CR>
map gp :Gpush<CR>
map gf :Gfetch<CR>
map gc :Git commit<CR>
" Ale
map <Leader>f :ALEFix<CR>
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-j> <Plug>(ale_next_wrap)
let g:ale_linters = {
\ 'php': ['php -l'],
\}
let g:ale_fixers = {
\ 'javascript': ['prettier'],
\ 'json': ['prettier'],
\ 'yaml': ['prettier'],
\ 'css': ['prettier'],
\ 'scss': ['prettier'],
\ 'less': ['prettier'],
\ 'html': ['prettier'],
\ 'php': ['prettier'],
\}
let g:ale_fix_on_save = 1
" Zoom window horizontal (e.g. results of DBUI)
map <Leader>z 50<C-w>_
" {{{ Autocommands
"
" Save on blur
"au FocusLost * :wa
" Save on blur for terminal vim
"au CursorHold,CursorHoldI * silent! wa
" copy to attached terminal using the yank(1) script:
" https://github.com/sunaku/home/blob/master/bin/yank
function! Yank(text) abort
let escape = system('yank', a:text)
if v:shell_error
echoerr escape
else
call writefile([escape], '/dev/tty', 'b')
endif
endfunction
noremap <silent> <Leader>y y:<C-U>call Yank(@0)<CR>
" automatically run yank(1) whenever yanking in Vim
" (this snippet was contributed by Larry Sanderson)
function! CopyYank() abort
call Yank(join(v:event.regcontents, "\n"))
endfunction
autocmd TextYankPost * call CopyYank()
" automatically rebalance windows on vim resize
autocmd VimResized * :wincmd =
" zoom a vim pane, <C-w>= to re-balance
nnoremap <leader>- :wincmd _<cr>:wincmd \|<cr>
nnoremap <leader>= :wincmd =<cr>
" PHP compplete
" Enable omni completion.
autocmd FileType css,less,sass,scss setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType json syntax match Comment +\/\/.\+$+
" SuperTab & omni completion
let g:SuperTabDefaultCompletionType = "<C-X><C-O>"
" Remember last location in file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
endif
" Do not fold
au BufWinEnter * normal zR
" }}}
set clipboard+=ideaput