1
0
Fork 0
mirror of https://github.com/nix-community/nixvim.git synced 2025-11-08 19:46:06 +01:00
Commit graph

31 commits

Author SHA1 Message Date
Matt Sturgeon
bb9d744b64 modules/lsp: propagate pkgs arg to server modules
This allows simplifying the `importApply` and also paves the way for
custom server modules to define arbitrary package options.
2025-10-10 14:11:54 +00:00
Matt Sturgeon
9e77c8e4a9 modules/lsp: allow servers to install multiple packages
Adds two internal per-server options: `packages.prefix` & `packages.suffix`.

These options allow the server module to install multiple packages, and
control which end up being prefixed or suffixed on the PATH.

This simplifies the propagating code in `modules/lsp/servers/default.nix`,
which can now zip up the enabled server `packages` attrs.
2025-10-10 14:11:54 +00:00
Matt Sturgeon
2414e8e99f modules/lsp: auto-import per-server custom modules
Adding a module in the following places will import the module into that
specific server's submodule.

This allows creating server-specific options.

Added a test case to ensure all custom modules correspond to an actual
server option to avoid accidental dead code.
2025-10-10 14:11:54 +00:00
Matt Sturgeon
cf6c8ef1fa modules/lsp: be explicit about shorthandOnlyDefinesConfig
`shorthandOnlyDefinesConfig` is true by default for `lib.types.submodule`,
and false by default for `lib.types.submoduleWith` and `lib.evalModules`.

Since we rely on it for our `lsp.servers.*.config` option, let's enable
it explicitly.
2025-10-09 15:31:01 +00:00
Matt Sturgeon
9f336d2d71 modules/lsp: rename server settingsconfig
See RFC: https://github.com/nix-community/nixvim/issues/3745

This effectively reverts 21688b1d2a
2025-10-09 15:31:01 +00:00
Matt Sturgeon
20a7c92306 modules/lsp: handle missing package in server option desc
The `lsp.servers.<name>` option description links to the server's
homepage if it can evaluate the default package's `meta.homepage`.

However, users may evaluate this description, e.g. when building NixOS
docs with `documentation.nixos.includeAllModules`. Further, users may
have a different nixpkgs revisions to ours. Therefore, we need to allow
for the package not being in nixpkgs.

Since `mkPackageOption` will throw in the default, we can catch it with
`tryEval`.
2025-10-07 21:41:36 +00:00
Matt Sturgeon
94331cc50d plugins/lsp: use the new lsp module under the hood
- Re-implement setup wrapping and capabilities to preserve existing
  behaviour
- Alias `package` options to new lsp module
- Alias `packageFallback` options to new lsp module
- Alias `preConfig` and `postConfig` to `lsp.luaConfig`
2025-09-30 20:16:00 +00:00
Matt Sturgeon
cb3653a1a8 modules/lsp: select relevant fields in keymaps table
We only use `mode`, `key`, `action`, and `options`; so explicitly
inherit those.

This means we don't serialise attrs that aren't needed at runtime,
such as `lspBufAction`.
2025-09-30 17:01:17 +00:00
Matt Sturgeon
f421af99fe modules/lsp: print keymaps table multiline
Makes `init.lua` easier to read.

Follow up to 9faa339d9e
2025-09-30 17:01:17 +00:00
Gaetan Lepage
9faa339d9e modules/lsp: use a for loop to create LSP keymaps 2025-09-30 07:30:40 +00:00
Matt Sturgeon
167ea865e5 modules/lsp: port packageFallback option from plugins.lsp
Added to `plugins.lsp` in 6a054de04d
2025-09-28 23:07:35 +00:00
Andrey Petrov
1c5c991fda
modules/lsp/servers: Fix lua_ls example
Example was referring to `luals` instead of `lua_ls`
2025-05-25 11:29:19 -04:00
Matt Sturgeon
cbd5f7de5e
modules/lsp/onAttach: fix bufnr and document event arg
`:h event-args`: https://neovim.io/doc/user/api.html#event-args
`:h LspAttach`: https://neovim.io/doc/user/lsp.html#LspAttach

