aboutsummaryrefslogtreecommitdiffstats
path: root/lua/alpha/composer.lua
diff options
context:
space:
mode:
authorAriel D'Alessandro <dalessandro.ariel@gmail.com>2022-09-09 08:47:02 +0200
committerAriel D'Alessandro <dalessandro.ariel@gmail.com>2022-09-09 08:47:02 +0200
commitb5af6000bdacef641182bd094dc23908dde14110 (patch)
treeafdfc5fcb4fe871c0bdb25839f8ed3c02675ed94 /lua/alpha/composer.lua
parent7d5683672cdf1d73914b637b7266e5602f3ac34b (diff)
downloadnvim-conf-b5af6000bdacef641182bd094dc23908dde14110.tar.gz
nvim-conf-b5af6000bdacef641182bd094dc23908dde14110.zip
Add composer check locally to avoid needing external library for that
Diffstat (limited to 'lua/alpha/composer.lua')
-rw-r--r--lua/alpha/composer.lua21
1 files changed, 21 insertions, 0 deletions
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