-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpython.lua
69 lines (67 loc) · 1.75 KB
/
python.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
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
"pyright",
"black",
"ruff",
"debugpy",
},
lsp = {
servers = {
pyright = {
settings = {
python = {
analysis = {
autoImportCompletions = true,
typeCheckingMode = "off",
autoSearchPaths = true,
useLibraryCodeForTypes = true,
diagnosticMode = "workspace", -- "openFilesOnly",
},
},
},
},
ruff = { -- linter
init_options = {
settings = {
args = { "--max-line-length=180" },
},
},
keys = {
{ "<leader>cI", U.lsp.action["source.organizeImports"], desc = "Organize Imports" },
},
},
},
},
formatters = { -- conform.nvim
"black",
},
dap = { -- nvim-dap: language specific extensions
{
"mfussenegger/nvim-dap-python",
config = function()
require("dap-python").setup("~/.local/share/nvim/mason/packages/debugpy/venv/bin/python")
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)