Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

cleanup lsp config with new root_dir behaviour #2904

Closed
emilioziniades opened this issue Nov 18, 2023 · 1 comment · Fixed by #2906
Closed

cleanup lsp config with new root_dir behaviour #2904

emilioziniades opened this issue Nov 18, 2023 · 1 comment · Fixed by #2906
Labels
enhancement New feature or request

Comments

@emilioziniades
Copy link
Contributor

Language server

No response

Requested feature

Now that #2885 has been merged, we can clean up a bunch of language server configs that had to manually specify priorities of patterns for finding the root directory. For example, in tsserver, this

root_dir = function(fname)
return util.root_pattern 'tsconfig.json'(fname)
or util.root_pattern('package.json', 'jsconfig.json', '.git')(fname)
end,

can simply become

return util.root_pattern('tsconfig.json', 'package.json', 'jsconfig.json', '.git')

Anywhere where a language server has something like return util.root_pattern(pattern1) or util.root_pattern(pattern2) or ... can be simplified.

Here's a list of language servers I've identified:

root_dir = function(fname)
return util.root_pattern 'Scarb.toml'(fname)
or util.root_pattern('Scarb.toml', 'cairo_project.toml', '.git')(fname)
end,

root_dir = function(fname)
return util.root_pattern 'tsconfig.json'(fname)
or util.root_pattern('package.json', 'jsconfig.json', '.git')(fname)
end,

return util.root_pattern 'go.work'(fname) or util.root_pattern('go.mod', '.git')(fname)

return util.root_pattern(unpack(root_files))(fname) or util.root_pattern(unpack(fallback_root_files))(fname)

return (
util.root_pattern('hie.yaml', 'stack.yaml', 'cabal.project')(filepath)
or util.root_pattern('*.cabal', 'package.yaml')(filepath)
)

return util.root_pattern(unpack(root_files))(fname) or util.root_pattern(unpack(fallback_root_files))(fname)

root_dir = function(fname)
local root_patterns = { '*.sln', '*.csproj', 'omnisharp.json', 'function.json' }
for _, pattern in ipairs(root_patterns) do
local found = util.root_pattern(pattern)(fname)
if found then
return found
end
end
end,

return util.root_pattern '.streerc'(fname) or util.root_pattern('Gemfile', '.git')(fname)

return util.root_pattern('tailwind.config.js', 'tailwind.config.cjs', 'tailwind.config.mjs', 'tailwind.config.ts')(
fname
) or util.root_pattern('postcss.config.js', 'postcss.config.cjs', 'postcss.config.mjs', 'postcss.config.ts')(
fname

root_dir = function(fname)
return util.root_pattern 'tsconfig.json'(fname)
or util.root_pattern('package.json', 'jsconfig.json', '.git')(fname)
end,

root_dir = function(fname)
return util.root_pattern 'tsconfig.json'(fname)
or util.root_pattern('package.json', 'jsconfig.json', '.git')(fname)
end,

Let me know if I have missed any.

cc @glepnir @justinmk

Other clients which have this feature

No response

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants