-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add support for Vim's tagstack to ALEGoToDefinition #2448
Conversation
I modified the |
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.
We should add tests for this. I'll have to update the Docker image so the 8.1 version we build is new enough to contain this feature.
autoload/ale/definition.vim
Outdated
let l:should_update_tagstack = exists('*gettagstack') && exists('*settagstack') && g:ale_update_tagstack | ||
|
||
if l:should_update_tagstack | ||
let l:from = [bufnr('%'), line('.'), col('.'), 0] |
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.
You can use the filename, line, and column we already have to determine this.
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.
Assuming you're referring to l:filename
, l:line
and l:column
defined in ale#definition#HandleTSServerResponse
and ale#definition#HandleLSPResponse
- these are the targets for the new location. The values I'm pushing on to the stack are based on the old location.
I'll change the variable names to be a bit more clear. 😄
if l:should_update_tagstack | ||
let l:from = [bufnr('%'), line('.'), col('.'), 0] | ||
let l:tagname = expand('<cword>') | ||
let l:winid = win_getid() |
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.
Get the window ID from the buffer number, instead of the current window.
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.
This sounds like it's probably really relevant and important - but I'm afraid I'm not an expert on the Vim functions involving windows and buffers. Any chance you can provide some pointers to the relevant docs?
|
||
if l:should_update_tagstack | ||
let l:from = [bufnr('%'), line('.'), col('.'), 0] | ||
let l:tagname = expand('<cword>') |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
Same as above - the values I'm pushing on to the stack are based on the old location. So I don't think I need to wait for the buffer to open; assuming I've understood this comment correctly?
Agreed. The test I added is fairly minimal; but passes when I build a custom Docker image and update the run-tests script to use a local image. I'm happy to include the Dockerfile change as well, if you'd like. |
The `settagstack` and `gettagstack` functions don't exist prior to Vim 8.1.0519. And the function definition was unclear whether it intended to grab the *old* or the *new* file/line/col.
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.
I'll merge this, and people can try it out.
@w0rp @reedriley doesn't seem to be working for me. :ALEGoToDefinition and when I C-t then it says tagstack is empty. So right now I use C-o |
What version of Vim are you running? |
@w0rp @reedriley I have the same problem (tagstack is empty). I am using Vim 8.1. Fresh ALE, commit * 27146ad 2019-05-30 |
Thanks, after upgrade using OLD VIM - Vi IMproved 8.1 (2018 May 18, compiled Nov 6 2018 09:45:53) NEW VIM - Vi IMproved 8.1 (2018 May 18, compiled May 27 2019 13:46:23) |
Is there any plan to provide this functionality for NeoVim? I'm on the latest NeoVim version (v0.3.7) and I'm getting the same 'tagstack is empty' mentioned above |
Yep its not working on neovim. |
Same issue here. It is not working on neovim 0.3.8. Can we make it work for neovim by any chance? Thanks in advance! |
@hourliert @rislah I just checked NeoVim's source, and it appears that their patch for vim-8.1.0519 hasn't made it out to a stable release yet. According to that pull request, the update is targeted to be out in the 0.4 release. I've tested out the nightly release which contains the fix and verified that this tagstack feature works correctly. |
Fixes #1236.
I added tests - but to be fair, this feature won't work on versions of Vim earlier than 8.1.0519 and the test automation script doesn't test on anything that recent.
The feature is designed to degrade gracefully; and I'm open to suggestions on how to best clarify the version requirement in the docs.