Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable language extensions to call emmet completion provider #29114

Closed
ramya-rao-a opened this issue Jun 20, 2017 · 12 comments
Closed

Enable language extensions to call emmet completion provider #29114

ramya-rao-a opened this issue Jun 20, 2017 · 12 comments
Assignees
Labels
emmet Emmet related issues feature-request Request for new features or functionality
Milestone

Comments

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Jun 20, 2017

See vuejs/vetur#232 (comment)

In html files, we use the html parser to figure out the cursor is inside the style tag and then use css instead of html abbr

In non html files that need html like abbreviations, the parsing is not available out of the box and so the emmet extension doesn't realize to use css instead html abbr inside the html tag

Update:
See #29114 (comment) for a proposal that could solve this issue by passing the responsibility of figuring out scope to language specific extensions

@ramya-rao-a ramya-rao-a added emmet Emmet related issues feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities labels Jun 20, 2017
@octref
Copy link
Contributor

octref commented Jun 20, 2017

But lang is available.

image

If TM scope inspector can figure it out there should be a way to find the current lang.
Previously syntaxProfiles worked with embedded lang like so:

https://github.com/octref/vetur/blob/master/package.json#L81-L95

@octref
Copy link
Contributor

octref commented Jun 20, 2017

So I guess you don't need to parse the whole document for providing emmet.
Imagine a php file where people'd ask for emmet for the html part...Can't parse PHP too, right 😅

@ramya-rao-a
Copy link
Contributor Author

ramya-rao-a commented Jun 20, 2017

@octref that's the catch. Scope info is not available to extensions. The new emmet is an extension.

Another way to go about this is to pass the responsibility of figuring out the right language to the language specific extension.

A simple version of the emmet completion provider can be pulled out into a module of its own. This version need not have any parsing or validation for position. That would be done by the language extension.

If the user has mapped the language using emmet.syntaxProfiles then the language extension would do nothing special. May be show a notification saying that Hey, you dont need emmet.syntaxProfiles for this language anymore If there is no mapping, then the language extension can call the simple emmet completion provider, pass the right syntax (html/css) and get completions.

Thoughts?

@octref
Copy link
Contributor

octref commented Jun 21, 2017

A simple version of the emmet completion provider can be pulled out into a module of its own.

Yep if you can have that I can incorporate it into Vetur.

If the user has mapped the language using emmet.syntaxProfiles then the language extension would do nothing special. May be show a notification saying that Hey, you dont need emmet.syntaxProfiles for this language anymore If there is no mapping, then the language extension can call the simple emmet completion provider, pass the right syntax (html/css) and get completions.

Sure.

Think this approach could possibly allow emmet completions for JSX too for Vue/React.

@ramya-rao-a
Copy link
Contributor Author

@octref I have moved the completion provider for emmet to a separate module https://www.npmjs.com/package/vscode-emmet-helper

Can you give it a try and see if you can use it in vetur?

Usage is just 2 lines: https://github.com/Microsoft/vscode/blob/07c5fe39ddad3dee42150afa8459954dfbca9538/extensions/emmet/src/defaultCompletionProvider.ts#L31-L32

All you have to do is to pass the right language

@ramya-rao-a ramya-rao-a changed the title Css abbr don't work inside style tag in non html files when using emmet.syntaxProfiles New emmet cannot resolve embedded languages Jun 21, 2017
@ramya-rao-a ramya-rao-a changed the title New emmet cannot resolve embedded languages Enable language extensions to call emmet completion provider Jun 22, 2017
@ramya-rao-a ramya-rao-a added this to the June 2017 milestone Jun 22, 2017
@ramya-rao-a ramya-rao-a removed the help wanted Issues identified as good community contribution opportunities label Jun 22, 2017
@octref
Copy link
Contributor

octref commented Jun 22, 2017

Will give it a try tonight :-)

@octref
Copy link
Contributor

octref commented Jun 28, 2017

@ramya-rao-a Was looking at this and suddenly https://github.com/Microsoft/vscode-emmet-helper went 404.

@ramya-rao-a
Copy link
Contributor Author

@ramya-rao-a
Copy link
Contributor Author

ramya-rao-a commented Jun 28, 2017

@octref Also see #29532 (comment)

Ifemmet.showExpandedAbbreviation is set to always and the user has the mapping "vue-html": "html" in emmet.includeLanguages, then the emmet extension itself will provide the emmet suggestions.

So check for that before providing completions from vetoer

emmet.includeLanguages is the replacement for emmet.syntaxProfiles.
See #29678 (comment)

@ramya-rao-a
Copy link
Contributor Author

Closing this issue as the work from vscode's side is done.

Using the module from vetur is being tracked in vuejs/vetur#232

@octref
Copy link
Contributor

octref commented Jun 29, 2017

@ramya-rao-a I see because npm package was pointing to Microsoft/vscode-emmet-helper.

But currently emmet doesn't seem to be working correctly in Insider, for either html or vue

emmet

Is it because the new build is not out yet? Mine is

9541932
2017-06-29T05:03:32.047Z

@ramya-rao-a
Copy link
Contributor Author

@octref That happens when you have a word stop (like * or :). The suggestions get filtered out. There was a change that went in yesterday in the filtering logic of suggest widget which caused this.

See #29758. I am working on it

You can still hit Ctrl+Space and you will see the same suggestions as before.

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
emmet Emmet related issues feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

2 participants