Skip to content

Commit

Permalink
refactor: deprecate util.path.is_absolute
Browse files Browse the repository at this point in the history
Work on #2079.
  • Loading branch information
dundargoc committed Dec 14, 2024
1 parent 3cb6c05 commit e198724
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/ci/run_sanitizer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if git diff --pickaxe-all -U0 -G "${SEARCH_PATTERN}" "${REF_BRANCH}" "${PR_BRANC
exit 1
fi

SEARCH_PATTERN='(util\.path\.dirname|util\.path\.sanitize|util\.path\.exists|util\.path\.is_file|util\.path\.is_dir|util\.find_mercurial_ancestor|util\.find_node_modules_ancestor|util\.find_package_json_ancestor)'
SEARCH_PATTERN='(util\.path\.dirname|util\.path\.sanitize|util\.path\.exists|util\.path\.is_file|util\.path\.is_dir|util\.path\.is_absolute|util\.find_mercurial_ancestor|util\.find_node_modules_ancestor|util\.find_package_json_ancestor)'

if git diff --pickaxe-all -U0 -G "${SEARCH_PATTERN}" "${REF_BRANCH}" "${PR_BRANCH}" -- '*.lua' | grep -Ev '\.lua$' | grep -E "^\+.*${SEARCH_PATTERN}" ; then
echo
Expand Down
18 changes: 7 additions & 11 deletions lua/lspconfig/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,6 @@ M.path = (function()
end
end

--- @param filename string
--- @return boolean
local function is_absolute(filename)
if iswin then
return filename:match '^%a:' or filename:match '^\\\\'
else
return filename:match '^/'
end
end

local function path_join(...)
return table.concat(M.tbl_flatten { ... }, '/')
end
Expand Down Expand Up @@ -180,7 +170,6 @@ M.path = (function()

return {
escape_wildcards = escape_wildcards,
is_absolute = is_absolute,
join = path_join,
traverse_parents = traverse_parents,
iterate_parents = iterate_parents,
Expand Down Expand Up @@ -370,6 +359,13 @@ M.path.dirname = vim.fs.dirname
--- @deprecated use `vim.fs.normalize` instead
M.path.sanitize = vim.fs.normalize

--- @deprecated use `vim.fn.isabsolutepath(filename) == 1` instead
--- @param filename string
--- @return boolean
function M.path.is_absolute(filename)
return vim.fn.isabsolutepath(filename) == 1
end

--- @deprecated use `vim.loop.fs_stat` instead
--- @param filename string
--- @return string|false
Expand Down
13 changes: 0 additions & 13 deletions test/lspconfig_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,6 @@ describe('lspconfig', function()
end)
end)

describe('is_absolute', function()
it('is absolute', function()
local lspconfig = require 'lspconfig'
eq(true, lspconfig.util.path.is_absolute '/foo/bar' ~= nil)
end)

it('is not absolute', function()
local lspconfig = require 'lspconfig'
assert.is_nil(lspconfig.util.path.is_absolute 'foo/bar')
assert.is_nil(lspconfig.util.path.is_absolute '../foo/bar')
end)
end)

describe('join', function()
it('', function()
local lspconfig = require 'lspconfig'
Expand Down

0 comments on commit e198724

Please sign in to comment.