Skip to content

Conversation

@hftsin
Copy link

@hftsin hftsin commented May 25, 2025

For non-ts LSP response, it only shows the filename, line number and column number. This PR enhance the preview window by showing the contents of definitions and references.

@hftsin hftsin marked this pull request as ready for review May 25, 2025 11:34
@w0rp
Copy link
Member

w0rp commented Jun 13, 2025

Very interesting. I'll have to try this out.

@w0rp w0rp requested a review from Copilot June 13, 2025 18:19
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 enhances the preview window by including the content of definitions and references for non-TypeScript LSP responses. It updates test assertions to include a new key ("use_relative_paths"), introduces a helper function for safely reading a file’s specific line, and adjusts formatting functions in both definition and references modules to display the retrieved content.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/test_go_to_definition.vader Updated test assertions to include "use_relative_paths" in the preview details
test/test_find_references.vader Added an empty 'match' key to reference items for content consistency
autoload/ale/util.vim Introduced SafeReadFileLine to read a particular line from a file safely
autoload/ale/references.vim Modified formatting function to include file content in the reference preview
autoload/ale/definition.vim Modified formatting function and command handler to incorporate file content and relative path options

function! ale#util#SafeReadFileLine(filename, line)
let l:content = ''
if filereadable(a:filename)
let l:content = readfile(a:filename, '', a:line)[-1]
Copy link

Copilot AI Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If performance becomes an issue for large files, consider using a method that reads only the target line rather than reading all lines up to it.

Suggested change
let l:content = readfile(a:filename, '', a:line)[-1]
let l:content = getline(a:line, a:filename)

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <[email protected]>
@rymdbar
Copy link
Contributor

rymdbar commented Aug 31, 2025

I assume this PR may be closed as the same functionality was merged with #5001?

@hftsin hftsin closed this Sep 12, 2025
@hftsin hftsin reopened this Sep 13, 2025
@hftsin hftsin changed the title fix: show contents of definition and references in preview window fix: show contents of definition in preview window Sep 13, 2025
@hftsin
Copy link
Author

hftsin commented Sep 13, 2025

I revise this PR to show definitions / implementations in preview window. E.g., show all implementations for go interface,
image

@w0rp pls help review 🙏

@hsanson hsanson requested a review from w0rp October 26, 2025 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants