Skip to content
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

Remove need for python, simplify range functionality #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Remove need for python, simplify range functionality #2

wants to merge 2 commits into from

Conversation

AndrewRadev
Copy link
Contributor

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.

Sadly, this also breaks Windows support, 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.

It also removes the need to get the visual selection, since taking just
the lines should be fine.
@AndrewRadev
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant