fix: show contents of definition in preview window#4982
fix: show contents of definition in preview window#4982hftsin wants to merge 11 commits intodense-analysis:masterfrom
Conversation
Signed-off-by: hftsin <hanfengtsin@gmail.com>
Signed-off-by: hftsin <hanfengtsin@gmail.com>
Signed-off-by: hftsin <hanfengtsin@gmail.com>
Signed-off-by: hftsin <hanfengtsin@gmail.com>
Signed-off-by: hftsin <hanfengtsin@gmail.com>
|
Very interesting. I'll have to try this out. |
There was a problem hiding this comment.
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 |
autoload/ale/util.vim
Outdated
| function! ale#util#SafeReadFileLine(filename, line) | ||
| let l:content = '' | ||
| if filereadable(a:filename) | ||
| let l:content = readfile(a:filename, '', a:line)[-1] |
There was a problem hiding this comment.
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.
| let l:content = readfile(a:filename, '', a:line)[-1] | |
| let l:content = getline(a:line, a:filename) |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
I assume this PR may be closed as the same functionality was merged with #5001? |
…in-preview-window Signed-off-by: hftsin <hanfengtsin@gmail.com>
…ow' into fix/show-content-in-preview-window
|
I revise this PR to show definitions / implementations in preview window. E.g., show all implementations for go interface, @w0rp pls help review 🙏 |
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.