From c066a50450f15be9ec64359f469fd7eac9dc894d Mon Sep 17 00:00:00 2001 From: Daveanand Mannie Date: Mon, 26 Aug 2024 01:06:52 -0400 Subject: [PATCH] updated python configs --- .ruff.toml | 81 ++++++++++++++++++++++++++++++++++++++++- lua/plugins/linting.lua | 16 ++++---- lua/plugins/python.lua | 17 ++++++++- 3 files changed, 104 insertions(+), 10 deletions(-) diff --git a/.ruff.toml b/.ruff.toml index fb4589f..e3b46a4 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -1,7 +1,8 @@ -[tool.ruff.lint] +# need to add to ~/appdata/Roaming/ruff/ruff.toml select = [ # pycodestyle "E", + "W", # Pyflakes "F", # pyupgrade @@ -12,3 +13,81 @@ select = [ "SIM", # isort "I", + # pep8-naming + "N", + # pycodestyle + # "D", + # "TD", +] +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".ipynb_checkpoints", + ".mypy_cache", + ".nox", + ".pants.d", + ".pyenv", + ".pytest_cache", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + ".vscode", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "site-packages", + "venv", +] + +# Same as Black. +line-length = 79 +indent-width = 4 + +# Assume Python 3.8 + +[lint] +# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. +# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or +# McCabe complexity (`C901`) by default. +select = [ + # pycodestyle + "E", + "W", + # Pyflakes + "F", + # pyupgrade + "UP", + # flake8-bugbear + "B", + # flake8-simplify + "SIM", + # isort + "I", + # pep8-naming + "N", + # pycodestyle + # "D", + # "TD", +] +ignore = [ + "N812" +] + +# Allow fix for all enabled rules (when `--fix`) is provided. +fixable = ["ALL"] +unfixable = [] + +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" +[format] +quote-style = "single" diff --git a/lua/plugins/linting.lua b/lua/plugins/linting.lua index e05c9ab..269f0c4 100644 --- a/lua/plugins/linting.lua +++ b/lua/plugins/linting.lua @@ -4,17 +4,17 @@ return { local lint = require("lint") lint.linters_by_ft = { - python = { "ruff" }, + python = { "flake8" }, } - local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) + -- local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) - vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { - group = lint_augroup, - callback = function() - lint.try_lint() - end, - }) + -- vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { + -- group = lint_augroup, + -- callback = function() + -- lint.try_lint() + -- end, + -- }) vim.keymap.set("n", "l", function() lint.try_lint() diff --git a/lua/plugins/python.lua b/lua/plugins/python.lua index 6ba4e66..0245c23 100644 --- a/lua/plugins/python.lua +++ b/lua/plugins/python.lua @@ -8,6 +8,21 @@ return { opts = { inlay_hints = { enabled = false }, servers = { + ruff = { + cmd_env = { RUFF_TRACE = "messages" }, + init_options = { + settings = { + logLevel = "error", + }, + }, + keys = { + { + "co", + LazyVim.lsp.action["source.organizeImports"], + desc = "Organize Imports", + }, + }, + }, basedpyright = { cmd_env = { RUFF_TRACE = "messages" }, init_options = { @@ -29,7 +44,7 @@ return { { "neovim/nvim-lspconfig", opts = function(_, opts) - local servers = { "basedpyright", "ruff" } + local servers = { "basedpyright" } for _, server in ipairs(servers) do opts.servers[server] = opts.servers[server] or {} opts.servers[server].enabled = server == "basedpyright"