Dynamic configuration UI

I would ideally like to have my configuration be a bit … dynamic. For example, I have an LSP that can have a number of diagnostic reports (lint conditions like unused parameters, etc.) that it supports. Rather than have a fixed list, I’d like to be able to query (the query exists) the server, and then generate a configuration UI that offers options based on what the language server supports.

A similar situation arises with CMake for example, where I might like to offer configuration parameters based on the actual project CMakeLists.txt file(s).

Right now the configuration UI is very static, and with the exception of enumeration values which can be resolved, does not offer the ability to add additional configuration UI elements.

This is somewhat limiting, and I’m stuck resorting to asking users to edit a configuration file or use some external tool outside of Nova.

Essentially what I’d like to be able to do is to add, or remove (e.g. via Disposable) entries, or whole sections, in the configuration section. These could take JSON structures just like the extension itself is structured.

1 Like

++

The gopls language server can be invoked to dump all its available configuration knobs as JSON (run: gopls api-json). I use this to programmatically generate the configuration UI JSON, which works well. For me and my unpublished extension. But being tied to the particular version of gopls I’m using when building the extension, would run into problems for a published extension where the config options would inevitably diverge from the gopls version in use.

It is possible get and set configuration options through code without the using the config UI. So one possibility is to create your own UI with a sidebar and choice palette. Sidebar could list the available options, and buttons in the sidebar’s toolbar can toggle the option value. A double-click, right-click, or toolbar button click could bring up a choice palette to choose from available choices for that option.

Unfortunately the sidebar right-click menu is not dynamic, it cannot change options depending on the item clicked – it can only enable/disable or checkmark the menu items.

Not ideal, I wish the sidebar was more capable, but it’s a possible workaround.

This can work, but it’s pretty lame. I’ll probably resort to this for build configuration, because I don’t see a better option at present.