From 50382dcdb54dda7a1dcc154442aebfc1c55d8508 Mon Sep 17 00:00:00 2001 From: Brian Henderson Date: Tue, 14 Apr 2026 22:50:00 +0200 Subject: [PATCH] refactor: polish lsp.lua and mason-extras.lua - Restore pyright inline comments explaining Ruff delegation - Add header comment documenting mason-lspconfig/vim.lsp.config coupling - Unwrap lsp.lua outer spec table (consistency with blink-cmp.lua, conform.lua) - pcall mason-registry.get_package (defensive against unknown package name) - Split inline autocmd opts across lines (style) --- lua/custom/plugins/lsp.lua | 24 ++++++++++++++++-------- lua/custom/plugins/mason-extras.lua | 7 ++++--- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/lua/custom/plugins/lsp.lua b/lua/custom/plugins/lsp.lua index 562766ac..9315e1c7 100644 --- a/lua/custom/plugins/lsp.lua +++ b/lua/custom/plugins/lsp.lua @@ -1,16 +1,24 @@ +-- Pyright settings merge via vim.lsp.config deep-merge; mason-lspconfig's +-- automatic_enable fires vim.lsp.enable() for each ensure_installed server. vim.lsp.config('pyright', { settings = { - pyright = { disableOrganizeImports = true }, - python = { analysis = { ignore = { '*' } } }, + pyright = { + -- Using Ruff's import organizer + disableOrganizeImports = true, + }, + python = { + analysis = { + -- Ignore all files for analysis to exclusively use Ruff for linting + ignore = { '*' }, + }, + }, }, }) return { - { - 'mason-org/mason-lspconfig.nvim', - opts = { - ensure_installed = { 'clangd', 'gopls', 'pyright', 'ts_ls', 'ruff' }, - automatic_enable = true, - }, + 'mason-org/mason-lspconfig.nvim', + opts = { + ensure_installed = { 'clangd', 'gopls', 'pyright', 'ts_ls', 'ruff' }, + automatic_enable = true, }, } diff --git a/lua/custom/plugins/mason-extras.lua b/lua/custom/plugins/mason-extras.lua index 0b34986f..3ab31626 100644 --- a/lua/custom/plugins/mason-extras.lua +++ b/lua/custom/plugins/mason-extras.lua @@ -1,10 +1,11 @@ vim.api.nvim_create_autocmd('User', { - pattern = 'VeryLazy', once = true, + pattern = 'VeryLazy', + once = true, callback = function() local mr = require 'mason-registry' mr.refresh(function() - local p = mr.get_package 'codelldb' - if not p:is_installed() then p:install() end + local ok, p = pcall(mr.get_package, 'codelldb') + if ok and not p:is_installed() then p:install() end end) end, })