Building a VSCode Extension: Part Two

Search for a command to run...

Hey man, this series is amazing and you're covering every step you do, from installations to docs! Great work. Keep this going💎💯
Sabarish Rajamohan Thank you for the kind words!
I just want to share my experience and how I am learning. It might not be the most efficient way of building the project but it has been fun so far.
Nice! I am glad I could help.
I will be documenting my journey as I slowly implement a vscode extension. Things covering - The planning - How I implement the features. - The struggles and challenges I will come across. - and more
Now that I have a blank VS Code extension set up and working, I want to start building on it. Adding some Code formatting configs The Yeoman template for VS Code Extension does not have any formatting configs that I typically use for my projects. I m...
Have you ever wondered how to set a hotkey to focus an input field in your React application? Follow along to learn how. We'll even handle showing different hotkeys based on whether the user is on a Mac or Windows system. Implementation const SearchI...

As a software engineer, choosing and understanding your text editor is important part of your work, as it impacts your productivity and workflow efficiency. It's like choosing the perfect tool for any trade - you need to know what tool to use and how...

Design systems are essential tools for software engineers as they provide a structured framework for maintaining consistency and coherence in product design. By offering clear guidelines and standards, design systems streamline the development proces...

Let's Build our own real-time page view tracker using Next.js as the frontend framework and a Postgres database hosted by Supabase. One of the best ways to understand how your blog posts are performing is by tracking page views. You can begin to unde...

One of the best ways to drive traffic to your website is to have strong Search Engine Optimization (SEO). You can provide search engines with all the URLs for your website using a Sitemap. This allows for easier indexing and more efficient crawling b...

Now that I have an idea of what I am going to build, It's time to set up the repository.
VSCode has a straightforward method for bootstrapping a new extension.
The prerequisites for developing an extension is having Node.js and Git installed on your machine.
If you need to install Node, I recommend using NVM if you are on Linux or macOS and NVM-windows for windows.
Disclaimer: I develop on Linux, so I will be using those commands.
Install NVM using
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
Restart your terminal then install node using
# Current LTS version while writing this is v12
nvm install 12
# I recommend setting this version as default
nvm alias default 12
Now that node is installed to the latest LTS, it's time to bootstrap the extension repository.
Navigate to wherever you want to create the repository. For me, it's in a folder called workspace
cd ~/workspace
VSCode offers a Yeoman template to generate a basic extension.
Install the required NPM packages globally for Yeoman and the VS Code Extension template. After its installed, you can run the generator.
# Install the npm packages globally
npm install -g yo generator-code
# Running the generator
yo code
# ? What type of extension do you want to create? New Extension (TypeScript)
# ? What's the name of your extension?
### Press <Enter> to choose default for all options below ###
# ? What's the identifier of your extension?
# ? What's the description of your extension?
# ? Initialize a git repository? Yes
# ? Which package manager to use? yarn
I decided to use yarn because I normally use NPM but I wanted to try something new.
Since I am hosting the code on GitHub, I create a new empty repository there. Then I linked my GitHub repository with my local one.
cd vscode-todo-task-manager/
git remote add origin git@github.com:CodeByCorey/vscode-todo-task-manager.git
git commit -am 'initialize extension'
git push -u origin master
Now that the repository is set up, time to run it locally.
# Since I am already in the project directory
code .
# the . means it will open the current directory in vscode
Once VScode is open, press F5 to compile and run the extension.
To verify it is running, hit (ctrl+shift+p) and run the hello world command.
Now that I have the base project running, I need to start reading the API Docs to figure out how to start implementing the task manager.
I might also look at some open-source extensions to see how they implement specific features. I tend to learn a lot from reading open-source projects.