-
Notifications
You must be signed in to change notification settings - Fork 395
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
Implement better inverse search #2219
Conversation
I'll work more on this as I think there are more "rough" edges yet. But I think it should already, possibly, work. So feel free to test! This was your idea, @user202729, so I hope you can help with testing. Which system are you on and which version of Vim? @clason I'd also appreciate some tests from your side with Skim and MacOS. You could already test, or you could wait until I've refined this some more. Btw: When this works, I can actually remove the dependency on neovim-remote(!), and we can simplify the docs quite a bit as this should, in principle, work in all cases, on all systems. (Famous last words, and everything!). (So, @user202729, it seems I am starting to think you had a great idea, here...) |
Hmm, that doesn't seem to work for me. If I run the command from the shell, I get
Should this be |
(I'll think about how to do this with |
Sorry, it should be I don't think there is a |
Hmm, that just "freezes"... The Python code works, though.
You're right, you don't need to access Neovim from Python. Then it's less critical (although zero dependency would be even nicer ;)) |
Actually it's still useful when zathura is started separately (need zathurarc configuration), but for the "zathura called from VimTeX" instance you don't need to loop (but another loop isn't a problem if it simplifies the code.
|
Ah, it's probably not working because |
Regarding my vim version:
TODO: see if I think the GUI one has the additional feature that spawn a new instance if there's no existing (would be nice to have, but require the user to specify the terminal command-line to use) |
b307ce5
to
90931d6
Compare
Yes, but only if you use Zathura. For every other viewer, one does need some manual configuration.
Yes.
Agreed - I've not decided if we should "short circuit" in this case or not. There is a very short extra delay. Barely noticable, but it is there.
Agreed.
I partly agree; I find the restrictions in Windows to be equally terrible. In any case, I agree it is hard to be 100% robust here. It will fail on
If you find this to be important, then please open a new issue when the current PR is merged.
I would not automatically start a server. And it is hard to issue a warning in this case. I think instead we should make the docs clear enough so that people configure and use Vim correctly. This should not be a problem on neovim, where there is always a server.
Not sure what you are referring to with "the GUI one". But I'm not sure if I want to make the callback start a new instance of Vim automatically. I think instead people should setup things correctly on their side. We can lower the barrier, but we can't put it on the floor. :p
Yes, sorry. I've pushed updates now that seem to work well for me. |
I've added a remaining tasks on the top post. |
Hmm, sorry, still not working for me (on macOS). The invocation on the command line just "freezes", and nothing happens. |
Yes, please close all neovim instances and restart them before testing. This feature will ask all neovim instances to run a function that may or may not be updated to the most recent version. I've failed to find a way to reliably force it to timeout. But I believe this is only a problem now while developing - when it works as it should, there should be no such issues afterwards. |
For the GUI part, I mean that there's a feature like this (not sure if it's intentional, and it's trivially workaround-able anyway)
while there's no gvim opened, it will open a gvim instance. |
Thanks, I understood that. My point was that I'm not really interested in supporting this part. |
Oh, that goes without saying. The issue is that Skim doesn't like that command -- every inverse search leaves a zombie It does work from the command line if no zombie instances are running. |
I've changed from |
Ah, OK, I see what's happening. Skim uses |
Yes, that seems right. Although, I would have thought things to work even if Skim is not launched by VimTeX. So that is actually unexpected... |
Indeed; I don't know why, yet... (Possibly -- and most likely -- an environment issue.) EDIT Yep, it's enough to |
Ok, I've pushed a big update to the docs now. It really is a significant simplification, so if this really does end up working as I hope it will, I believe it will be a very useful improvement! |
cee9005
to
a27b31e
Compare
Ok, I've tested with both Zathura and Okular on Linux now, with both Vim and neovim. Everything seems to work very well. Now it remains to have this properly tested with:
I know you already tried a couple of times before, @clason, but now I'm quite sure that things should work in general. There might be a minor issue if you open Skim in a strange way, although I don't understand why. I would appreciate feedback here. @jdhao I know you have been using VimTeX on Windows (since you wrote nice blog posts about this); would you be able and willing to test the new ideas there? I.e., try to use the new configuration suggested in |
@user202729 You're on Arch Linux and Vim, and I postulate that the current version should work well for you. Please criticise me! :) |
I wish I had an answer. Getting the right environment for applications launched from the Finder is always a nightmare on macOS, and this seems to be the issue here. I'm a bit out of ideas (unless you can think of environment variables, especially In any case, this is not on you, so this shouldn't be a blocker. |
It's strange - I can't really think of anything here. Perhaps it is more "severe"? One thing you can do is to add things like
Ok, thanks; I agree, but I would like things to "just work"™ - if possible. Btw: Does anyone have a better idea for the name of the function |
@clason Did you test with both Vim and neovim - did things work with Skim as long as you started it from VimTeX (either directly or through latexmk)? |
I did not test with Vim, as I haven't used that in ages and don't have a compatible config anymore. Things work though as long as Skim is started from the shell (via VimTeX or
|
Seems to work well. Except
It's
Okay, I don't really need it anyway. |
f72393c
to
1041219
Compare
A compromise, then: let's do
Sorry, my mistake. You are right,
Agreed; however, I've been thinking about it, and I don't think we need
I'm curious: why?
Yes; I believe we can use the
The current version should include these patches and so I'll mark it as verified for neovim on Windows. Thanks!
I think setting the environment variable is good. The deprecation notice at the very least indicates that we should not rely on Notice, I tried to make the environment variable approach work on Linux, but here the
Ok, I'll update the docs accordingly. I'm curious, did you try the |
All look OK now for Neovim on Windows.
I am not sure what you mean for the other variant but the code look fine now!
I was thinking the same. And that is why I made a new conda environment to test it.
You can see the output of
Not a strong preference honestly. Mostly comes from my frustration that ALL the applications dumping a file in my $HOME directory which then becomes a huge mess. There is a chaos there of files. (Which btw was a "huge" advantage of neovim as vim and the plugins I was using were also part of the problem). But jokes aside, if you can configure where the file will be then is fine.
That is interesting! I suppose here is why https://unix.stackexchange.com/questions/29128/how-to-read-environment-variables-of-a-process
I did try a lot of things and options for both cmd and nvim. I did not remember which exactly now.
Adding So what I think happens in 1. is that we need to open cmd, in order to run start, which runs nvim. So the short flash is from cmd. https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/start EDIT: Also, this command assumes |
So sorry for the confusion. I think part of the confusion stems from which "previous comment" I was referring to. (I have now linked to the correct "comment" in the quote above) Summarizing that "previous comment" (and rephrasing),
Not quite, without my suggested change, the inverse search only works when 'shellslash' is not set; it should also work when 'shellslash' is set.
By this, I mean that one should always replace I hope that clarifies, please write back to me otherwise :) |
I was actually curious so I tried it vim on Windows. so Here is a minimal vimrc if &compatible
set nocompatible
endif
set runtimepath+=C:\Users\ps\.cache\dein\repos\github.com\Shougo\dein.vim
call dein#begin('C:\Users\ps\.cache\dein')
call dein#add('C:\Users\ps\.cache\dein\repos\github.com\Shougo\dein.vim')
call dein#add('lervag/vimtex', {'rev': 'feat/better-inverse-search'})
call dein#end()
filetype plugin indent on
syntax enable
set number
set shellslash @lervag
No clue where this symbol comes from. Using Finally, now it works for me with both vim and neovim on Windows. EDIT: P.S. Also from
|
Agreed, That was exactly my point. I guess I had not been clear enough, but that was what I was trying to say :S
Again, that was exactly what I was getting at. The code does not use globpath, so there is no need to use shellslash in the code.
No, I am afraid it does not work with shellslash set.
It only makes the correction ( |
Regarding As I mentioned above in the general case VBScript may be needed.
But for gvim in particular, it may be possible without VBScript: I tried running some commands. The "nothing pops up" cases are highlighted.
(assuming there's a GVIM remote server) A terminal window pop up very quickly then exits
Nothing pops up
(assuming there's a VIM remote server) A terminal pops up quickly then exits
Gvim window pop up quickly then exits
A terminal window pop up very quickly then exits
Nothing pops up
A terminal window pop up (longer than gvim's terminal window) then exits The cause of some of the popups is that So in conclusion
is likely to work. (drop |
@PanagiootisS
Glad to hear it!
Thanks; I understand this as evidence that
No, sorry - I'll remove. Thanks for noticing!
Well, I strongly relate to this frustration and I'll of course avoid messing with your home. I plan to look into this idea in a follow-up PR after I merge this one.
Thanks, this seems to confirm my suspicion.
I'm left with the impression that the current version of the docs are satisfactory, then. Is that right?
Yes, good point. But I would think it is not necessary to document this, it seems an edge case? @PanagiootisS and @BertrandSim
Again I'm slightly confused, but my understanding is that I should apply the patch suggested by @BertrandSim here. Do you both agree?
@BertrandSim Is this the same on your end?
Great, glad to hear it! This is quite close to ready, then!
Thanks; it seems the above |
Up to you. The disadvantage is that you need to know the "real" path to gvim to do it. Alternatively add it (only) if many people ask for it. |
Github had the doc file folded so I missed. I though you were planning this last thing or something.
Based on my experience a vim example is needed. I suppose you are waiting for more feedback before updating this, but just in case I wanted to point it.
Shouldn't this be "Both Vim and Neovim have" ?
We probably still need this for the "pynvim" part. And probably a reference from the
Nowdays I am not sure as I do use mostly Linux. It really depends on how one installs (n)vim. In the past, I certainly had to edit PATH a lot of times and I still do every now and then. For example, I had to manually add mingw bin to the path a couple of days ago. And lets not start with Python and Windows and the huge mess that existed already, which Windows 10 made worse with their intrusive tactics. And (I am sorry for giving once again a personal example) considering that most people I know that they use latex (engineering, in academia) probably do not know what exactly PATH is or how it works (nor they care). So, having an explicit one-line example (or try"this" if it doesn't work) would be very helpful for them, if they ever came to use this plugin (some of them are using vim but without plugins). But then again I do not know. You can maybe leave it off and if someone asks you can add it later. Regarding path and shellslash@BertrandSim I am sorry. You are right. With shellslash it does not work. I messed it up apparently. (I did not take into account that half of the code is executed in a different (n)vim instance than the one we start with.)
Yes. So it seems that regardless of To see what is going on I will put a couple of echoms in the code and posting them here so you can see what's going on, in function! vimtex#view#inverse_search(line, filename) abort " {{{1
" Only activate in VimTeX buffers
if !exists('b:vimtex') | return -1 | endif
echom '-----------'
echom 'Shellslash = ' . &shellslash
" Only activate in relevant VimTeX projects
let l:file = resolve(a:filename)
let l:sources = copy(b:vimtex.sources)
echom '1: l:file = ' . l:file
if vimtex#paths#is_abs(l:file)
call map(l:sources, {_, x -> vimtex#paths#join(b:vimtex.root, x)})
endif
echom '4: l:sources = ' . string(l:sources)
if index(l:sources, l:file) < 0 | return -2 | endif in function! vimtex#paths#s(path) abort " {{{1
" Handle shellescape issues and simplify path
echom '2: a:path = ' . a:path
" let l:path = exists('+shellslash') && &shellslash
" \ ? tr(a:path, '/', '\')
" \ : a:path
let l:path = tr(a:path, '/', '\')
echom '3: l:path = ' . l:path
return simplify(l:path)
endfunction And the result is (for both vim and neovim),
|
Thanks for the comments; I've updated the docs now.
Ok, thanks; I'll add/update that.
I'll consider to add something here.
Great, I'll fix and update. Thanks for looking into it so thoroughly! I'll now take the liberty of merging this PR. Please don't hesitate to open issues with ideas for improving the docs or this new feature. And again, thanks to everyone who took their time to pitch in! I very much appreciate it! |
Again, thank you all. This was more work than anticipated, but I think and hope it will make the experience better for inverse search with VimTeX. |
This PR is inspired by #2217. The idea is to implement the inverse search functionality within Vimscript for both Vim and neovim, so that the viewer configuration can be simplified. I.e., when this is finished, a viewer can run something like this:
Then the function
inverse_search_comm
will pass this on to all available Vim/neovim instances. The idea is that each instance will inspect the received arguments and only perform the inverse search if relevant.Pseudocode:
and
Remaining tasks:
vimtex#view#inverse_search_comm
vimtex#view#inverse_search