From 1d5036f411392a199f205a868fe793f1e33718cc Mon Sep 17 00:00:00 2001 From: Ariel D'Alessandro Date: Wed, 21 Sep 2022 09:34:54 +0200 Subject: Fix the symfony reference for the null ls and composer to load in from worktree folders --- after/plugin/null-ls.lua | 6 ++++-- lua/alpha/composer.lua | 19 +++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/after/plugin/null-ls.lua b/after/plugin/null-ls.lua index 79a90db..3b9257f 100644 --- a/after/plugin/null-ls.lua +++ b/after/plugin/null-ls.lua @@ -40,11 +40,13 @@ local symonfy_sources = { }), } -if composer.query({ "require", "symfony/symonfy" }) ~= nil then +if composer.query({ "require", "symfony/framework-bundle" }) ~= nil then for _, source in ipairs(symonfy_sources) do table.insert(sources, source) end -else +end + +if composer.query({ "require", "laravel/framework" }) ~= nil then for _, source in ipairs(laravel_sources) do table.insert(sources, source) end diff --git a/lua/alpha/composer.lua b/lua/alpha/composer.lua index e67d523..4792979 100644 --- a/lua/alpha/composer.lua +++ b/lua/alpha/composer.lua @@ -1,13 +1,24 @@ local M = {} +local function get_composer_file() + if vim.fn.findfile("composer.json") ~= "" then + return vim.fn.json_decode(vim.fn.readfile(vim.fn.getcwd() .. "/composer.json")) + end + + if vim.fn.findfile("master/composer.json") ~= "" then + return vim.fn.json_decode(vim.fn.readfile(vim.fn.getcwd() .. "/master/composer.json")) + end + + return nil +end + M.query = function (path) - if vim.fn.findfile("composer.json") == "" then - P("did not found the file") + local target = get_composer_file() + + if target == nil then return nil end - local target = vim.fn.json_decode(vim.fn.readfile(vim.fn.getcwd() .. "/composer.json")) - for _, part in ipairs(path) do target = target[part] if target == nil then -- cgit v1.2.3