fix(scripts): format-queries defaults to cwd

This commit is contained in:
Christian Clason
2024-02-19 18:43:32 +01:00
committed by Phạm Huy Hoàng
parent e04ce8bcec
commit 4b27f87fef
2 changed files with 5 additions and 7 deletions

View File

@@ -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

View File

@@ -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)