Compare commits
No commits in common. "6435a7b51aaf5369bec383c83b08cc1420445d98" and "de462a270bb82275c083c394112bd35a81b47b5b" have entirely different histories.
6435a7b51a
...
de462a270b
7 changed files with 110 additions and 94 deletions
|
|
@ -1,3 +0,0 @@
|
||||||
return {
|
|
||||||
on_new_config = require("arduino").on_new_config,
|
|
||||||
}
|
|
||||||
|
|
@ -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 = { "*" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
@ -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,
|
|
||||||
}
|
|
||||||
|
|
@ -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,
|
|
||||||
}
|
|
||||||
|
|
@ -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 {}
|
|
||||||
|
|
@ -26,7 +26,7 @@ local function mason_dir()
|
||||||
end
|
end
|
||||||
|
|
||||||
local languages = {
|
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" } } },
|
awk = { ts = { "awk" }, format = { awk = { "gawk" } } },
|
||||||
astro = {
|
astro = {
|
||||||
lsp = { astro = {} },
|
lsp = { astro = {} },
|
||||||
|
|
|
||||||
|
|
@ -87,9 +87,115 @@ local lsp = {
|
||||||
register("nushell")
|
register("nushell")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- arduino lsp only works if arduino-cli is installed
|
register("marksman", {
|
||||||
if vim.fn.executable("arduino-cli") == 1 then
|
filetypes = { "markdown", "quarto" },
|
||||||
register("arduino_language_server")
|
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
|
end
|
||||||
|
|
||||||
-- attach ltex for fitting ft only when spell checking becomes enabled
|
-- attach ltex for fitting ft only when spell checking becomes enabled
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue