X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/f6f762b6ab4a27d8102a86fc7a700a233fb3bf61..55b39c6121082b3c8ecf1bab5085d11dfa299dd6:/nvim/lua/plugins/lang/python.lua diff --git a/nvim/lua/plugins/lang/python.lua b/nvim/lua/plugins/lang/python.lua index aee4474..ab0ad79 100644 --- a/nvim/lua/plugins/lang/python.lua +++ b/nvim/lua/plugins/lang/python.lua @@ -1,61 +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 = { - root_dir = function(fname) - return require("lspconfig.util").root_pattern("pyproject.toml", "setup.cfg", "ruff.toml")(fname) - end, + ruff = { + cmd_env = { RUFF_TRACE = "messages" }, + init_options = { + settings = { + logLevel = "error", + }, + }, keys = { { "co", - function() - vim.lsp.buf.code_action({ - apply = true, - context = { - only = { "source.organizeImports" }, - diagnostics = {}, - }, - }) - end, + rmz.lsp.action["source.organizeImports"], desc = "Organize Imports", }, }, }, - pylsp = { - settings = { - pylsp = { - plugins = { - autopep8 = { enabled = false }, - flake8 = { enabled = false }, - mccabe = { enabled = false }, - pycodestyle = { enabled = false }, - pydocstyle = { enabled = false }, - pyflakes = { enabled = false }, -- covered by flake8 - } - } - } - } }, 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, }, }, @@ -67,7 +38,8 @@ return { }, opts = { adapters = { - ["neotest-python"] = { }, + ["neotest-python"] = { + dap = { justMyCode = false }}, }, }, }, @@ -75,7 +47,6 @@ return { "mfussenegger/nvim-dap", dependencies = { "mfussenegger/nvim-dap-python", - -- stylua: ignore keys = { { "dPt", function() require('dap-python').test_method() end, desc = "Debug Method", ft = "python" }, { "dPc", function() require('dap-python').test_class() end, desc = "Debug Class", ft = "python" }, @@ -86,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 = { { "cv", ":VenvSelect", 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 = { { "cv", ":VenvSelect", desc = "Select VirtualEnv" } }, }, }