update basedpyright and vim.diagnostic config

This commit is contained in:
kyasuda
2025-08-19 14:14:57 -07:00
parent 180160fee1
commit a53991c53d
6 changed files with 117 additions and 63 deletions

View File

@@ -1,7 +1,22 @@
local function set_python_path(path)
local clients = vim.lsp.get_clients({
bufnr = vim.api.nvim_get_current_buf(),
name = "basedpyright",
})
for _, client in ipairs(clients) do
if client.settings then
client.settings.python = vim.tbl_deep_extend("force", client.settings.python or {}, { pythonPath = path })
else
client.config.settings =
vim.tbl_deep_extend("force", client.config.settings, { python = { pythonPath = path } })
end
client:notify("workspace/didChangeConfiguration", { settings = nil })
end
end
return {
"neovim/nvim-lspconfig",
config = function()
local lspconfig = require("lspconfig")
vim.notify = require("notify")
local servers = {
"bashls",
@@ -82,11 +97,32 @@ return {
autoSearchPaths = true,
diagnosticMode = "openFilesOnly",
useLibraryCodeForTypes = true,
autoFormatStrings = true,
},
diagnosticMode = "openFilesOnly",
inlayHints = {
callArgumentNames = true,
},
allowedUntypedLibraries = true,
reportMissingTypeStubs = false,
reportImportCycles = true,
reportUnusedImport = true,
on_attach = function(client, bufnr)
vim.api.nvim_buf_create_user_command(bufnr, "LspPyrightOrganizeImports", function()
client:exec_cmd({
command = "basedpyright.organizeimports",
arguments = { vim.uri_from_bufnr(bufnr) },
})
end, {
desc = "Organize Imports",
})
vim.api.nvim_buf_create_user_command(bufnr, "LspPyrightSetPythonPath", set_python_path, {
desc = "Reconfigure basedpyright with the provided python path",
nargs = 1,
complete = "file",
})
end,
})
vim.lsp.enable(lsp)
else