Debug del plugin matchit in vim (sotto Cygwin)
-
10-07-2019 - |
Domanda
Il " matchit " si suppone che il plugin per vim ti consenta di usare il tasto %
per saltare tra i tag di inizio / fine corrispondenti durante la modifica di HTML, nonché / *
e * /
delimitatori di commenti durante la modifica di altri tipi di codice.
Ho seguito le istruzioni esatte in " : help matchit
" ;, ma %
continua a non funzionare per me.
Sembra sciocco chiedere " Perché non funziona? " quindi invece sto chiedendo Come posso diagnosticare il problema? I puntatori ai riferimenti sono i benvenuti, ma sono preferite specifiche tecniche di debug del plugin vim.
Ecco la directory ~ / .vim:
$ ls -ltaGR ~/.vim
/cygdrive/y/.vim:
total 0
drwxr-xr-x 1 spause 0 Sep 17 13:20 ..
drwxr-xr-x 1 spause 0 Sep 16 13:59 doc
drwxr-xr-x 1 spause 0 Sep 16 13:58 .
drwxr-xr-x 1 spause 0 Sep 16 13:58 plugin
/cygdrive/y/.vim/doc:
total 24
-rw-r--r-- 1 spause 1961 Sep 16 13:59 tags
drwxr-xr-x 1 spause 0 Sep 16 13:59 .
-rw-r--r-- 1 spause 19303 Sep 16 13:58 matchit.txt
drwxr-xr-x 1 spause 0 Sep 16 13:58 ..
/cygdrive/y/.vim/plugin:
total 32
drwxr-xr-x 1 spause 0 Sep 16 13:58 ..
-rw-r--r-- 1 spause 30714 Sep 16 13:58 matchit.vim
drwxr-xr-x 1 spause 0 Sep 16 13:58 .
Sto eseguendo vim 7.2 sotto Cygwin (installato nell'autunno 2008). cygcheck
mostra:
1829k 2008/06/12 C:\cygwin\bin\cygwin1.dll
Cygwin DLL version info:
DLL version: 1.5.25
DLL epoch: 19
DLL bad signal mask: 19005
DLL old termios: 5
DLL malloc env: 28
API major: 0
API minor: 156
Shared data: 4
DLL identifier: cygwin1
Mount registry: 2
Cygnus registry name: Cygnus Solutions
Cygwin registry name: Cygwin
Program options name: Program Options
Cygwin mount registry name: mounts v2
Cygdrive flags: cygdrive flags
Cygdrive prefix: cygdrive prefix
Cygdrive default prefix:
Build date: Thu Jun 12 19:34:46 CEST 2008
CVS tag: cr-0x5f1
Shared id: cygwin1S4
In vim, : set
mostra:
--- Options ---
autoindent fileformat=dos shiftwidth=3
background=dark filetype=html syntax=html
cedit=^F scroll=24 tabstop=3
expandtab shelltemp textmode
viminfo='20,<50,s10,h
In particolare, la sintassi e il tipo di file sono entrambi riconosciuti come HTML. (La colorazione della sintassi va bene.)
Se sono necessarie ulteriori informazioni, si prega di commentare.
UPDATE:
Per risposta di troppo php :
Dopo aver provato vim -V1
, avevo modificato il mio .vimrc
per includere una riga
set nocp
quindi l'opzione compatibile
non è attiva.
: lascia loadad_matchit
loaded_matchit #1
: imposta runtimepath?
runtimepath=~/.vim,/usr/share/vim/vimfiles,/usr/share/vim/vim72,/usr/share/vim/vimfiles/after,~/.vim/after
( ~
è / cygdrive / y
)
Per risposta di michael :
: scriptnames
1: /cygdrive/y/.vimrc
2: /usr/share/vim/vim72/syntax/syntax.vim
3: /usr/share/vim/vim72/syntax/synload.vim
4: /usr/share/vim/vim72/syntax/syncolor.vim
5: /usr/share/vim/vim72/filetype.vim
6: /usr/share/vim/vim72/colors/evening.vim
7: /cygdrive/y/.vim/plugin/matchit.vim
8: /cygdrive/y/.vim/plugin/python_match.vim
9: /usr/share/vim/vim72/plugin/getscriptPlugin.vim
10: /usr/share/vim/vim72/plugin/gzip.vim
11: /usr/share/vim/vim72/plugin/matchparen.vim
12: /usr/share/vim/vim72/plugin/netrwPlugin.vim
13: /usr/share/vim/vim72/plugin/rrhelper.vim
14: /usr/share/vim/vim72/plugin/spellfile.vim
15: /usr/share/vim/vim72/plugin/tarPlugin.vim
16: /usr/share/vim/vim72/plugin/tohtml.vim
17: /usr/share/vim/vim72/plugin/vimballPlugin.vim
18: /usr/share/vim/vim72/plugin/zipPlugin.vim
19: /usr/share/vim/vim72/syntax/html.vim
20: /usr/share/vim/vim72/syntax/javascript.vim
21: /usr/share/vim/vim72/syntax/vb.vim
22: /usr/share/vim/vim72/syntax/css.vim
Nota che matchit.vim, html.vim, tohtml.vim, css.vim e javascript.vim sono tutti presenti.
: echo b: match_words
E121: Undefined variable: b:match_words
E15: Invalid expression: b:match_words
Hm, questo sembra molto rilevante. Ora sto esaminando : aiuto matchit-debug
per scoprire come risolvere b: match_words
.
Soluzione
Grazie a questa pubblicazione dalla vim_use mailing list, ho trovato una sequenza di comandi che funziona:
vim -u NONE somefile.html
(questo avvia vim senza leggere .vimrc)
Poi,
:set nocp
:source /usr/share/vim/vim72/macros/matchit.vim
:filetype plugin on
:filetype detect
:syntax on
Non è l'ideale, ma non sembra funzionare da .vimrc. E non funziona quando sintassi su
precede il rilevamento del tipo di file, quindi sospetto che ci sia un conflitto nell'interazione tra la sintassi che evidenzia elementi e oggetti corrispondenti.
Altri suggerimenti
Utilizza il seguente comando per vedere se il plugin è stato caricato:
:let loaded_matchit
Se ricevi un errore variabile non definito, il plugin non è stato caricato - dovresti assicurarti che '/cygdrive/y/.vim' sia nell'opzione 'runtimepath' (usa ': set runtimepath?
')
Nota anche che il plugin matchit non si carica se l'opzione 'compatibile' è attiva.
Potresti voler leggere : he matchit
. La sezione sulla configurazione potrebbe aiutare.
: ha matchit-debug
- informazioni di debug specifiche per matchit
: debug
- debug generale di vim (puoi fare ogni sorta di breakpoint / fare cose)
Un gotcha comune (ma non il tuo caso) è che il tipo di file html può essere modificato se stai usando un plug-in modello. (Ad esempio il mio HTML viene trasformato in HTML.djangotemplate) Prova : imposta ft?
per trovare il tuo tipo di file. potresti dover copiare b: match_words
nel ftplugin per il tipo di file del modello.
: echo b: match_words
- dovrebbe fornire un elenco di html che sembrano regex
anche nel caso dell'ovvio : scriptnames
dovrebbe mostrare matchit.vim da qualche parte
Buona fortuna
Non ho idea di vim (oltre a usarlo molto), ma ho scoperto che mettere le seguenti due righe nel mio .vimrc mi ha aiutato molto:
:source /usr/share/vim/addons/plugin/matchit.vim
:source /usr/share/vim/vim72/ftplugin/html.vim
Sono sicuro che esiste un modo corretto, ma almeno questo ha funzionato per me.
Saluti,
Joerg
Ho ottenuto i comandi sopra per funzionare nel mio .vimrc rimuovendolo la maggior parte delle altre schifezze in ~ / vim, come ~ / .vim / ftdetect e ~ / .vim / ftplugin. Inizia con un ~ / .vim pulito e solo copia ciò che è specifico per te, evitando tutto ciò che potrebbe avere una versione più recente in $ VIMRUNTIME e dovrebbe funzionare.