diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-01-09 23:17:37 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-01-09 23:17:37 +0100 |
| commit | f04bb93e982060ed27e5cf6e4a8d97edeb0910b6 (patch) | |
| tree | 5dc44812f253699dc3b05be7895169ece61e6453 /util.lua | |
| parent | 0a1fdd0eb9642e52f985971827beb33d54f21cf4 (diff) | |
| download | vis-lspc-f04bb93e982060ed27e5cf6e4a8d97edeb0910b6.tar.gz vis-lspc-f04bb93e982060ed27e5cf6e4a8d97edeb0910b6.zip | |
extract the upwards find code into the util module
Diffstat (limited to 'util.lua')
| -rw-r--r-- | util.lua | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -7,6 +7,9 @@ -- @copyright 2024 git-bruh <prathamIN@proton.me> local util = {} +local source_str = debug.getinfo(1, 'S').source:sub(2) +local source_path = source_str:match('(.*/)') + local lspc function util.init(lspc_) @@ -161,4 +164,18 @@ function util.file_line_iterator_to_n(path) end end +--- Find file based on globs in the parent file system tree +-- @param globs a new line separated string of file globs +-- @param start the starting path +function util.find_upwards(globs, start) + local status, out = vis:pipe(globs, source_path .. '/tools/find-upwards "' .. start .. '"') + + if status ~= 0 then + return nil + end + + -- Skip trailing newline + return out:sub(1, #out - 1) +end + return util |
