diff --git a/.github/ci/run_sanitizer.sh b/.github/ci/run_sanitizer.sh index 9f6fd3580d..fb99839006 100644 --- a/.github/ci/run_sanitizer.sh +++ b/.github/ci/run_sanitizer.sh @@ -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 diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua index 4bd82b5be8..58804b030a 100644 --- a/lua/lspconfig/util.lua +++ b/lua/lspconfig/util.lua @@ -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 @@ -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, @@ -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 diff --git a/test/lspconfig_spec.lua b/test/lspconfig_spec.lua index 256faba203..63a5cd9422 100644 --- a/test/lspconfig_spec.lua +++ b/test/lspconfig_spec.lua @@ -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'