From 13a3c83138f73562a49417f48afbc0e508d1d495 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 21 Jun 2023 08:47:05 +0100 Subject: [PATCH] fix(nvim): code formatting and diagnostics --- lua/opdavies/lsp/null-ls.lua | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/lua/opdavies/lsp/null-ls.lua b/lua/opdavies/lsp/null-ls.lua index 8bafdb0..17255c2 100644 --- a/lua/opdavies/lsp/null-ls.lua +++ b/lua/opdavies/lsp/null-ls.lua @@ -3,28 +3,22 @@ if not status_ok then return end -local lsp_formatting = function(bufnr) - vim.lsp.buf.format { - filter = function(client) - return client.name == "null-ls" - end, - bufnr = bufnr, - } -end - -local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) - local code_actions = null_ls.builtins.code_actions local diagnostics = null_ls.builtins.diagnostics local formatting = null_ls.builtins.formatting null_ls.setup { sources = { - formatting.phpcbf, code_actions.gitsigns, formatting.black, formatting.markdownlint, + formatting.phpcbf.with({ + command = "./vendor/bin/phpcbf", + condition = function(utils) + return utils.root_has_file({ 'phpcs.xml.dist' }) + end, + }), formatting.prettier, formatting.rustywind, formatting.stylua, @@ -37,6 +31,7 @@ null_ls.setup { diagnostics.markdownlint, diagnostics.php, diagnostics.phpcs.with({ + command = "./vendor/bin/phpcs", condition = function(utils) return utils.root_has_file({ 'phpcs.xml.dist' }) end,