Supercharge your Neovim experience with AI-powered text completion!
- 🧠 AI-powered text completion using customizable LLM models
- ⚡ Lightning-fast suggestions with multi-beam search
- 🎨 Sleek, non-intrusive UI that respects your Neovim setup
- 🛠 Highly configurable to fit your workflow
- 📚 Context-aware completions that understand your code
- 💾 Persistent storage for your custom prompts and settings
Using packer.nvim
use {
'maldevide/llm-beamer.nvim',
requires = {
'nvim-lua/plenary.nvim' -- Required for HTTP requests
},
config = function()
require('llm_beamer').setup({
-- Your configuration here (see Configuration section)
})
end
}
Using lazy.nvim
{
'maldevide/llm-beamer.nvim',
dependencies = {
'nvim-lua/plenary.nvim'
},
config = function()
require('llm_beamer').setup({
-- Your configuration here (see Configuration section)
})
end
}
LLM Beamer comes with sensible defaults, but you can customize it to your heart's content. Here's a full configuration with all available options:
require('llm_beamer').setup({
api_url = "http://your-api-url:5000/v1/chat/completions",
api_key = "your-api-key", -- Consider using an environment variable for security
model = "gpt-3.5-turbo", -- or any other model supported by your API
num_words = 5,
num_beams = 4,
num_preceding_lines = 10,
context_window_width = 200,
max_tokens = 48,
system_prompt = "Continue the story from where the user leaves off; continue the story, adding new content.",
debounce_ms = 100,
temperature = 0.85,
top_p = 1,
status_update_interval_ms = 100,
fold_at = 5,
debug = false
})
api_url
: The URL of your LLM API endpointapi_key
: Your API key for authenticationmodel
: The name of the LLM model to usenum_words
: Number of words to generate in each suggestionnum_beams
: Number of alternative suggestions to generatenum_preceding_lines
: Number of lines before the cursor to use as contextcontext_window_width
: Width of the suggestion windowmax_tokens
: Maximum number of tokens to generatesystem_prompt
: The initial prompt to set the context for the LLMdebounce_ms
: Debounce time in milliseconds for API requeststemperature
: Controls randomness in generation (0.0 to 1.0)top_p
: Controls diversity via nucleus sampling (0.0 to 1.0)status_update_interval_ms
: Interval for updating the status windowfold_at
: Line number to fold the context atdebug
: Enable debug logging
LLM Beamer integrates seamlessly into your Neovim workflow. Here are the default keybindings:
<S-Tab>
in insert mode: Activate LLM Beamer<leader>bi
in normal mode: Open info windows<Enter>
in suggestion window: Select suggestionr
in suggestion window: Reroll suggestions<Esc>
in any LLM Beamer window: Close window<leader>bh
in normal mode: Show help window<leader>bs
in normal mode: Save LLM Beamer buffers<leader>bl
in normal mode: Load LLM Beamer buffers
:LLMBeamer
: Set up or reconfigure LLM Beamer:LLMBeamerSave
: Save the contents of LLM Beamer buffers:LLMBeamerLoad
: Load the contents of LLM Beamer buffers
- When you activate LLM Beamer, it captures the context around your cursor.
- This context is sent to the configured LLM API.
- The API generates multiple suggestions based on the context.
- LLM Beamer displays these suggestions in a sleek, non-intrusive window.
- You can select a suggestion to insert it into your text, or reroll for new suggestions.
You can customize the keybindings in your Neovim configuration:
vim.api.nvim_set_keymap('i', '<C-Space>', [[<Cmd>lua require('llm_beamer').handle_activation()<CR>]], {noremap = true, silent = true})
vim.api.nvim_set_keymap('n', '<leader>lb', [[<Cmd>lua require('llm_beamer').create_or_focus_windows()<CR>]], {noremap = true, silent = true})
You can customize the system prompt to tailor the LLM's behavior to your needs:
require('llm_beamer').setup({
system_prompt = "You are an expert programmer. Complete the code with best practices and optimizations.",
})
If you encounter any issues:
- Enable debug mode in the configuration.
- Check the Neovim error messages (
:messages
). - Ensure your API key and URL are correct.
- Verify your internet connection.
If the problem persists, please open an issue on our GitHub repository with the debug log and a description of the problem.
We welcome contributions! Please see our CONTRIBUTING.md for details on how to submit pull requests, report issues, or request features.
LLM Beamer is released under the MIT License. See the LICENSE file for more details.
- Thanks to the Neovim team for creating an amazing text editor.
- Shoutout to the creators of plenary.nvim for their HTTP request library.
- And of course, a big thank you to the LLM community for pushing the boundaries of what's possible with AI.
Enjoy supercharging your Neovim experience with LLM Beamer! If you find it helpful, consider giving us a star on GitHub. Happy coding! 🚀✨