mirror of
https://github.com/d0zingcat/dotfiles.git
synced 2026-05-14 15:09:44 +00:00
- 架构重构:新增 plugins/lang/ 子目录,按语言拆分配置 - 补全引擎:nvim-cmp → blink.cmp + LuaSnip - 文件浏览:新增 neo-tree(<Space>e) - 语言支持: - Go: ray-x/go.nvim + dap-go + neotest-go - Rust: rustaceanvim + crates.nvim - Python: venv-selector + dap-python + neotest-python - TypeScript: typescript-tools.nvim(替换 ts_ls) - LSP: lazydev + mason + mason-lspconfig + fidget + inc-rename - 格式化: conform.nvim(lsp_format fallback,保存时自动格式化) - Lint: nvim-lint(selene 替换 luacheck,Mason 可直接安装) - UI: snacks.nvim(dashboard+notifier+picker)+ noice + lualine + bufferline - 编辑增强: mini.ai + mini.surround + grug-far + flash + ufo + trouble v3 - 删除废弃文件: cmp/coding/null-ls/mason/lspconfig/go/python 等旧文件 - 修复: Neovim 0.12 treesitter query 校验报错(noice routes 过滤) - 新增: NVIM_GUIDE.md 快捷键使用手册 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
96 lines
3.3 KiB
Lua
96 lines
3.3 KiB
Lua
-- lang/python.lua - Python 开发专用配置
|
|
|
|
return {
|
|
-- 虚拟环境选择器
|
|
{
|
|
"linux-cultist/venv-selector.nvim",
|
|
branch = "regexp",
|
|
cmd = "VenvSelect",
|
|
ft = "python",
|
|
dependencies = { "neovim/nvim-lspconfig", "nvim-telescope/telescope.nvim" },
|
|
opts = {
|
|
settings = {
|
|
options = {
|
|
notify_user_on_venv_activation = true,
|
|
},
|
|
},
|
|
},
|
|
keys = {
|
|
{ "<leader>pv", "<cmd>VenvSelect<cr>", ft = "python", desc = "选择虚拟环境" },
|
|
},
|
|
},
|
|
|
|
-- Python DAP 支持
|
|
{
|
|
"mfussenegger/nvim-dap-python",
|
|
ft = "python",
|
|
dependencies = { "mfussenegger/nvim-dap" },
|
|
config = function()
|
|
local ok, mason_registry = pcall(require, "mason-registry")
|
|
local python_path = "python3"
|
|
if ok and mason_registry.is_installed("debugpy") then
|
|
python_path = mason_registry.get_package("debugpy"):get_install_path() .. "/venv/bin/python"
|
|
end
|
|
require("dap-python").setup(python_path)
|
|
require("dap-python").test_runner = "pytest"
|
|
|
|
-- 带参数启动
|
|
table.insert(require("dap").configurations.python, {
|
|
type = "python", request = "launch",
|
|
name = "带参数启动",
|
|
program = "${file}",
|
|
args = function()
|
|
return vim.split(vim.fn.input("命令行参数: "), " ")
|
|
end,
|
|
console = "integratedTerminal",
|
|
})
|
|
end,
|
|
keys = {
|
|
{ "<leader>dpm", function() require("dap-python").test_method() end, ft = "python", desc = "调试当前方法" },
|
|
{ "<leader>dpc", function() require("dap-python").test_class() end, ft = "python", desc = "调试当前类" },
|
|
},
|
|
},
|
|
|
|
-- neotest Python 适配器
|
|
{
|
|
"nvim-neotest/neotest",
|
|
optional = true,
|
|
dependencies = { "nvim-neotest/neotest-python" },
|
|
opts = function(_, opts)
|
|
opts.adapters = opts.adapters or {}
|
|
table.insert(opts.adapters, require("neotest-python")({
|
|
runner = "pytest",
|
|
args = { "--color=yes", "-v" },
|
|
python = function()
|
|
if vim.env.VIRTUAL_ENV then
|
|
return vim.env.VIRTUAL_ENV .. "/bin/python"
|
|
end
|
|
return "python3"
|
|
end,
|
|
}))
|
|
return opts
|
|
end,
|
|
keys = {
|
|
{ "<leader>pt", function() require("neotest").run.run() end, ft = "python", desc = "运行最近测试" },
|
|
{ "<leader>pT", function() require("neotest").run.run(vim.fn.expand("%")) end, ft = "python", desc = "运行文件测试" },
|
|
{ "<leader>pd", function() require("neotest").run.run({ strategy = "dap" }) end, ft = "python", desc = "调试测试" },
|
|
{ "<leader>ps", function() require("neotest").run.stop() end, ft = "python", desc = "停止测试" },
|
|
{ "<leader>po", function() require("neotest").output.open() end, ft = "python", desc = "测试输出" },
|
|
{ "<leader>pO", function() require("neotest").output_panel.toggle() end, ft = "python", desc = "输出面板" },
|
|
{ "<leader>pS", function() require("neotest").summary.toggle() end, ft = "python", desc = "摘要窗口" },
|
|
},
|
|
},
|
|
|
|
-- Mason Python 工具
|
|
{
|
|
"williamboman/mason.nvim",
|
|
optional = true,
|
|
opts = function(_, opts)
|
|
opts.ensure_installed = opts.ensure_installed or {}
|
|
vim.list_extend(opts.ensure_installed, {
|
|
"pyright", "ruff", "isort", "debugpy",
|
|
})
|
|
end,
|
|
},
|
|
}
|