Skip to content

Conversation

@w0rp
Copy link
Member

@w0rp w0rp commented Jun 25, 2025

Summary

  • add ale#linter#GetRoot and use it when starting LSP linters
  • use ale_root first in ale#python#FindProjectRoot
  • update docs to describe the new root lookup behaviour
  • adjust tests and add new test for python root option

Testing

  • ./run-tests --fast (fails: docker not found)

https://chatgpt.com/codex/tasks/task_b_685c4b409780832aaeb2154798173c38

@w0rp w0rp marked this pull request as draft June 25, 2025 20:07
@w0rp w0rp marked this pull request as draft June 25, 2025 20:07
@w0rp w0rp requested a review from Copilot June 25, 2025 20:08
Copy link

Copilot AI left a 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#GetRoot and 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

Copy link

Copilot AI Jun 25, 2025

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
@rymdbar
Copy link
Contributor

rymdbar commented Jul 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:

Adding a sentence or section to the documentation about the need for the for a project root to be found would likely be a good idea too. This might be a common theme applying to the documentation for most language servers.

Expecting everyone to have read :help ale-options.root and realise it is what is needed is probably unrealistic.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants