This commit is contained in:
Venkatesan Ravi 2025-04-07 18:00:20 +00:00 committed by GitHub
commit 3abae4960b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 97 additions and 0 deletions

View file

@ -303,6 +303,7 @@
- Disable mini.indentscope for applicable filetypes.
- Fix fzf-lua having a hard dependency on fzf.
- Enable inlay hints support - `config.vim.lsp.inlayHints`.
- Add Fish language support under `vim.languages.fish`.
[tebuevd](https://github.com/tebuevd):

View file

@ -10,6 +10,7 @@ in {
./clang.nix
./css.nix
./elixir.nix
./fish.nix
./fsharp.nix
./gleam.nix
./go.nix

View file

@ -0,0 +1,95 @@
{
config,
pkgs,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.meta) getExe;
inherit (lib.lists) isList;
inherit (lib.types) bool either enum listOf package str;
inherit (lib.nvim.lua) expToLua toLuaObject;
inherit (lib.nvim.types) mkGrammarOption;
cfg = config.vim.languages.fish;
defaultFormat = "fish_indent";
formats = {
fish_indent = {
cmd = "${pkgs.fish}/bin/fish_indent";
};
};
in {
options.vim.languages.fish = {
enable = mkEnableOption "Fish language support";
format = {
enable = mkOption {
type = bool;
default = config.vim.languages.enableFormat;
description = "Enable Fish formatting";
};
type = mkOption {
type = enum (attrNames formats);
default = defaultFormat;
description = "Fish formatter to use";
};
cmd = mkOption {
type = str;
default = formats.${cfg.format.type}.cmd;
description = "Path to fish formatter executable";
};
};
lsp = {
enable = mkEnableOption "Fish LSP support via fish-lsp" // {default = config.vim.languages.enableLSP;};
package = mkOption {
description = "fish-lsp package, or the command to run as a list of strings";
type = either package (listOf str);
default = pkgs.fish-lsp;
};
};
treesitter = {
enable = mkEnableOption "Fish Treesitter support" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "fish";
};
};
config = mkMerge [
(mkIf cfg.format.enable {
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.fish = [cfg.format.type];
setupOpts.formatters.${cfg.format.type} = {command = cfg.format.cmd;};
};
})
(mkIf (cfg.enable && cfg.lsp.enable) {
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.fish-lsp = let
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else toLuaObject ["${getExe cfg.lsp.package}" "start"];
in ''
lspconfig.fish_lsp.setup {
capabilities = capabilities;
on_attach = default_on_attach;
cmd = ${cmd};
}
'';
})
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.package];
})
];
}