Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/MilesCranmer/gso
🏃 Google StackOverflow in Vim. Copy-pastes the code directly in your script.
https://github.com/MilesCranmer/gso
autocomplete automation developer-tools editor-plugin google lxml python stackoverflow vim
Last synced: 3 months ago
JSON representation
🏃 Google StackOverflow in Vim. Copy-pastes the code directly in your script.
- Host: GitHub
- URL: https://github.com/MilesCranmer/gso
- Owner: MilesCranmer
- License: mit
- Created: 2015-09-12T07:17:02.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2020-08-02T11:29:51.000Z (over 4 years ago)
- Last Synced: 2024-07-04T04:34:13.393Z (4 months ago)
- Topics: autocomplete, automation, developer-tools, editor-plugin, google, lxml, python, stackoverflow, vim
- Language: Vim script
- Homepage:
- Size: 328 KB
- Stars: 82
- Watchers: 7
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GSO
*Googling Stack Overflow*
[![Screencast](http://i.imgur.com/feBUqnJ.gif)](https://asciinema.org/a/123375)Thank you [Daniel](https://stackoverflow.com/a/35754890/2689923),
[Brionius](https://stackoverflow.com/a/18262384/2689923),
and [bytecode77](https://stackoverflow.com/a/29915909/2689923)!GSO now work exclusively in Python 3. Confirmed to work in NeoVim.
*(GSO now also prints the answer URL.)*
## Installation
*(If you just want to try,
there are demo keys at the bottom of this page.
They are shared, so play nice.)*Make sure your vim supports python scripting (`vim --version | grep +python3` should return something).
If this doesn't work, the `vim-nox-py2` package on ubuntu has this (`sudo apt-get install vim-nox-py2`),
else, look to [SO](https://vi.stackexchange.com/questions/10242/vim-8-0-python-support).Then, install python dependencies:
````
pip3 install google-api-python-client Cython py-stackexchange lxml
````If there are issues with installing `lxml`, it's probably to do with a missing `libxml` library.
The [`lxml`](http://lxml.de/installation.html) site has some help for this.Get API keys for [Google Custom Search](https://developers.google.com/custom-search/json-api/v1/overview)
(scroll to API key), and [Stack Apps](https://stackapps.com/apps/oauth/register).
This is free, don't be intimidated by the forms!
Enter *whatever* in the boxes, and the key generated for you will be compatible with this app.
Trust me, it's worth it.Put these into
environment variables `GOOGLE_KEY` and
`SE_KEY`, respectively (e.g., `export GOOGLE_KEY="......"`).(Vundle) Add this repo to your `.vimrc` file:
````
Plugin 'MilesCranmer/gso'
````Then, just `:PluginInstall` in vim.
**(optional)** Map Ctrl-E to type ":GSO " for you, by putting the following in your `.vimrc`:
```vim
nnoremap :GSO
```Usage
-----````
:GSO [(-l | --language) ] [-n | --no-text] [...]
````For example, in a file `sort.py`, run:
````
:GSO Do a bubble sort
````And watch the python code get dumped below your cursor.
GSO will append the language to your query by the file extension, but you can set it explicitly by:````
:GSO -l haskell Generate a fibonacci sequence
````FAQ
---- The Python compiled into my vim is saying it can't see googleapi-client, what do I do?
I have a similar problem and made a hack around it. Your gso should be installed into ~/.vim/gso. Edit the file ~/.vim/gso/plugin/gso.vim, and after each `python << EOF`, paste the following lines:
```
import sys
sys.path.append('....')
```Replace the inside of the string with the "site-packages" directory where googleapi-client is installed. Make sure you use python 3 to install the packages, or optionally replace the `python3 << EOF` with `python << EOF`.
## Tools
There is a shell utility in `tools`. It simply calls the GSO command and dumps the result to the /dev/stdout.
Copy it to `/usr/bin/gso` (or anywhere on the `PATH`), then call it as you normally would:```bash
➜ gso How to change the url of a git remoteGSO>>>
You can
git remote set-url origin git://new.url.here(see git help remote) or you can just edit .git/config and change the
URLs there. You're not in any danger of losing history unless you do
something very silly (and if you're worried, just make a copy of your
repo, since your repo is your history.)
<<