Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Emmet in typescript styled plugin #33

Merged
merged 7 commits into from
Feb 16, 2018
Merged

Emmet in typescript styled plugin #33

merged 7 commits into from
Feb 16, 2018

Conversation

ramya-rao-a
Copy link
Contributor

@ramya-rao-a ramya-rao-a commented Feb 16, 2018

  • Use vscode-emmet-helper to get emmet completions at the right places
  • Add tests based on current completion tests
  • Add emmet configurations

Fixes #34

@ramya-rao-a ramya-rao-a requested a review from mjbvz February 16, 2018 02:28
Copy link
Contributor

@mjbvz mjbvz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool!

As discussed, let's add a basic config option to that allows users to disable emmet completions if they really want to. The rest of the change looks good to me.

const completionsCss = this.cssLanguageService.doComplete(doc, virtualPosition, stylesheet) || emptyCompletionList;
const completionsScss = this.scssLanguageService.doComplete(doc, virtualPosition, stylesheet) || emptyCompletionList;
completionsScss.items = filterScssCompletionItems(completionsScss.items);
const completions: vscode.CompletionList = {
isIncomplete: false,
items: [...completionsCss.items, ...completionsScss.items],
};
if (emmetResults.items.length) {
completions.items.push(...emmetResults.items);
completions.isIncomplete = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a heads up: isIncomplete is ignored by TS so setting it to true won't have any effect. Does emmet depend on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it does. For example: m -> margin: ; and mt -> margin-top: ;. So the completions need to be re-calculated for almost every char

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened microsoft/TypeScript#21999. I've discussed this problem with TS before but emmet may be the first real use case for it.

As we discussed offline, I believe we should be able to take in this PR even without isIncomplete. Users will just have to manually trigger completions in some cases. Do you agree @ramya-rao-a?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

'm10-20',
'`'
].join('\n'));
server.send({ command: 'completions', arguments: { file: mockFileName, offset: 22, line: 1 } });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Use the actual line numbers for the tests

@mjbvz mjbvz mentioned this pull request Feb 16, 2018
@mjbvz mjbvz merged commit f88c4b9 into master Feb 16, 2018
@mjbvz
Copy link
Contributor

mjbvz commented Feb 16, 2018

Awesome! Thank you for the great work

I'll publish a 0.6 of this plugin shortly and submit a PR back to the vscode-styled-components extension to pick up the new version of the plugin

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants