-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpython.lua
More file actions
84 lines (82 loc) · 2.18 KB
/
python.lua
File metadata and controls
84 lines (82 loc) · 2.18 KB
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
83
84
local generator = require("plugins.extras.langspec"):new()
---@type LangConfig
local conf = {
ft = "python",
parsers = { -- nvim-treesitter: language parsers
"python",
},
cmdtools = { -- mason.nvim: cmdline tools for LSP servers, DAP servers, formatters and linters
-- "ty",
"basedpyright",
-- "pyright",
-- "mypy",
"ruff",
"debugpy",
},
lsp = {
servers = {
basedpyright = {
settings = {
python = {
analysis = {
autoImportCompletions = true,
typeCheckingMode = "basic", -- strict
autoSearchPaths = true,
useLibraryCodeForTypes = true,
diagnosticMode = "workspace", -- openFilesOnly
},
},
},
},
-- ty 默认支持自动导入和库代码类型解析,无需手动开启
-- ty = { -- type checker
-- diagnosticMode = "workspace",
-- },
ruff = { -- linter
init_options = {
settings = {
args = { "--max-line-length=140" },
},
},
keys = {
{ "<leader>ci", U.lsp.action["source.organizeImports"], desc = "Organize Imports" },
},
},
},
},
formatters = { -- conform.nvim
-- To fix auto-fixable lint errors.
"ruff_fix",
-- To run the Ruff formatter.
"ruff_format",
-- To organize the imports.
"ruff_organize_imports",
},
linters = { -- nvim-lint
-- "mypy",
},
dap = { -- nvim-dap: language specific extensions
{
"mfussenegger/nvim-dap-python",
config = function()
-- https://github.com/mfussenegger/nvim-dap-python#usage
require("dap-python").setup("uv")
end,
},
},
test = { -- neotest: language specific adapters
"nvim-neotest/neotest-python",
adapters = {
-- https://github.com/nvim-neotest/neotest-python/blob/master/lua/neotest-python/init.lua#L72
-- match_root_pattern: touch pyproject.toml in project root directory
--
-- ├── foo_test.py
-- └── pyproject.toml
--
["neotest-python"] = {
dap = { justMyCode = false },
},
},
},
}
return generator:generate(conf)