-
Notifications
You must be signed in to change notification settings - Fork 57
Emmet in typescript styled plugin #33
Conversation
There was a problem hiding this 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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed
e2e/tests/emmetCompletions.js
Outdated
'm10-20', | ||
'`' | ||
].join('\n')); | ||
server.send({ command: 'completions', arguments: { file: mockFileName, offset: 22, line: 1 } }); |
There was a problem hiding this comment.
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
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 |
vscode-emmet-helper
to get emmet completions at the right placesFixes #34