Compare commits
4 commits
de462a270b
...
6435a7b51a
| Author | SHA1 | Date | |
|---|---|---|---|
| 6435a7b51a | |||
| 99098f56a1 | |||
| bb6f401ff3 | |||
| 07e820ac00 |
7 changed files with 94 additions and 110 deletions
3
nvim/.config/nvim/after/lsp/arduino.lua
Normal file
3
nvim/.config/nvim/after/lsp/arduino.lua
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
return {
|
||||
on_new_config = require("arduino").on_new_config,
|
||||
}
|
||||
22
nvim/.config/nvim/after/lsp/basedpyright.lua
Normal file
22
nvim/.config/nvim/after/lsp/basedpyright.lua
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
-- 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 = { "*" },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
39
nvim/.config/nvim/after/lsp/marksman.lua
Normal file
39
nvim/.config/nvim/after/lsp/marksman.lua
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
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,
|
||||
}
|
||||
9
nvim/.config/nvim/after/lsp/ruff.lua
Normal file
9
nvim/.config/nvim/after/lsp/ruff.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
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,
|
||||
}
|
||||
17
nvim/.config/nvim/after/lsp/vue_ls.lua
Normal file
17
nvim/.config/nvim/after/lsp/vue_ls.lua
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
-- 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
|
||||
|
||||
local languages = {
|
||||
arduino = { lsp = { arduino_language_server = {} }, ts = { "arduino" } },
|
||||
arduino = { lsp = { clangd = {}, arduino_language_server = { disable = true } }, ts = { "arduino" } },
|
||||
awk = { ts = { "awk" }, format = { awk = { "gawk" } } },
|
||||
astro = {
|
||||
lsp = { astro = {} },
|
||||
|
|
|
|||
|
|
@ -87,115 +87,9 @@ local lsp = {
|
|||
register("nushell")
|
||||
end
|
||||
|
||||
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" },
|
||||
})
|
||||
-- arduino lsp only works if arduino-cli is installed
|
||||
if vim.fn.executable("arduino-cli") == 1 then
|
||||
register("arduino_language_server")
|
||||
end
|
||||
|
||||
-- attach ltex for fitting ft only when spell checking becomes enabled
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue