This feature is somewhat similar to Github Copilot's code suggestion. But instead of using AI, it sends your search query to Google, then retrieves StackOverflow and Github Gist answers and autocompletes them for you.
Table of contents:
You can search for "Captain Stack" on the VSCode Extension Marketplace, or use this link to install. Have questions? Join our Discord server
To trigger inline completion, you'll need to type //find {your keyword}.
(start with //find
, end with a dot .
)
For example
//find binary search in javascript.
Make sure Inline Suggest
is enabled
from the VS Code Settings
Check out the installation video: https://youtu.be/MD-kzsF0Scg
To install and starting Captain Stack:
-
Clone this repository to your PC using
git clone https://github.com/hieunc229/copilot-clone.git .
. Please note there is a dot at the end of the command -
Run
npm install
in the terminal to install dependencies -
Now, you can start the extension. From the top menu, choose
Run > Start Debugging
.
This will:
- Start a task
npm: watch
to compile the code and watch for changes - Open a new VSCode window (you should use the extension there)
Note: When you make changes, you should refresh that window to apply changes. To refresh, open Command Palette (Command+Shift+P on MacOS, or Ctrl+Shift+P on Windows), then choose "Developer: Reload window"
There are a few configurations available for Captain Stack. To open the settings page:
- Click on the Cog icon in the bottom left
- Choose Settings
- In the Search settings search box, enter "Captain Stack"
-
sites
allows to enable or disable a source site. By default, onlyStackoverflow
is enabled. -
maxResults
is the maximum number of results. It's12
by default. Note: Since Captain Stack will fetch all the results from a page, the final number of results could be more thanmaxResults
- There are more code sources that should be considered besides StackOverflow
- If you see an
unsupported
error message, ignore it
Limits:
- The extension uses fetch-node to get page content, and I don't know if there is any fetching limit
- The extension uses querySelector to extract code and other info. There is a risk of either StackOverflow or Google changing its querySelector
If those factors became problems, the extension could be using their official APIs instead.
- Jul 02, 2022 — Officially published Captain Stack on the extension marketplace
- Mar 22, 2022 — Added AI Code Validation
- Aug 15, 2021 - Added
sites
andmaxResults
configurations - Jul 31, 2022 — Added GithubGist source
- Jul 31, 2021 — Create code extracting abstracting to add more code sources
- Jul 14, 2021 - Adapted to VS Code Insiders Release Version 1.59
- Jul 01, 2021 - Added snippet source (thanks for mechero's suggestion)
- Jun 30, 2021 - Publish the initial version
- When pressing
Run debugger
, it shows different target options (nodejs, edge, etc.). Your VSCode root directory might be incorrect. Make sure your root directory is the folder in which thepackage.json
file is. - Error message
module "node-fetch" not found...
. You need to runnpm install
. canvas.node
was compiled against a different Node.js. Try to remove canvas (npm uninstall canvas
)
- You haven't enabled the inline completion feature. To enable, set VSCode config
"editor.inlineSuggest.enabled": true
- It might conflict with some other plugins. You might need to disable plugins to check
If none of the above works, open a thread or join our Discord channel and have a chat.
The plugin is available, thanks to:
Feel free to open a thread for feedback or discussion. And have fun!
Love Captain Stack? Check out other things I do: