diff --git a/blueprint-compiler.py b/blueprint-compiler.py index 91a8dde..ce5b2cc 100755 --- a/blueprint-compiler.py +++ b/blueprint-compiler.py @@ -29,4 +29,4 @@ if os.path.isdir(os.path.join(dirname, "blueprintcompiler")): from blueprintcompiler import main if __name__ == "__main__": - main.main() + main.main("uninstalled" if version == literal("VERSION") else version) diff --git a/blueprintcompiler/lsp.py b/blueprintcompiler/lsp.py index fbc45ea..224da67 100644 --- a/blueprintcompiler/lsp.py +++ b/blueprintcompiler/lsp.py @@ -151,6 +151,8 @@ class LanguageServer: @command("initialize") def initialize(self, id, params): + from . import main + self.client_capabilities = params.get("capabilities") self._send_response(id, { "capabilities": { @@ -167,7 +169,11 @@ class LanguageServer: "completionProvider": {}, "codeActionProvider": {}, "hoverProvider": True, - } + }, + "serverInfo": { + "name": "Blueprint", + "version": main.VERSION, + }, }) @command("textDocument/didOpen") diff --git a/blueprintcompiler/main.py b/blueprintcompiler/main.py index b79de43..1a5e92a 100644 --- a/blueprintcompiler/main.py +++ b/blueprintcompiler/main.py @@ -27,9 +27,7 @@ from . import parser, tokenizer, decompiler, interactive_port from .utils import Colors from .xml_emitter import XmlEmitter - -VERSION = "0.1.0" - +VERSION = "uninstalled" class BlueprintApp: def main(self): @@ -53,6 +51,8 @@ class BlueprintApp: self.add_subcommand("help", "Show this message", self.cmd_help) + self.parser.add_argument("--version", action="version", version=VERSION) + try: opts = self.parser.parse_args() opts.func(opts) @@ -144,5 +144,7 @@ class BlueprintApp: return ast.generate(), warnings -def main(): +def main(version): + global VERSION + VERSION = version BlueprintApp().main()