fix ruff/Ruff duplication
This commit is contained in:
parent
0685135ccf
commit
b56d703662
|
|
@ -33,3 +33,16 @@ map('n', 'K', function()
|
||||||
vim.cmd("normal! K")
|
vim.cmd("normal! K")
|
||||||
end
|
end
|
||||||
end, { desc = 'Hover/Help (LSP or keywordprg fallback)', silent = true })
|
end, { desc = 'Hover/Help (LSP or keywordprg fallback)', silent = true })
|
||||||
|
|
||||||
|
-- Diagnostic keymaps
|
||||||
|
map('n', '<leader>xx', vim.diagnostic.setloclist, { desc = 'Show buffer diagnostics in location list', silent = true })
|
||||||
|
map('n', '<leader>xX', vim.diagnostic.setqflist, { desc = 'Show all diagnostics in quickfix', silent = true })
|
||||||
|
map('n', '<leader>xe', function()
|
||||||
|
vim.diagnostic.setloclist({ severity = vim.diagnostic.severity.ERROR })
|
||||||
|
end, { desc = 'Show buffer errors in location list', silent = true })
|
||||||
|
map('n', '<leader>xE', function()
|
||||||
|
vim.diagnostic.setqflist({ severity = vim.diagnostic.severity.ERROR })
|
||||||
|
end, { desc = 'Show all errors in quickfix', silent = true })
|
||||||
|
map('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic', silent = true })
|
||||||
|
map('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic', silent = true })
|
||||||
|
map('n', '<leader>xd', vim.diagnostic.open_float, { desc = 'Show diagnostic under cursor', silent = true })
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,16 @@ return {
|
||||||
config = function()
|
config = function()
|
||||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||||
|
|
||||||
|
-- Disable ruff LSP entirely (we use ruff via nvim-lint + none-ls instead)
|
||||||
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
|
callback = function(args)
|
||||||
|
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||||
|
if client and client.name == "ruff" then
|
||||||
|
vim.lsp.stop_client(client.id)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
-- Load project-local LSP settings from .nvim.lua
|
-- Load project-local LSP settings from .nvim.lua
|
||||||
local function load_project_lsp_settings(server_name, root_dir)
|
local function load_project_lsp_settings(server_name, root_dir)
|
||||||
if not root_dir then
|
if not root_dir then
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,14 @@ return {
|
||||||
-- Formatters
|
-- Formatters
|
||||||
"prettier", -- JS, TS, CSS, JSON, Markdown, HTML
|
"prettier", -- JS, TS, CSS, JSON, Markdown, HTML
|
||||||
"stylua", -- Lua
|
"stylua", -- Lua
|
||||||
"black", -- Python
|
"ruff", -- Python (formatter + linter in one)
|
||||||
-- Note: phpcbf already installed globally
|
-- Note: phpcbf already installed globally
|
||||||
|
|
||||||
-- Linters
|
-- Linters
|
||||||
"eslint_d", -- JS, TS (daemon version for speed)
|
"eslint_d", -- JS, TS (daemon version for speed)
|
||||||
"markdownlint", -- Markdown
|
"markdownlint", -- Markdown
|
||||||
"ruff", -- Python (fast linter + import sorter)
|
|
||||||
-- Note: phpcs already installed globally
|
-- Note: phpcs already installed globally
|
||||||
|
-- Note: ruff also does linting (listed above)
|
||||||
},
|
},
|
||||||
auto_update = false,
|
auto_update = false,
|
||||||
run_on_start = true,
|
run_on_start = true,
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,17 @@ return {
|
||||||
|
|
||||||
-- Note: Diagnostics (linters) moved to nvim-lint plugin
|
-- Note: Diagnostics (linters) moved to nvim-lint plugin
|
||||||
|
|
||||||
|
-- Custom ruff formatter (ruff format subcommand)
|
||||||
|
local ruff_format = {
|
||||||
|
method = null_ls.methods.FORMATTING,
|
||||||
|
filetypes = { "python" },
|
||||||
|
generator = null_ls.formatter({
|
||||||
|
command = find_executable({ "ruff" }) or "ruff",
|
||||||
|
args = { "format", "--stdin-filename", "$FILENAME", "-" },
|
||||||
|
to_stdin = true,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
|
||||||
null_ls.setup({
|
null_ls.setup({
|
||||||
sources = {
|
sources = {
|
||||||
-- Prettier (JS, TS, CSS, SCSS, JSON, Markdown, HTML)
|
-- Prettier (JS, TS, CSS, SCSS, JSON, Markdown, HTML)
|
||||||
|
|
@ -75,10 +86,8 @@ return {
|
||||||
command = find_executable({ "stylua" }),
|
command = find_executable({ "stylua" }),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
-- black (Python)
|
-- ruff (Python formatter - custom since not in builtins)
|
||||||
formatting.black.with({
|
ruff_format,
|
||||||
command = find_executable({ "black" }),
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Format on save
|
-- Format on save
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ return {
|
||||||
typescriptreact = { "eslint_d" },
|
typescriptreact = { "eslint_d" },
|
||||||
markdown = { "markdownlint" },
|
markdown = { "markdownlint" },
|
||||||
php = { "phpcs" },
|
php = { "phpcs" },
|
||||||
python = { "ruff" },
|
python = { "ruff" }, -- Code quality/style checks (pyright handles types)
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Helper: Find project-local executable, fallback to global
|
-- Helper: Find project-local executable, fallback to global
|
||||||
|
|
@ -69,8 +69,18 @@ return {
|
||||||
-- Configure markdownlint
|
-- Configure markdownlint
|
||||||
lint.linters.markdownlint.cmd = find_executable({ "markdownlint" }) or "markdownlint"
|
lint.linters.markdownlint.cmd = find_executable({ "markdownlint" }) or "markdownlint"
|
||||||
|
|
||||||
-- Configure ruff for Python
|
-- Configure ruff for Python linting (separate from formatting)
|
||||||
lint.linters.ruff.cmd = find_executable({ "ruff" }) or "ruff"
|
lint.linters.ruff.cmd = find_executable({ "ruff" }) or "ruff"
|
||||||
|
lint.linters.ruff.args = {
|
||||||
|
"check",
|
||||||
|
"--select", "ALL", -- All rules
|
||||||
|
"--ignore", "E501,E999", -- Ignore line length (formatter handles) and syntax errors (pyright handles)
|
||||||
|
"--force-exclude",
|
||||||
|
"--quiet",
|
||||||
|
"--output-format", "json",
|
||||||
|
"--stdin-filename", function() return vim.api.nvim_buf_get_name(0) end,
|
||||||
|
"-",
|
||||||
|
}
|
||||||
|
|
||||||
-- Auto-lint on these events
|
-- Auto-lint on these events
|
||||||
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
|
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue