aboutsummaryrefslogtreecommitdiff
path: root/util.lua
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-01-11 15:11:16 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2025-01-11 15:11:16 +0100
commit29afc301ea05bc907444b698c91b141c26167baa (patch)
tree63141257deab54705be8c937ef7f1c0b95b7512d /util.lua
parentf04bb93e982060ed27e5cf6e4a8d97edeb0910b6 (diff)
downloadvis-lspc-29afc301ea05bc907444b698c91b141c26167baa.tar.gz
vis-lspc-29afc301ea05bc907444b698c91b141c26167baa.zip
make universal root detection opt-in
Diffstat (limited to 'util.lua')
-rw-r--r--util.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/util.lua b/util.lua
index 114aad4..8d9df9b 100644
--- a/util.lua
+++ b/util.lua
@@ -123,6 +123,13 @@ function util.get_relative_path(cwd_components, absolute_path_or_components)
return dir:sub(2)
end
+--- Strip the last component from a pathname
+-- @param the pathname
+-- @return the pathname up to the last '/'
+function util.dirname(name)
+ return name:match('(.*[/])')
+end
+
--- Create an iterator yielding the nth line of a file
--
-- @param path The path to the file