This commit is contained in:
Ching Pei Yang 2025-09-03 16:56:19 -07:00 committed by GitHub
commit f1d9c3eacb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
45 changed files with 264 additions and 68 deletions

View file

@ -1,23 +1,40 @@
# LSP Custom Packages/Command {#sec-languages-custom-lsp-packages}
# Configuring supported LSP servers {#sec-languages-configuraing-lsp-servers}
One of the strengths of **nvf** is convenient aliases to quickly configure LSP
servers through the Nix module system. By default the LSP packages for relevant
language modules will be pulled into the closure. If this is not desirable, you
may provide **a custom LSP package** (e.g., a Bash script that calls a command)
or **a list of strings** to be interpreted as the command to launch the language
server. By using a list of strings, you can use this to skip automatic
installation of a language server, and instead use the one found in your `$PATH`
during runtime, for example:
may modify [](#opt-vim.lsp.servers._name_.cmd) (see example below).
Any other forms of configuration can be done via [](#opt-vim.lsp.servers), which
is a wrapper for the neovim lua API `vim.lsp.config()`. Getting familiar with
`:help vim.lsp.config()` may help you better understand how to configure LSPs.
```nix
vim.languages.java = {
lsp = {
{
vim.languages.python = {
enable = true;
lsp = {
enable = true;
# You can now enable multiple LSPs per language
servers = ["basedpyright"];
};
};
# This expects 'jdt-language-server' to be in your PATH or in
# 'vim.extraPackages.' There are no additional checks performed to see
# if the command provided is valid.
package = ["jdt-language-server" "-data" "~/.cache/jdtls/workspace"];
# vim.lsp.servers is a wrapper for the lua API vim.lsp.config
# (see :help vim.lsp.config)
vim.lsp.servers = {
basedpyright = {
# `vim.languages.<lang>.lsp.package` is now removed, you have to
# modify the cmd field, and remember to copy over the arguments!
cmd = [(getExe pkgs.myCustomPackage) "--stdio"];
# server specific settings, see documentation of the respective language
# servers
settings = {
basedpyright.analysis.logLevel = "Error";
python.pythonPath = getExe pkgs.myPython3;
};
};
};
}
```

View file

@ -28,6 +28,61 @@
align with the "hunks" themed mapping and avoid conflict with the new [neogit]
group.
- Language modules are reworked to allow more flexible and close-to-neovim-API
configs. LSP configuration options are removed from `vim.languages` and should
be done via `vim.lsp.servers`.
## Language module LSP rework
in nvf v0.8, language modules are overhauled, with a few goals in mind:
1. get rid of our rigid "hard-coded" lua scripts, in favor of the more flexible
`setupOpts` styled options
2. have our new API stick closer to lua APIs, in this case `vim.lsp.config`
3. allow enabling multile LSPs per-language
This is, however, a big change, so breaking changes are inevitable. The most
important change is the removal of `vim.languages.<lang>.lsp.package` - you now
need to modify `vim.lsp.servers.<server>.cmd`, copying over any additional
arguments - these can be found in the source code files of the respective
language.
> [!NOTE] The `<server>` mentioned here is the name of the language server, as
> shown in `vim.languages.<lang>.lsp.servers`. This is NOT the name of the
> language.
Here's a quick overview at what the new language module, looks like:
```nix
{
vim.languages.python = {
enable = true;
lsp = {
enable = true;
# You can now enable multiple LSPs per language
servers = ["pyright" "python-lsp-server"];
};
};
# vim.lsp.servers is a wrapper for the lua API vim.lsp.config
# (see :help vim.lsp.config)
vim.lsp.servers = {
pyright = {
# `vim.languages.<lang>.lsp.package` is now removed, you have to
# modify the cmd field, and remember to copy over the arguments!
cmd = [(getExe pkgs.myCustomPyright) "--stdio"];
};
python-lsp-server = {
# server specific settings
settings = {
pylsp.signature.line_length = 100;
};
};
};
}
```
[NotAShelf](https://github.com/notashelf):
[typst-preview.nvim]: https://github.com/chomosuke/typst-preview.nvim