{"id":13870231,"url":"https://github.com/MilesCranmer/gso","last_synced_at":"2025-07-15T20:31:59.805Z","repository":{"id":86181260,"uuid":"42348508","full_name":"MilesCranmer/gso","owner":"MilesCranmer","description":"🏃  Google StackOverflow in Vim. Copy-pastes the code directly in your script.","archived":false,"fork":false,"pushed_at":"2020-08-02T11:29:51.000Z","size":336,"stargazers_count":82,"open_issues_count":1,"forks_count":4,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-17T10:45:12.581Z","etag":null,"topics":["autocomplete","automation","developer-tools","editor-plugin","google","lxml","python","stackoverflow","vim"],"latest_commit_sha":null,"homepage":"","language":"Vim script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MilesCranmer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-09-12T07:17:02.000Z","updated_at":"2024-06-28T03:54:27.000Z","dependencies_parsed_at":"2023-05-05T06:24:01.297Z","dependency_job_id":null,"html_url":"https://github.com/MilesCranmer/gso","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MilesCranmer%2Fgso","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MilesCranmer%2Fgso/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MilesCranmer%2Fgso/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MilesCranmer%2Fgso/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MilesCranmer","download_url":"https://codeload.github.com/MilesCranmer/gso/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226068313,"owners_count":17568734,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autocomplete","automation","developer-tools","editor-plugin","google","lxml","python","stackoverflow","vim"],"created_at":"2024-08-05T20:01:35.800Z","updated_at":"2024-11-23T16:31:22.420Z","avatar_url":"https://github.com/MilesCranmer.png","language":"Vim script","funding_links":[],"categories":["Vim Script"],"sub_categories":[],"readme":"# GSO\n*Googling Stack Overflow*\n[![Screencast](http://i.imgur.com/feBUqnJ.gif)](https://asciinema.org/a/123375)\n\nThank you [Daniel](https://stackoverflow.com/a/35754890/2689923),\n[Brionius](https://stackoverflow.com/a/18262384/2689923),\nand [bytecode77](https://stackoverflow.com/a/29915909/2689923)!\n\nGSO now work exclusively in Python 3. Confirmed to work in NeoVim.\n\n*(GSO now also prints the answer URL.)*\n\n## Installation\n\n*(If you just want to try,\nthere are demo keys at the bottom of this page.\nThey are shared, so play nice.)*\n\nMake sure your vim supports python scripting (`vim --version | grep +python3` should return something). \nIf this doesn't work, the `vim-nox-py2` package on ubuntu has this (`sudo apt-get install vim-nox-py2`),\nelse, look to [SO](https://vi.stackexchange.com/questions/10242/vim-8-0-python-support).\n\nThen, install python dependencies:\n\n```` \npip3 install google-api-python-client Cython py-stackexchange lxml\n````\n\nIf there are issues with installing `lxml`, it's probably to do with a missing `libxml` library.\nThe [`lxml`](http://lxml.de/installation.html) site has some help for this.\n\nGet API keys for [Google Custom Search](https://developers.google.com/custom-search/json-api/v1/overview)\n(scroll to API key), and [Stack Apps](https://stackapps.com/apps/oauth/register). \nThis is free, don't be intimidated by the forms!\nEnter *whatever* in the boxes, and the key generated for you will be compatible with this app.\nTrust me, it's worth it.\n\nPut these into\nenvironment variables `GOOGLE_KEY` and\n`SE_KEY`, respectively (e.g., `export GOOGLE_KEY=\"......\"`).\n\n(Vundle) Add this repo to your `.vimrc` file:\n\n````\nPlugin 'MilesCranmer/gso'\n````\n\nThen, just `:PluginInstall` in vim.\n\n**(optional)** Map Ctrl-E to type \":GSO \" for you, by putting the following in your `.vimrc`:\n```vim\nnnoremap \u003cC-e\u003e :GSO \n```\n\nUsage\n-----\n\n````\n:GSO [(-l | --language) \u003clanguage\u003e] [-n | --no-text] [\u003csearch\u003e...]\n````\n\n\nFor example, in a file `sort.py`, run:\n\n````\n:GSO Do a bubble sort\n````\n\nAnd watch the python code get dumped below your cursor.\nGSO will append the language to your query by the file extension, but you can set it explicitly by:\n\n````\n:GSO -l haskell Generate a fibonacci sequence\n````\n\nFAQ\n---\n\n- The Python compiled into my vim is saying it can't see googleapi-client, what do I do?\n\nI 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 \u003c\u003c EOF`, paste the following lines:\n\n```\nimport sys\nsys.path.append('....')\n```\n\nReplace 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 \u003c\u003c EOF` with `python \u003c\u003c EOF`.\n\n## Tools\n\nThere is a shell utility in `tools`. It simply calls the GSO command and dumps the result to the /dev/stdout.\nCopy it to `/usr/bin/gso` (or anywhere on the `PATH`), then call it as you normally would:\n\n```bash\n➜  gso How to change the url of a git remote\n\nGSO\u003e\u003e\u003e\nYou can\ngit remote set-url origin git://new.url.here\n\n\n(see git help remote) or you can just edit .git/config and change the \nURLs there. You're not in any danger of losing history unless you do \nsomething very silly (and if you're worried, just make a copy of your \nrepo, since your repo is your history.)\n\u003c\u003c\u003cGSO\n```\n\nDocker\n------\n\nTo pull and run (with your Google and Stack apps API keys, or the demo ones at the bottom):\n\n```` \ndocker run -it -e GOOGLE_KEY=$GOOGLE_KEY -e SE_KEY=$SE_KEY mcranmer/gso\n````\n\nThen, inside vim:\n\n```` \n:GSO Flatten a list of lists\n````\n\nAnd it will dump the highest score answer to below your cursor.\n\n# TODO/Ideas\n\n- Unit tests. Apparently these are uncommon among vim plugins, so there is little built-in testing functionality, but since I am using a lot of python, I could just write regular python `unittests` on the `gso` module.\n- Automatic reading of code, triggered by a flag, so that you can dump the current line of code to the search query to help your results. This way, it's a little bit like an advanced `man` function.\n- Automatic piping of error messages to GSO, have it dump a solution to your error in the code. This might have to be linked to the build command, e.g., make. Then, if make produces a nonzero error message, you activate GSO at the cursor position. This could be something you toggle on and off. It could also just be called, e.g., by an empty :GSO command after an error. You could also add functionality to turn specific errors off if they are too basic (e.g., forgetting a semi-colon), or too common (e.g., generic seg fault).\n- (#1 TODO) **Multi answer/multi question, as well as easy keystroke swapping. This would have GSO load up a bunch of answers/questions to the quickfix list, then you could use unimpaired.vim to quickly replace the pasted text below your cursor.**\n- Answer preview, so you can see answers in a new pane, and swipe between them until you like one. Then you could hit some keystroke to dump it in.\n- General speedups (though this isn't really needed on an AWS instance, so I might not work on this for a while).\n- Comments for more languages built-in.\n- Improve the shell utility so it doesn't have to open vim, it just calls the python functions.\n- (crazy idea) Have something that recognizes what variables you are dealing with, tries to guess which ones to use in the dumped code, then does a search and replace. This could be so you can just rapid fire dump code without thinking much. It wouldn't be a negative, as you likely have to replace some variables manually anyway. The initial implementation could do simple things, such as seeing if you are inside a loop, then taking the looped over variable, and maybe replacing the most common variable in the pasted text with your looped one... But again, this is a crazy idea.\n\n## Other\n\nThis is the custom search engine that GSO uses: https://cse.google.com/cse/publicurl?cx=003962226882031433174:qk7rs-ca-bi\n\nCurrently, it searches the stackoverflow, superuser, tex, and unix forums.\n\nSE: \"NExeVkJzlom8ZUagXLcHQA((\"\n\nGOOGLE: \"AIzaSyAk7sxnY_yHAP2OIdSOrgf9JysO8E_xJRo\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMilesCranmer%2Fgso","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMilesCranmer%2Fgso","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMilesCranmer%2Fgso/lists"}