-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
334 lines (293 loc) · 10.1 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
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
"
" _
" __ _(_)_ __ ___ _ __ ___
" \ \ / / | '_ ` _ \| '__/ __|
" \ V /| | | | | | | | | (__
" (_)_/ |_|_| |_| |_|_| \___|forPHP
"
" ==========================================================================
"
" RESUMEN DE ATAJOS:
" GENERAL:
" <leader>n :: Alterna visualización de Fern
" <leader>nr :: Revela la ubicación de un archivo en Fern
" a :: En Fern, hace aparecer el menu de acciones
" + :: En Fern, expande una carpeta
" - :: En Fern, colapsa una carpeta
" <leader>k :: Mueve línea actual hacia arriba (funciona con selecciones)
" <leader>j :: Mueve línea actual hacia abajo (funciona con selecciones)
" <leader><leader> :: Alterna entre los dos últimos buffers abiertos
" <leader>B :: Crea un nuevo buffer
" <tab> :: Cambia al siguiente buffer
" <s-tab> :: Cambia al buffer anterior
" <leader>bq :: Elimina el buffer actual
" <leader>ba :: Elimina todos los buffers
" <c-[h|j|k|l]> :: Navega entre las diferentes ventanas abiertas
" <leader>+ :: Amplía la ventana actual
" <leader>- :: Reduce la ventana actual
" <leader>sf :: Abre FZFpara archivos
" <leader>sb :: Saca ZFZ para buffers
" <leader>v :: Muestra la lista de símbolos
" <leader>t :: Abre la prueba asociada al archivo actual
" <leader><esc> :: Sale del modo búsqueda
"
" PHP:
" <leader>ga :: Genera métodos get/set en una clase
" <leader>em :: Extrae a un método la selección actual
" <leader>mf :: Mueve el archivo actual (esto actualiza el namespace automáticamente)
" <leader>cn :: Crea una nueva clase
" <leader>ic :: Abre el menú de transformación de PHPactor
" gtd :: Va a la definición del símbolo
" gti :: Va a la implementación del símbolo actual
" gte :: Muestra los errores en el archivo actual
" fr :: Busca referencias del símbolo actual
" gt :: Muestra la definición del símbolo actual
" rn :: Renombra el símbolo actual
" [g :: Va al error anterior
" ]g :: Va al error siguiente
"
" RESUMEN DE COMANDOS:
" find :: Busca un archivo recursivamente desde :pwd (funciona con RegExp)
" split :: Divide la ventana en horizontal
" vplit :: Divide la ventana en vertical
" close :: Cierra la ventana actual
"
" Autodescarga de VimPlug
let vimplug_exists=expand('~/.vim/autoload/plug.vim')
if !filereadable(vimplug_exists)
echo "Instalando Vim-Plug…"
echo ""
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall
endif
" Carga de plugins
call plug#begin(expand('~/.vim/plugged'))
Plug 'chaoren/vim-wordmotion'
Plug 'chr4/nginx.vim'
Plug 'editorconfig/editorconfig-vim'
Plug 'itchyny/lightline.vim'
Plug 'itchyny/vim-gitbranch'
Plug 'itchyny/vim-cursorword'
Plug 'airblade/vim-gitgutter'
Plug 'vim-vdebug/vdebug'
Plug 'lumiliet/vim-twig'
Plug 'liuchengxu/vista.vim'
Plug 'hashivim/vim-terraform'
Plug 'osyo-manga/vim-over'
Plug 'andymass/vim-matchup'
Plug 'APZelos/blamer.nvim'
Plug 'obcat/vim-hitspop'
Plug 'lambdalisue/fern.vim'
Plug 'Yggdroot/indentLine'
Plug 'phpactor/phpactor', {'for': 'php', 'branch': 'master', 'do': 'composer install --no-dev -o'}
Plug 'prabirshrestha/vim-lsp'
Plug 'mattn/vim-lsp-settings'
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
Plug 'mg979/vim-visual-multi', {'branch': 'master'}
Plug 'github/copilot.vim'
Plug 'ap/vim-css-color'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'jwalton512/vim-blade'
Plug 'tinted-theming/base16-vim'
Plug 'kerunaru/base16lightline'
call plug#end()
" Definición de constantes interesantes
let vimDir='$HOME/.vim'
let &runtimepath.=','.vimDir
" Mantenimiento de histórico de cambios persistente
if has('persistent_undo')
let myUndoDir=expand(vimDir . '/undodir')
call system('mkdir ' . vimDir)
call system('mkdir ' . myUndoDir)
let &undodir=myUndoDir
set undofile
endif
" Básicos
syntax on
filetype plugin on
" base16 theme
if exists('$BASE16_THEME')
\ && (!exists('g:colors_name')
\ || g:colors_name != 'base16-$BASE16_THEME')
let base16colorspace=256
colorscheme base16-$BASE16_THEME
endif
set background=dark
set laststatus=2
set backspace=indent,eol,start
set path+=**
set wildmenu
set scrolloff=25
set incsearch
set ignorecase
set smartcase
set hlsearch
set autoindent
set noswapfile
set autoread
set lazyredraw
set relativenumber
set number
set colorcolumn=80,120
set tw=119
set listchars=eol:↓,tab:»\ ,trail:~,space:·
set list
set cursorline
set noshowmode
set tabstop=4
set mouse=a
" Define la tecla líder
let mapleader=","
" Accede rápidamente al .vimrc
nnoremap <leader>rc :edit $MYVIMRC<cr>
" Elimina espacios al guardar
augroup PreSaveTasks
autocmd!
autocmd BufWritePre * :%s/\s\+$//e
augroup END
" Movimiento de líneas
nnoremap <leader>k :move-2<cr>==
nnoremap <leader>j :move+<cr>==
" Movimiento de selección
xnoremap <leader>k :move-2<cr>gv=gv
xnoremap <leader>j :move'>+<cr>gv=gv
" Mantiene selección después de tabulación
vnoremap < <gv
vnoremap > >gv
" Fern
function! s:init_fern() abort
nmap <buffer> + <Plug>(fern-action-expand)
nmap <buffer> - <Plug>(fern-action-collapse)
endfunction
augroup FernCustom
autocmd! *
autocmd FileType fern call s:init_fern()
autocmd FileType fern set nonumber norelativenumber nolist
augroup END
nnoremap <leader>n :Fern . -drawer -toggle<cr>
nnoremap <leader>nr :Fern . -reveal=% -drawer<cr>
" Gestión de buffers (¡No uses pestañas!)
nnoremap <leader>B :enew<cr>
nnoremap <tab> :bnext<cr>
nnoremap <s-tab> :bprevious<cr>
nnoremap <leader>bq :bp <bar> bd! #<cr>
nnoremap <leader>ba :bufdo bd!<cr>
nnoremap <leader><leader> :bprev<cr>
nnoremap <silent> <c-h> :wincmd h<cr>
nnoremap <silent> <c-j> :wincmd j<cr>
nnoremap <silent> <c-k> :wincmd k<cr>
nnoremap <silent> <c-l> :wincmd l<cr>
nnoremap <silent> <leader>+ :vertical resize +5<cr>
nnoremap <silent> <leader>- :vertical resize -5<cr>
" Función para localizar la prueba del archivo actual y abrirla
function! GetTestFileName()
return system("fd " . expand("%:t:r") . 'Test')
endfunction
nnoremap <leader>t :execute ':e ' . GetTestFileName()<cr>
inoremap ' ''<left>
inoremap " ""<left>
inoremap ( ()<left>
inoremap [ []<left>
inoremap { {}<left>
" Elimina búsqueda actual
nnoremap <silent> <leader><esc> :nohlsearch<CR>
" Vista
let g:vista#renderer#enable_icon = 0
let g:vista_default_executive = 'vim_lsp'
nnoremap <silent> <leader>v :Vista!!<cr>
" FZF
let g:fzf_preview_window = []
nnoremap <leader>sf :Files<cr>
nnoremap <leader>sb :Buffers<cr>
nnoremap <leader>st :BTags<cr>
" VIM LSP
function! s:on_lsp_buffer_enabled() abort
setlocal omnifunc=lsp#complete
setlocal signcolumn=yes
if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
nmap <buffer> gtd <plug>(lsp-definition)
nmap <buffer> gti <plug>(lsp-implementation)
nmap <buffer> gte <plug>(lsp-document-diagnostics)
nmap <buffer> fr <plug>(lsp-references)
nmap <buffer> gt <plug>(lsp-type-definition)
nmap <buffer> <leader>rn <plug>(lsp-rename)
nmap <buffer> [g <plug>(lsp-previous-diagnostic)
nmap <buffer> ]g <plug>(lsp-next-diagnostic)
let g:lsp_format_sync_timeout = 1000
autocmd! BufWritePre *.php call execute('LspDocumentFormatSync')
endfunction
augroup lsp_install
au!
" call s:on_lsp_buffer_enabled only for languages that has the server registered.
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup END
augroup User lsp_setup call lsp#register_server({
\ 'name': 'intelephense',
\ 'cmd': {server_info->['intelephense', '--stdio']},
\ 'initialization_options': {"storagePath": "/tmp/intelephense", "clearCache": v:true},
\ 'whitelist': ['php'],
\ 'root_uri':{server_info->lsp#utils#path_to_uri(
\ lsp#utils#find_nearest_parent_file_directory(
\ lsp#utils#get_buffer_path(),
\ ['.git/']
\ ))},
\ 'workspace_config': { 'intelephense': {
\ 'files.maxSize': 1000000,
\ 'files.associations': ['*.php'],
\ 'trace.server': 'verbose',
\ 'stubs': [
\ "Memcached",
\ ],
\ }},
\ })
augroup END
" Phpactor
nnoremap <leader>ga :PhpactorGenerateAccessor<cr>
nnoremap <leader>em :PhpactorExtractMethod<cr>
nnoremap <leader>mf :PhpactorMoveFile<cr>
nnoremap <leader>cn :PhpactorClassNew<cr>
nnoremap <leader>ic :PhpactorTransform<cr>
" Blamer
let g:blamer_enabled = 1
let g:blamer_show_in_insert_modes = 0
" TODOTags personalizados
augroup CustomTODOTags
autocmd!
autocmd BufWinEnter * let w:m1=matchadd('Error', '\<BROKEN\>\|\<WTF\>', -1)
autocmd BufWinEnter * let w:m1=matchadd('Todo', '\<HACK\>\|\<BUG\>\|\<REVIEW\>\|\<FIXME\>\|\<TODO\>\|\<NOTE\>', -1)
augroup END
" Personaliza Lightline
" Obtiene el método actual para mostrarlo desde Vista
function! NearestMethodOrFunction() abort
return 'ƒ() ' . get(b:, 'vista_nearest_method_or_function', '')
endfunction
augroup VistaNearestMethodOrFunction
autocmd!
autocmd VimEnter * call vista#RunForNearestMethodOrFunction()
augroup END
let g:lightline = {
\ 'colorscheme': 'base16lightline',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'gitbranch', 'readonly', 'filename', 'modified', 'method' ] ],
\ 'right': [ [ 'lineinfo' ],
\ [ 'percent' ],
\ [ 'fileformat', 'fileencoding', 'filetype', 'charvaluehex' ] ]
\ },
\ 'component': {
\ 'charvaluehex': '0x%B'
\ },
\ 'component_function': {
\ 'gitbranch': 'gitbranch#name',
\ 'method': 'NearestMethodOrFunction'
\ }
\ }
" Hitspop
highlight link hitspopErrorMsg ErrorMsg
" Personaliza indentLines
let g:indentLine_defaultGroup = 'SpecialKey'
let g:indentLine_char_list = ['|', '¦', '┆', '┊']
" .conf files syntax highlighting
autocmd BufRead,BufNewFile *.conf setf dosini