2024-12-01 16:54:44 +01:00
|
|
|
{
|
|
|
|
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.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()
|
2024-12-14 21:44:39 +01:00
|
|
|
-- Reserve a space in the gutter
|
|
|
|
-- This will avoid an annoying layout shift in the screen
|
|
|
|
vim.opt.signcolumn = 'yes'
|
|
|
|
|
2024-12-01 16:54:44 +01:00
|
|
|
---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()
|
2024-12-14 21:44:39 +01:00
|
|
|
local lsp_defaults = require('lspconfig').util.default_config
|
|
|
|
|
|
|
|
-- Add cmp_nvim_lsp capabilities settings to lspconfig
|
|
|
|
-- This should be executed before you configure any language server
|
|
|
|
lsp_defaults.capabilities = vim.tbl_deep_extend(
|
|
|
|
'force',
|
|
|
|
lsp_defaults.capabilities,
|
|
|
|
require('cmp_nvim_lsp').default_capabilities()
|
|
|
|
)
|
|
|
|
|
|
|
|
-- LspAttach is where you enable features that only work
|
|
|
|
-- if there is a language server active in the file
|
|
|
|
vim.api.nvim_create_autocmd('LspAttach', {
|
|
|
|
desc = 'LSP actions',
|
|
|
|
callback = function(event)
|
|
|
|
local opts = {buffer = event.buf}
|
2024-12-01 16:54:44 +01:00
|
|
|
|
2024-12-14 21:44:39 +01:00
|
|
|
vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts)
|
|
|
|
vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts)
|
|
|
|
vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts)
|
|
|
|
vim.keymap.set('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts)
|
|
|
|
vim.keymap.set('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts)
|
|
|
|
vim.keymap.set('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', opts)
|
|
|
|
vim.keymap.set('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts)
|
|
|
|
vim.keymap.set('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>', opts)
|
|
|
|
vim.keymap.set({'n', 'x'}, '<F3>', '<cmd>lua vim.lsp.buf.format({async = true})<cr>', opts)
|
|
|
|
vim.keymap.set('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>', opts)
|
|
|
|
end,
|
|
|
|
})
|
2024-12-01 16:54:44 +01:00
|
|
|
|
|
|
|
-- (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;
|
|
|
|
# }
|
|
|
|
];
|
|
|
|
}
|