vim-instacode
vim-instacode copied to clipboard
Remove need for python, simplify range functionality
This rewrites a bunch of stuff in order not to use python. It also removes the need to get the visual selection.
For the first part, url encoding is easily implementable in Vim. Apparently. I'll be honest, I'm not entirely sure why the s:url_encode
function works, but it seems to work quite well.
The other reason to use python, though, is the cross-platform webbrowser.open
. Vim has nothing like that, but a simple replacement is easy to whip up, as you can see in the s:open_url
function. Sadly, this doesn't work on Windows, since I don't know how to open urls on Windows. I'm sure there's an easy way using the "start" command, I just don't know it. I'm also not sure how robust relying on xdg-open
is, but I'm thinking it would be quite easy to add replacements, like gnome-open
or whatever if people complain.
These are drawbacks, but the benefit is that you don't need to sleep 500m
, and you don't get weird messages due to python stdout.
As for the visual selection, I've removed the need for it, since -range=%
provides the ability to take the start and end lines of the selection, defaulting to the start and end lines of the entire buffer. It seems very unlikely to me that someone would actually like to share only half of the first line of a piece of code and/or half of the last one. If nothing else, it might mess with indentation. Seems reasonable to assume that people would like to share a set of lines, and not a random selection.
Given that this pull request improves some things and makes some things worse, I would definitely understand if you reject it. Or, if you want, I could implement only those changes you'd rather have.
Actually, I managed to find a way to open a url on Windows. Haven't tested it, though. It's from s:get_browser_command
from here.