From b5af6000bdacef641182bd094dc23908dde14110 Mon Sep 17 00:00:00 2001 From: Ariel D'Alessandro Date: Fri, 9 Sep 2022 08:47:02 +0200 Subject: Add composer check locally to avoid needing external library for that --- lua/alpha/composer.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lua/alpha/composer.lua (limited to 'lua/alpha/composer.lua') diff --git a/lua/alpha/composer.lua b/lua/alpha/composer.lua new file mode 100644 index 0000000..e67d523 --- /dev/null +++ b/lua/alpha/composer.lua @@ -0,0 +1,21 @@ +local M = {} + +M.query = function (path) + if vim.fn.findfile("composer.json") == "" then + P("did not found the file") + 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 + return nil + end + end + + return target +end + +return M -- cgit v1.2.3