| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- --- @type vim.lsp.ClientConfig
- return {
- cmd = { 'basedpyright-langserver', '--stdio' },
- filetypes = { 'python' },
- root_markers = {
- 'pyproject.toml',
- 'setup.py',
- 'setup.cfg',
- 'requirements.txt',
- 'Pipfile',
- 'pyrightconfig.json',
- },
- single_file_support = true,
- settings = {
- basedpyright = {
- analysis = {
- typeCheckingMode = "standard",
- diagnosticMode = "openFilesOnly",
- autoSearchPaths = true,
- include = { "*" },
- exclude = { "**/node_modules", "**/__pycache__", "**/build" },
- useLibraryCodeForTypes = true,
- analyzeUnannotatedFunctions = true,
- reportUnreachable = true,
- },
- openFilesOnly = true,
- autoImportCompletions = true,
- disableOrganizeImports = true,
- }
- },
- on_init = function(client, _)
- local typecheckingPicker = function(opts)
- local pickers = require("telescope.pickers")
- local themes = require("telescope.themes")
- local actions = require("telescope.actions")
- local action_state = require("telescope.actions.state")
- local finders = require("telescope.finders")
- local conf = require("telescope.config").values
- local current = client.settings.basedpyright.analysis
- .typeCheckingMode
- if current == nil then current = "unset" end
- pickers.new(themes.get_dropdown({}), {
- prompt_title = "BasedPyright Typechecking (Current: " ..
- current .. ")",
- finder = finders.new_table({
- results = vim.tbl_filter(
- function(r) return r ~= current end,
- { "off", "basic", "standard", "strict", "all" }),
- }),
- sorter = conf.generic_sorter(opts),
- attach_mappings = function(prompt_bufnr, _)
- actions.select_default:replace(function()
- actions.close(prompt_bufnr)
- local selection = action_state
- .get_selected_entry()
- client.settings.basedpyright.analysis.typeCheckingMode =
- selection.value
- client:notify(
- "workspace/didChangeConfiguration",
- client.settings)
- end)
- return true
- end,
- }):find()
- end
- if pcall(require, "command-palette") and pcall(require, "telescope.pickers") then
- require("command-palette").add({ {
- "BasedPyright Typechecking",
- "Set `typeCheckingMode` of BasedPyright",
- typecheckingPicker }
- })
- end
- end,
- }
|