You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: refactor context system for modularity and quick chat improvements
- Refactored context system to use static modules (ChatContext, QuickChatContext, BaseContext) for better modularity and testability.
- Removed legacy context instance class and JSON/plain-text formatters; now each context type has its own implementation.
- Updated quick chat formatting, increased flexibility for selection and diagnostics context, and improved whitespace-tolerant patching.
- Improved README: clarified quick chat, moved acknowledgements, added links and instructions for prompt guard.
- Enhanced test coverage—especially for flexible whitespace patch application.
This is an experimental feature that allows you to chat with the AI using the current buffer context. In visual mode, it captures the selected text as context, while in normal mode, it uses the current line. The AI will respond with quick edits to the files that are applied by the plugin.
16
+
17
+
Don't hesitate to give it a try and provide feedback!
18
+
19
+
Refer to the [Quick Chat](#-quick-chat) section for more details.
8
20
9
21
<divalign="center">
10
22
<imgsrc="https://i.imgur.com/5JNlFZn.png">
11
23
</div>
12
24
13
-
> neovim frontend for opencode - a terminal-based AI coding agent
This plugin is a fork of the original [goose.nvim](https://github.com/azorng/goose.nvim) plugin by [azorng](https://github.com/azorng/)
26
-
For git history purposes the original code is copied instead of just forked.
27
-
28
33
## ✨ Description
29
34
30
35
This plugin provides a bridge between neovim and the [opencode](https://github.com/sst/opencode) AI agent, creating a chat interface while capturing editor context (current file, selections) to enhance your prompts. It maintains persistent sessions tied to your workspace, allowing for continuous conversations with the AI assistant similar to what tools like Cursor AI offer.
@@ -44,6 +49,8 @@ This plugin provides a bridge between neovim and the [opencode](https://github.c
44
49
-[Agents](#-agents)
45
50
-[User Commands](#user-commands)
46
51
-[Contextual Actions for Snapshots](#-contextual-actions-for-snapshots)
52
+
-[Prompt Guard](#-prompt-guard)
53
+
-[Quick Chat](#-quick-chat)
47
54
-[Setting up opencode](#-setting-up-opencode)
48
55
49
56
## ⚠️Caution
@@ -633,6 +640,21 @@ The plugin defines several highlight groups that can be customized to match your
633
640
634
641
The `prompt_guard` configuration option allows you to control when prompts can be sent to Opencode. This is useful for preventing accidental or unauthorized AI interactions in certain contexts.
635
642
643
+
### Configuration
644
+
645
+
Set `prompt_guard` to a function that returns a boolean:
646
+
647
+
```lua
648
+
require('opencode').setup({
649
+
prompt_guard=function()
650
+
-- Your custom logic here
651
+
-- Return true to allow, false to deny
652
+
returntrue
653
+
end,
654
+
})
655
+
656
+
```
657
+
636
658
## 🪝 Custom user hooks
637
659
638
660
You can define custom functions to be called at specific events in Opencode:
@@ -665,20 +687,6 @@ require('opencode').setup({
665
687
})
666
688
```
667
689
668
-
### Configuration
669
-
670
-
Set `prompt_guard` to a function that returns a boolean:
671
-
672
-
```lua
673
-
require('opencode').setup({
674
-
prompt_guard=function()
675
-
-- Your custom logic here
676
-
-- Return true to allow, false to deny
677
-
returntrue
678
-
end,
679
-
})
680
-
```
681
-
682
690
### Behavior
683
691
684
692
-**Before sending prompts**: The guard is checked before any prompt is sent to the AI. If denied, an ERROR notification is shown and the prompt is not sent.
@@ -691,6 +699,8 @@ require('opencode').setup({
691
699
Quick chat allows you to start a temporary opencode session with context from the current line or selection.
692
700
This is optimized for narrow code edits or insertion. When the request is complex it will and require more context, it is recommended to use the full opencode UI.
693
701
702
+
Due to the narrow context the resulting may be less accurate and edits may sometime fails. For best results, try to keep the request focused and simple.
703
+
694
704
### Starting a quick chat
695
705
696
706
Press `<leader>o/` in normal mode to open a quick chat input window.
@@ -725,3 +735,8 @@ If you're new to opencode:
725
735
3.**Configuration:**
726
736
- Run `opencode auth login` to set up your LLM provider
727
737
- Configure your preferred LLM provider and model in the `~/.config/opencode/config.json` or `~/.config/opencode/opencode.json` file
738
+
739
+
## 🙏 Acknowledgements
740
+
741
+
This plugin is a fork of the original [goose.nvim](https://github.com/azorng/goose.nvim) plugin by [azorng](https://github.com/azorng/)
742
+
For git history purposes the original code is copied instead of just forked.
0 commit comments