typst-lsp
typst-lsp copied to clipboard
Highlighting not working for unsaved snippets on VS Code
-
Component:
- VSCode Extension
- Extension version: 0.9.4
- LSP version: built-in
- OS version and name: macOS Ventura 13.5
- I am on the latest stable version of the extension/LSP.
- I have searched the issues of this repo and believe that this is not a duplicate.
Issue
With VS Code extension, saved .typ
files have their highlighting feature working but not for unsaved ones.
Here are the screenshots:
Logs
[Trace - 01:05:40] Sending request 'initialize - (0)'.
Params: {
"processId": 88461,
"clientInfo": {
"name": "Visual Studio Code",
"version": "1.81.1"
},
"locale": "zh-cn",
"rootPath": null,
"rootUri": null,
"capabilities": {
"workspace": {
"applyEdit": true,
"workspaceEdit": {
"documentChanges": true,
"resourceOperations": [
"create",
"rename",
"delete"
],
"failureHandling": "textOnlyTransactional",
"normalizesLineEndings": true,
"changeAnnotationSupport": {
"groupsOnLabel": true
}
},
"configuration": true,
"didChangeWatchedFiles": {
"dynamicRegistration": true,
"relativePatternSupport": true
},
"symbol": {
"dynamicRegistration": true,
"symbolKind": {
"valueSet": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26
]
},
"tagSupport": {
"valueSet": [
1
]
},
"resolveSupport": {
"properties": [
"location.range"
]
}
},
"codeLens": {
"refreshSupport": true
},
"executeCommand": {
"dynamicRegistration": true
},
"didChangeConfiguration": {
"dynamicRegistration": true
},
"workspaceFolders": true,
"semanticTokens": {
"refreshSupport": true
},
"fileOperations": {
"dynamicRegistration": true,
"didCreate": true,
"didRename": true,
"didDelete": true,
"willCreate": true,
"willRename": true,
"willDelete": true
},
"inlineValue": {
"refreshSupport": true
},
"inlayHint": {
"refreshSupport": true
},
"diagnostics": {
"refreshSupport": true
}
},
"textDocument": {
"publishDiagnostics": {
"relatedInformation": true,
"versionSupport": false,
"tagSupport": {
"valueSet": [
1,
2
]
},
"codeDescriptionSupport": true,
"dataSupport": true
},
"synchronization": {
"dynamicRegistration": true,
"willSave": true,
"willSaveWaitUntil": true,
"didSave": true
},
"completion": {
"dynamicRegistration": true,
"contextSupport": true,
"completionItem": {
"snippetSupport": true,
"commitCharactersSupport": true,
"documentationFormat": [
"markdown",
"plaintext"
],
"deprecatedSupport": true,
"preselectSupport": true,
"tagSupport": {
"valueSet": [
1
]
},
"insertReplaceSupport": true,
"resolveSupport": {
"properties": [
"documentation",
"detail",
"additionalTextEdits"
]
},
"insertTextModeSupport": {
"valueSet": [
1,
2
]
},
"labelDetailsSupport": true
},
"insertTextMode": 2,
"completionItemKind": {
"valueSet": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25
]
},
"completionList": {
"itemDefaults": [
"commitCharacters",
"editRange",
"insertTextFormat",
"insertTextMode"
]
}
},
"hover": {
"dynamicRegistration": true,
"contentFormat": [
"markdown",
"plaintext"
]
},
"signatureHelp": {
"dynamicRegistration": true,
"signatureInformation": {
"documentationFormat": [
"markdown",
"plaintext"
],
"parameterInformation": {
"labelOffsetSupport": true
},
"activeParameterSupport": true
},
"contextSupport": true
},
"definition": {
"dynamicRegistration": true,
"linkSupport": true
},
"references": {
"dynamicRegistration": true
},
"documentHighlight": {
"dynamicRegistration": true
},
"documentSymbol": {
"dynamicRegistration": true,
"symbolKind": {
"valueSet": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26
]
},
"hierarchicalDocumentSymbolSupport": true,
"tagSupport": {
"valueSet": [
1
]
},
"labelSupport": true
},
"codeAction": {
"dynamicRegistration": true,
"isPreferredSupport": true,
"disabledSupport": true,
"dataSupport": true,
"resolveSupport": {
"properties": [
"edit"
]
},
"codeActionLiteralSupport": {
"codeActionKind": {
"valueSet": [
"",
"quickfix",
"refactor",
"refactor.extract",
"refactor.inline",
"refactor.rewrite",
"source",
"source.organizeImports"
]
}
},
"honorsChangeAnnotations": false
},
"codeLens": {
"dynamicRegistration": true
},
"formatting": {
"dynamicRegistration": true
},
"rangeFormatting": {
"dynamicRegistration": true
},
"onTypeFormatting": {
"dynamicRegistration": true
},
"rename": {
"dynamicRegistration": true,
"prepareSupport": true,
"prepareSupportDefaultBehavior": 1,
"honorsChangeAnnotations": true
},
"documentLink": {
"dynamicRegistration": true,
"tooltipSupport": true
},
"typeDefinition": {
"dynamicRegistration": true,
"linkSupport": true
},
"implementation": {
"dynamicRegistration": true,
"linkSupport": true
},
"colorProvider": {
"dynamicRegistration": true
},
"foldingRange": {
"dynamicRegistration": true,
"rangeLimit": 5000,
"lineFoldingOnly": true,
"foldingRangeKind": {
"valueSet": [
"comment",
"imports",
"region"
]
},
"foldingRange": {
"collapsedText": false
}
},
"declaration": {
"dynamicRegistration": true,
"linkSupport": true
},
"selectionRange": {
"dynamicRegistration": true
},
"callHierarchy": {
"dynamicRegistration": true
},
"semanticTokens": {
"dynamicRegistration": true,
"tokenTypes": [
"namespace",
"type",
"class",
"enum",
"interface",
"struct",
"typeParameter",
"parameter",
"variable",
"property",
"enumMember",
"event",
"function",
"method",
"macro",
"keyword",
"modifier",
"comment",
"string",
"number",
"regexp",
"operator",
"decorator"
],
"tokenModifiers": [
"declaration",
"definition",
"readonly",
"static",
"deprecated",
"abstract",
"async",
"modification",
"documentation",
"defaultLibrary"
],
"formats": [
"relative"
],
"requests": {
"range": true,
"full": {
"delta": true
}
},
"multilineTokenSupport": false,
"overlappingTokenSupport": false,
"serverCancelSupport": true,
"augmentsSyntaxTokens": true
},
"linkedEditingRange": {
"dynamicRegistration": true
},
"typeHierarchy": {
"dynamicRegistration": true
},
"inlineValue": {
"dynamicRegistration": true
},
"inlayHint": {
"dynamicRegistration": true,
"resolveSupport": {
"properties": [
"tooltip",
"textEdits",
"label.tooltip",
"label.location",
"label.command"
]
}
},
"diagnostic": {
"dynamicRegistration": true,
"relatedDocumentSupport": false
}
},
"window": {
"showMessage": {
"messageActionItem": {
"additionalPropertiesSupport": true
}
},
"showDocument": {
"support": true
},
"workDoneProgress": true
},
"general": {
"staleRequestSupport": {
"cancel": true,
"retryOnContentModified": [
"textDocument/semanticTokens/full",
"textDocument/semanticTokens/range",
"textDocument/semanticTokens/full/delta"
]
},
"regularExpressions": {
"engine": "ECMAScript",
"version": "ES2020"
},
"markdown": {
"parser": "marked",
"version": "1.1.0"
},
"positionEncodings": [
"utf-16"
]
},
"notebookDocument": {
"synchronization": {
"dynamicRegistration": true,
"executionSummarySupport": true
}
}
},
"initializationOptions": {
"exportPdf": "onSave",
"rootPath": null,
"semanticTokens": "enable",
"serverPath": null,
"trace": {
"server": "verbose"
}
},
"trace": "verbose",
"workspaceFolders": null
}
[Trace - 01:05:42] Received notification 'window/logMessage'.
Params: {
"message": "src/workspace/package/external/manager.rs:48 { message = got user external package directory; user = LocalProvider { root: \"/Users/whyto/Library/Application Support/typst/packages/\" }; }",
"type": 3
}
[Info - 01:05:42] src/workspace/package/external/manager.rs:48 { message = got user external package directory; user = LocalProvider { root: "/Users/whyto/Library/Application Support/typst/packages/" }; }
[Trace - 01:05:42] Received response 'initialize - (0)' in 1062ms.
Result: {
"capabilities": {
"completionProvider": {
"triggerCharacters": [
"#",
".",
"@"
]
},
"documentSymbolProvider": true,
"executeCommandProvider": {
"commands": [
"typst-lsp.doPdfExport",
"typst-lsp.doClearCache"
]
},
"hoverProvider": true,
"selectionRangeProvider": true,
"signatureHelpProvider": {
"triggerCharacters": [
"(",
","
]
},
"textDocumentSync": {
"change": 2,
"openClose": true,
"save": true
},
"workspace": {
"workspaceFolders": {
"changeNotifications": true,
"supported": true
}
},
"workspaceSymbolProvider": true
}
}
[Trace - 01:05:42] Sending notification 'initialized'.
Params: {}
[Trace - 01:05:42] Received notification 'window/logMessage'.
Params: {
"message": "src/workspace/package/external/manager.rs:58 { message = got external package cache; cache = LocalProvider { root: \"/Users/whyto/Library/Caches/typst/packages/\" }; }",
"type": 3
}
[Info - 01:05:42] src/workspace/package/external/manager.rs:58 { message = got external package cache; cache = LocalProvider { root: "/Users/whyto/Library/Caches/typst/packages/" }; }
[Trace - 01:05:42] Received notification 'window/logMessage'.
Params: {
"message": "src/workspace/package/manager.rs:42 { message = initialized package manager; current = {}; external = ExternalPackageManager { providers: [LocalProvider { root: \"/Users/whyto/Library/Application Support/typst/packages/\" }, LocalProvider { root: \"/Users/whyto/Library/Caches/typst/packages/\" }], cache: Some(LocalProvider { root: \"/Users/whyto/Library/Caches/typst/packages/\" }), repo: Some(RemoteRepoProvider { base_url: Url { scheme: \"https\", cannot_be_a_base: false, username: \"\", password: None, host: Some(Domain(\"packages.typst.org\")), port: None, path: \"/\", query: None, fragment: None }, client: Client { accepts: Accepts, proxies: [Proxy(System({\"https\": http://127.0.0.1:7890, \"http\": http://127.0.0.1:7890}), None)], referer: true, default_headers: {\"accept\": \"*/*\"}, timeout: 30s } }) }; }",
"type": 3
}
[Info - 01:05:42] src/workspace/package/manager.rs:42 { message = initialized package manager; current = {}; external = ExternalPackageManager { providers: [LocalProvider { root: "/Users/whyto/Library/Application Support/typst/packages/" }, LocalProvider { root: "/Users/whyto/Library/Caches/typst/packages/" }], cache: Some(LocalProvider { root: "/Users/whyto/Library/Caches/typst/packages/" }), repo: Some(RemoteRepoProvider { base_url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("packages.typst.org")), port: None, path: "/", query: None, fragment: None }, client: Client { accepts: Accepts, proxies: [Proxy(System({"https": http://127.0.0.1:7890, "http": http://127.0.0.1:7890}), None)], referer: true, default_headers: {"accept": "*/*"}, timeout: 30s } }) }; }
[Trace - 01:05:42] Received request 'client/registerCapability - (0)'.
Params: {
"registrations": [
{
"id": "semantic_tokens",
"method": "textDocument/semanticTokens",
"registerOptions": {
"full": {
"delta": true
},
"legend": {
"tokenModifiers": [
"strong",
"emph",
"math"
],
"tokenTypes": [
"comment",
"string",
"keyword",
"operator",
"number",
"function",
"decorator",
"bool",
"punct",
"escape",
"link",
"raw",
"label",
"ref",
"heading",
"marker",
"term",
"delim",
"pol",
"error",
"text"
]
}
}
}
]
}
[Trace - 01:05:42] Sending response 'client/registerCapability - (0)'. Processing request took 0ms
No result returned.
[Trace - 01:05:42] Received request 'client/registerCapability - (1)'.
Params: {
"registrations": [
{
"id": "config",
"method": "workspace/didChangeConfiguration"
}
]
}
[Trace - 01:05:42] Sending response 'client/registerCapability - (1)'. Processing request took 0ms
No result returned.
[Trace - 01:05:42] Received request 'client/registerCapability - (2)'.
Params: {
"registrations": [
{
"id": "watch_typst_files",
"method": "workspace/didChangeWatchedFiles",
"registerOptions": {
"watchers": [
{
"globPattern": "**/*"
}
]
}
}
]
}
[Trace - 01:05:42] Sending response 'client/registerCapability - (2)'. Processing request took 1ms
No result returned.
[Trace - 01:05:42] Received notification 'window/logMessage'.
Params: {
"message": "src/server/lsp.rs:185 { message = server initialized; }",
"type": 3
}
[Info - 01:05:42] src/server/lsp.rs:185 { message = server initialized; }
[Trace - 01:05:44] Sending notification 'textDocument/didOpen'.
Params: {
"textDocument": {
"uri": "file:///Users/whyto/Desktop/1.typ",
"languageId": "typst",
"version": 1,
"text": "#set page(\n paper: \"a5\",\n margin: (x: 2cm, y: 2cm)\n)\n\n= Intro\n\n"
}
}
[Trace - 01:05:44] Sending request 'textDocument/documentSymbol - (1)'.
Params: {
"textDocument": {
"uri": "file:///Users/whyto/Desktop/1.typ"
}
}
[Trace - 01:05:44] Received response 'textDocument/documentSymbol - (1)' in 1ms.
Result: [
{
"kind": 3,
"location": {
"range": {
"end": {
"character": 7,
"line": 5
},
"start": {
"character": 2,
"line": 5
}
},
"uri": "file:///Users/whyto/Desktop/1.typ"
},
"name": "Intro"
}
]
[Trace - 01:05:44] Sending request 'textDocument/semanticTokens/full - (2)'.
Params: {
"textDocument": {
"uri": "file:///Users/whyto/Desktop/1.typ"
}
}
[Trace - 01:05:44] Received response 'textDocument/semanticTokens/full - (2)' in 2ms.
Result: {
"data": [
0,
0,
1,
2,
0,
0,
1,
3,
2,
0,
0,
3,
1,
20,
0,
0,
1,
4,
5,
0,
0,
4,
1,
8,
0,
0,
1,
5,
20,
0,
1,
4,
5,
18,
0,
0,
5,
1,
8,
0,
0,
1,
1,
20,
0,
0,
1,
4,
1,
0,
0,
4,
1,
8,
0,
0,
1,
5,
20,
0,
1,
4,
6,
18,
0,
0,
6,
1,
8,
0,
0,
1,
1,
20,
0,
0,
1,
1,
8,
0,
0,
1,
1,
18,
0,
0,
1,
1,
8,
0,
0,
1,
1,
20,
0,
0,
1,
3,
4,
0,
0,
3,
1,
8,
0,
0,
1,
1,
20,
0,
0,
1,
1,
18,
0,
0,
1,
1,
8,
0,
0,
1,
1,
20,
0,
0,
1,
3,
4,
0,
0,
3,
1,
8,
0,
0,
1,
1,
20,
0,
1,
0,
1,
8,
0,
0,
1,
2,
20,
0,
2,
0,
7,
14,
0,
0,
0,
1,
14,
0,
0,
1,
1,
20,
0,
0,
1,
5,
20,
0,
0,
5,
2,
20,
0
],
"resultId": "0"
}
[Trace - 01:05:51] Sending notification '$/setTrace'.
Params: {
"value": "verbose"
}
[Trace - 01:05:51] Sending notification 'workspace/didChangeConfiguration'.
Params: {
"settings": null
}
[Trace - 01:05:51] Received request 'workspace/configuration - (3)'.
Params: {
"items": [
{
"section": "typst-lsp.exportPdf"
},
{
"section": "typst-lsp.rootPath"
},
{
"section": "typst-lsp.semanticTokens"
}
]
}
[Trace - 01:05:51] Sending response 'workspace/configuration - (3)'. Processing request took 0ms
Result: [
"onSave",
null,
"enable"
]
[Trace - 01:05:51] Received request 'client/registerCapability - (4)'.
Params: {
"registrations": [
{
"id": "semantic_tokens",
"method": "textDocument/semanticTokens",
"registerOptions": {
"full": {
"delta": true
},
"legend": {
"tokenModifiers": [
"strong",
"emph",
"math"
],
"tokenTypes": [
"comment",
"string",
"keyword",
"operator",
"number",
"function",
"decorator",
"bool",
"punct",
"escape",
"link",
"raw",
"label",
"ref",
"heading",
"marker",
"term",
"delim",
"pol",
"error",
"text"
]
}
}
}
]
}
[Trace - 01:05:51] Sending response 'client/registerCapability - (4)'. Processing request took 0ms
No result returned.
[Trace - 01:05:51] Received notification 'window/logMessage'.
Params: {
"message": "src/server/lsp.rs:513 { message = new settings applied; }",
"type": 3
}
[Info - 01:05:51] src/server/lsp.rs:513 { message = new settings applied; }
From the logs, it looks like VS Code isn't telling the language server about the unsaved file, so it can't highlight it. Do you know of another language that does highlight unsaved files? I can see if it does something special that typst-lsp
doesn't.
I think examples are a lot. Take C and C++, they both support unsaved file highlighting. You may have a try.发自我的 iPhone在 2023年8月30日,02:27,Nathan Varner @.***> 写道: From the logs, it looks like VS Code isn't telling the language server about the unsaved file, so it can't highlight it. Do you know of another language that does highlight unsaved files? I can see if it does something special that typst-lsp doesn't.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>