-
Notifications
You must be signed in to change notification settings - Fork 13
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
Use gf/gx to open files/URLs from anywhere in a link #100
Comments
I do not think is a wise thing to change the standard behaviour of the There is another way of linking files using |
But this is then inconsistent with gx, which does work from inside the squared bracket - no? Good point for |
Hello @victorkristof! Thank you for taking the time to submit an issue, it's always appreciated :) I checked With that said, I think you can remap Let me know what you think, or why I should still implement this as a native feature of mkdx, personally I don't think it's worth it if it can be solved by remapping within vimrc without too much pain :) |
Alright, my bad, actually gx doesn't behave like I thought it did. It doesn't open the URL from within the brackets. Sorry for that... That being said, I still think it could be a nice-to-have feature for both gf and gx to open a file or a URL when the cursor is within the brackets. (I think some other Markdown plugins have this feature, but I prefer yours :p). I also understand, however, the philosophy of your plugin to keep things simple and minimal, which I really like and which @samarulmeu pointed out ("I do not think is a wise thing to change the standard behaviour of the gf."). Thank you again and feel free to close this issue! |
@victorkristof, seeing you mentioned other plugins do support it, it might actually be interesting to support it as "disabled by default, when enabled, only apply to markdown filetype buffers". I've done this with many features as to not step on users' preferences, if they want something from mkdx, they can choose to opt-in instead which allows me to make quite a lot of crazy functionality :) I'll keep this issue open for now and think about it a bit, I want to make sure that it provides good functionality and doesn't impede with default behavior too much if possible. I'm not sure when I'll add it but I don't like keeping issues open for too long if it can be helped :) Could you help me out by specifying some plugins that provide this functionality? Then I can take a look at what they did and perhaps save myself some time finding them. |
Hey @SidOfc, this sounds great!
I've seen vim-markdown implement this for gx. As per this comment, here is the entry point to their implementation of the feature. I hope this helps and thanks again for the great work! |
Cool cool @victorkristof, thank you for gathering the info, I'm a bit busy coming week but may be able to squeeze it in somewhere, otherwise possibly coming weekend. Thanks for your patience in the meantime :) |
Sure, no problem! Thank you for the great work! (I edited the title of this issue.) |
Alright @victorkristof, should be there as well now in master (no crazy count bugs this time I promise :P) What I did was just enhance It will open files and URL's from anywhere in a markdown link but anywhere else it acts like regular |
Just tested it - really cool! A few bugs on my side:
It should only display
It works fine when path/to/file.txt is not in a link, and it works with URLs in all cases.
I understand your argument of "gf is faster to type than gx", but it differs significantly to what one is used to. I'm not sure I understand this sentence:
Thanks! |
My thoughts on the subject
I agree with @victorkristof that this is not nice. The standard behavior of Thank you both for making the plugin better. |
Alright, cheers for the feedback! I believe the first point is just about verbosity of the error, so now it will require you to press "enter" explicitly whereas before it would just show up in the bottom. Will fix that one. I'll also look into the second issue as well, it should function exactly like About the third issue, Also @samarulmeu I decided it would not interfere too much (I understand right now the verbose error makes it more annoying) since it's only different while on markdown links, you can, of course disable the mapping: https://github.com/sidofc/mkdx#unmapping-functionality-using-plug
|
Actually my problem was with issue no. 2 of @victorkristof . I like the new way |
Of course @samarulmeu I understand, this is indeed not intended but rather a bug which I am currently working on :) |
1 should be fixed Cheers for pointing these things out, 1 and 2 were definitely unintended bugs and perhaps 3 is too, looking forward to your replies 👍 |
I'd also like to stress that both of you have been very useful and constructive during all this, thanks for that and taking the time to think about what is good and bad behavior, these are usually things I have to figure out by myself. It really is lovely to have multiple brains crunching on these scenario's :) |
Thank for your kind words. But from my part, all the praise goes to you as you are doing the hard work. Now Concerning 3 I also think that Some new issue that I discovered: it will be nice to have the same thing on images too Thank you for your prompt answers and solutions. You are amazing and the plugin is getting better and better. |
@samarulmeu the edit: it uses the existing g:mkdx#settings.image_extension_pattern setting to determine what images are based on extension as well. As for doing this for |
I'd also like to expand on some reasoning actually.
I know Vim literally specifies To me, having two mappings with "half-assed" functionality is worse than having one (or both) act the same way in this case. Since allowing full functionality for both mappings allows for more freedom, and no punishment for using the "wrong key for the job". I'm not sure if any or all of it makes sense however, it's just me theorizing about it a bit, happy to hear any thought you guys may have :) |
Thank you for the quick answer and solution. I start by apologizing, but it should have been the other way around. To be consistent Hope I was clear enough. From here:
So, I think that in order to preserve the spirit we should use |
I understand this @samarulmeu, I mentioned that I know that Vim literally defines this as If you want to use I just see no reason to punish someone for trying to open a link with |
Or well, that is if I make |
Oke, I just remapped |
Finally, if we really do want to respect the spirit of Vim, this is something I can't actually deny either when I think about it. In this case I can add a setting to mkdx (which will then also be enabled by default, e.g. respect Vim by default) which will limit I think I'll actually just go ahead and add this setting and I'll just edit my vimrc to allow the "non-vim" behavior for myself :) |
My apologies! I've seen your second message only later. I updated to the latest version but in this case
if I press About the |
…ide gf_on_steroids (disabled by default) setting to allow flexibility (#100)
@samarulmeu alright, think I've got it implemented by default the way you and victor initially suggested. I've also fixed the issue with Thinking about it I was primarily the one wanting flexibility whereas I had two votes for default implementation, so I could have been less stubborn in this process. I've also shot myself in the foot plenty of times with plugins overriding Vim's defaults, leaving me in the dust as to why something doesn't work sometimes so your remark about expectations is definitely something I can sympathize with :) Are there any other issues you can see samarulmeu? |
Thank you so much! That is great. For the moment nothing I can see. And also toggling bold, italic (#101) was a nice touch. I was missing it, but as I work my way into vim using VISUAL mode and different commands I thought is a way to learn. So much easier now! Again, great job! |
Alright, I'll also wait for @victorkristof to report back and to let the functionality "sink in" a bit, perhaps something may pop up later still. In any case I'm glad you were able to change my mind since I do think you are correct about key expectations (especially for folks learning Vim and dabbling around with plugins). If victor also says it's good as-is then I will proceed to close this issue. Of course if you or anyone else reading this finds one please feel free to reopen at any time! Now I'm going to update the docs to reflect recent changes as I don't think there will be any other behavioral changes. As usual, thanks for the feedback! 👍 |
This is absolutely perfect! No bug to report, and the behavior of gf and gx is exactly how I expected it! Thank you @samarulmeu for providing great arguments to have it that way :) Have a nice weekend both of you and thank you for the discussions. |
Alright, closing this one, have a good remainder of the weekend! |
Hi there! I really enjoy your plugin, that's really great great work.
I'm using Markdown to take notes, and I often link one note to another like this:
With the cursor positioned between the squared brackets (indicated by
^
), I tried to use gf to openother-note.md
but it didn't work.It does work with gx though (and when the link is a URL).
Any chance to make gf behave like gx?
Thanks again for the great plugin!
The text was updated successfully, but these errors were encountered: