]> git.rmz.io Git - dotfiles.git/blobdiff - nvim/lua/plugins/lang/python.lua
nvim: remove unnecessary python lsp server config
[dotfiles.git] / nvim / lua / plugins / lang / python.lua
index 537d0325a69a260600cdfec5abb7a353ecf400ab..ab0ad79c870167c58ceb0390e8bb819e206c4997 100644 (file)
@@ -1,44 +1,32 @@
 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,
+  { "nvim-treesitter/nvim-treesitter",
+    opts = { ensure_installed = { "ninja", "rst" } },
   },
-  {
-    "neovim/nvim-lspconfig",
+  { "neovim/nvim-lspconfig",
     opts = {
-      ---@type lspconfig.options
       servers = {
-        pyright = {},
-        ruff_lsp = {
+        ruff = {
+          cmd_env = { RUFF_TRACE = "messages" },
+          init_options = {
+            settings = {
+              logLevel = "error",
+            },
+          },
           keys = {
             {
               "<leader>co",
-              function()
-                vim.lsp.buf.code_action({
-                  apply = true,
-                  context = {
-                    only = { "source.organizeImports" },
-                    diagnostics = {},
-                  },
-                })
-              end,
+              rmz.lsp.action["source.organizeImports"],
               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)
+        ["ruff"] = function()
+          rmz.lsp.on_attach(function(client, _)
+            -- Disable hover in favor of Pyright
+            client.server_capabilities.hoverProvider = false
+          end, "ruff")
         end,
       },
     },
@@ -50,7 +38,8 @@ return {
     },
     opts = {
       adapters = {
-        ["neotest-python"] = { },
+        ["neotest-python"] = {
+          dap = { justMyCode = false }},
       },
     },
   },
@@ -58,7 +47,6 @@ return {
     "mfussenegger/nvim-dap",
     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" },
@@ -69,22 +57,34 @@ return {
       end,
     },
   },
-  {
-    "linux-cultist/venv-selector.nvim",
+  { "jay-babu/mason-nvim-dap.nvim",
+    opts = {
+      handlers = {
+        python = function() end,
+      },
+      ensure_installed = { "python" },
+    },
+  },
+  { "linux-cultist/venv-selector.nvim", enabled = false,
+    -- TODO needs fd to be installed (I don't know what that is)
+    branch = "regexp", -- Use this branch for the new version
     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",
+    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",
+    optional = true,
+    opts = function(_, opts)
+      opts.auto_brackets = opts.auto_brackets or {}
+      table.insert(opts.auto_brackets, "python")
     end,
-    keys = { { "<leader>cv", "<cmd>:VenvSelect<cr>", desc = "Select VirtualEnv" } },
   },
 }