diff --git a/pkgsets/nvim/lsp.nix b/pkgsets/nvim/lsp.nix index 07aa715..2f2e38d 100644 --- a/pkgsets/nvim/lsp.nix +++ b/pkgsets/nvim/lsp.nix @@ -7,131 +7,117 @@ }@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; - } - ) + programs.nvim-lazy.lazyPlugins = [ + # 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 + blink-cmp + SchemaStore-nvim + # coq_nvim + ] ); - in - [ - # Yaml schema store for yamlls - { - lazy = true; - dir = vPlug: vPlug.SchemaStore-nvim; - } + init = # lua + '' + function() + -- Reserve a space in the gutter + -- This will avoid an annoying layout shift in the screen + vim.opt.signcolumn = 'yes' - { - dir = vPlug: vPlug.cmp-nvim-lsp; - lazy = true; - } + ---Force a specific language for ltex-ls + ---@param lang string + function SetLtexLang(lang) + local clients = vim.lsp.get_clients({ buffer = 0 }) - { - 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 + 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 - ''; - config = # lua - '' - function() - local lsp_defaults = require('lspconfig').util.default_config + end + ''; - -- 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; - }; + 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; - # } - ]; + servers = lib.foldl (l: r: l // r) { } ( + lib.map (path: import "${path}" (inputs // { inherit pkgs; })) ( + fn.lst { + path = ((toString ./.) + "/lsp"); + fullPath = true; + } + ) + ); + }; + + config = # lua + '' + function(_, opts) + 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, + }) + + local lspconfig = require('lspconfig') + for server, config in pairs(opts.servers) do + ${lib.optionalString (lib.elem "nvim::blink" config.machine.pkgs) # lua + '' + -- passing config.capabilities to blink.cmp merges with the capabilities in your + -- `opts[server].capabilities, if you've defined it + config.capabilities = require('blink.cmp').get_lsp_capabilities(config.capabilities) + '' + } + lspconfig[server].setup(config) + end + end + ''; + } + ]; } diff --git a/pkgsets/nvim/lsp/bash.nix b/pkgsets/nvim/lsp/bash.nix index eb53549..b048fc4 100644 --- a/pkgsets/nvim/lsp/bash.nix +++ b/pkgsets/nvim/lsp/bash.nix @@ -5,10 +5,12 @@ ... }: -lib.optionalString (lib.elem "nvim::lsp::bash" config.machine.pkgs) # lua - '' - lspconfig.bashls.setup({ - cmd = {"${pkgs.nodePackages.bash-language-server}/bin/bash-language-server", "start"}, - filetypes = {"sh"}, - }) - '' +lib.optionalAttrs (lib.elem "nvim::lsp::bash" config.machine.pkgs) { + bashls = { + cmd = [ + "${pkgs.nodePackages.bash-language-server}/bin/bash-language-server" + "start" + ]; + filetypes = [ "sh" ]; + }; +} diff --git a/pkgsets/nvim/lsp/c.nix b/pkgsets/nvim/lsp/c.nix index d7d64dc..066a9ea 100644 --- a/pkgsets/nvim/lsp/c.nix +++ b/pkgsets/nvim/lsp/c.nix @@ -5,18 +5,17 @@ ... }: -lib.optionalString (lib.elem "nvim::lsp::c" config.machine.pkgs) # lua - '' - lspconfig.ccls.setup { - cmd = { "${pkgs.ccls}/bin/ccls" }, - init_options = { - compilationDatabaseDirectory = "build"; - index = { - threads = 0; - }; - clang = { - excludeArgs = { "-frounding-math"} ; - }; - } - } - '' +lib.optionalAttrs (lib.elem "nvim::lsp::c" config.machine.pkgs) { + ccls = { + cmd = [ "${pkgs.ccls}/bin/ccls" ]; + init_options = { + # compilationDatabaseDirectory = "build"; + index = { + threads = 0; + }; + clang = { + excludeArgs = [ "-frounding-math" ]; + }; + }; + }; +} diff --git a/pkgsets/nvim/lsp/emmet.nix b/pkgsets/nvim/lsp/emmet.nix index 9fa4af1..9de1459 100644 --- a/pkgsets/nvim/lsp/emmet.nix +++ b/pkgsets/nvim/lsp/emmet.nix @@ -5,9 +5,11 @@ ... }: -lib.optionalString (lib.elem "nvim::lsp::emmet" config.machine.pkgs) # lua - '' - lspconfig.emmet_language_server.setup({ - cmd = {"${pkgs.emmet-language-server}/bin/emmet-language-server", "--stdio"} - }) - '' +lib.optionalAttrs (lib.elem "nvim::lsp::emmet" config.machine.pkgs) { + emmet_language_server = { + cmd = [ + "${pkgs.emmet-language-server}/bin/emmet-language-server" + "--stdio" + ]; + }; +} diff --git a/pkgsets/nvim/lsp/go.nix b/pkgsets/nvim/lsp/go.nix index 397a815..6c44552 100644 --- a/pkgsets/nvim/lsp/go.nix +++ b/pkgsets/nvim/lsp/go.nix @@ -5,9 +5,8 @@ ... }: -lib.optionalString (lib.elem "nvim::lsp::go" config.machine.pkgs) # lua - '' - lspconfig.gopls.setup({ - cmd = {"${pkgs.gopls}/bin/gopls"} - }) - '' +lib.optionalAttrs (lib.elem "nvim::lsp::go" config.machine.pkgs) { + gopls = { + cmd = [ "${pkgs.gopls}/bin/gopls" ]; + }; +} diff --git a/pkgsets/nvim/lsp/harper.nix b/pkgsets/nvim/lsp/harper.nix index 95897f1..a867ae3 100644 --- a/pkgsets/nvim/lsp/harper.nix +++ b/pkgsets/nvim/lsp/harper.nix @@ -5,9 +5,11 @@ ... }: -lib.optionalString (lib.elem "nvim::lsp::harper" config.machine.pkgs) # lua - '' - lspconfig.harper_ls.setup({ - cmd = { "${pkgs.harper}/bin/harper-ls", "--stdio" }, - }) - '' +lib.optionalAttrs (lib.elem "nvim::lsp::harper" config.machine.pkgs) { + harper_ls = { + cmd = [ + "${pkgs.harper}/bin/harper-ls" + "--stdio" + ]; + }; +} diff --git a/pkgsets/nvim/lsp/html.nix b/pkgsets/nvim/lsp/html.nix index 1b5878b..7270f87 100644 --- a/pkgsets/nvim/lsp/html.nix +++ b/pkgsets/nvim/lsp/html.nix @@ -5,12 +5,11 @@ ... }: -lib.optionalString (lib.elem "nvim::lsp::html" config.machine.pkgs) # lua - '' - local html_capabilities = vim.lsp.protocol.make_client_capabilities() - html_capabilities.textDocument.completion.completionItem.snippetSupport = true - lspconfig.html.setup({ - capabilities = html_capabilities, - cmd = {"${pkgs.vscode-langservers-extracted}/bin/vscode-html-language-server"} - }) - '' +lib.optionalAttrs (lib.elem "nvim::lsp::html" config.machine.pkgs) { + # local html_capabilities = vim.lsp.protocol.make_client_capabilities() + # html_capabilities.textDocument.completion.completionItem.snippetSupport = true + html = { + capabilities = _: "vim.lsp.protocol.make_client_capabilities()"; + cmd = [ "${pkgs.vscode-langservers-extracted}/bin/vscode-html-language-server" ]; + }; +} diff --git a/pkgsets/nvim/lsp/ltex.nix b/pkgsets/nvim/lsp/ltex.nix index f56f6fa..11d37dc 100644 --- a/pkgsets/nvim/lsp/ltex.nix +++ b/pkgsets/nvim/lsp/ltex.nix @@ -5,20 +5,23 @@ ... }: -lib.optionalString (lib.elem "nvim::lsp::ltex" config.machine.pkgs) # lua - '' - lspconfig.ltex.setup({ - cmd = { "${pkgs.ltex-ls}/bin/ltex-ls" }, - settings = { - ltex = { - language = "de-DE", - }, - }, - }) - - vim.api.nvim_create_user_command( - "LtexLang", - "lua SetLtexLang()", - { nargs = 1, desc = "Set ltex-ls language" } - ) - '' +lib.optionalAttrs (lib.elem "nvim::lsp::ltex" config.machine.pkgs) { + ltex = { + cmd = [ "${pkgs.ltex-ls}/bin/ltex-ls" ]; + settings = { + ltex = { + language = "de-DE"; + }; + }; + on_attach = + _: # lua + '' + function(client, bufnr) + vim.api.nvim_create_user_command( + "LtexLang", + "lua SetLtexLang()", + { nargs = 1, desc = "Set ltex-ls language" } + ) + end''; + }; +} diff --git a/pkgsets/nvim/lsp/lua.nix b/pkgsets/nvim/lsp/lua.nix index 1dc9eab..c77df9a 100644 --- a/pkgsets/nvim/lsp/lua.nix +++ b/pkgsets/nvim/lsp/lua.nix @@ -5,22 +5,21 @@ ... }: -lib.optionalString (lib.elem "nvim::lsp::lua" config.machine.pkgs) # lua - '' - lspconfig.lua_ls.setup({ - cmd = {"${pkgs.lua-language-server}/bin/lua-language-server"}, - settings = { - Lua = { - runtime = { - version = 'LuaJIT' - }, - workspace = { - checkThirdParty = false, - library = { - vim.env.VIMRUNTIME - } - } - } - } - }) - '' +lib.optionalAttrs (lib.elem "nvim::lsp::lua" config.machine.pkgs) { + lua_ls = { + cmd = [ "${pkgs.lua-language-server}/bin/lua-language-server" ]; + settings = { + Lua = { + runtime = { + version = "LuaJIT"; + }; + workspace = { + checkThirdParty = false; + library = [ + (_: "vim.env.VIMRUNTIME") + ]; + }; + }; + }; + }; +} diff --git a/pkgsets/nvim/lsp/markdown.nix b/pkgsets/nvim/lsp/markdown.nix index 626e0f8..f22a959 100644 --- a/pkgsets/nvim/lsp/markdown.nix +++ b/pkgsets/nvim/lsp/markdown.nix @@ -5,9 +5,11 @@ ... }: -lib.optionalString (lib.elem "nvim::lsp::markdown" config.machine.pkgs) # lua - '' - lspconfig.marksman.setup { - cmd = { "${pkgs.marksman}/bin/marksman", "server" }, - } - '' +lib.optionalAttrs (lib.elem "nvim::lsp::markdown" config.machine.pkgs) { + marksman = { + cmd = [ + "${pkgs.marksman}/bin/marksman" + "server" + ]; + }; +} diff --git a/pkgsets/nvim/lsp/nix-nil.nix b/pkgsets/nvim/lsp/nix-nil.nix index 0109c7f..44e16c4 100644 --- a/pkgsets/nvim/lsp/nix-nil.nix +++ b/pkgsets/nvim/lsp/nix-nil.nix @@ -5,22 +5,21 @@ ... }: -lib.optionalString (lib.elem "nvim::lsp::nix-nil" config.machine.pkgs) # lua - '' - lspconfig.nil_ls.setup({ - cmd = {"${pkgs.nil}/bin/nil"}, - settings = { - ['nil'] = { - formatting = { - command = { "${pkgs.nixfmt-rfc-style}/bin/nixfmt" } - }, - maxMemoryMB = 4069, - -- nix = { - -- flake = { - -- autoEvalInputs = true - -- } - -- } - } - } - }) - '' +lib.optionalAttrs (lib.elem "nvim::lsp::nix-nil" config.machine.pkgs) { + nil_ls = { + cmd = [ "${pkgs.nil}/bin/nil" ]; + settings = { + "['nil']" = { + formatting = { + command = [ "${pkgs.nixfmt-rfc-style}/bin/nixfmt" ]; + }; + maxMemoryMB = 4069; + # nix = { + # flake = { + # autoEvalInputs = true; + # }; + # }; + }; + }; + }; +} diff --git a/pkgsets/nvim/lsp/nix-nixd.nix b/pkgsets/nvim/lsp/nix-nixd.nix index 00f527a..66662fa 100644 --- a/pkgsets/nvim/lsp/nix-nixd.nix +++ b/pkgsets/nvim/lsp/nix-nixd.nix @@ -5,38 +5,42 @@ ... }: -lib.optionalString (lib.elem "nvim::lsp::nix-nixd" config.machine.pkgs) # lua - '' - lspconfig.nixd.setup({ - cmd = { "${pkgs.nixd}/bin/nixd" }, - settings = { - nixd = { - -- on_init = function(client) - -- local path = client.workspace_folders[1].name +lib.optionalAttrs (lib.elem "nvim::lsp::nix-nixd" config.machine.pkgs) { + nixd = { + cmd = [ "${pkgs.nixd}/bin/nixd" ]; + settings = { + nixd = { + on_init = + _: # lua + '' + function(client) + local path = client.workspace_folders[1].name - -- if path == '/path/to/project1' then - -- client.config.settings["rust-analyzer"].checkOnSave.overrideCommand = { "cargo", "check" } - -- client.notify("workspace/didChangeConfiguration", { settings = client.config.settings }) - -- end + if path == '/path/to/project1' then + client.config.settings["rust-analyzer"].checkOnSave.overrideCommand = { "cargo", "check" } + client.notify("workspace/didChangeConfiguration", { settings = client.config.settings }) + end - -- return true - -- end, - nixpkgs = { - expr = 'import (builtins.getFlake ("git+file:///etc/nixos")).inputs.nixpkgs {}', - }, - formatting = { - command = { "${pkgs.nixfmt-rfc-style}/bin/nixfmt" }, - }, - options = { - nixos = { - expr = '(builtins.getFlake ("git+file:///etc/nixos")).outputs.nixosConfigurations.Lilim.options', - }, - -- TODO: Find a good general expression for this. - -- home_manager = { - -- expr = '(builtins.getFlake ("git+file://" + toString ./.)).homeConfigurations."ruixi@k-on".options', - -- }, - }, - }, - }, - }) - '' + return true + end + ''; + nixpkgs = { + expr = ''import (builtins.getFlake ("git+file:///etc/nixos")).inputs.nixpkgs {}''; + }; + formatting = { + command = [ "${pkgs.nixfmt-rfc-style}/bin/nixfmt" ]; + }; + options = { + nixos = { + expr = ''(builtins.getFlake ("git+file:///etc/nixos")).outputs.nixosConfigurations.Lilim.options''; + }; + # TODO: Find a good general expression for this. + # home_manager = { + # expr = + # "'(builtins.getFlake (\"git+file://\" + toString ./.)).homeConfigurations.\"ruixi@k-on\".options'"; + # }; + }; + }; + }; + }; +} diff --git a/pkgsets/nvim/lsp/php.nix b/pkgsets/nvim/lsp/php.nix index c9b2d81..9ccf9f4 100644 --- a/pkgsets/nvim/lsp/php.nix +++ b/pkgsets/nvim/lsp/php.nix @@ -5,15 +5,17 @@ ... }: -lib.optionalString (lib.elem "nvim::lsp::php" config.machine.pkgs) # lua - '' - lspconfig.phpactor.setup({ - cmd = {"${pkgs.phpactor}/bin/phpactor", "language-server"}, - init_options = { - ["symfony.enabled"] = true, - ["language_server_phpstan.enabled"] = true, - ["language_server_phpstan.bin"] = "${pkgs.phpPackages.phpstan}/bin/phpstan", - ["language_server_phpstan.level"] = 5, - }, - }) - '' +lib.optionalAttrs (lib.elem "nvim::lsp::php" config.machine.pkgs) { + phpactor = { + cmd = [ + "${pkgs.phpactor}/bin/phpactor" + "language-server" + ]; + init_options = { + "[\"symfony.enabled\"]" = true; + "[\"language_server_phpstan.enabled\"]" = true; + "[\"language_server_phpstan.bin\"]" = "${pkgs.phpPackages.phpstan}/bin/phpstan"; + "[\"language_server_phpstan.level\"]" = 5; + }; + }; +} diff --git a/pkgsets/nvim/lsp/python.nix b/pkgsets/nvim/lsp/python.nix index 5a12dbb..621525d 100644 --- a/pkgsets/nvim/lsp/python.nix +++ b/pkgsets/nvim/lsp/python.nix @@ -5,40 +5,50 @@ ... }: -lib.optionalString (lib.elem "nvim::lsp::python" config.machine.pkgs) # lua - '' - lspconfig.pyright.setup({ - cmd = {"${pkgs.pyright}/bin/pyright-langserver", "--stdio"}, +lib.optionalAttrs (lib.elem "nvim::lsp::python" config.machine.pkgs) { + pyright = { + cmd = [ + "${pkgs.pyright}/bin/pyright-langserver" + "--stdio" + ]; + settings = { + pyright = { + disableOrganizeImports = true; + }; + python = { + # analysis = { + # ignore = { '*' }, + # }, + }; + }; + }; + ruff = { + cmd = [ + "${pkgs.ruff}/bin/ruff" + "server" + "--preview" + ]; + init_options = { settings = { - pyright = { - disableOrganizeImports = true, - }, - python = { - -- analysis = { - -- ignore = { '*' }, - -- }, - }, - }, - }) - lspconfig.ruff.setup({ - cmd = {"${pkgs.ruff}/bin/ruff", "server", "--preview"}, - init_options = { - settings = { - -- Modification to any of these settings has no effect. - enable = true, - ignoreStandardLibrary = true, - organizeImports = true, - fixAll = true, - lint = { - enable = true, - run = 'onType', - }, - }, - }, - on_attach = function(client, bufnr) - if client.name == 'ruff' then - client.server_capabilities.hoverProvider = false; - end - end, - }) - '' + # Modification to any of these settings has no effect. + enable = true; + ignoreStandardLibrary = true; + organizeImports = true; + fixAll = true; + lineLength = 120; + lint = { + enable = true; + run = "onType"; + }; + }; + }; + on_attach = + _: # lua + '' + function(client, bufnr) + if client.name == 'ruff' then + client.server_capabilities.hoverProvider = false; + end + end''; + }; +} diff --git a/pkgsets/nvim/lsp/rust.nix b/pkgsets/nvim/lsp/rust.nix index 52db3c0..80dfffa 100644 --- a/pkgsets/nvim/lsp/rust.nix +++ b/pkgsets/nvim/lsp/rust.nix @@ -5,9 +5,13 @@ ... }: -lib.optionalString (lib.elem "nvim::lsp::rust" config.machine.pkgs) # lua - '' - lspconfig.rust_analyzer.setup({ - cmd = {"${pkgs.rustup}/bin/rustup", "run", "nightly", "rust-analyzer"} - }) - '' +lib.optionalAttrs (lib.elem "nvim::lsp::rust" config.machine.pkgs) { + rust_analyzer = { + cmd = [ + "${pkgs.rustup}/bin/rustup" + "run" + "nightly" + "rust-analyzer" + ]; + }; +} diff --git a/pkgsets/nvim/lsp/typescript.nix b/pkgsets/nvim/lsp/typescript.nix index 6c0cc14..f8835ff 100644 --- a/pkgsets/nvim/lsp/typescript.nix +++ b/pkgsets/nvim/lsp/typescript.nix @@ -5,9 +5,11 @@ ... }: -lib.optionalString (lib.elem "nvim::lsp::typescript" config.machine.pkgs) # lua - '' - lspconfig.ts_ls.setup({ - cmd = {"${pkgs.nodePackages.typescript-language-server}/bin/typescript-language-server", "--stdio"} - }) - '' +lib.optionalAttrs (lib.elem "nvim::lsp::typescript" config.machine.pkgs) { + ts_ls = { + cmd = [ + "${pkgs.nodePackages.typescript-language-server}/bin/typescript-language-server" + "--stdio" + ]; + }; +} diff --git a/pkgsets/nvim/lsp/yaml.nix b/pkgsets/nvim/lsp/yaml.nix index 9ffe633..bc7f713 100644 --- a/pkgsets/nvim/lsp/yaml.nix +++ b/pkgsets/nvim/lsp/yaml.nix @@ -5,20 +5,22 @@ ... }: -lib.optionalString (lib.elem "nvim::lsp::yaml" config.machine.pkgs) # lua - '' - lspconfig.yamlls.setup({ - cmd = { "${pkgs.yaml-language-server}/bin/yaml-language-server", "--stdio" }, - settings = { - yaml = { - schemaStore = { - -- Disable to use Store from SchemaStore-nvim plugin - enable = false, - -- Avoid TypeError: Cannot read properties of undefined (reading 'length') - url = "", - }, - schemas = require('schemastore').yaml.schemas(), - }, - }, - }) - '' +lib.optionalAttrs (lib.elem "nvim::lsp::yaml" config.machine.pkgs) { + yamlls = { + cmd = [ + "${pkgs.yaml-language-server}/bin/yaml-language-server" + "--stdio" + ]; + settings = { + yaml = { + schemaStore = { + # Disable to use Store from SchemaStore-nvim plugin + enable = false; + # Avoid TypeError: Cannot read properties of undefined (reading 'length') + url = ""; + }; + schemas = _: "require('schemastore').yaml.schemas()"; + }; + }; + }; +}