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

51 lines
1.1 KiB
Nix

{ 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";
afterSetup = with lib.nix2lua; lib.mapAttrsToList
(ls: lsSettings:
pipe [
(var "lspconfig")
(var ls)
(call "setup" lsSettings)
]
)
cfg.serverSettings;
};
};
}