Apply local settings to Tinymist#70
Conversation
|
We require contributors to sign our Contributor License Agreement, and we don't have @alexanderkoller on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
MrSubidubi
left a comment
There was a problem hiding this comment.
Thanks for this!
I am somewhat wondering whether this is not an issue with our documentation more if we suddenly need to merge the settings into the initialization options? Feels somewhat off to me and would like to know more about the root issue.
|
Well, if you look at the issues I referenced, they are all caused by the fact that the plugin currently ignores local Zed settings (in Lack of support for project-local settings just looked like an oversight to me, and judging from the issues, I'm not the only one. But if there's a better way to achieve this with respect to the internal logic of Zed or this plugin, I'm more than happy to withdraw the PR. My main concern was to get project-local settings working. |
Summary
Fix Tinymist configuration propagation so project-local
.zed/settings.jsonsettings are applied reliably.This makes the Typst extension pass
lsp.tinymist.settingsto Tinymist both:initializationOptions, so settings such asexportPdfare available before Tinymist initializes its project/export statenullIt also normalizes Tinymist settings so both flat keys and
tinymist-namespaced keys are available.Motivation
Project-local Tinymist settings were not applied reliably (cf. #56, #42, #21). In particular, settings such as:
{ "lsp": { "tinymist": { "settings": { "exportPdf": "onSave", "outputPath": "$root/$name", "projectResolution": "lockDatabase", "typstExtraArgs": ["main.typ"] } } } }could fail to make Tinymist compile the intended root document on save.
With this change, Tinymist receives those settings during initialization and through workspace/didChangeConfiguration.
Validation
Tested with a dev extension in Zed using Tinymist LSP mirroring.
Confirmed that the LSP
initializerequest now contains:exportPdf: "onSave"outputPath: "$root/$name"projectResolution: "lockDatabase"typstExtraArgs: ["main.typ"]Confirmed that
workspace/didChangeConfigurationsends the same settings instead ofnull.Confirmed that saving a project subfile updates
main.pdf.Also ran:
Issues
Should fix #56.
Should fix #42.
Likely addresses #21, since typstExtraArgs: ["main.typ"] is now propagated to Tinymist in the expected configuration shape.
Caveat
I used Codex to implement this fix and did not look at the code deeply. Someone with better knowledge of the extension should review it before accepting the PR. However, I tested the fix locally and it works for me.