-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
280 lines (242 loc) · 9.8 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
let skip_defaults_vim=1 " Don't use Vim defaults' settings
let mapleader=',' " Use the comma as leader
let &colorcolumn=80 " Display the column #80
set ttyfast " Send more characters to the screen for redrawing
set hidden " Allow switch beetween modified buffers
set number " Show line numbers.
set ignorecase " Case-insensitive searching.
set smartcase " But case-sensitive if expression contains a capital letter.
set expandtab " Converts tabs to spaces
set tabstop=4 " Number of spaces a tab count for
set softtabstop=4 " Number of spaces a tab count for when editing
set shiftwidth=4 " Number of spaces an autoindent count for
set incsearch " Highlight matches as you type
set hlsearch " Highlight matches
set cursorcolumn " Highlight the column the cursor is in
set ttimeoutlen=0 " Escape Insert Mode faster
set autoread " Auto reload current file if externally changed
set noswapfile " Use an SCM instead of swap files
set encoding=utf-8 " Sets the character encoding
set fileencoding=utf-8 " Sets the character encoding
set list " Active list mode
set listchars=nbsp:¬,eol:↩,trail:…,tab:▸▸ " Strings to use in 'list' mode
set t_ut= " Disable Background Color Erase (BCE)
set backupcopy=yes " Disable safe write
" Change gutter color in insert mode
autocmd InsertEnter * hi LineNr ctermfg=4 ctermbg=232
autocmd InsertLeave * hi LineNr ctermfg=59 ctermbg=232
"------------------ CTAGS MAPPING ------------------
au FileType php set tags=tags_php-src.tags,tags_php-vendor.tags
au FileType behat set tags=tags_gherkin.tags
au FileType javascript set tags=tags_js-lib.tags,tags_js-src.tags,tags_js-modules.tags
au FileType typescript set tags=tags_ts-lib.tags,tags_ts-typings.tags,tags_ts-modules.tags,tags_ts-src.tags
au FileType python set tags=tags_python.tags
"------------------ KEY MAPPING ------------------
" Unbind help on F1
:nmap <F1> <nop>
" Make CTRL+C trigger InsertLeave
inoremap <C-c> <Esc>
" Change panel focus with tab
nnoremap <tab> <c-w><c-w>
" Explore tags list for the word under the cursor
map tt g<C-]>
map TT <C-T>
" Show next matched string at the center of the screen
nnoremap n nzz
nnoremap N Nzz
" Do a grep search on the selected text
if executable('ag')
vmap <leader>f y:Ack! -i "<C-r>""
nmap <leader>f :Ack! -i "<C-r><C-w>"
else
vmap <leader>f y:grep -r "<C-r>""
nmap <leader>f :grep -r "<C-r><C-w>"
endif
" Navigate throught words and lines
nmap <C-h> b
nmap <C-j> 7j
nmap <C-k> 7k
nmap <C-l> w
vmap <C-h> b
vmap <C-j> 7j
vmap <C-k> 7k
vmap <C-l> w
" Quit buffer keeping the split
nnoremap <leader>q :bp<bar>sp<bar>bn<bar>bd<CR>
" Fast split resize
nnoremap <silent> <Leader>+ :exe "resize " . (winheight(0) * 3/2)<CR>
nnoremap <silent> <Leader>- :exe "resize " . (winheight(0) * 2/3)<CR>
nnoremap <silent> <Leader>> :exe "vertical resize " . (winwidth(0) * 3/2)<CR>
nnoremap <silent> <Leader>< :exe "vertical resize " . (winwidth(0) * 2/3)<CR>
" Make :grep great again
if executable('ag')
set grepprg=ag\ --group
endif
"---------------- PLUGINS INSTALL ----------------
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'DataWraith/auto_mkdir' " Create dir tree on save if it doesnt exist
Plug 'Galooshi/vim-import-js' " JS library import helper
Plug 'airblade/vim-gitgutter' " Shows a git diff in the gutter
Plug 'arnaud-lb/vim-php-namespace' " Manage 'use' statements automatically.
Plug 'christoomey/vim-sort-motion' " Sort inline words
Plug 'editorconfig/editorconfig-vim' " Respect .editorconfig
Plug 'godlygeek/tabular' " Text filtering and alignment
Plug 'itchyny/lightline.vim' " Light and configurable statusline/tabline
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } " Command-line fuzzy finder
Plug 'junegunn/fzf.vim' " FZF support for vim
Plug 'maralla/completor.vim', { 'dir': '~/.vim/plugged/completor.vim', 'do': 'make js' } " Asynchronous code completion framework
Plug 'mileszs/ack.vim' " Search tool
Plug 'nanotech/jellybeans.vim' " Colorscheme
Plug 'ntpeters/vim-better-whitespace' " Delete useless whitespaces
Plug 'reasonml-editor/vim-reason-plus' " ReasonML syntax
Plug 'scrooloose/nerdtree' " File system explorer
Plug 'sirver/ultisnips' " Snippet solution
Plug 'sjbach/lusty' " Manage files and buffers
Plug 'tpope/vim-eunuch' " helpers for UNIX, eg: `:Rename` `:Delete`
Plug 'tpope/vim-fugitive' " Git wrappern eg: `:Gblame`, `:Gdiff`
Plug 'w0rp/ale' " Asynchronous Lint Engine
call plug#end()
"---------------- PLUGINS CONFIGS ----------------
"
" nanotech/jellybeans
"
colorscheme jellybeans
"
" sjbach/lusty
"
let g:LustyJugglerShowKeys = 0
map <leader>lp :LustyJugglePrevious<cr>
"
" arnaud-lb/vim-php-namespace
"
let g:php_namespace_sort_after_insert = 1
function! IPhpInsertUse()
call PhpInsertUse()
call feedkeys('a', 'n')
endfunction
function! IPhpExpandClass()
call PhpExpandClass()
call feedkeys('a', 'n')
endfunction
autocmd FileType php inoremap <Leader>u <Esc>:call IPhpInsertUse()<CR>
autocmd FileType php noremap <Leader>u :call PhpInsertUse()<CR>
autocmd FileType php inoremap <Leader>e <Esc>:call IPhpExpandClass()<CR>
autocmd FileType php noremap <Leader>e :call PhpExpandClass()<CR>
autocmd FileType php inoremap <Leader>s <Esc>:call PhpSortUse()<CR>
autocmd FileType php noremap <Leader>s :call PhpSortUse()<CR>
"
" scrooloose/nerdtree
"
map <C-n> :NERDTreeToggle<CR>
"
" itchyny/lightline.vim
"
set laststatus=2
let g:lightline = {
\ 'colorscheme': 'powerline',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'gitbranch', 'readonly', 'relativepath', 'modified' ] ]
\ },
\ 'component_function': {
\ 'gitbranch': 'fugitive#head'
\ },
\ }
"
" sirver/ultisnips
"
let g:UltiSnipsExpandTrigger = '<tab>'
let g:UltiSnipsListSnippets = '<c-tab>'
let g:UltiSnipsJumpForwardTrigger = '<tab>'
let g:UltiSnipsJumpBackwardTrigger = '<s-tab>'
"
" godlygeek/tabular
"
nmap <Leader>= :Tabularize /=<CR>
vmap <Leader>= :Tabularize /=<CR>
nmap <Leader>: :Tabularize /:\zs<CR>
vmap <Leader>: :Tabularize /:\zs<CR>
nmap <Leader>\| :Tabularize /\|<CR>
vmap <Leader>\| :Tabularize /\|<CR>
nmap <Leader>// :Tabularize ////<CR>
vmap <Leader>// :Tabularize ////<CR>
"
" mileszs/ack.vim
"
if executable('ag')
let g:ackprg = 'ag --group --vimgrep'
endif
"
" junegunn/fzf.vim
"
set rtp+=~/.fzf
let g:fzf_colors = {
\ 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ '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']
\ }
nnoremap <C-p> :Files<CR>
nnoremap <leader>mr :History<CR>
"
" maralla/completor.vim
"
let g:completor_node_binary = '/usr/bin/node'
"
" ntpeters/vim-better-whitespace
"
autocmd BufEnter * EnableStripWhitespaceOnSave
let g:strip_whitespace_confirm=0
"
" w0rp/ale
"
nnoremap <leader>ale :ALEDetail<CR>
nnoremap <leader>esl :ALEFix eslint<CR>
highlight ALEWarningSign ctermfg=172
let g:ale_sign_warning = '>>'
let g:ale_completion_enabled = 1
let g:ale_linter_aliases = {
\ 'javascript': ['css', 'javascript'],
\ 'jsx': ['css', 'javascript'],
\ 'ts': ['typescript'],
\ 'tsx': ['typescript'],
\}
let g:ale_linters = {
\ 'javascript': ['stylelint', 'eslint'],
\ 'typescript': ['stylelint', 'eslint'],
\ 'jsx': ['stylelint', 'eslint'],
\ 'vue': ['stylelint', 'eslint'],
\}
let g:ale_fixers = {
\ 'javascript': ['stylelint', 'eslint'],
\ 'typescript': ['stylelint', 'eslint'],
\ 'jsx': ['stylelint', 'eslint'],
\ 'vue': ['stylelint', 'eslint'],
\ 'css': ['stylelint'],
\}
"
" editorconfig/editorconfig-vim
"
let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*']
"
" christoomey/vim-sort-motion
"
let g:sort_motion_flags = "ui"
let g:sort_motion = '<leader>s'
"
" flowtype/vim-flow
"
let g:flow#enable = 0