From a57f72f7c7cbc9976875bc69ab38c6232dcade2c Mon Sep 17 00:00:00 2001 From: ray Date: Sun, 7 Dec 2025 23:53:32 +0000 Subject: [PATCH] show pyright errors --- lua/plugins/lsp.lua | 35 ++++++++++++++++++---------- lua/plugins/mason-lspconfig.lua | 1 + lua/plugins/mason-tool-installer.lua | 4 ++-- lua/plugins/none-ls.lua | 15 +----------- lua/plugins/nvim-lint.lua | 15 +----------- 5 files changed, 28 insertions(+), 42 deletions(-) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index eae03ed..c8eed65 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -7,16 +7,6 @@ return { config = function() 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 local function load_project_lsp_settings(server_name, root_dir) if not root_dir then @@ -105,9 +95,30 @@ return { configure("intelephense", { 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 - 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, } diff --git a/lua/plugins/mason-lspconfig.lua b/lua/plugins/mason-lspconfig.lua index 910f2d5..62f3dc3 100644 --- a/lua/plugins/mason-lspconfig.lua +++ b/lua/plugins/mason-lspconfig.lua @@ -14,6 +14,7 @@ return { "marksman", "intelephense", "pyright", + "ruff", -- Ruff LSP for Python linting + formatting }, automatic_installation = true, }) diff --git a/lua/plugins/mason-tool-installer.lua b/lua/plugins/mason-tool-installer.lua index b76028a..fabd6bf 100644 --- a/lua/plugins/mason-tool-installer.lua +++ b/lua/plugins/mason-tool-installer.lua @@ -10,14 +10,14 @@ return { -- Formatters "prettier", -- JS, TS, CSS, JSON, Markdown, HTML "stylua", -- Lua - "ruff", -- Python (formatter + linter in one) -- Note: phpcbf already installed globally + -- Note: ruff (Python) installed as LSP server via mason-lspconfig -- Linters "eslint_d", -- JS, TS (daemon version for speed) "markdownlint", -- Markdown -- 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, run_on_start = true, diff --git a/lua/plugins/none-ls.lua b/lua/plugins/none-ls.lua index ad7e73b..9696965 100644 --- a/lua/plugins/none-ls.lua +++ b/lua/plugins/none-ls.lua @@ -44,17 +44,7 @@ return { local formatting = null_ls.builtins.formatting -- 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, - }), - } + -- Note: Python formatting handled by ruff LSP null_ls.setup({ sources = { @@ -85,9 +75,6 @@ return { formatting.stylua.with({ command = find_executable({ "stylua" }), }), - - -- ruff (Python formatter - custom since not in builtins) - ruff_format, }, -- Format on save diff --git a/lua/plugins/nvim-lint.lua b/lua/plugins/nvim-lint.lua index 69af2fd..c14ab58 100644 --- a/lua/plugins/nvim-lint.lua +++ b/lua/plugins/nvim-lint.lua @@ -15,7 +15,7 @@ return { typescriptreact = { "eslint_d" }, markdown = { "markdownlint" }, php = { "phpcs" }, - python = { "ruff" }, -- Code quality/style checks (pyright handles types) + -- Python: ruff LSP handles linting } -- Helper: Find project-local executable, fallback to global @@ -69,19 +69,6 @@ return { -- Configure 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 local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {