mirror of
https://github.com/ksyasuda/dotfiles.git
synced 2025-12-05 02:53:38 -08:00
update basedpyright and vim.diagnostic config
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user