modules/lsp: feat add ansiblels back and add defaults for ansiblels cmd#4211
modules/lsp: feat add ansiblels back and add defaults for ansiblels cmd#4211dtvillafana wants to merge 1 commit intonix-community:mainfrom
Conversation
|
nixpkgs needs to be updated so that ansible-language-server is available, but updating it also causes build failures. |
cd299fe to
1bc2750
Compare
MattSturgeon
left a comment
There was a problem hiding this comment.
Some feedback on the approach taken and some comments on how this highlights issues with Nixvim's existing architecture.
Thanks for opening the PR!
nixpkgs needs to be updated so that ansible-language-server is available
I think this is resolved now on main?
| @@ -0,0 +1,8 @@ | |||
| { lib, config, ... }: | |||
| { | |||
There was a problem hiding this comment.
| { | |
| { | |
| options.config = lib.mkOption { | |
| // Use option declaration merging to set defaultText | |
| type = with lib.types; attrsOf anything; | |
| defaultText = lib.literalExpression '' | |
| [ | |
| (lib.getExe config.${options.package}) | |
| "--stdio" | |
| ] | |
| ''; | |
| }; |
That'll render the default in docs as something like:
[
(lib.getExe config.lsp.servers.ansiblels.package)
"--stdio"
]However, we don't need this if we drop the below config definition.
| { | ||
| # cmd depends on evaluated config.package, so set via module config | ||
| config.config.cmd = lib.mkIf (config.package != null) [ | ||
| (lib.getExe config.package) |
There was a problem hiding this comment.
Do we really need getExe here? The lsp module installs config.package onto the neovim PATH. Most (all?) servers run the LSP via the path rather than an absolute path-in-store.
| (lib.getExe config.package) | |
| "ansible-language-server" |
(if so, we can drop this entire file)
| { lib, config, ... }: | ||
| { | ||
| # cmd depends on evaluated config.package, so set via module config | ||
| config.config.cmd = lib.mkIf (config.package != null) [ |
There was a problem hiding this comment.
This sets config and config.cmd at the defaultOverridePriority (100). That's bad because it is the same override priority typically used by end-users, so their cmd definition will be merged with this one into a single list.
Ideally, we want mkOptionDefault as that is the override priority used by mkOption's default. mkDefault is also acceptable, as is mkOverride 1499 (1 less than mkOptionDefault).
In this case, I don't think we need this definition at all. The default you passed into config = mkOption already specifies [ "ansible-language-server" "--stdio" ] and the lsp module ensures that config.package is on neovim's PATH.
| @@ -195,6 +190,15 @@ | |||
| aiken = "aiken"; | |||
| air = "air-formatter"; | |||
There was a problem hiding this comment.
This file is currently supposed to be a simple mapping of lsp->package. Having a mixture of plain package values and default config values complicates it, and complicates our usage in modules/lsp/servers/default.nix and tests.
We can simplify by doing this throughout the file:
| air = "air-formatter"; | |
| air.package = "air-formatter"; |
But this has a bunch of follow-up implications:
E.g. renaming packages to something like configs, modules, args, etc. Maybe rename the file to something like known-servers.nix or servers/known.nix (requires treewide updates).
...and we could also simplify unpackaged = [ "foo" ] to foo = null and filter out nulls in modules/lsp/servers/default.nix. Maybe.
Therefore, we'd want to isolate such a refactor to a separate PR, though. Especially as it'll require treewide updates everywhere the file is imported.
This might not be the best way to do this, but I figured out a way to add back in ansiblels and set the cmd.
did this because I added ansible-language-server to upstream nixpkgs so that I could use it in nixvim, so I figured I'd open a PR here.