]> git.rmz.io Git - dotfiles.git/blob - nvim/lua/plugins/lang/python.lua
09ee671ab8249e474acb4fe06cf090a642100c2c
[dotfiles.git] / nvim / lua / plugins / lang / python.lua
1 return {
2 { "nvim-treesitter/nvim-treesitter",
3 opts = { ensure_installed = { "ninja", "rst" } },
4 },
5 { "neovim/nvim-lspconfig",
6 opts = {
7 servers = {
8 ruff = {
9 cmd_env = { RUFF_TRACE = "messages" },
10 init_options = {
11 settings = {
12 logLevel = "error",
13 },
14 },
15 keys = {
16 {
17 "<leader>co",
18 rmz.lsp.action["source.organizeImports"],
19 desc = "Organize Imports",
20 },
21 },
22 },
23 },
24 setup = {
25 ["ruff"] = function()
26 rmz.lsp.on_attach(function(client, _)
27 -- Disable hover in favor of Pyright
28 client.server_capabilities.hoverProvider = false
29 end, "ruff")
30 end,
31 },
32 },
33 },
34 {
35 "neovim/nvim-lspconfig",
36 opts = function(_, opts)
37 local servers = { "pyright", "ruff"}
38 for _, server in ipairs(servers) do
39 opts.servers[server] = opts.servers[server] or {}
40 opts.servers[server].enabled = server == lsp or server == ruff
41 end
42 end,
43 },
44 {
45 "nvim-neotest/neotest",
46 dependencies = {
47 "nvim-neotest/neotest-python",
48 },
49 opts = {
50 adapters = {
51 ["neotest-python"] = {
52 dap = { justMyCode = false }},
53 },
54 },
55 },
56 {
57 "mfussenegger/nvim-dap",
58 dependencies = {
59 "mfussenegger/nvim-dap-python",
60 keys = {
61 { "<leader>dPt", function() require('dap-python').test_method() end, desc = "Debug Method", ft = "python" },
62 { "<leader>dPc", function() require('dap-python').test_class() end, desc = "Debug Class", ft = "python" },
63 },
64 config = function()
65 local path = require("mason-registry").get_package("debugpy"):get_install_path()
66 require("dap-python").setup(path .. "/venv/bin/python")
67 end,
68 },
69 },
70 { "jay-babu/mason-nvim-dap.nvim",
71 opts = {
72 handlers = {
73 python = function() end,
74 },
75 ensure_installed = { "python" },
76 },
77 },
78 { "linux-cultist/venv-selector.nvim", enabled = false,
79 -- TODO needs fd to be installed (I don't know what that is)
80 branch = "regexp", -- Use this branch for the new version
81 cmd = "VenvSelect",
82 opts = {
83 settings = {
84 options = {
85 notify_user_on_venv_activation = true,
86 },
87 },
88 },
89 -- Call config for python files and load the cached venv automatically
90 ft = "python",
91 keys = { { "<leader>cv", "<cmd>:VenvSelect<cr>", desc = "Select VirtualEnv", ft = "python" } },
92 },
93 { "hrsh7th/nvim-cmp",
94 optional = true,
95 opts = function(_, opts)
96 opts.auto_brackets = opts.auto_brackets or {}
97 table.insert(opts.auto_brackets, "python")
98 end,
99 },
100 }