From 12d163c5c2b05e85431f2deef5d9d59a8fd8dfc2 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 13 Dec 2024 14:53:08 +0100 Subject: refactor: deprecate util.find_git_ancestor Work on https://github.com/neovim/nvim-lspconfig/issues/2079. --- lua/lspconfig/util.lua | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'lua/lspconfig/util.lua') diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua index 4bd82b5b..9b888efe 100644 --- a/lua/lspconfig/util.lua +++ b/lua/lspconfig/util.lua @@ -236,16 +236,6 @@ function M.root_pattern(...) end end -function M.find_git_ancestor(startpath) - return M.search_ancestors(startpath, function(path) - -- Support git directories and git files (worktrees) - local gitpath = M.path.join(path, '.git') - if vim.fn.isdirectory(gitpath) == 1 or (vim.loop.fs_stat(gitpath) or {}).type == 'file' then - return path - end - end) -end - function M.insert_package_json(config_files, field, fname) local path = vim.fn.fnamemodify(fname, ':h') local root_with_package = vim.fs.dirname(vim.fs.find('package.json', { path = path, upward = true })[1]) @@ -393,4 +383,9 @@ function M.find_package_json_ancestor(startpath) return vim.fs.dirname(vim.fs.find('package.json', { path = startpath, upward = true })[1]) end +--- @deprecated use `vim.fs.dirname(vim.fs.find('.git', { path = startpath, upward = true })[1])` instead +function M.find_git_ancestor(startpath) + return vim.fs.dirname(vim.fs.find('.git', { path = startpath, upward = true })[1]) +end + return M -- cgit v1.2.3-70-g09d2