╭──────────────╮
│ ⚜ l.nvim ⚜ │
│ ━━━━━━━━━ │
╰──────────────╯
l.nvim is a Neovim plugin that integrates large language models (LLMs) into your editing workflow.
Stability warning: Development is currently when I feel like it. I try not to break master
but user beware.
- Chat with LLMs directly from your editor
- Execute shell commands and add their output to the prompt
- Add files from your repo into your chat automatically.
- Built-in project-level chat logging, system prompt.
- LSP aware replacement. select the chat codeblock, activate the binding, choose where to replace functions in your file.
(Read the entire README for details, there's a lot of stuff in here)
I use lazy.nvim. It's pretty straightforward if you want defaults, see customization if you want overrides.
New: You need nvim-treesitter
for the LSP replacement to work. Don't forget to :TSInstall <lang>
for your language's grammar. Currently only works for Zig, more languages by request or as I get to them.
{
"baketnk/l.nvim",
dependencies = {
"nvim-treesitter"
},
opts = {}
}
You can configure l.nvim by passing options to the setup function:
require('lnvim').setup({
keymap_prefix = "<Leader>;",
open_drawer_on_setup = true,
})
models
: A list of model configurations to use instead of the default models.additional_models
: A list of additional model configurations to append to the default models.autocomplete
: Configuration for autocomplete settings, including:max_tokens
: Maximum number of tokens for autocomplete.temperature
: Temperature setting for autocomplete.
autocomplete_model
: Configuration for the autocomplete model. (WIP)wtf_model
: The model to use for the "wtf" functionality. (WIP)default_prompt_path
: Path to the default system prompt file. (default:~/.local/share/lnvim
)keymap_prefix
: Prefix for keybindings (default is<Leader>;
).llm_log_path
: Path to store LLM logs. (defaults to./.lnvim/logs
)open_drawer_on_setup
: Boolean to determine if the plugin layout should be opened on setup.
You can either override this list with opts.models
or just add additional models with opts.additional_models
.
{
model_id = "hermes3", -- passed directly to the backend
model_type = "openaicompat", -- anthropic, openaicompat
api_url = "http://localhost:11434/v1/chat/completions", -- specify the exact URL, not just /v1
api_key = "PROVIDER_API_KEY", -- name of key/token env var
noauth = false, -- set to true to disable token usage (e.g. local)
use_toolcalling = false, -- WIP
},
-
YankCodeBlock
- Keybinding:
<Leader>;y
- Description: Yank code block.
- Keybinding:
-
SetSystemPrompt
- Keybinding:
<Leader>;s
- Description: Set system prompt.
- Keybinding:
-
SetPromptFile
- Keybinding:
<Leader>;f
- Description: Select prompt files.
- Keybinding:
-
SetAllFiles
- Keybinding:
<Leader>;F
- Description: Select hidden/ignored files for prompt.
- Keybinding:
-
LspIntrospect
- Keybinding:
<Leader>;/
- Description: LSP Introspection.
- Keybinding:
-
Next
- Keybinding:
<Leader>;j
- Description: Next code block.
- Keybinding:
-
Prev
- Keybinding:
<Leader>;k
- Description: Previous code block.
- Keybinding:
-
OpenClose
- Keybinding:
<Leader>;;
- Description: Toggle drawer.
- Keybinding:
-
LLMChat
- Keybinding:
<Leader>;l
- Description: Chat with LLM. (submits current chat)
- Keybinding:
-
ReplaceFile
- Keybinding:
<Leader>;r
- Description: Replace entire file with code.
- Keybinding:
-
SmartReplaceCodeblock
- Keybinding:
<Leader>;R
- Description: Smart replace code block.
- Keybinding:
-
SelectToPrompt
- Keybinding:
<Leader>;p
(in visual mode) - Description: Copy selection to end of prompt.
- Keybinding:
-
SelectToPromptWrap
- Keybinding:
<Leader>;P
(in visual mode) - Description: Copy selection to end of prompt in codeblock.
- Keybinding:
-
SelectModel
- Keybinding:
<Leader>;m
- Description: Select LLM model.
- Keybinding:
-
ClearAllBuffers
- Keybinding:
<Leader>;dg
- Description: Clear chat & file buffers.
- Keybinding:
-
ClearDiffBuffer
- Keybinding:
<Leader>;dd
- Description: Clear chat buffer.
- Keybinding:
-
ClearFilesList
- Keybinding:
<Leader>;df
- Description: Clear files buffer.
- Keybinding:
-
FocusMain
- Keybinding:
<Leader>;i
- Description: Focus main window.
- Keybinding:
-
ToggleToolUsage
- Keybinding:
<Leader>;t
- Description: Toggle tool usage. (WIP)
- Keybinding:
-
ShellToPrompt
- Keybinding:
<Leader>;p
- Description: Run shell command and add output to prompt.
- Keybinding:
-
ApplyDiff
- Keybinding:
<Leader>;a
- Description: Apply diff to buffer. (WIP/Broken)
- Keybinding:
-
StreamSelected
- Keybinding:
<Leader>;w
(in visual mode) - Description: Stream selected text through qask. (WIP/Undocumented)
- Keybinding:
CacheOnlyFiles
- Keybinding:
<Leader>;c
- Description: Select files to be cached but not included in prompts. Useful for maintaining context without cluttering the chat.
- Keybinding:
The following commands are available for plugin development and debugging:
-
DevToggleDebug
- Keybinding:
<Leader>;ud
- Description: Toggle developer debug logging mode.
- Keybinding:
-
DevOpenLogs
- Keybinding:
<Leader>;ul
- Description: Open the developer debug logs in a split window.
- Keybinding:
-
DevClearLogs
- Keybinding:
<Leader>;uc
- Description: Clear the developer debug logs.
- Keybinding:
-
DumpSymbols
- Keybinding:
<Leader>;uS
- Description: Dump LSP symbols from current buffer to debug buffer. Useful for debugging LSP integration.
- Keybinding:
Contributions are welcome, feel free to submit issues or PRs.
MIT