mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
feat(python): support basedpyright as another option
This commit is contained in:
parent
1432f318b6
commit
68ec955374
1 changed files with 95 additions and 0 deletions
95
lua/lazyvim/plugins/extras/lang/based-python.lua
Normal file
95
lua/lazyvim/plugins/extras/lang/based-python.lua
Normal file
|
|
@ -0,0 +1,95 @@
|
||||||
|
return {
|
||||||
|
{
|
||||||
|
"nvim-treesitter/nvim-treesitter",
|
||||||
|
opts = function(_, opts)
|
||||||
|
if type(opts.ensure_installed) == "table" then
|
||||||
|
vim.list_extend(opts.ensure_installed, { "ninja", "python", "rst", "toml" })
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"neovim/nvim-lspconfig",
|
||||||
|
opts = {
|
||||||
|
servers = {
|
||||||
|
basedpyright = {},
|
||||||
|
ruff_lsp = {
|
||||||
|
keys = {
|
||||||
|
{
|
||||||
|
"<leader>co",
|
||||||
|
function()
|
||||||
|
vim.lsp.buf.code_action({
|
||||||
|
apply = true,
|
||||||
|
context = {
|
||||||
|
only = { "source.organizeImports" },
|
||||||
|
diagnostics = {},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
desc = "Organize Imports",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
setup = {
|
||||||
|
ruff_lsp = function()
|
||||||
|
require("lazyvim.util").lsp.on_attach(function(client, _)
|
||||||
|
if client.name == "ruff_lsp" then
|
||||||
|
-- Disable hover in favor of Pyright
|
||||||
|
client.server_capabilities.hoverProvider = false
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"nvim-neotest/neotest",
|
||||||
|
optional = true,
|
||||||
|
dependencies = {
|
||||||
|
"nvim-neotest/neotest-python",
|
||||||
|
},
|
||||||
|
opts = {
|
||||||
|
adapters = {
|
||||||
|
["neotest-python"] = {
|
||||||
|
-- Here you can specify the settings for the adapter, i.e.
|
||||||
|
-- runner = "pytest",
|
||||||
|
-- python = ".venv/bin/python",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"mfussenegger/nvim-dap",
|
||||||
|
optional = true,
|
||||||
|
dependencies = {
|
||||||
|
"mfussenegger/nvim-dap-python",
|
||||||
|
-- stylua: ignore
|
||||||
|
keys = {
|
||||||
|
{ "<leader>dPt", function() require('dap-python').test_method() end, desc = "Debug Method", ft = "python" },
|
||||||
|
{ "<leader>dPc", function() require('dap-python').test_class() end, desc = "Debug Class", ft = "python" },
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
local path = require("mason-registry").get_package("debugpy"):get_install_path()
|
||||||
|
require("dap-python").setup(path .. "/venv/bin/python")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"linux-cultist/venv-selector.nvim",
|
||||||
|
cmd = "VenvSelect",
|
||||||
|
opts = function(_, opts)
|
||||||
|
if require("lazyvim.util").has("nvim-dap-python") then
|
||||||
|
opts.dap_enabled = true
|
||||||
|
end
|
||||||
|
return vim.tbl_deep_extend("force", opts, {
|
||||||
|
name = {
|
||||||
|
"venv",
|
||||||
|
".venv",
|
||||||
|
"env",
|
||||||
|
".env",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
keys = { { "<leader>cv", "<cmd>:VenvSelect<cr>", desc = "Select VirtualEnv" } },
|
||||||
|
},
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue