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
@@ -636,6 +643,21 @@ The plugin defines several highlight groups that can be customized to match your
636
643
637
644
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.
638
645
646
+
### Configuration
647
+
648
+
Set `prompt_guard` to a function that returns a boolean:
649
+
650
+
```lua
651
+
require('opencode').setup({
652
+
prompt_guard=function()
653
+
-- Your custom logic here
654
+
-- Return true to allow, false to deny
655
+
returntrue
656
+
end,
657
+
})
658
+
659
+
```
660
+
639
661
## 🪝 Custom user hooks
640
662
641
663
You can define custom functions to be called at specific events in Opencode:
@@ -668,20 +690,6 @@ require('opencode').setup({
668
690
})
669
691
```
670
692
671
-
### Configuration
672
-
673
-
Set `prompt_guard` to a function that returns a boolean:
674
-
675
-
```lua
676
-
require('opencode').setup({
677
-
prompt_guard=function()
678
-
-- Your custom logic here
679
-
-- Return true to allow, false to deny
680
-
returntrue
681
-
end,
682
-
})
683
-
```
684
-
685
693
### Behavior
686
694
687
695
-**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.
@@ -694,6 +702,8 @@ require('opencode').setup({
694
702
Quick chat allows you to start a temporary opencode session with context from the current line or selection.
695
703
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.
696
704
705
+
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.
706
+
697
707
### Starting a quick chat
698
708
699
709
Press `<leader>o/` in normal mode to open a quick chat input window.
@@ -728,3 +738,8 @@ If you're new to opencode:
728
738
3.**Configuration:**
729
739
- Run `opencode auth login` to set up your LLM provider
730
740
- Configure your preferred LLM provider and model in the `~/.config/opencode/config.json` or `~/.config/opencode/opencode.json` file
741
+
742
+
## 🙏 Acknowledgements
743
+
744
+
This plugin is a fork of the original [goose.nvim](https://github.com/azorng/goose.nvim) plugin by [azorng](https://github.com/azorng/)
745
+
For git history purposes the original code is copied instead of just forked.
0 commit comments