mattn / emmet-vim

emmet for vim: http://emmet.io/
http://mattn.github.io/emmet-vim
MIT License
6.41k stars 411 forks source link

Prioritizes syntax at the current cursor position for determining the file type #433

Closed resolritter closed 5 years ago

resolritter commented 6 years ago

Motivation

A .vue file usually has three blocks:

All inside of the same file. emmet-vim was not correctly identifying the syntax provided for each of those sections and always expanding the abbreviation as HTML instead.

Goal

Some plugins are dedicated to providing the correct syntax for each code block inside a file, thus are more accurate for their specific filetype targets (e.g. https://github.com/posva/vim-vue).

screenshot from 2018-08-25 15-39-35

screenshot from 2018-08-25 15-42-30

The main goal here is to rely on them first and then fallback to the internal logic if it doesn't work. In practice, reorder the filetype identification sequence in order to prioritize the syntax provided for the current cursor's block.

mattn commented 6 years ago

Thank you. test seems to be fail

resolritter commented 6 years ago

@mattn running the tests locally with make test, all of them pass without issues. Do you think it could be hanging because emmet#util#getcurpos() is now at the top of the function?

Also if you want to fix it yourself, feel very welcome! I don't understand much about Vim yet.

resolritter commented 6 years ago

@mattn I've installed Vim 7.4 and now I seem to be able to reproduce the error locally. I'll tag you again when I manage to fix it.

resolritter commented 6 years ago

@mattn The build is passing now. I've changed the code back to matching on both "js" and "javascript" insensitively (ignore-case).

resolritter commented 6 years ago

@mattn just after you pointed out the matching for javascript, I've added a clause tag for JSX just above since they share the same prefix. I believe for the well-known types it's better now. Is something missing?

mattn commented 5 years ago

Thank you