diff --git a/nvim/.config/nvim/after/lsp/arduino.lua b/nvim/.config/nvim/after/lsp/arduino.lua deleted file mode 100644 index 70ca6ab..0000000 --- a/nvim/.config/nvim/after/lsp/arduino.lua +++ /dev/null @@ -1,3 +0,0 @@ -return { - on_new_config = require("arduino").on_new_config, -} diff --git a/nvim/.config/nvim/after/lsp/basedpyright.lua b/nvim/.config/nvim/after/lsp/basedpyright.lua deleted file mode 100644 index 84d1033..0000000 --- a/nvim/.config/nvim/after/lsp/basedpyright.lua +++ /dev/null @@ -1,22 +0,0 @@ --- ensure python virtualenv is determined automatically on lsp start --- we primarily use pyright for cmp lsp completion & hover info -return { - on_attach = function(client, _) - require("core.util").set_python_env() - local python_path, _ = vim.fn.expand(require("core.util").get_python_venv_bin(client.config.root_dir)) - client.config.settings.python = {} or client.config.settings.python - client.config.settings.python.pythonPath = python_path - end, - settings = { - -- disable imports and linting since, using ruff for it - pyright = { - disableOrganizeImports = true, - }, - python = { - analysis = { - -- ignore all files, use ruff for linting - ignore = { "*" }, - }, - }, - }, -} diff --git a/nvim/.config/nvim/after/lsp/marksman.lua b/nvim/.config/nvim/after/lsp/marksman.lua deleted file mode 100644 index cece8ba..0000000 --- a/nvim/.config/nvim/after/lsp/marksman.lua +++ /dev/null @@ -1,39 +0,0 @@ -local util = require("lspconfig.util") - -local function filter_marksman_diagnostics(diagnostic) - -- code == 2 filters all 'non-existent link' diagnostics - if diagnostic.source == "marksman" and diagnostic.code == 2 then - return false - end - return true -end - -local function handle_diagnostics(err, result, _) - result.diagnostics = vim.tbl_filter(filter_marksman_diagnostics, result.diagnostics) - return result, err -end - -return { - filetypes = { "markdown", "quarto", "djot" }, - on_attach = function(client, bufnr) - local fname = vim.api.nvim_buf_get_name(bufnr) - local is_zk_root_dir = util.root_pattern(".zk") - - -- turn off diagnostics if we are in a ZK directory - if is_zk_root_dir(fname) then - client.capabilities.completionProvider = false - client.capabilities.hoverProvider = false - client.capabilities.publishDiagnostics = false - client.capabilities.diagnostic = false - local namespace = vim.lsp.diagnostic.get_namespace(client.id) - - -- hides diagnostics from displaying in buffer - vim.diagnostic.enable(false, { ns_id = namespace, bufnr = bufnr }) - vim.diagnostic.get() - - -- actually removes all marksman diagnostics - client["handlers"] = client.handlers or {} - client.handlers["textDocument/publishDiagnostics"] = handle_diagnostics - end - end, -} diff --git a/nvim/.config/nvim/after/lsp/ruff.lua b/nvim/.config/nvim/after/lsp/ruff.lua deleted file mode 100644 index b3fbdb6..0000000 --- a/nvim/.config/nvim/after/lsp/ruff.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - on_attach = function(client, _) - require("core.util").set_python_env() - client.server_capabilities.hoverProvider = false -- we use pyright for hover info - local python_path, _ = vim.fn.expand(require("core.util").get_python_venv_bin(client.config.root_dir)) - client.config.settings.python = {} or client.config.settings.python - client.config.settings.python.pythonPath = python_path - end, -} diff --git a/nvim/.config/nvim/after/lsp/vue_ls.lua b/nvim/.config/nvim/after/lsp/vue_ls.lua deleted file mode 100644 index 0c42edd..0000000 --- a/nvim/.config/nvim/after/lsp/vue_ls.lua +++ /dev/null @@ -1,17 +0,0 @@ --- we have to set up ts server with an additional vue plugin -vim.lsp.config("ts_ls", { - init_options = { - plugins = { - { - name = "@vue/typescript-plugin", - location = vim.fn.expand("$MASON/packages") - .. "/vue-language-server" - .. "/node_modules/@vue/language-server", - languages = { "vue" }, - }, - }, - }, - filetypes = { "typescript", "javascript", "javascriptreact", "typescriptsreact", "vue" }, -}) - -return {} diff --git a/nvim/.config/nvim/lua/core/languages.lua b/nvim/.config/nvim/lua/core/languages.lua index 8fa0595..fb32cd4 100644 --- a/nvim/.config/nvim/lua/core/languages.lua +++ b/nvim/.config/nvim/lua/core/languages.lua @@ -26,7 +26,7 @@ local function mason_dir() end local languages = { - arduino = { lsp = { clangd = {}, arduino_language_server = { disable = true } }, ts = { "arduino" } }, + arduino = { lsp = { arduino_language_server = {} }, ts = { "arduino" } }, awk = { ts = { "awk" }, format = { awk = { "gawk" } } }, astro = { lsp = { astro = {} }, diff --git a/nvim/.config/nvim/lua/plugins/lsp.lua b/nvim/.config/nvim/lua/plugins/lsp.lua index 5d0a9d3..3f6151b 100644 --- a/nvim/.config/nvim/lua/plugins/lsp.lua +++ b/nvim/.config/nvim/lua/plugins/lsp.lua @@ -87,9 +87,115 @@ local lsp = { register("nushell") end - -- arduino lsp only works if arduino-cli is installed - if vim.fn.executable("arduino-cli") == 1 then - register("arduino_language_server") + register("marksman", { + filetypes = { "markdown", "quarto" }, + on_attach = function(client, _) + -- TODO: for some reason this stays true even after rootdir switch? + if client.config.in_zk_notebook then + local default_handler = vim.diagnostic.handlers.virtual_text + vim.diagnostic.handlers.virtual_text = { + show = function(namespace, bufnrr, diagnostics, opts) + for i, diagnostic in ipairs(diagnostics) do + if + diagnostic.source + == "Marksman" -- You need to check what the correct value should be here + then + table.remove(diagnostics, i) + end + end + default_handler.show(namespace, bufnrr, diagnostics, opts) + end, + hide = function(...) + default_handler.hide(...) + end, + } + default_handler = vim.diagnostic.handlers.signs + vim.diagnostic.handlers.signs = { + show = function(namespace, bufnrr, diagnostics, opts) + for i, diagnostic in ipairs(diagnostics) do + if + diagnostic.source + == "Marksman" -- You need to check what the correct value should be here + then + table.remove(diagnostics, i) + end + end + default_handler.show(namespace, bufnrr, diagnostics, opts) + end, + hide = function(...) + default_handler.hide(...) + end, + } + end + end, + on_new_config = function(conf, new_root) + if require("lspconfig.util").root_pattern(".zk")(new_root) then + conf.in_zk_notebook = true + else + conf.in_zk_notebook = false + end + end, + }) + + local python_path + -- ensure python virtualenv is determined automatically on lsp start + -- we primarily use pyright for cmp lsp completion & hover info + register("basedpyright", { + on_attach = function(client, _) + require("core.util").set_python_env() + if python_path == nil then + python_path, _ = vim.fn.expand(require("core.util").get_python_venv_bin(client.config.root_dir)) + end + client.config.settings.python = {} or client.config.settings.python + client.config.settings.python.pythonPath = python_path + end, + settings = { + -- disable imports and linting since, using ruff for it + pyright = { + disableOrganizeImports = true, + }, + python = { + analysis = { + -- ignore all files, use ruff for linting + ignore = { "*" }, + }, + }, + }, + }) + register("ruff", { + on_attach = function(client, _) + require("core.util").set_python_env() + client.server_capabilities.hoverProvider = false -- we use pyright for hover info + if python_path == nil then + python_path, _ = vim.fn.expand(require("core.util").get_python_venv_bin(client.config.root_dir)) + end + client.config.settings.python = {} or client.config.settings.python + client.config.settings.python.pythonPath = python_path + end, + }) + + -- set up arduino with the help of arduino.nvim plugin + if require("core.util").is_available("arduino") then + register("arduino_language_server", { + on_new_config = require("arduino").on_new_config, + }) + end + + if vim.lsp.is_enabled("vue_ls") then + register("ts_ls", { + init_options = { + plugins = { + { + name = "@vue/typescript-plugin", + location = vim.fn.expand("$MASON/packages") + .. "/vue-language-server" + .. "/node_modules/@vue/language-server", + languages = { "vue" }, + }, + }, + }, + filetypes = { "typescript", "javascript", "javascriptreact", "typescriptsreact", "vue" }, + }) end -- attach ltex for fitting ft only when spell checking becomes enabled