be less picky about XDG_DATA_HOME and HOME environment variable trailing slash

In fennel-ls.utils, there's a path-join function that has the logic
for joining paths and putting a slash in the middle if it's not already
there.
This commit is contained in:
XeroOl 2025-06-02 22:46:12 -05:00
parent 13415a97d3
commit 456acb4e15
2 changed files with 6 additions and 5 deletions

View File

@ -1,3 +1,4 @@
(local {: path-join} (require :fennel-ls.utils))
(local fennel (require :fennel))
(local {:metadata METADATA
:scopes {:global {:specials SPECIALS
@ -5,9 +6,9 @@
(require :fennel.compiler))
(local docset-ext ".lua")
(local data-dir (.. (or (os.getenv "XDG_DATA_HOME")
(.. (or (os.getenv "HOME") "") "/.local/share"))
"/fennel-ls/docsets/"))
(local data-dir (path-join (or (os.getenv "XDG_DATA_HOME")
(path-join (or (os.getenv "HOME") "") ".local/share"))
"fennel-ls/docsets/"))
(local specials
(collect [name value (pairs SPECIALS)]

View File

@ -201,10 +201,10 @@ WARNING: this is only used in the test code, not in the real language server"
(-> (.. path path-sep suffix)
;; delete duplicate
;; windows
(: :gsub "%.\\" "")
(: :gsub "^%.\\" "")
(: :gsub "\\+" "\\")
;; modern society
(: :gsub "%./" "")
(: :gsub "^%./" "")
(: :gsub "/+" "/")
(->> (pick-values 1))))