-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(watcher): implement watcher to detect and invoke on file change
- Loading branch information
Showing
7 changed files
with
356 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
local d = {} | ||
|
||
---@param str string | ||
function d.flatten(str) | ||
return table.concat(vim.split(str:gsub("\n", " "), " +", { trimempty = true, plain = false }), " ") | ||
end | ||
|
||
---@param t table | ||
function d.tbl(t) | ||
return d.flatten(vim.inspect(t)) | ||
end | ||
|
||
function d.p(...) | ||
return vim.print(d.ps(...)) | ||
end | ||
|
||
function d.ps(...) | ||
return (d.tbl({ ... }):sub(3, -3):gsub([[^['"](.*)["']$]], "%1"):gsub([[\t]], " ")) | ||
end | ||
|
||
function d.pt(...) | ||
local result = {} | ||
for index, value in ipairs({ ... }) do | ||
result[index] = tostring(value) | ||
end | ||
return unpack(result) | ||
end | ||
|
||
function d.pp(path, ...) | ||
return d.p(tostring(path), ...) | ||
end | ||
|
||
d.f = string.format | ||
|
||
function d.pf(s, ...) | ||
return d.p(d.f(s, ...)) | ||
end | ||
|
||
function d.ptr(x) | ||
return d.f("%p", x) | ||
end | ||
|
||
---@param state PathlibGitState | ||
function d.g(state) | ||
return d.tbl(vim.tbl_deep_extend("force", state, { git_root = state.git_root:tostring() })) | ||
end | ||
|
||
---@param dir PathlibPath | ||
function d.rmdir(dir) | ||
for _p in dir:iterdir() do | ||
if _p:is_dir(true) then | ||
d.rmdir(_p) | ||
_p:rmdir() | ||
end | ||
_p:unlink() | ||
end | ||
dir:rmdir() | ||
end | ||
|
||
return d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.