Skip to content

Commit

Permalink
refactor!: deprecate util.root_pattern
Browse files Browse the repository at this point in the history
This will be breaking primarily for language servers that rely on
code dependencies that is archived but still needs to be read. More
context: neovim#1687.

Work on neovim#2079.
  • Loading branch information
dundargoc committed Jan 20, 2025
1 parent 9ee2e7d commit 3ca0200
Show file tree
Hide file tree
Showing 341 changed files with 918 additions and 994 deletions.
6 changes: 3 additions & 3 deletions lua/lspconfig/configs/ada_ls.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
local util = require 'lspconfig.util'

return {
default_config = {
cmd = { 'ada_language_server' },
filetypes = { 'ada' },
root_dir = util.root_pattern('Makefile', '.git', '*.gpr', '*.adc'),
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find({ 'Makefile', '.git', '*.gpr', '*.adc' }, { path = fname, upward = true })[1])
end,
},
docs = {
description = [[
Expand Down
6 changes: 3 additions & 3 deletions lua/lspconfig/configs/agda_ls.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
local util = require 'lspconfig.util'

return {
default_config = {
cmd = { 'als' },
filetypes = { 'agda' },
root_dir = util.root_pattern('.git', '*.agda-lib'),
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find({ '.git', '*.agda-lib' }, { path = fname, upward = true })[1])
end,
single_file_support = true,
},
docs = {
Expand Down
4 changes: 1 addition & 3 deletions lua/lspconfig/configs/aiken.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
local util = require 'lspconfig.util'

return {
default_config = {
cmd = { 'aiken', 'lsp' },
filetypes = { 'aiken' },
root_dir = function(fname)
return util.root_pattern('aiken.toml', '.git')(fname)
return vim.fs.dirname(vim.fs.find({ 'aiken.toml', '.git' }, { path = fname, upward = true })[1])
end,
},
docs = {
Expand Down
2 changes: 1 addition & 1 deletion lua/lspconfig/configs/alloy_ls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ return {
cmd = { 'alloy', 'lsp' },
filetypes = { 'alloy' },
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
return vim.fs.dirname(vim.fs.find({ '.git' }, { path = fname, upward = true })[1])
end,
single_file_support = true,
},
Expand Down
5 changes: 1 addition & 4 deletions lua/lspconfig/configs/anakin_language_server.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
local util = require 'lspconfig.util'

return {
default_config = {
cmd = { 'anakinls' },
Expand All @@ -12,8 +10,7 @@ return {
'requirements.txt',
'Pipfile',
}
return util.root_pattern(unpack(root_files))(fname)
or vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
return vim.fs.dirname(vim.fs.find({ unpack(root_files), '.git' }, { path = fname, upward = true })[1])
end,
single_file_support = true,
settings = {
Expand Down
6 changes: 3 additions & 3 deletions lua/lspconfig/configs/angularls.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
local util = require 'lspconfig.util'

-- Angular requires a node_modules directory to probe for @angular/language-service and typescript
-- in order to use your projects configured versions.
-- This defaults to the vim cwd, but will get overwritten by the resolved root of the file.
Expand All @@ -25,7 +23,9 @@ return {
-- Check for angular.json since that is the root of the project.
-- Don't check for tsconfig.json or package.json since there are multiple of these
-- in an angular monorepo setup.
root_dir = util.root_pattern 'angular.json',
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find({ 'angular.json' }, { path = fname, upward = true })[1])
end,
},
on_new_config = function(new_config, new_root_dir)
local new_probe_dir = get_probe_dir(new_root_dir)
Expand Down
6 changes: 3 additions & 3 deletions lua/lspconfig/configs/ansiblels.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
local util = require 'lspconfig.util'

return {
default_config = {
cmd = { 'ansible-language-server', '--stdio' },
Expand All @@ -24,7 +22,9 @@ return {
},
},
filetypes = { 'yaml.ansible' },
root_dir = util.root_pattern('ansible.cfg', '.ansible-lint'),
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find({ 'ansible.cfg', '.ansible-lint' }, { path = fname, upward = true })[1])
end,
single_file_support = true,
},
docs = {
Expand Down
6 changes: 3 additions & 3 deletions lua/lspconfig/configs/antlersls.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
local util = require 'lspconfig.util'

return {
default_config = {
cmd = { 'antlersls', '--stdio' },
filetypes = { 'html', 'antlers' },
root_dir = util.root_pattern 'composer.json',
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find({ 'composer.json' }, { path = fname, upward = true })[1])
end,
},
docs = {
description = [[
Expand Down
6 changes: 3 additions & 3 deletions lua/lspconfig/configs/apex_ls.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
local util = require 'lspconfig.util'

return {
default_config = {
filetypes = { 'apexcode' },
root_dir = util.root_pattern 'sfdx-project.json',
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find({ 'sfdx-project.json' }, { path = fname, upward = true })[1])
end,
on_new_config = function(config)
if not config.cmd and config.apex_jar_path then
config.cmd = {
Expand Down
6 changes: 3 additions & 3 deletions lua/lspconfig/configs/arduino_language_server.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
local util = require 'lspconfig.util'

return {
default_config = {
filetypes = { 'arduino' },
root_dir = util.root_pattern '*.ino',
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find({ '*.ino' }, { path = fname, upward = true })[1])
end,
cmd = {
'arduino-language-server',
},
Expand Down
6 changes: 3 additions & 3 deletions lua/lspconfig/configs/ast_grep.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
local util = require 'lspconfig.util'

return {
default_config = {
cmd = { 'ast-grep', 'lsp' },
Expand All @@ -18,7 +16,9 @@ return {
'dart',
'lua',
},
root_dir = util.root_pattern('sgconfig.yaml', 'sgconfig.yml'),
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find({ 'sgconfig.yaml', 'sgconfig.yml' }, { path = fname, upward = true })[1])
end,
},
docs = {
description = [[
Expand Down
8 changes: 5 additions & 3 deletions lua/lspconfig/configs/astro.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
local util = require 'lspconfig.util'

local function get_typescript_server_path(root_dir)
local project_root = vim.fs.find('node_modules', { path = root_dir, upward = true })[1]
return project_root and (project_root .. '/typescript/lib') or ''
Expand All @@ -9,7 +7,11 @@ return {
default_config = {
cmd = { 'astro-ls', '--stdio' },
filetypes = { 'astro' },
root_dir = util.root_pattern('package.json', 'tsconfig.json', 'jsconfig.json', '.git'),
root_dir = function(fname)
return vim.fs.dirname(
vim.fs.find({ 'package.json', 'tsconfig.json', 'jsconfig.json', '.git' }, { path = fname, upward = true })[1]
)
end,
init_options = {
typescript = {},
},
Expand Down
4 changes: 1 addition & 3 deletions lua/lspconfig/configs/atlas.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
local util = require 'lspconfig.util'

return {
default_config = {
cmd = { 'atlas', 'tool', 'lsp', '--stdio' },
filetypes = {
'atlas-*',
},
root_dir = function(fname)
return util.root_pattern('atlas.hcl')(fname)
return vim.fs.dirname(vim.fs.find({ 'atlas.hcl' }, { path = fname, upward = true })[1])
end,
single_file_support = true,
},
Expand Down
4 changes: 1 addition & 3 deletions lua/lspconfig/configs/autotools_ls.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
local util = require 'lspconfig.util'

local root_files = { 'configure.ac', 'Makefile', 'Makefile.am', '*.mk' }

return {
default_config = {
cmd = { 'autotools-language-server' },
filetypes = { 'config', 'automake', 'make' },
root_dir = function(fname)
return util.root_pattern(unpack(root_files))(fname)
return vim.fs.dirname(vim.fs.find({ unpack(root_files) }, { path = fname, upward = true })[1])
end,
single_file_support = true,
},
Expand Down
6 changes: 3 additions & 3 deletions lua/lspconfig/configs/azure_pipelines_ls.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
local util = require 'lspconfig.util'

return {
default_config = {
cmd = { 'azure-pipelines-language-server', '--stdio' },
filetypes = { 'yaml' },
root_dir = util.root_pattern 'azure-pipelines.yml',
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find({ 'azure-pipelines.yml' }, { path = fname, upward = true })[1])
end,
single_file_support = true,
settings = {},
},
Expand Down
6 changes: 3 additions & 3 deletions lua/lspconfig/configs/bacon_ls.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
local util = require 'lspconfig.util'

return {
default_config = {
cmd = { 'bacon-ls' },
filetypes = { 'rust' },
root_dir = util.root_pattern('.bacon-locations', 'Cargo.toml'),
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find({ '.bacon-locations', 'Cargo.toml' }, { path = fname, upward = true })[1])
end,
single_file_support = true,
settings = {},
},
Expand Down
6 changes: 3 additions & 3 deletions lua/lspconfig/configs/ballerina.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
local util = require 'lspconfig.util'

return {
default_config = {
cmd = { 'bal', 'start-language-server' },
filetypes = { 'ballerina' },
root_dir = util.root_pattern 'Ballerina.toml',
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find({ 'Ballerina.toml' }, { path = fname, upward = true })[1])
end,
},
docs = {
description = [[
Expand Down
12 changes: 6 additions & 6 deletions lua/lspconfig/configs/basedpyright.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local util = require 'lspconfig.util'
local util = require('lspconfig.util')

local root_files = {
'pyproject.toml',
Expand All @@ -16,20 +16,20 @@ local function organize_imports()
arguments = { vim.uri_from_bufnr(0) },
}

local clients = util.get_lsp_clients {
local clients = util.get_lsp_clients({
bufnr = vim.api.nvim_get_current_buf(),
name = 'basedpyright',
}
})
for _, client in ipairs(clients) do
client.request('workspace/executeCommand', params, nil, 0)
end
end

local function set_python_path(path)
local clients = util.get_lsp_clients {
local clients = util.get_lsp_clients({
bufnr = vim.api.nvim_get_current_buf(),
name = 'basedpyright',
}
})
for _, client in ipairs(clients) do
if client.settings then
client.settings.python = vim.tbl_deep_extend('force', client.settings.python or {}, { pythonPath = path })
Expand All @@ -45,7 +45,7 @@ return {
cmd = { 'basedpyright-langserver', '--stdio' },
filetypes = { 'python' },
root_dir = function(fname)
return util.root_pattern(unpack(root_files))(fname)
return vim.fs.dirname(vim.fs.find({ unpack(root_files) }, { path = fname, upward = true })[1])
end,
single_file_support = true,
settings = {
Expand Down
2 changes: 1 addition & 1 deletion lua/lspconfig/configs/bashls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ return {
},
filetypes = { 'bash', 'sh' },
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
return vim.fs.dirname(vim.fs.find({ '.git' }, { path = fname, upward = true })[1])
end,
single_file_support = true,
},
Expand Down
8 changes: 5 additions & 3 deletions lua/lspconfig/configs/bazelrc_lsp.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
local util = require 'lspconfig/util'

return {
default_config = {
cmd = { 'bazelrc-lsp' },
filetypes = { 'bazelrc' },
root_dir = util.root_pattern('WORKSPACE', 'WORKSPACE.bazel', 'MODULE.bazel'),
root_dir = function(fname)
return vim.fs.dirname(
vim.fs.find({ 'WORKSPACE', 'WORKSPACE.bazel', 'MODULE.bazel' }, { path = fname, upward = true })[1]
)
end,
},
docs = {
description = [[
Expand Down
2 changes: 1 addition & 1 deletion lua/lspconfig/configs/beancount.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ return {
cmd = { 'beancount-language-server', '--stdio' },
filetypes = { 'beancount', 'bean' },
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
return vim.fs.dirname(vim.fs.find({ '.git' }, { path = fname, upward = true })[1])
end,
single_file_support = true,
init_options = {},
Expand Down
2 changes: 1 addition & 1 deletion lua/lspconfig/configs/bicep.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ return {
default_config = {
filetypes = { 'bicep' },
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
return vim.fs.dirname(vim.fs.find({ '.git' }, { path = fname, upward = true })[1])
end,
init_options = {},
},
Expand Down
6 changes: 3 additions & 3 deletions lua/lspconfig/configs/biome.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
local util = require 'lspconfig.util'

return {
default_config = {
cmd = { 'biome', 'lsp-proxy' },
Expand All @@ -17,7 +15,9 @@ return {
'typescriptreact',
'vue',
},
root_dir = util.root_pattern('biome.json', 'biome.jsonc'),
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find({ 'biome.json', 'biome.jsonc' }, { path = fname, upward = true })[1])
end,
single_file_support = false,
},
docs = {
Expand Down
2 changes: 1 addition & 1 deletion lua/lspconfig/configs/bitbake_language_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ return {
cmd = { 'bitbake-language-server' },
filetypes = { 'bitbake' },
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
return vim.fs.dirname(vim.fs.find({ '.git' }, { path = fname, upward = true })[1])
end,
},
docs = {
Expand Down
2 changes: 1 addition & 1 deletion lua/lspconfig/configs/bitbake_ls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ return {
cmd = { 'language-server-bitbake', '--stdio' },
filetypes = { 'bitbake' },
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
return vim.fs.dirname(vim.fs.find({ '.git' }, { path = fname, upward = true })[1])
end,
single_file_support = false,
},
Expand Down
2 changes: 1 addition & 1 deletion lua/lspconfig/configs/blueprint_ls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ return {
},
filetypes = { 'blueprint' },
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
return vim.fs.dirname(vim.fs.find({ '.git' }, { path = fname, upward = true })[1])
end,
single_file_support = true,
},
Expand Down
6 changes: 3 additions & 3 deletions lua/lspconfig/configs/bqnlsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
local function library_path(path, cmd_env)
path = path or '/usr/local/lib'
cmd_env = cmd_env or {}
if vim.fn.has 'macunix' and not cmd_env.DYLD_LIBRARY_PATH then
if vim.fn.has('macunix') and not cmd_env.DYLD_LIBRARY_PATH then
cmd_env.DYLD_LIBRARY_PATH = path
elseif vim.fn.has 'linux' and not cmd_env.LD_LIBRARY_PATH then
elseif vim.fn.has('linux') and not cmd_env.LD_LIBRARY_PATH then
cmd_env.LD_LIBRARY_PATH = path
end
return cmd_env
Expand All @@ -15,7 +15,7 @@ return {
cmd = { 'bqnlsp' },
filetypes = { 'bqn' },
root_dir = function(fname)
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
return vim.fs.dirname(vim.fs.find({ '.git' }, { path = fname, upward = true })[1])
end,
single_file_support = true,
libcbqnPath = nil,
Expand Down
Loading

0 comments on commit 3ca0200

Please sign in to comment.