-
Notifications
You must be signed in to change notification settings - Fork 11
Add initial custom-element standard snippet #106
Conversation
@@ -0,0 +1,19 @@ | |||
import {CompletionItemKind, InsertTextFormat} from 'vscode-languageserver'; |
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.
License
src/standard-snippets.ts
Outdated
@@ -0,0 +1,19 @@ | |||
import {CompletionItemKind, InsertTextFormat} from 'vscode-languageserver'; | |||
|
|||
export default [ |
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.
Recommend giving this a name, as these are specifically snippets for when the user is in a JS file.
src/test/auto-completer_test.ts
Outdated
@@ -437,7 +438,7 @@ suite('AutoCompleter', () => { | |||
await client.openFile(indexFile, '<script>\n\n</script>\n' + indexContents); | |||
const completions = | |||
await client.getCompletions(indexFile, {line: 1, column: 0}); | |||
assert.deepEqual(completions, {isIncomplete: true, items: []}); | |||
assert.deepEqual(completions, {isIncomplete: false, items: standardSnippets}); |
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.
Update the test name
@@ -114,6 +115,7 @@ export default class AutoCompleter extends Handler { | |||
if (location.kind === 'attribute') { | |||
return this.getAttributeCompletions(document, location); | |||
} | |||
return this.getStandardSnippetCompletions(); |
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.
Hm, should explicitly check for the location being inside of a script section, as we might add other location kinds.
For bonus points it would be cool to do to JS what we did for CSS, and have an entire class of result for locResult.language === js
but that might be more than you're interested in doing right now.
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.
I left a TODO, as I tried to make that work, but it required new AST traversal methods in ast-from-source-position
, which seemed too much for this PR. Should be fixed someday though 😄
This PR adds a simple standard snippet for a custom element definition. I didn't want to publish Polymer-specific definitions yet, as HTML imports are gone and test suites are probably going to change as well. Once the dust is settled, we can discuss extra snippets.
Fixes Polymer/atom-plugin#11
Supersedes #36
This change is