Files
nvim-kickstart/lua/custom/none-ls.lua
T
mathiasandClaude Sonnet 5 2646541406 Clean up config: fix broken plugin specs, dedupe options/keymaps, drop dead code
- lspsaga: custom keys lived outside config(), so setup({}) ran empty and
  they never worked; moved into setup() and updated to the plugin's current
  option schema (finder_action_keys/definition_action_keys/move_in_saga
  are stale names in the installed version)
- catppuccin: fixed a stray `as = "catppuccin"` key left outside the plugin
  table; wrapped as { "catppuccin/nvim", name = "catppuccin" }
- options: consolidated the three competing sources (vimrc, init.lua,
  custom/options.lua) into custom/options.lua alone; hlsearch/wrap were
  silently landing opposite to what init.lua's own comments said, purely
  from require-order. custom/options.lua now loads first in the require
  chain since colorizer.lua and others need termguicolors set before their
  own setup() runs
- removed duplicate keymaps that were dead on arrival due to load order
  (<leader>rn, <leader>sf/sg/sh, jj, <leader>y, mapleader x3, manual
  C-h/j/k/l vs vim-tmux-navigator)
- removed dead code: smart_format, root_dir/fallback_root_dir, toggleterm's
  unused _LAZYGIT_TOGGLE/_NODE_TOGGLE/_PYTHON_TOGGLE globals, unused local
  cmp, stale commented blocks, lua/custom/startup.lua
- removed unused plugins: mini.icons, telescope-dap.nvim,
  startup-nvim/startup.nvim (malformed spec, never actually required),
  plus leftover ALE globals with no ALE plugin installed
- vim.loop.* -> vim.uv.*, vim.diagnostic.goto_prev/next ->
  vim.diagnostic.jump({count=...}) for 0.12.5
- guard vim.treesitter.start() at the top of init.lua: the system's
  bundled Lua highlight query is currently ahead of the available
  tree-sitter-lua grammar (a packaging skew, confirmed nvim-treesitter is
  fully up to date), which was throwing on every Lua buffer and taking
  omnifunc/foldexpr down with it; now falls back to regex highlighting
  with a single notify instead

Verified end-to-end against a real Neovim 0.12.5 headless instance with a
fresh plugin install: no load errors, lspsaga's custom keys now actually
apply, and the treesitter guard was confirmed against the real environment.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013jVh2Lhn386JAvjSFCHUhn
2026-08-27 22:27:37 +02:00

73 lines
2.5 KiB
Lua

local null_ls = require("null-ls")
-- phpstan: use the project's own phpstan.neon when there is one, otherwise fall
-- back to the generic config in dotfiles.
local phpstan_global_config = vim.fn.expand("~/repos/dotfiles/php/phpstan-global.neon")
-- returns the config path to pass via -c, or nil when phpstan can discover a
-- local config itself (that also picks up its `includes:`, e.g. a baseline)
local function phpstan_config_arg(root)
for _, name in ipairs({ "phpstan.neon", "phpstan.neon.dist" }) do
if vim.uv.fs_stat(root .. "/" .. name) then
return nil
end
end
return phpstan_global_config
end
null_ls.setup({
sources = {
null_ls.builtins.formatting.phpcbf.with({
command = "phpcbf", -- or full path if not in PATH
extra_args = { "--standard=PSR12", "--standard=phpcs.xml" },
}),
null_ls.builtins.diagnostics.phpstan.with({
-- prefer the project's own phpstan (extensions and baselines are
-- version bound), fall back to the mason binary
dynamic_command = function(params, done)
local local_bin = params.root .. "/vendor/bin/phpstan"
if vim.fn.executable(local_bin) == 1 then
return done(local_bin)
end
return done("phpstan")
end,
args = function(params)
local args = { "analyse", "--error-format", "json", "--no-progress" }
local config = phpstan_config_arg(params.root)
if config then
vim.list_extend(args, { "-c", config })
end
table.insert(args, "$FILENAME")
return args
end,
-- analyse the file on disk, not a copy in /tmp: phpstan needs the
-- project's autoloader and its configured paths/scanDirectories
method = null_ls.methods.DIAGNOSTICS_ON_SAVE,
to_temp_file = false,
timeout = 60000, -- a cold run easily exceeds null-ls' 5s default
condition = function(utils)
return utils.root_has_file({ "phpstan.neon", "phpstan.neon.dist" })
or vim.uv.fs_stat(phpstan_global_config) ~= nil
end,
}),
null_ls.builtins.diagnostics.phpcs.with({
command = "phpcs", -- or "vendor/bin/phpcs" if local
args = {
"--standard=PSR12", -- or "phpcs.xml", "phpcs.xml.dist", etc.
"-s", -- show sniff codes
"-q", -- suppress warnings
"--report=emacs",
"--stdin-path", "$FILENAME",
"-"
},
condition = function(utils)
return utils.root_has_file({ "phpcs.xml", "phpcs.xml.dist" }) or true
end,
}),
null_ls.builtins.formatting.phpcsfixer.with({
command = "php-cs-fixer",
-- no extra_args needed if config file is correctly named and in root
}),
},
})