From e5dc5faaebe941ae1f0f0595f5aa99ae4747fbe5 Mon Sep 17 00:00:00 2001 From: Daveanand Mannie Date: Mon, 26 Aug 2024 00:03:29 -0400 Subject: [PATCH] 80percent working state python --- .ruff.toml | 14 ++++++ lazy-lock.json | 2 +- lazyvim.json | 3 +- lua/plugins/linting.lua | 7 +-- lua/plugins/lsp.lua | 40 --------------- lua/plugins/python.lua | 106 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 123 insertions(+), 49 deletions(-) create mode 100644 .ruff.toml delete mode 100644 lua/plugins/lsp.lua create mode 100644 lua/plugins/python.lua diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 0000000..fb4589f --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,14 @@ +[tool.ruff.lint] +select = [ + # pycodestyle + "E", + # Pyflakes + "F", + # pyupgrade + "UP", + # flake8-bugbear + "B", + # flake8-simplify + "SIM", + # isort + "I", diff --git a/lazy-lock.json b/lazy-lock.json index 91a96bb..1d75c91 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -33,7 +33,7 @@ "nvim-lspconfig": { "branch": "master", "commit": "911167921d49cd5c1c9b2436031d0da3945e787f" }, "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, "nvim-snippets": { "branch": "main", "commit": "56b4052f71220144689caaa2e5b66222ba5661eb" }, - "nvim-treesitter": { "branch": "master", "commit": "bef7ec6f7a01ba0717da73082e33c224bdc2ddcc" }, + "nvim-treesitter": { "branch": "master", "commit": "397982d197768ebdefc0e2db396d95c4d371ca86" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "41e3abf6bfd9a9a681eb1f788bdeba91c9004b2b" }, "nvim-ts-autotag": { "branch": "main", "commit": "0cb76eea80e9c73b88880f0ca78fbd04c5bdcac7" }, "nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" }, diff --git a/lazyvim.json b/lazyvim.json index 4389a42..59c71b8 100644 --- a/lazyvim.json +++ b/lazyvim.json @@ -1,8 +1,7 @@ { "extras": [ "lazyvim.plugins.extras.lang.json", - "lazyvim.plugins.extras.lang.markdown", - "lazyvim.plugins.extras.lang.python" + "lazyvim.plugins.extras.lang.markdown" ], "news": { "NEWS.md": "6520" diff --git a/lua/plugins/linting.lua b/lua/plugins/linting.lua index 0fb5024..e05c9ab 100644 --- a/lua/plugins/linting.lua +++ b/lua/plugins/linting.lua @@ -1,14 +1,10 @@ return { "mfussenegger/nvim-lint", - event = { - "BufReadPre", - "BufNewFile", - }, config = function() local lint = require("lint") lint.linters_by_ft = { - python = { "flake8" }, + python = { "ruff" }, } local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) @@ -24,5 +20,4 @@ return { lint.try_lint() end, { desc = "Trigger linting for current file" }) end, - } diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua deleted file mode 100644 index f66da3f..0000000 --- a/lua/plugins/lsp.lua +++ /dev/null @@ -1,40 +0,0 @@ -return { - "williamboman/mason-lspconfig.nvim", - config = function() - require("mason-lspconfig").setup({ - -- Configure which LSP servers to automatically install - ensure_installed = { - "basedpyright", - "flake8", - "json-lsp", - "lua-language-server", - "marksman", - "ruff", - "shfmt", - "sylua" - }, - }) - - local lspconfig = require("lspconfig") - - -- Disable inlay hints for basedpyright - lspconfig.basedpyright.setup({ - settings = { - python = { - analysis = { - inlayHints = { - enabled = false - } - } - } - } - }) - end, ---- idk but this fixed it lol -{ - "neovim/nvim-lspconfig", - opts = { - inlay_hints = { enabled = false }, - }, -} -} diff --git a/lua/plugins/python.lua b/lua/plugins/python.lua new file mode 100644 index 0000000..6ba4e66 --- /dev/null +++ b/lua/plugins/python.lua @@ -0,0 +1,106 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + opts = { ensure_installed = { "ninja", "rst" } }, + }, + { + "neovim/nvim-lspconfig", + opts = { + inlay_hints = { enabled = false }, + servers = { + basedpyright = { + cmd_env = { RUFF_TRACE = "messages" }, + init_options = { + settings = { + logLevel = "error", + }, + }, + }, + }, + setup = { + basedpyright = function() + LazyVim.lsp.on_attach(function(client, _) + client.server_capabilities.hoverProvider = true + end, "basedpyright") + end, + }, + }, + }, + { + "neovim/nvim-lspconfig", + opts = function(_, opts) + local servers = { "basedpyright", "ruff" } + for _, server in ipairs(servers) do + opts.servers[server] = opts.servers[server] or {} + opts.servers[server].enabled = server == "basedpyright" + end + end, + }, + { + "nvim-neotest/neotest", + optional = true, + dependencies = { + "nvim-neotest/neotest-python", + }, + opts = { + adapters = { + ["neotest-python"] = { + -- Example settings for the adapter + -- runner = "pytest", + -- python = ".venv/bin/python", + }, + }, + }, + }, + { + "mfussenegger/nvim-dap", + optional = true, + dependencies = { + "mfussenegger/nvim-dap-python", + }, + 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" }, + }, + config = function() + if vim.fn.has("win32") == 1 then + require("dap-python").setup(LazyVim.get_pkg_path("debugpy", "/venv/Scripts/pythonw.exe")) + else + require("dap-python").setup(LazyVim.get_pkg_path("debugpy", "/venv/bin/python")) + end + end, + }, + { + "linux-cultist/venv-selector.nvim", + branch = "regexp", + cmd = "VenvSelect", + enabled = function() + return LazyVim.has("telescope.nvim") + end, + opts = { + settings = { + options = { + notify_user_on_venv_activation = true, + }, + }, + }, + ft = "python", + keys = { { "cv", ":VenvSelect", 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, + }, + { + "jay-babu/mason-nvim-dap.nvim", + optional = true, + opts = { + handlers = { + python = function() end, -- Avoid messing up DAP adapters provided by nvim-dap-python + }, + }, + }, +}