]> git.rmz.io Git - dotfiles.git/blob - nvim/lua/plugins/lang/python.lua
nvim: get python lang from lazyvim
[dotfiles.git] / nvim / lua / plugins / lang / python.lua
1 return {
2 {
3 "nvim-treesitter/nvim-treesitter",
4 opts = function(_, opts)
5 if type(opts.ensure_installed) == "table" then
6 vim.list_extend(opts.ensure_installed, { "ninja", "python", "rst", "toml" })
7 end
8 end,
9 },
10 {
11 "neovim/nvim-lspconfig",
12 opts = {
13 ---@type lspconfig.options
14 servers = {
15 pyright = {},
16 ruff_lsp = {
17 keys = {
18 {
19 "<leader>co",
20 function()
21 vim.lsp.buf.code_action({
22 apply = true,
23 context = {
24 only = { "source.organizeImports" },
25 diagnostics = {},
26 },
27 })
28 end,
29 desc = "Organize Imports",
30 },
31 },
32 },
33 },
34 setup = {
35 ruff_lsp = function()
36 require("lazyvim.util").lsp.on_attach(function(client, _)
37 if client.name == "ruff_lsp" then
38 -- Disable hover in favor of Pyright
39 client.server_capabilities.hoverProvider = false
40 end
41 end)
42 end,
43 },
44 },
45 },
46 {
47 "nvim-neotest/neotest",
48 dependencies = {
49 "nvim-neotest/neotest-python",
50 },
51 opts = {
52 adapters = {
53 ["neotest-python"] = { },
54 },
55 },
56 },
57 {
58 "mfussenegger/nvim-dap",
59 dependencies = {
60 "mfussenegger/nvim-dap-python",
61 -- stylua: ignore
62 keys = {
63 { "<leader>dPt", function() require('dap-python').test_method() end, desc = "Debug Method", ft = "python" },
64 { "<leader>dPc", function() require('dap-python').test_class() end, desc = "Debug Class", ft = "python" },
65 },
66 config = function()
67 local path = require("mason-registry").get_package("debugpy"):get_install_path()
68 require("dap-python").setup(path .. "/venv/bin/python")
69 end,
70 },
71 },
72 {
73 "linux-cultist/venv-selector.nvim",
74 cmd = "VenvSelect",
75 opts = function(_, opts)
76 if require("lazyvim.util").has("nvim-dap-python") then
77 opts.dap_enabled = true
78 end
79 return vim.tbl_deep_extend("force", opts, {
80 name = {
81 "venv",
82 ".venv",
83 "env",
84 ".env",
85 },
86 })
87 end,
88 keys = { { "<leader>cv", "<cmd>:VenvSelect<cr>", desc = "Select VirtualEnv" } },
89 },
90 }