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 5fb17fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 24 deletions.
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 5fb17fa

Please sign in to comment.