updated python configs

This commit is contained in:
Daveanand Mannie
2024-08-26 01:06:52 -04:00
parent e5dc5faaeb
commit c066a50450
3 changed files with 104 additions and 10 deletions

View File

@@ -1,7 +1,8 @@
[tool.ruff.lint] # need to add to ~/appdata/Roaming/ruff/ruff.toml
select = [ select = [
# pycodestyle # pycodestyle
"E", "E",
"W",
# Pyflakes # Pyflakes
"F", "F",
# pyupgrade # pyupgrade
@@ -12,3 +13,81 @@ select = [
"SIM", "SIM",
# isort # isort
"I", "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"

View File

@@ -4,17 +4,17 @@ return {
local lint = require("lint") local lint = require("lint")
lint.linters_by_ft = { 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" }, { -- vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
group = lint_augroup, -- group = lint_augroup,
callback = function() -- callback = function()
lint.try_lint() -- lint.try_lint()
end, -- end,
}) -- })
vim.keymap.set("n", "<leader>l", function() vim.keymap.set("n", "<leader>l", function()
lint.try_lint() lint.try_lint()

View File

@@ -8,6 +8,21 @@ return {
opts = { opts = {
inlay_hints = { enabled = false }, inlay_hints = { enabled = false },
servers = { servers = {
ruff = {
cmd_env = { RUFF_TRACE = "messages" },
init_options = {
settings = {
logLevel = "error",
},
},
keys = {
{
"<leader>co",
LazyVim.lsp.action["source.organizeImports"],
desc = "Organize Imports",
},
},
},
basedpyright = { basedpyright = {
cmd_env = { RUFF_TRACE = "messages" }, cmd_env = { RUFF_TRACE = "messages" },
init_options = { init_options = {
@@ -29,7 +44,7 @@ return {
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
opts = function(_, opts) opts = function(_, opts)
local servers = { "basedpyright", "ruff" } local servers = { "basedpyright" }
for _, server in ipairs(servers) do for _, server in ipairs(servers) do
opts.servers[server] = opts.servers[server] or {} opts.servers[server] = opts.servers[server] or {}
opts.servers[server].enabled = server == "basedpyright" opts.servers[server].enabled = server == "basedpyright"