From 4b27f87fef2df2feaca47a8498f5f7f51e94b765 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Mon, 19 Feb 2024 18:43:32 +0100 Subject: fix(scripts): format-queries defaults to cwd --- .github/workflows/lint.yml | 2 +- scripts/format-queries.lua | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 47a2ee386..b73f03cf8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -46,5 +46,5 @@ jobs: - name: Lint run: | - nvim -l scripts/format-queries.lua queries + nvim -l scripts/format-queries.lua git diff --exit-code diff --git a/scripts/format-queries.lua b/scripts/format-queries.lua index ab7aa237b..61309f817 100755 --- a/scripts/format-queries.lua +++ b/scripts/format-queries.lua @@ -6,13 +6,11 @@ local get_node_text = ts.get_node_text ---@type string[] local files -if not _G.arg[1] then - print "Must specify file or directory to format!" - return -elseif _G.arg[1]:match ".*%.scm$" then - files = { _G.arg[1] } +local arg = _G.arg[1] or "." +if arg:match ".*%.scm$" then + files = { arg } else - files = vim.fn.split(vim.fn.glob(_G.arg[1] .. "/**/*.scm")) + files = vim.fn.split(vim.fn.glob(arg .. "/**/*.scm")) end ts.query.add_predicate("has-type?", function(match, _, _, pred) -- cgit v1.3.1