Skip to content

Commit

Permalink
v0.4.1 - fixed TypeScript IntelliSense support and did some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
uguraslan committed Oct 16, 2023
1 parent ce557fb commit 071d4cd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 35 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 2 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publisher": "lightningjs",
"displayName": "Lightning Blits",
"description": "Template syntax highlighting and code completion for the Lightning Blits framework",
"version": "0.4.0",
"version": "0.4.1",
"repository": {
"type": "git",
"url": "https://github.com/lightning-js/blits-vscode-extension.git"
Expand Down Expand Up @@ -42,41 +42,13 @@
"grammars": [
{
"injectTo": [
"source.js"
],
"scopeName": "inline.custom-blits-html",
"path": "./syntaxes/embedded-html.json"
},
{
"injectTo": [
"source.js",
"source.ts"
],
"scopeName": "inline.custom-blits-html",
"path": "./syntaxes/embedded-html.json"
}
],
"languages": [
{
"id": "javascript",
"extensions": [
".js"
],
"aliases": [
"JavaScript",
"javascript"
]
},
{
"id": "typescript",
"extensions": [
".ts"
],
"aliases": [
"TypeScript",
"typescript"
]
}
],
"keybindings": [
{
"key": "ctrl+/",
Expand Down
2 changes: 2 additions & 0 deletions src/completionItems/componentProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ module.exports = async (tag, attributes, doc, docAst) => {
completionItem.insertText = new vscode.SnippetString(
`${prop.key}="$0"`
)
completionItem.sortText = '0' + prop.key
completionItems.push(completionItem)
}

Expand All @@ -69,6 +70,7 @@ module.exports = async (tag, attributes, doc, docAst) => {
reactiveCompletionItem.insertText = new vscode.SnippetString(
`${prop.key}="${prop.default ? prop.default : ''}$0"`
)
reactiveCompletionItem.sortText = '0' + `:${prop.key}`
completionItems.push(reactiveCompletionItem)
}
})
Expand Down
5 changes: 3 additions & 2 deletions src/completionProviders/templateAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ const completionItems = require('../completionItems')
const parse = require('../parsers')

module.exports = vscode.languages.registerCompletionItemProvider(
{ language: 'javascript' },
[{ language: 'javascript' }, { language: 'typescript' }],
{
// eslint-disable-next-line no-unused-vars
async provideCompletionItems(document, position, token, context) {
const currentDoc = document.getText()
const currentDocAst = parse.AST(currentDoc)
const fileExtension = document.uri.fsPath.split('.').pop()
const currentDocAst = parse.AST(currentDoc, fileExtension)

if (
templateHelper.isCursorInsideTemplate(document, currentDocAst, position)
Expand Down
8 changes: 7 additions & 1 deletion src/parsers/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@

const parser = require('@babel/parser')

module.exports = (code) => {
module.exports = (code, fileExtension) => {
let plugins = []
if (fileExtension === 'ts') {
plugins.push('typescript')
}

try {
return parser.parse(code, {
sourceType: 'module',
plugins: plugins,
})
} catch (e) {
console.error('error parsing AST')
Expand Down

0 comments on commit 071d4cd

Please sign in to comment.