Skip to content

Commit

Permalink
refactor: deprecate util.find_git_ancestor
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 12f3c41
Show file tree
Hide file tree
Showing 156 changed files with 404 additions and 216 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\.find_mercurial_ancestor|util\.find_node_modules_ancestor|util\.find_package_json_ancestor|util\.find_git_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
14 changes: 11 additions & 3 deletions doc/lspconfig.txt
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,17 @@ below returns a function that takes as its argument the current buffer path.
filesystem. Parent directories are traversed once per pattern, in the order
the patterns are specified. >
root_dir = util.root_pattern('pyproject.toml', 'requirements.txt')
- `util.find_git_ancestor`: a function that locates the first parent directory
containing a `.git` directory. >
root_dir = util.find_git_ancestor
- Locate the first parent dir containing a ".git" file or directory: >lua
vim.fs.dirname(vim.fs.find('.git', { path = root_dir, upward = true })[1])
<
If you have Nvim 0.10 or newer then >lua
vim.fs.root(root_dir, ".git")
<
can be used instead.
- Note: The old `util.find_git_ancestor` API is deprecated and will
be removed.
<
- Locate the first parent dir containing a "node_modules" dir: >lua
vim.fs.dirname(vim.fs.find('node_modules', { path = root_dir, upward = true })[1])
<
Expand Down
3 changes: 2 additions & 1 deletion lua/lspconfig/configs/anakin_language_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ return {
'requirements.txt',
'Pipfile',
}
return util.root_pattern(unpack(root_files))(fname) or util.find_git_ancestor(fname)
return util.root_pattern(unpack(root_files))(fname)
or vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
single_file_support = true,
settings = {
Expand Down
6 changes: 3 additions & 3 deletions lua/lspconfig/configs/asm_lsp.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
local util = require 'lspconfig.util'

return {
default_config = {
cmd = { 'asm-lsp' },
filetypes = { 'asm', 'vmasm' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
},
docs = {
description = [[
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/bashls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ return {
},
},
filetypes = { 'bash', 'sh' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
single_file_support = true,
},
docs = {
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/beancount.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ return {
default_config = {
cmd = { 'beancount-language-server', '--stdio' },
filetypes = { 'beancount', 'bean' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
single_file_support = true,
init_options = {},
},
Expand Down
6 changes: 3 additions & 3 deletions lua/lspconfig/configs/bicep.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
local util = require 'lspconfig.util'

return {
default_config = {
filetypes = { 'bicep' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
init_options = {},
},
docs = {
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/bitbake_language_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ return {
default_config = {
cmd = { 'bitbake-language-server' },
filetypes = { 'bitbake' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
},
docs = {
description = [[
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/bitbake_ls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ return {
default_config = {
cmd = { 'language-server-bitbake', '--stdio' },
filetypes = { 'bitbake' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
single_file_support = false,
},
docs = {
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/blueprint_ls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ return {
GLOB_PATTERN = vim.env.GLOB_PATTERN or '*@(.blp)',
},
filetypes = { 'blueprint' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
single_file_support = true,
},
docs = {
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/bqnlsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ return {
default_config = {
cmd = { 'bqnlsp' },
filetypes = { 'bqn' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
single_file_support = true,
libcbqnPath = nil,
on_new_config = function(new_config, _)
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/bsl_ls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ local util = require 'lspconfig.util'
return {
default_config = {
filetypes = { 'bsl', 'os' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
},
docs = {
description = [[
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/buddy_ls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ return {
default_config = {
cmd = { 'buddy-lsp-server' },
filetypes = { 'mlir' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
single_file_support = true,
},
docs = {
Expand Down
3 changes: 2 additions & 1 deletion lua/lspconfig/configs/ccls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ return {
cmd = { 'ccls' },
filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda' },
root_dir = function(fname)
return util.root_pattern('compile_commands.json', '.ccls')(fname) or util.find_git_ancestor(fname)
return util.root_pattern('compile_commands.json', '.ccls')(fname)
or vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
offset_encoding = 'utf-32',
-- ccls does not support sending a null root directory
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/circom-lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ return {
default_config = {
cmd = { 'circom-lsp' },
filetypes = { 'circom' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
single_file_support = true,
},
docs = {
Expand Down
2 changes: 1 addition & 1 deletion lua/lspconfig/configs/clangd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ return {
'compile_commands.json',
'compile_flags.txt',
'configure.ac' -- AutoTools
)(fname) or util.find_git_ancestor(fname)
)(fname) or vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
single_file_support = true,
capabilities = {
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/cobol_ls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ return {
default_config = {
cmd = { 'cobol-language-support' },
filetypes = { 'cobol' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
},
docs = {
description = [[
Expand Down
3 changes: 2 additions & 1 deletion lua/lspconfig/configs/coq_lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ return {
cmd = { 'coq-lsp' },
filetypes = { 'coq' },
root_dir = function(fname)
return util.root_pattern '_CoqProject'(fname) or util.find_git_ancestor(fname)
return util.root_pattern '_CoqProject'(fname)
or vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
single_file_support = true,
},
Expand Down
2 changes: 1 addition & 1 deletion lua/lspconfig/configs/crystalline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ return {
default_config = {
cmd = { 'crystalline' },
filetypes = { 'crystal' },
root_dir = util.root_pattern 'shard.yml' or util.find_git_ancestor,
root_dir = util.root_pattern 'shard.yml' or vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1]),
single_file_support = true,
},
docs = {
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/cucumber_language_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ return {
default_config = {
cmd = { 'cucumber-language-server', '--stdio' },
filetypes = { 'cucumber' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
},
docs = {
description = [[
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/cypher_ls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ return {
default_config = {
cmd = { 'cypher-language-server', '--stdio' },
filetypes = { 'cypher' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
single_file_support = true,
},
docs = {
Expand Down
2 changes: 1 addition & 1 deletion lua/lspconfig/configs/dafny.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ return {
cmd = { 'dafny', 'server' },
filetypes = { 'dfy', 'dafny' },
root_dir = function(fname)
util.find_git_ancestor(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
single_file_support = true,
},
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/dhall_lsp_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ return {
default_config = {
cmd = { 'dhall-lsp-server' },
filetypes = { 'dhall' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
single_file_support = true,
},
docs = {
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/diagnosticls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ return {
-- Configuration from https://github.com/iamcco/diagnostic-languageserver#config--document
default_config = {
cmd = { 'diagnostic-languageserver', '--stdio' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
single_file_support = true,
-- Empty by default, override to add filetypes.
filetypes = {},
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/digestif.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ return {
default_config = {
cmd = { 'digestif' },
filetypes = { 'tex', 'plaintex', 'context' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
single_file_support = true,
},
docs = {
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/djlsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ return {
default_config = {
cmd = { 'djlsp' },
filetypes = { 'html', 'htmldjango' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
settings = {},
},
docs = {
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/dolmenls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ return {
default_config = {
cmd = { 'dolmenls' },
filetypes = { 'smt2', 'tptp', 'p', 'cnf', 'icnf', 'zf' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
single_file_support = true,
},
docs = {
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/dotls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ return {
default_config = {
cmd = { 'dot-language-server', '--stdio' },
filetypes = { 'dot' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
single_file_support = true,
},
docs = {
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/drools_lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ end
return {
default_config = {
filetypes = { 'drools' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
single_file_support = true,
on_new_config = function(new_config)
new_config.cmd = get_cmd(new_config)
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/ds_pinyin_lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ return {
default_config = {
cmd = { bin_name },
filetypes = { 'markdown', 'org' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
single_file_support = true,
init_options = {
completion_on = true,
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/efm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'efm-langserver' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
single_file_support = true,
},

Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/emmet_language_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ return {
'typescriptreact',
'htmlangular',
},
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
single_file_support = true,
},
docs = {
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/emmet_ls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ return {
'vue',
'htmlangular',
},
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
single_file_support = true,
},
docs = {
Expand Down
3 changes: 2 additions & 1 deletion lua/lspconfig/configs/erg_language_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ return {
cmd = { 'erg', '--language-server' },
filetypes = { 'erg' },
root_dir = function(fname)
return util.root_pattern 'package.er'(fname) or util.find_git_ancestor(fname)
return util.root_pattern 'package.er'(fname)
or vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
},
docs = {
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/esbonio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ return {
default_config = {
cmd = { 'python3', '-m', 'esbonio' },
filetypes = { 'rst' },
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
},
docs = {
description = [[
Expand Down
4 changes: 3 additions & 1 deletion lua/lspconfig/configs/facility_language_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ return {
cmd = { 'facility-language-server' },
filetypes = { 'fsd' },
single_file_support = true,
root_dir = util.find_git_ancestor,
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
end,
},
docs = {
description = [[
Expand Down
Loading

0 comments on commit 12f3c41

Please sign in to comment.