-
Notifications
You must be signed in to change notification settings - Fork 76
In‐Editor Chatting
LSP-AI provides powerful in-editor chatting capabilities through code actions, allowing you to interact with AI assistants directly within your code editor. This feature enhances your coding experience by providing instant access to AI-powered help and suggestions.
- Configure LSP-AI for in-editor chatting (see Configuration)
- Open a file (maybe a Markdown file) in your supported editor
- Type a chat trigger (e.g.,
!C
) followed by your question - Activate the code action for chatting (e.g., in Helix, press space + a)
- View the AI's response and continue the conversation
For detailed information on configuring in-editor chatting, please refer to the Configuration page.
{
"chat": [
{
"trigger": "!C",
"action_display_name": "Chat",
"model": "model1",
"parameters": {
"max_context": 4096,
"max_tokens": 1024,
"system": "You are a code assistant chatbot. The user will ask you for assistance coding and you will do your best to answer succinctly and accurately"
}
},
{
"trigger": "!CC",
"action_display_name": "Chat with context",
"model": "model1",
"parameters": {
"max_context": 4096,
"max_tokens": 1024,
"system": "You are a code assistant chatbot. The user will ask you for assistance coding and you will do your best to answer succinctly and accurately given the code context:\n\n{CONTEXT}"
}
}
]
}
- LSP-AI detects the chat trigger in your file
- Your editor requests available code actions
- LSP-AI offers the appropriate chat action
- You activate the chat action
- LSP-AI processes the request and returns the AI's response
- The response is inserted into your file
Conversations follow this format:
!C Your question here
<|assistant|>
AI's response here
<|user|>
Your follow-up question here
<|assistant|>
AI's follow-up response here
<|user|>
It is required the LSP-AI is running on the file / buffer to perform the chat action.
You don't have to use Markdown files, but for the Helix editor I have found Markdown is an easy choice for this.
Tip: Create a shortcut to open a dedicated chat file (e.g., lsp-ai-chat.md
) for quick access.
To chat about your codebase, use the !CC
trigger (or your configured equivalent) and ensure you're using a Memory Backend that supports context, such as the VectorStore backend (not the FileStore backend).
For advanced usage and customization of prompts, please read our Prompting page. Note that for chat prompts, we don't recommend using the {CODE}
keyword, as it will refer to the chat itself.
- Issue: Chat actions not appearing Solution: Ensure the trigger is present in the file and LSP-AI is properly configured for your file type
- Issue: Unexpected AI responses Solution: Check your system prompt and consider adjusting it for better results
- Use
space + a
to prompt for code actions - Create a shortcut (e.g.,
Ctrl-t
) to open your chat file quickly
For more information or if you encounter any issues not covered here, please check our GitHub issues or open a new one.