Skip to content

Using Variables

Variables allow you to share data about the current state of Neovim with an LLM. Simply type # in the chat buffer and trigger code completion if you're not using blink.cmp or nvim-cmp. Alternatively, type the variables manually. After the response is sent to the LLM, you should see the variable output tagged as a reference in the chat buffer.

Custom variables can be shared by adding them to the strategies.chat.variables table in your configuration.

#buffer

The #buffer variable shares the full contents from the buffer that the user was last in when they initiated :CodeCompanionChat. To select another buffer, use the /buffer slash command. These buffers can be pinned or watched to enable updated content to be automatically shared with the LLM:

  • #buffer{pin} - To pin the current buffer
  • #buffer{watch} - To watch the current buffer

#lsp

TIP

The Action Palette has a pre-built prompt which asks an LLM to explain LSP diagnostics in a visual selection

The #lsp variable shares any information from the LSP servers that active in the current buffer. This can serve as useful context should you wish to troubleshoot any errors with an LLM.

#viewport

The #viewport variable shares with the LLM, exactly what you see on your screen at the point a response is sent (excluding the chat buffer of course).

Released under the MIT License.