show pyright errors

This commit is contained in:
Ray Elliott 2025-12-07 23:53:32 +00:00
parent b56d703662
commit a57f72f7c7
5 changed files with 28 additions and 42 deletions

View File

@ -7,16 +7,6 @@ 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
@ -105,9 +95,30 @@ return {
configure("intelephense", { configure("intelephense", {
single_file_support = false, single_file_support = false,
}) })
configure("pyright") -- Python LSP
-- Python: pyright for type checking, ruff for linting/formatting
configure("pyright", {
settings = {
pyright = {
-- Only use pyright for type checking
disableOrganizeImports = true, -- Let ruff handle imports
},
python = {
analysis = {
typeCheckingMode = "basic", -- Type checking only
-- Let ruff handle style/formatting diagnostics
diagnosticSeverityOverrides = {
-- Keep type/syntax errors, warnings
-- Disable style-related diagnostics (ruff handles these)
},
},
},
},
})
configure("ruff") -- Ruff LSP for formatting + linting
-- Enable all configured servers -- Enable all configured servers
vim.lsp.enable({ "lua_ls", "ts_ls", "html", "cssls", "jsonls", "bashls", "marksman", "intelephense", "pyright" }) vim.lsp.enable({ "lua_ls", "ts_ls", "html", "cssls", "jsonls", "bashls", "marksman", "intelephense", "pyright", "ruff" })
end, end,
} }

View File

@ -14,6 +14,7 @@ return {
"marksman", "marksman",
"intelephense", "intelephense",
"pyright", "pyright",
"ruff", -- Ruff LSP for Python linting + formatting
}, },
automatic_installation = true, automatic_installation = true,
}) })

View File

@ -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
"ruff", -- Python (formatter + linter in one)
-- Note: phpcbf already installed globally -- Note: phpcbf already installed globally
-- Note: ruff (Python) installed as LSP server via mason-lspconfig
-- Linters -- Linters
"eslint_d", -- JS, TS (daemon version for speed) "eslint_d", -- JS, TS (daemon version for speed)
"markdownlint", -- Markdown "markdownlint", -- Markdown
-- Note: phpcs already installed globally -- Note: phpcs already installed globally
-- Note: ruff also does linting (listed above) -- Note: ruff (Python) installed as LSP server via mason-lspconfig
}, },
auto_update = false, auto_update = false,
run_on_start = true, run_on_start = true,

View File

@ -44,17 +44,7 @@ return {
local formatting = null_ls.builtins.formatting local formatting = null_ls.builtins.formatting
-- Note: Diagnostics (linters) moved to nvim-lint plugin -- Note: Diagnostics (linters) moved to nvim-lint plugin
-- Note: Python formatting handled by ruff LSP
-- 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 = {
@ -85,9 +75,6 @@ return {
formatting.stylua.with({ formatting.stylua.with({
command = find_executable({ "stylua" }), command = find_executable({ "stylua" }),
}), }),
-- ruff (Python formatter - custom since not in builtins)
ruff_format,
}, },
-- Format on save -- Format on save

View File

@ -15,7 +15,7 @@ return {
typescriptreact = { "eslint_d" }, typescriptreact = { "eslint_d" },
markdown = { "markdownlint" }, markdown = { "markdownlint" },
php = { "phpcs" }, php = { "phpcs" },
python = { "ruff" }, -- Code quality/style checks (pyright handles types) -- Python: ruff LSP handles linting
} }
-- Helper: Find project-local executable, fallback to global -- Helper: Find project-local executable, fallback to global
@ -69,19 +69,6 @@ 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 linting (separate from formatting)
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 })
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {