- Notifications
You must be signed in to change notification settings - Fork1.5k
Prefer ale_root option when detecting roots#4993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Pull Request Overview
This PR introduces a unifiedale#linter#GetRoot function to prefer theg:ale_root/b:ale_root settings when detecting project roots, replaces legacy root-detection calls with it, and updates documentation and tests accordingly.
- Added
ale#linter#GetRootand wired it into LSP and Python linters - Updated tests to cover the new root-lookup priority
- Revised documentation (
ale.txt,ale-python.txt) to describe the new behavior
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| autoload/ale/linter.vim | NewGetRoot function that handlesale_root vars |
| autoload/ale/python.vim | Python root lookup now usesGetRoot |
| autoload/ale/lsp_linter.vim | Removed oldFindProjectRoot, now callsGetRoot |
| autoload/ale/assert.vim | Assertion helper updated to useGetRoot |
| ale_linters/python/pyright.vim | UseGetRoot instead of LSP-specific finder |
| ale_linters/python/pylsp.vim | Ditto forpylsp |
| test/test_python_root_option.vader | New tests for buffer/globalale_root behaviors |
| test/test_linter_defintion_processing.vader | Updated tests to assertGetRoot is used |
| doc/ale.txt | Documentation ofg:ale_root updated |
| doc/ale-python.txt | Added note onale_root shortcut for Python |
| letl:Root=a:linter.project_root | ||
| returntype(l:Root)isv:t_func ?l:Root(a:buffer) :l:Root | ||
| endif | ||
CopilotAIJun 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
GetRoot currently returns an empty string by default when no root is found, which drops the fallback to a linter's existingproject_root_callback. Consider invokinga:linter.project_root_callback (viaale#util#GetFunction) when present to maintain the original behavior for linters that define callbacks.
| ifhas_key(a:linter,'project_root_callback') | |
| letl:Callback=ale#util#GetFunction(a:linter.project_root_callback) | |
| iftype(l:Callback)isv:t_func | |
| returnl:Callback(a:buffer) | |
| endif | |
| endif |
rymdbar commentedJul 8, 2025
Problems, as well as confusion, with getting the correct project root happens often enough for this to warrant both a technical change such as the one in this pull-request and some updates to the documentation. I might be confused myself and mixing contexts, but figure it's likely a good idea to add this quote of myself from#3481 here:
My mind is a bit fuzzy and my notes aren't making it crystal clear, but I think once the project roots are discovered the same way for all language servers, what needs to be done is to go through documentation for them all and make sure it mentions the requirement for a root to be found and the ability to hard code the root if desired. |
Summary
ale#linter#GetRootand use it when starting LSP lintersale_rootfirst inale#python#FindProjectRootTesting
./run-tests --fast(fails: docker not found)https://chatgpt.com/codex/tasks/task_b_685c4b409780832aaeb2154798173c38