gregsexton / MatchTag

Vim's MatchParen for HTML tags
http://www.vim.org/scripts/script.php?script_id=3818
311 stars 30 forks source link

Incorrect highlighting, when file are open from [g]vim menu #20

Open Sloun opened 11 years ago

Sloun commented 11 years ago

I can't get working html.vim plugin if I open vim first, and then open some file (e.g. open test.html or via NERDTree). In this situation I have this: http://s18.postimg.org/miqsywm8p/Selection_2013_04_24_03_21.png

But if I open file via terminal (gvim test.html) plugin works perfectly: http://s24.postimg.org/sxoaypr45/Selection_2013_04_24_03_22.png

vim version: 7.3.547 (Debian testing)

Thank you.

gregsexton commented 11 years ago

If you do in Vim :set runtimepath? in both cases, what do you get? Sounds like in the first case the file isn't getting picked up.

Sloun commented 11 years ago

Sorry for late reply. In case when plugin works well I get this: runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim73,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after In other case: runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim73,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after It's identical.

gregsexton commented 11 years ago

I'm sorry, I have no idea. My best guess would be that you have a file somewhere that is checking whether vim is running as gvim and then setting b:did_ftplugin so that the html.vim file does not load. You should try moving all of your files out and adding them back in to narrow down where the problem is.

gregsexton commented 11 years ago

Sorry, by 'all your files', I mean all of your ~/.vim files.

Sloun commented 11 years ago

This trouble is identical in vim and gvim. Also, I've put plugin in ~/.vim/plugin directory. Because if I move it in ~/.vim/ftplugin it doesn't work at all. I've recreated home directory for user, problem is still here. Test ~/.vim directory: /home/all/makeuser/.vim ├── doc │   └── tags ├── ftplugin ├── .netrwhist ├── plugin │   ├── html.vim │   └── xml.vim └── .VimballRecord

3 directories, 5 files

And .vimrc: makeuser@localhost:~$ cat ~/.vimrc syntax on set nu color elflord

gregsexton commented 11 years ago

It should work in the ftplugin folder. Try removing the following lines from the top of the html.vim file to see if this resolves the problem:

if exists("b:did_ftplugin")
    finish
endif
Sloun commented 11 years ago

Unfortunately, that's didn't help.

Sloun commented 11 years ago

Maybe it's some bug in debian build of vim, I dont know at all.

gregsexton commented 11 years ago

How do you open a file once vim is running? If you describe the steps maybe that will help. Also, try :set ft? when it is working and when it isn't to compare the differences.

kitzberger commented 10 years ago

Having the same issue here. As soon as I load a file into vim not opening it right away as cli parameter from the shell, the plugin doesn't work anymore.

For example via calling :tabedit file2.html.

Would really appreciate a fix for this. Thanks for a great plugin ;-)

gregsexton commented 10 years ago

Are there any similarities with your setup and the one described above?

I can't reproduce this. You guys are going to have to debug it. See if you can narrow down the problem by temporarily removing other plugins, commenting out guard lines of code as I suggested above etc. @Sloun, did you resolve this issue?

kitzberger commented 10 years ago

Modifying line 10 did the trick for me:

  9 augroup matchhtmlparen
 10     autocmd! CursorMoved,CursorMovedI,WinEnter <buffer> call s:Highlight_Matching_Pair()
 11 augroup END

I'm not that familiar with vim autocommands, so I honestly have no idea what side effects this may cause. I substituted [buffer] by an asterisk and it works like a charm, even with NERDtree.

Oh, btw. I noticed some weird behavior as well: having a tag highlighted in the first buffer and then opening a copy in a second buffer leads to the same tag being highlighted in the second buffer. But nothing happens when repositioning the cursor. In the first buffer all works fine, when I switch back to that....

gregsexton commented 10 years ago

By substituting an asterisk, this function will be being called for every buffer you open. It suggests that this block is called at least once but not for every buffer. Do you always start vim/gvim with a file argument?

Sloun commented 10 years ago

@gregsexton Unfortunately, no. The issue is still here. @Kitzberger Thanks for some fix, I'll try to use it.

kitzberger commented 10 years ago

@gregsexton Yes, in most cases I do start vim with a file argument.

Out of curiousity: why don't we wanna call the auto command for every buffer? We certainly want the highlighting to work for every buffer, right?

gregsexton commented 10 years ago

If you don't start with a file argument and open files from within Vim, does the issue still occur?

Not every buffer has tags. With an asterisk it will be applied to every buffer regardless of whether this is appropriate. You could substitute for something like *.html but that defeats being able to symlink the file to provide the functionality for other file types.

kitzberger commented 10 years ago

Yes, the plugin's only working as long as I open the file as an argument.

Maybe a white list variable for file extensions that do usually contain tags to substitute that asterisk?

skylite21 commented 10 years ago

Having the same problem I would use the :tabedit and open another html file, but there are no highlights in the new tab, only in the first.