An awesome project to help you spell and grammar better! Pass your code with comments through stdin and receive a corrected version through stdout.
Table of Contents
A command-line tool written in Rust that uses LLM API to correct spelling and grammar in code comments.
This is useful for developers who want to improve their spelling and grammar in their code comments. That can connect to your editor through a plugin or extension, or you can use it as a standalone tool.
The app uses at the moment the OpenAI GPT-4 mini, and only send to the model the comments, avoiding the code, that is important for reducing the cost of the service. I will add more models in the future, and the user will be able to choose the model to use.
You need two simple things to get started, an API key from OpenAI and make sure you have Rust installed in your machine. If you don't have Rust installed, you can install it using rustup.
-
Clone the repo
git clone https://github.com/richardhapb/neospeller.git
-
Execute the installation script (that will request your password to install the binary in /usr/local/bin)
cd neospeller ./install.sh
-
Export the API key as an environment variable:
export OPENAI_API_KEY="your-api-key"
You can use the app in two ways, passing the code through stdin or passing a file as an argument. A needed argument is --lang
that is the language of the comments in the code. The language is used to extract the comments from the code, and the code is not sent to the model.
neospeller --lang python < file.py
neospeller --lang javascript < file.js
or
cat file.py | neospeller --lang python
cat file.js | neospeller --lang javascript
You can redirect the output to a file:
neospeller --lang python < file.py > corrected_file.py
or
cat file.py | neospeller --lang python > corrected_file.py
Also, you can use this neovim plugin to correct the comments in the current buffer: neospeller.nvim
Available languages and their respective codes:
- Python (python)
- Rust (rust)
- Javascript (javascript)
- CSS (css)
- C (c)
- Lua (lua)
- Bash (bash)
- Plain text (text)
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git switch -c feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request