Skip to content

Commit 556eb29

Browse files
committed
plugins/lspconfig: init
A simplified replacement for `plugins.lsp`. Eventually, once the `lsp` and `plugins.lspconfig` modules are mature, `plugins.lsp` will be deprecated and/or aliased.
1 parent 29aa60b commit 556eb29

File tree

3 files changed

+92
-2
lines changed

3 files changed

+92
-2
lines changed

modules/lsp/default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ in
2929
LSP servers to enable and/or configure.
3030
3131
This option is implemented using neovim's `vim.lsp` lua API.
32-
If you prefer to use [nvim-lspconfig], see [`plugins.lsp`].
32+
If you prefer to use [nvim-lspconfig], see [`plugins.lspconfig`].
3333
3434
[nvim-lspconfig]: https://github.com/neovim/nvim-lspconfig
35-
[`plugins.lsp`]: https://nix-community.github.io/nixvim/plugins/lsp/index.html
35+
[`plugins.lspconfig`]: https://nix-community.github.io/nixvim/plugins/lspconfig/index.html
3636
'';
3737
default = { };
3838
example = {

plugins/by-name/lspconfig/default.nix

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
lib,
3+
config,
4+
options,
5+
...
6+
}:
7+
let
8+
# cfg = config.plugins.lspconfig;
9+
opts = options.plugins.lspconfig;
10+
oldCfg = config.plugins.lsp;
11+
oldOpts = options.plugins.lsp;
12+
in
13+
lib.nixvim.plugins.mkNeovimPlugin {
14+
name = "lspconfig";
15+
packPathName = "nvim-lspconfig";
16+
package = "nvim-lspconfig";
17+
18+
maintainers = with lib.maintainers; [
19+
GaetanLepage
20+
MattSturgeon
21+
khaneliman
22+
traxys
23+
];
24+
25+
description = ''
26+
[nvim-lspconfig] provides default configs for many language servers, but it does not enable any of them.
27+
You should use the [`lsp`] module to configure and enable LSP servers.
28+
29+
> [!NOTE]
30+
> This plugin module will soon replace [`plugins.lsp`].
31+
>
32+
> Both `${opts.enable}` and `${oldOpts.enable}` will install nvim-lspconfig,
33+
> however the older [`plugins.lsp`] module includes additional options and
34+
> setup that relate to neovim's builtin LSP and are now being moved to the
35+
> new [`lsp`] module.
36+
37+
[`lsp`]: ../../lsp/servers.md
38+
[`plugins.lsp`]: ../lsp/index.md
39+
[nvim-lspconfig]: ${opts.package.default.meta.homepage}
40+
'';
41+
42+
# nvim-lspconfig provides configs for `vim.lsp.config` and requires no setup
43+
# all configuration should be done via nvim's builtin `vim.lsp` API
44+
callSetup = false;
45+
hasLuaConfig = false;
46+
hasSettings = false;
47+
48+
extraConfig = {
49+
warnings = lib.nixvim.mkWarnings "plugins.lspconfig" [
50+
{
51+
when = oldCfg.enable;
52+
message = ''
53+
Both `${opts.enable}' and `${oldOpts.enable}' configure the same plugin (nvim-lspconfig).
54+
${lib.pipe
55+
[ opts oldOpts ]
56+
[
57+
(builtins.catAttrs "enable")
58+
(map (o: "`${o}' defined in ${lib.options.showFiles o.files}."))
59+
lib.strings.concatLines
60+
]
61+
}
62+
'';
63+
}
64+
];
65+
};
66+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
empty = {
3+
plugins.lspconfig.enable = true;
4+
};
5+
6+
# TODO: test integration with `vim.lsp.enable`, etc
7+
# TODO: test some examples of enabling/configuring specific LSP servers
8+
9+
plugins-lsp-warning = {
10+
plugins.lsp.enable = true;
11+
plugins.lspconfig.enable = true;
12+
13+
test.warnings = expect: [
14+
(expect "count" 1)
15+
(expect "any" ''
16+
Nixvim (plugins.lspconfig): Both `plugins.lspconfig.enable' and `plugins.lsp.enable' configure the same plugin (nvim-lspconfig).
17+
'')
18+
(expect "any" "`plugins.lspconfig.enable' defined in `/nix/store/")
19+
(expect "any" "`plugins.lsp.enable' defined in `/nix/store/")
20+
];
21+
22+
test.buildNixvim = false;
23+
};
24+
}

0 commit comments

Comments
 (0)