nixos/pkgsets/nvim/lsp.nix

128 lines
3.4 KiB
Nix

{
lib,
config,
pkgs,
fn,
...
}@inputs:
lib.mkIf (lib.elem "nvim::lsp" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins =
let
lspServers = lib.concatStrings (
map (path: import "${path}" (inputs // { inherit pkgs; })) (
fn.lst {
path = ((toString ./.) + "/lsp");
fullPath = true;
}
)
);
in
[
# Yaml schema store for yamlls
{
lazy = true;
dir = vPlug: vPlug.SchemaStore-nvim;
}
{
dir = vPlug: vPlug.lsp-zero-nvim;
lazy = true;
# TODO: This is a bit of a workaround...
config = "false";
init = # lua
''
function()
-- Disable automatic setup, we are doing it manually
vim.g.lsp_zero_extend_cmp = 0
vim.g.lsp_zero_extend_lspconfig = 0
end
'';
}
{
dir = vPlug: vPlug.cmp-nvim-lsp;
lazy = true;
}
{
dir = vPlug: vPlug.nvim-lspconfig;
cmd = [ "LspInfo" ];
event = [
"BufReadPre"
"BufNewFile"
];
dependencies = (
vPlug: with vPlug; [
cmp-nvim-lsp
SchemaStore-nvim
# coq_nvim
]
);
init = # lua
''
function()
---Force a specific language for ltex-ls
---@param lang string
function SetLtexLang(lang)
local clients = vim.lsp.get_clients({ buffer = 0 })
for _, client in ipairs(clients) do
if client.name == "ltex" then
vim.api.nvim_notify("Set ltex-ls lang to " .. lang, vim.log.levels.INFO, { title = "LTex Language", timeout = 2000, })
client.config.settings.ltex.language = lang
vim.lsp.buf_notify(0, "workspace/didChangeConfiguration", { settings = client.config.settings })
return
end
end
end
end
'';
config = # lua
''
function()
-- This is where all the LSP shenanigans will live
local lsp_zero = require('lsp-zero')
lsp_zero.extend_lspconfig()
lsp_zero.on_attach(function(client, bufnr)
-- see :help lsp-zero-keybindings
-- to learn the available actions
lsp_zero.default_keymaps({buffer = bufnr})
end)
-- (Optional) Configure lua language server for neovim
local lspconfig = require('lspconfig')
${lspServers}
end
'';
opts = {
inlay_hints = {
enabled = true;
};
};
}
# {
# dir = vPlug: vPlug.lspsaga-nvim;
# config = /* lua */ ''
# function()
# require('lspsaga').setup({
# ui = {
# code_action = "󰌵",
# },
# lightbulb = {
# enable = true,
# enable_in_insert = false,
# virtual_text = false,
# },
# })
# end
# '';
# dependencies = [ "nvim-treesitter" "nvim-web-devicons" ];
# }
# {
# lazy = true;
# dir = vPlug: vPlug.nvim-web-devicons;
# }
];
}