nvarner / typst-lsp

A brand-new language server for Typst, plus a VS Code extension
MIT License
1.21k stars 78 forks source link

Document configuration options (pdf export) for other editors #47

Open kanashimia opened 1 year ago

kanashimia commented 1 year ago

For example in helix you have to add this to the languages.toml:

[[language]]
name = "typst"
scope = "source.typst"
injection-regex = "^typ(st)?$"
file-types = ["typ"]
roots = []
comment-token = "//"
language-server = { command = "typst-lsp" }
config = { exportPdf = "onType"}

Should note specifically what can be passed as a config.

I was able to find this only by looking through https://github.com/nvarner/typst-lsp/blob/5887fe041ef0bdfa15f4a15c76e636ea6265d90a/addons/vscode/package.json#L22-L39 You can just add a reference to that file.

giacomogallina commented 1 year ago

I was also trying to use the lsp in the helix editor, and while it recompiles just fine using the "onType" option, it doesn't if i choose the "onSave" option. Very weird

DianaNites commented 1 year ago

Yeah, It doesn't work manually with :lsp-workspace-command or on save, it complains about missing file URI, and helix only exposes the doPdfExport command and not the exportCurrentPdf command thats in the VScode extension, aiui??

Tweoss commented 1 year ago

I'm trying to use the lsp as well in helix, with the configuration mentioned in the opening comment and a cargo installed version of typst-lsp. I'm not getting syntax highlighting though, is that something that should be there?

My languages.toml:

image

a .typ file:

image
alxsimon commented 1 year ago

If I'm not mistaken you also need the grammar to have syntax highlighting. I've just installed that one, but haven't really tried it: https://github.com/frozolotl/tree-sitter-typst

Tweoss commented 1 year ago

@alxsimon Thank you so much! That worked perfectly. I'll note that I did have to copy over the queries directory as opposed to just symlinking, but the results look pretty good to me.

gnull commented 10 months ago

How should I configure kak-lsp to work with typst lsp?

I tried this and typst-lsp doesn't seem to build pdf on save:

[language.typst]
filetypes = ["typ", "typst"]
roots = [".git"]
command = "typst-lsp"
args = []
[language.typst.settings.typst-lsp]
exportPdf = "onType"

But kak-lsp confirms that typst-lsp is up, it can read LSP server capabilities and whatnot.

Ivan