What's
word?
word is a Neovim plugin that generates sentence-by-sentence rewrites.
How do I set up
word?
-
Make sure you're using a Mac.
-
Install Homebrew.
-
Make sure you're using Alacritty.
-
Make sure you're using
lazy.nvim. -
Open a terminal.
-
Merge these bindings into your Alacritty configuration:
[keyboard] bindings = [ { chars = "\u001bf", key = "F", mods = "Command" }, { chars = "\u001bj", key = "J", mods = "Command" }, { chars = "\u001bk", key = "K", mods = "Command" }, ]
-
Add this block to your
lazy.nvimconfiguration:{ "8ta4/word", build = "./install.sh", dependencies = { "8ta4/sentence", build = "./install.sh", }, keys = { { "<M-f>", function() require('word').suggest() end, mode = {"n", "i", "v"} }, { "<M-j>", function() require('word').apply(2) end, mode = {"n", "i", "v"} }, { "<M-k>", function() require('word').apply(1) end, mode = {"n", "i", "v"} }, }, opts = { styles = { { name = "casual", prompt = "Use a casual tone. Use correct grammar. Check if the sentence meets these requirements. Explain any failures. Give two rewrites of the sentence. Do not rewrite the context." }, }, }, } -
Run the following commands:
brew install node npm install -g neovim nvim --headless +UpdateRemotePlugins +qa! mkdir -p ~/.config/word/
-
Copy an API key from the Cerebras website.
-
Run this command:
pbpaste > ~/.config/word/cerebras
Is the prompt I specify a system prompt or a user prompt?
The prompt is a system prompt.
How do I get suggestions from Normal mode?
Press ⌘ + f. Think fix.
How do I apply the first suggestion from Normal mode?
Press ⌘ + k. Vim uses k for up.
How do I apply the second suggestion from Normal mode?
Press ⌘ + j. Vim uses j for down.
Can I generate suggestions for multiple sentences at once?
Yes. Select the text in Visual mode and press ⌘ + f. You don't even have to select the whole sentence. As long as your selection touches part of a sentence, word rewrites the entire sentence.
Can I add more styles?
Yes.
-
Add the number keybindings to your Alacritty configuration:
[keyboard] bindings = [ { chars = "\u001b1", key = "Key1", mods = "Command" }, { chars = "\u001b2", key = "Key2", mods = "Command" }, { chars = "\u001bf", key = "F", mods = "Command" }, { chars = "\u001bj", key = "J", mods = "Command" }, { chars = "\u001bk", key = "K", mods = "Command" }, ]
-
Add the number keybindings and the second style to your
lazy.nvimconfiguration:local base = " Use correct grammar. Check if the sentence meets these requirements. Explain any failures. Give two rewrites of the sentence. Do not rewrite the context." { "8ta4/word", build = "./install.sh", dependencies = { "8ta4/sentence", build = "./install.sh", }, keys = { { "<M-1>", function() require('word').style(1) end, mode = {"n", "i", "v"} }, { "<M-2>", function() require('word').style(2) end, mode = {"n", "i", "v"} }, { "<M-f>", function() require('word').suggest() end, mode = {"n", "i", "v"} }, { "<M-j>", function() require('word').apply(2) end, mode = {"n", "i", "v"} }, { "<M-k>", function() require('word').apply(1) end, mode = {"n", "i", "v"} }, }, opts = { styles = { { name = "casual", prompt = "Use a casual tone." .. base }, { name = "formal", prompt = "Use a formal tone." .. base }, }, }, }
How do I select the second style in the configuration?
Press ⌘ + 2. It picks the second entry in your styles list.