{ 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() -- Reserve a space in the gutter -- This will avoid an annoying layout shift in the screen vim.opt.signcolumn = 'yes' ---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() 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} vim.keymap.set('n', 'K', 'lua vim.lsp.buf.hover()', opts) vim.keymap.set('n', 'gd', 'lua vim.lsp.buf.definition()', opts) vim.keymap.set('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) vim.keymap.set('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) vim.keymap.set('n', 'go', 'lua vim.lsp.buf.type_definition()', opts) vim.keymap.set('n', 'gr', 'lua vim.lsp.buf.references()', opts) vim.keymap.set('n', 'gs', 'lua vim.lsp.buf.signature_help()', opts) vim.keymap.set('n', '', 'lua vim.lsp.buf.rename()', opts) vim.keymap.set({'n', 'x'}, '', 'lua vim.lsp.buf.format({async = true})', opts) vim.keymap.set('n', '', 'lua vim.lsp.buf.code_action()', opts) 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; # } ]; }