Updgraded python linters and formatters. Changed zoo of them to one ruff

This commit is contained in:
pro100ton 2024-11-22 20:56:36 +03:00
parent 22e0121ba7
commit b05e831bd2
3 changed files with 116 additions and 99 deletions

View file

@ -18,6 +18,32 @@ return {
-- import cmp-nvim-lsp plugin
local cmp_nvim_lsp = require("cmp_nvim_lsp")
-- Ruff setup
lspconfig.ruff.setup({
init_options = {
settings = {
-- Ruff language server settings go here
logLevel = "debug",
},
},
})
-- Pyright setup
lspconfig.pyright.setup({
settings = {
pyright = {
-- Using Ruff's import organizer
disableOrganizeImports = true,
},
python = {
analysis = {
-- Ignore all files for analysis to exclusively use Ruff for linting
ignore = { "*" },
},
},
},
})
local keymap = vim.keymap -- for conciseness
-- nvim_create_autocmd - used to execute some logic automaticaly on a specific event
@ -72,7 +98,9 @@ return {
keymap.set("n", "<leader>rs", ":LspRestart<CR>", opts) -- mapping to restart lsp if necessary
opts.desc = "Run formatting on current buffer"
keymap.set('n', '<space>f', function() vim.lsp.buf.format { async = true } end, opts)
keymap.set("n", "<space>f", function()
vim.lsp.buf.format({ async = true })
end, opts)
end,
})
@ -106,4 +134,3 @@ return {
})
end,
}

View file

@ -40,17 +40,10 @@ return {
"goimports-reviser",
"prettier", -- prettier formatter
"stylua", -- lua formatter
"isort", -- python formatter
"black", -- python formatter
"ruff", -- Python formatter and linter
"gofumpt",
"pylint",
"flake8",
-- Astra settings for 3.7 Python
-- { "isort", version = "5.11.5" }, -- python formatter
-- { "black", version = "23.3.0" }, -- python formatter
-- { "pylint", version = "2.9.0" },
-- { "pylint", version = "2.9.0" },
-- { "flake8", version = "4.0.1" },
-- NOTE: On Astra you need to install Ruff as standalone package
"eslint_d",
},
})

View file

@ -8,13 +8,10 @@ return {
null_ls.setup({
sources = {
null_ls.builtins.formatting.black,
null_ls.builtins.formatting.isort,
null_ls.builtins.formatting.gofumpt,
null_ls.builtins.formatting.goimports_reviser,
null_ls.builtins.formatting.stylua,
null_ls.builtins.formatting.golines,
require("none-ls.diagnostics.flake8"),
},
})
end,