Fixes #3319
2025-05-13 18:45:00 +01:00
Matt Sturgeon
a45b5f372f modules/lsp: add onAttach option
Similar to `plugins.lsp.onAttach`, implement a "global" equivalent to
the per-server `on_attach` callback.

This is implemented using a `LspAttach` autoCmd.
2025-05-06 14:08:03 +01:00
Matt Sturgeon
5308425718
modules/lsp/servers: move to dedicated file/dir
Move the code related to the `lsp.servers` option into a dedicated module,
cleaning up `modules/lsp/default.nix`.
2025-05-05 23:43:30 +01:00
Matt Sturgeon
552dec0e55
modules/lsp/keymaps: init
Initial LSP keymaps option, inspired by `keymapsOnEvent` and
`plugins.lsp.keymaps`.

Users can define `lspBufAction` instead of `action` if they wish to use
a `vim.lsp.buf.<action>` callback.
2025-05-03 22:50:28 +01:00
Matt Sturgeon
90eb4e681c
modules/lsp/servers: move the * server to its own module
Introduce a bespoke `global-server.nix` module. This is less DRY, but
much simpler.

The `lsp.servers."*"` options are different enough from the other
`lsp.servers.<name>` options that it is simpler to just declare them
separately.

Now that we have a dedicated `global-server.nix` module, we no longer
need to split the normal server module into `server.nix`+`server-base.nix`

This partially reverts f2e96b67a3
2025-05-03 20:20:19 +01:00
Matt Sturgeon
a072e3c3a7
modules/lsp: enable servers."*" by default 2025-05-01 00:36:41 +01:00
Matt Sturgeon
b6e2016b7f
modules/lsp: check if server settings is empty
Avoid unnecessary lua lines by checking if `server.settings` is empty
before writing `vim.lsp.config()` to `init.lua`.
2025-05-01 00:36:16 +01:00
Matt Sturgeon
f2e96b67a3
modules/lsp: declare a stripped down servers."*" option
`"*"` is effectively a meta server, where shared config/defaults can be
set.

It shouldn't have options like `activate` or `package` which relate to
"real" servers. Therefore, we'll use `server-base.nix` directly, instead
of the full `server.nix` module.
2025-05-01 00:12:39 +01:00
Johan Larsson
eeae362038
modules/lsp: add enable = true to wildcard config section 2025-04-30 20:55:26 +01:00
Johan Larsson
2d65c66a1a
modules/lsp: don't enable wildcard server
The wildcard server ("*") should have its config set, but not be enabled
through `vim.lsp.enable()`.
2025-04-30 20:55:26 +01:00
Matt Sturgeon
21688b1d2a
modules/lsp/server: rename config -> settings
`config` is a loaded term within modules and options.

`settings` is the name usually used for freeform config in nixvim and
most other module configurations.
2025-04-30 17:35:46 +01:00
Matt Sturgeon
e34eaf8395
modules/lsp/server: declare package defaults
Convert the `attrsOf (servers.nix)` option to a freeform submodule.

Declare a `servers.nix` option for each lsp server listed in
`lsp-packages.nix` that has a known nixpkgs package.
2025-04-30 16:53:55 +01:00
Matt Sturgeon
29aa22c41a
modules/lsp: use relative link to plugins.lspconfig 2025-04-28 18:54:05 +01:00
Matt Sturgeon
5c67a96a86
modules/lsp: get nvim-lspconfig link from plugins.lspconfig.package 2025-04-28 18:54:04 +01:00
Matt Sturgeon
812b2b0903
modules/lsp: update wording for plugins.lspconfig recommendation 2025-04-28 18:54:04 +01:00
Matt Sturgeon
556eb29548
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.
2025-04-28 18:54:04 +01:00
Matt Sturgeon
29aa60b43a
modules/lsp: add per-server name option
This allows users to override the name used for a given `lsp.servers.*`
entry. The default is still the attr-name.

This may be useful to inject raw lua, or to configure the same server in
different ways via different attrs.
2025-04-28 18:23:49 +01:00
Matt Sturgeon
3722f88c5d
modules/lsp: move server module to dedicated file 2025-04-28 18:04:11 +01:00
Matt Sturgeon
74368bcfc1
modules/lsp: move to dedicated directory 2025-04-28 17:59:05 +01:00