nixeovim/modules/plugins/language-server/lspconfig.nix

53 lines
1.2 KiB
Nix
Raw Normal View History

2024-05-03 17:50:57 +03:00
{ config, lib, pkgs, ... }:
let
cfg = config.plugins.language-server.lspconfig;
in
{
options.plugins.language-server.lspconfig = with lib; {
enable = mkEnableOption "lspconfig";
package = mkPackageOption pkgs.vimPlugins "nvim-lspconfig" { };
serverSettings = mkOption {
type = with types; attrsOf attrs;
default = { };
};
keymap.set = mkOption {
type = with types; listOf keymap;
default = [ ];
};
};
config = lib.mkIf cfg.enable {
fn.lspconfig-on-attach = {
args = [ "event" ];
content = with lib.nix2lua; { event }: {
vim.keymap.set = map
(attrs: attrs // { buffer = pipe1 event (var "buf"); })
cfg.keymap.set;
};
};
vim.augroup.user-lsp-config = {
event = "LspAttach";
callback = config.fn.lspconfig-on-attach.lambda;
};
plugin.nvim-lspconfig = {
name = "lspconfig";
2024-05-08 01:57:06 +03:00
package = cfg.package;
2024-05-03 17:50:57 +03:00
afterSetup = with lib.nix2lua; lib.mapAttrsToList
(ls: lsSettings:
pipe [
(var "lspconfig")
(var ls)
(call "setup" lsSettings)
]
)
cfg.serverSettings;
};
};
}