-
Notifications
You must be signed in to change notification settings - Fork 1.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 our terms of service and privacy 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?
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 unified ale#linter#GetRoot function to prefer the g: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 | New GetRoot function that handles ale_root vars |
| autoload/ale/python.vim | Python root lookup now uses GetRoot |
| autoload/ale/lsp_linter.vim | Removed old FindProjectRoot, now calls GetRoot |
| autoload/ale/assert.vim | Assertion helper updated to use GetRoot |
| ale_linters/python/pyright.vim | Use GetRoot instead of LSP-specific finder |
| ale_linters/python/pylsp.vim | Ditto for pylsp |
| test/test_python_root_option.vader | New tests for buffer/global ale_root behaviors |
| test/test_linter_defintion_processing.vader | Updated tests to assert GetRoot is used |
| doc/ale.txt | Documentation of g:ale_root updated |
| doc/ale-python.txt | Added note on ale_root shortcut for Python |
| let l:Root = a:linter.project_root | ||
| return type(l:Root) is v:t_func ? l:Root(a:buffer) : l:Root | ||
| endif | ||
|
|
Copilot
AI
Jun 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 existing project_root_callback. Consider invoking a:linter.project_root_callback (via ale#util#GetFunction) when present to maintain the original behavior for linters that define callbacks.
| if has_key(a:linter, 'project_root_callback') | |
| let l:Callback = ale#util#GetFunction(a:linter.project_root_callback) | |
| if type(l:Callback) is v:t_func | |
| return l:Callback(a:buffer) | |
| endif | |
| endif |
|
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