This repository has been archived by the owner on Nov 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathpyright.lua
82 lines (78 loc) · 3.05 KB
/
pyright.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
-- https://github.com/microsoft/pyright
local util = require("lspconfig.util")
local aid_nvim_lsputils = require("utils.aid.nvim-lsputils")
local root_files = {
"pyproject.toml",
"setup.py",
"setup.cfg",
"requirements.txt",
"Pipfile",
"pyrightconfig.json",
-- customize
"manage.py",
"server.py",
"main.py",
}
local ignore_diagnostic_message = {
'"e" is not accessed',
'Variable "e" is not accessed',
'"i" is not accessed',
'Variable "i" is not accessed',
'"j" is not accessed',
'Variable "j" is not accessed',
}
return {
filetypes = { "python" },
single_file_support = true,
cmd = { "pyright-langserver", "--stdio" },
---@diagnostic disable-next-line: deprecated
root_dir = util.root_pattern(unpack(root_files)),
handlers = {
-- If you want to disable pyright's diagnostic prompt, open the code below
-- ["textDocument/publishDiagnostics"] = function(...) end,
-- If you want to disable pyright from diagnosing unused parameters, open the function below
["textDocument/publishDiagnostics"] = vim.lsp.with(aid_nvim_lsputils.filter_publish_diagnostics, {
ignore_diagnostic_level = {},
ignore_diagnostic_message = ignore_diagnostic_message,
}),
},
---@diagnostic disable-next-line: unused-local
on_attach = function(client, bufnr)
-- aid_nvim_lsputils.did_change_configuration(client)
vim.api.nvim_buf_create_user_command(bufnr, "LspChange", function()
client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
end, {
desc = "send didChangeConfiguration to Langserver",
})
end,
settings = {
python = {
analysis = {
typeCheckingMode = "basic", -- off, basic, strict
autoSearchPaths = true,
useLibraryCodeForTypes = true,
autoImportCompletions = true,
diagnosticMode = "workspace",
-- https://github.com/microsoft/pyright/blob/main/docs/configuration.md#type-check-diagnostics-settings
diagnosticSeverityOverrides = {
strictListInference = true,
strictDictionaryInference = true,
strictSetInference = true,
reportUnusedImport = "warning",
reportUnusedClass = "warning",
reportUnusedFunction = "warning",
reportUnusedVariable = "warning",
reportUnusedCoroutine = "warning",
reportDuplicateImport = "warning",
reportPrivateUsage = "warning",
reportUnusedExpression = "warning",
reportConstantRedefinition = "error",
reportIncompatibleMethodOverride = "error",
reportMissingImports = "error",
reportUndefinedVariable = "error",
reportAssertAlwaysTrue = "error",
},
},
},
},
}