mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-22 00:49:03 +02:00
It has eliminated many bugs and allows users to easily add their searches, if the plugin doesn't find them automatically.
135 lines
3.4 KiB
Lua
135 lines
3.4 KiB
Lua
if lazyvim_docs then
|
|
-- LSP Server to use for Python.
|
|
-- Set to "basedpyright" to use basedpyright instead of pyright.
|
|
vim.g.lazyvim_python_lsp = "pyright"
|
|
vim.g.lazyvim_python_ruff = "ruff_lsp"
|
|
end
|
|
|
|
local lsp = vim.g.lazyvim_python_lsp or "pyright"
|
|
local ruff = vim.g.lazyvim_python_ruff or "ruff_lsp"
|
|
|
|
return {
|
|
recommended = function()
|
|
return LazyVim.extras.wants({
|
|
ft = "python",
|
|
root = {
|
|
"pyproject.toml",
|
|
"setup.py",
|
|
"setup.cfg",
|
|
"requirements.txt",
|
|
"Pipfile",
|
|
"pyrightconfig.json",
|
|
},
|
|
})
|
|
end,
|
|
{
|
|
"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 = {
|
|
pyright = {
|
|
enabled = lsp == "pyright",
|
|
},
|
|
basedpyright = {
|
|
enabled = lsp == "basedpyright",
|
|
},
|
|
[lsp] = {
|
|
enabled = true,
|
|
},
|
|
ruff_lsp = {
|
|
enabled = ruff == "ruff_lsp",
|
|
},
|
|
ruff = {
|
|
enabled = ruff == "ruff",
|
|
},
|
|
[ruff] = {
|
|
keys = {
|
|
{
|
|
"<leader>co",
|
|
function()
|
|
vim.lsp.buf.code_action({
|
|
apply = true,
|
|
context = {
|
|
only = { "source.organizeImports" },
|
|
diagnostics = {},
|
|
},
|
|
})
|
|
end,
|
|
desc = "Organize Imports",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
setup = {
|
|
[ruff] = function()
|
|
LazyVim.lsp.on_attach(function(client, _)
|
|
if client.name == ruff 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()
|
|
require("dap-python").setup(LazyVim.get_pkg_path("debugpy", "/venv/bin/python"))
|
|
end,
|
|
},
|
|
},
|
|
{
|
|
"linux-cultist/venv-selector.nvim",
|
|
branch = "regexp", -- Use this branch for the new version
|
|
cmd = "VenvSelect",
|
|
opts = {
|
|
settings = {
|
|
options = {
|
|
notify_user_on_venv_activation = true,
|
|
},
|
|
},
|
|
},
|
|
-- Call config for python files and load the cached venv automatically
|
|
ft = "python",
|
|
keys = { { "<leader>cv", "<cmd>:VenvSelect<cr>", desc = "Select VirtualEnv", ft = "python" } },
|
|
},
|
|
{
|
|
"hrsh7th/nvim-cmp",
|
|
opts = function(_, opts)
|
|
opts.auto_brackets = opts.auto_brackets or {}
|
|
table.insert(opts.auto_brackets, "python")
|
|
end,
|
|
},
|
|
}
|