Skip to content

Commit

Permalink
feat: add Python/JS injections for VSCode
Browse files Browse the repository at this point in the history
  • Loading branch information
Desdaemon committed Mar 9, 2024
1 parent c09a54b commit 8cc6c0f
Show file tree
Hide file tree
Showing 9 changed files with 703 additions and 53 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
"typescript.tsc.autoDetect": "off",
"typescript.tsdk": "node_modules/typescript/lib",
}
2 changes: 1 addition & 1 deletion odoo.rng
Original file line number Diff line number Diff line change
Expand Up @@ -695,4 +695,4 @@
<ref name="openerp" />
</choice>
</start>
</grammar>
</grammar>
42 changes: 18 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,30 @@
"description": "Language server for Odoo Python/JS/XML",
"license": "MIT",
"version": "0.3.1",
"categories": [
"Programming Languages"
],
"keywords": [
"language-server",
"tower-lsp"
],
"categories": ["Programming Languages"],
"keywords": ["language-server", "tower-lsp"],
"repository": {
"type": "git",
"url": "https://github.com/Desdaemon/odoo-lsp.git"
},
"engines": {
"vscode": "^1.66.0"
},
"activationEvents": [
"onLanguage:xml",
"onLanguage:python",
"onLanguage:javascript"
],
"activationEvents": ["onLanguage:xml", "onLanguage:python", "onLanguage:javascript"],
"publisher": "Desdaemon",
"main": "./dist/extension.js",
"contributes": {
"grammars": [
{
"path": "./syntaxes/odoo-xml.tmLanguage.json",
"scopeName": "text.xml.odoo",
"injectTo": ["text.xml"],
"embeddedLanguages": {
"meta.embedded.inline.python": "python",
"meta.embedded.inline.javascript": "javascript"
}
}
],
"commands": [
{
"command": "odoo-lsp.tsconfig",
Expand All @@ -46,16 +48,8 @@
"odoo-lsp.trace.server": {
"type": "string",
"scope": "window",
"enum": [
"off",
"messages",
"verbose"
],
"enumDescriptions": [
"No traces",
"Error only",
"Full log"
],
"enum": ["off", "messages", "verbose"],
"enumDescriptions": ["No traces", "Error only", "Full log"],
"default": "off",
"description": "Traces the communication between VS Code and the language server."
},
Expand Down Expand Up @@ -92,7 +86,7 @@
},
"scripts": {
"postinstall": "pnpm i -C client",
"vscode:prepublish": "npm run esbuild-base -- --minify",
"vscode:prepublish": "./scripts/prepublish",
"esbuild-base": "esbuild ./client/src/extension.ts --bundle --outfile=dist/extension.js --external:vscode --format=cjs --platform=node",
"esbuild": "npm run esbuild-base -- --sourcemap",
"esbuild-watch": "npm run esbuild-base -- --sourcemap --watch",
Expand Down Expand Up @@ -128,7 +122,7 @@
"mocha": "^8.4.0",
"prettier": "^3.0.3",
"ts-loader": "^9.5.0",
"typescript": "^4.9.5",
"typescript": "^5.4.2",
"vscode-uri": "^3.0.8",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4"
Expand Down
52 changes: 26 additions & 26 deletions pnpm-lock.yaml

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

10 changes: 10 additions & 0 deletions scripts/prepublish
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -euxo pipefail

rm dist/**
npm run esbuild-base -- --minify
if command -v deno &> /dev/null; then
./syntaxes/gen/odoo-xml.ts > ./syntaxes/odoo-xml.tmLanguage.json
else
echo "Deno not found, skipping grammar generation"
fi
8 changes: 7 additions & 1 deletion src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,12 @@ class TransifexCodeTranslation(models.Model):
"#,
)
.unwrap();
assert_eq!(models.len(), 1);
assert!(matches!(
&models[..],
[super::Model {
type_: super::ModelType::Base { .. },
..
}]
));
}
}
Loading

0 comments on commit 8cc6c0f

Please sign in to comment.