Repository navigation
Expand file tree
/
Copy pathopencode.txt
More file actions
211 lines (171 loc) · 8.5 KB
/
Copy pathopencode.txt
File metadata and controls
211 lines (171 loc) · 8.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
*opencode.txt* Seamless integration between Opencode AI and Neovim
==============================================================================
CONTENTS *opencode-contents*
1. Introduction .......................... |opencode-introduction|
2. Installation .......................... |opencode-installation|
3. Usage ................................ |opencode-usage|
4. Configuration ........................ |opencode-configuration|
5. Commands ............................. |opencode-commands|
6. Mappings ............................. |opencode-mappings|
7. Contributing ......................... |opencode-contributing|
8. License .............................. |opencode-license|
==============================================================================
1. INTRODUCTION *opencode-introduction*
Opencode is a plugin that provides seamless integration between the Opencode
Code AI assistant (command-line tool) and Neovim. It allows you to:
- Toggle Opencode in a terminal window at the bottom of your Neovim screen
- Automatically detect and reload files modified by Opencode
- Keep your Neovim buffers in sync with any changes made by Opencode
NOTE: This plugin requires the official Opencode CLI tool to be installed
and available in your system's PATH.
==============================================================================
2. INSTALLATION *opencode-installation*
Install using your favorite plugin manager:
Using lazy.nvim:
>lua
return {
"AuenKr/open-code.nvim",
dependencies = {
"nvim-lua/plenary.nvim", -- Required for git operations
},
config = function()
require("opencode").setup()
end
}
<
Using vim-plug:
>vim
Plug 'nvim-lua/plenary.nvim'
Plug 'AuenKr/open-code.nvim'
" After installing, add this to your init.vim:
" lua require('opencode').setup()
<
Using packer.nvim:
>lua
use {
'AuenKr/open-code.nvim',
requires = {
'nvim-lua/plenary.nvim', -- Required for git operations
},
config = function()
require('opencode').setup()
end
}
<
PREREQUISITES:
- Neovim 0.7.0 or later
- Opencode CLI tool (https://github.com/anthropics/opencode)
- plenary.nvim plugin (https://github.com/nvim-lua/plenary.nvim) for git operations
==============================================================================
3. USAGE *opencode-usage*
- Use the `:Opencode` command to toggle the Opencode terminal window
- Press <leader>ac in normal mode to toggle Opencode terminal window
- Press <C-o> in the terminal to close the Opencode window
- When Opencode modifies files that are open in Neovim, they'll be
automatically reloaded
- When in a git repository, Opencode will automatically use the git root
directory as its working directory using pushd/popd commands (configurable)
==============================================================================
4. CONFIGURATION *opencode-configuration*
Configure the plugin by passing a table to the setup function. Below is the
default configuration:
>lua
require("opencode").setup({
-- Terminal window settings
window = {
split_ratio = 0.3, -- Percentage of screen for the terminal window (height or width)
position = "botright", -- Position of the window: "botright", "topleft", "vertical"/"vsplit", "float", etc.
enter_insert = true, -- Whether to enter insert mode when opening Opencode
start_in_normal_mode = false, -- Whether to start in normal mode instead of insert mode
hide_numbers = true, -- Hide line numbers in the terminal window
hide_signcolumn = true, -- Hide the sign column in the terminal window
-- Floating window configuration (only applies when position = "float")
float = {
width = "80%", -- Width: number of columns or percentage string
height = "80%", -- Height: number of rows or percentage string
row = "center", -- Row position: number, "center", or percentage string
col = "center", -- Column position: number, "center", or percentage string
relative = "editor", -- Relative to: "editor" or "cursor"
border = "rounded", -- Border style: "none", "single", "double", "rounded", "solid", "shadow"
},
},
-- File refresh settings
refresh = {
enable = true, -- Enable file change detection
updatetime = 100, -- updatetime when Opencode is active (milliseconds)
timer_interval = 1000, -- How often to check for file changes (milliseconds)
show_notifications = true, -- Show notification when files are reloaded
},
-- Git project settings
git = {
use_git_root = true, -- Set CWD to git root when opening Opencode (if in git project)
},
-- Command settings
command = "opencode", -- Command used to launch Opencode (do not include --cwd)
-- Command variants
command_variants = {
-- Conversation management
continue = "--continue", -- Resume the most recent conversation
resume = "--resume", -- Display an interactive conversation picker
-- Output options
verbose = "--verbose", -- Enable verbose logging with full turn-by-turn output
},
-- Keymaps
keymaps = {
toggle = {
normal = "<leader>a", -- Normal mode keymap for toggling Opencode
terminal = "<C-o>", -- Terminal mode keymap for toggling Opencode
variants = {
-- variants are disabled by default
-- continue = "<leader>aC", -- Normal mode keymap for Opencode with continue flag
-- verbose = "<leader>aV", -- Normal mode keymap for Opencode with verbose flag
},
}
}
})
<
==============================================================================
5. COMMANDS *opencode-commands*
:Opencode *:Opencode*
Toggle the Opencode terminal window.
:OpencodeRestart *:OpencodeRestart*
Restart the Opencode session (delete buffer and start new).
Conversation Management Commands:
:OpencodeContinue *:OpencodeContinue*
Toggle Opencode with the --continue flag to resume the most recent conversation.
:OpencodeResume *:OpencodeResume*
Toggle Opencode with the --resume flag to display an interactive conversation picker.
Output Options Commands:
:OpencodeVerbose *:OpencodeVerbose*
Toggle Opencode with the --verbose flag for full turn-by-turn output.
Note: Commands are automatically generated for each entry in your command_variants configuration.
==============================================================================
6. MAPPINGS *opencode-mappings*
Default key mappings:
<leader>a Toggle Opencode terminal window (normal mode)
<leader>A Start a new Opencode session (restart)
<leader>a (Visual mode) Add selected text to Opencode context
<C-o> Toggle Opencode terminal window (terminal mode)
<Esc><Esc> Exit terminal mode to normal mode
Variant mode mappings (if configured):
<leader>aC Toggle Opencode with --continue flag
<leader>aV Toggle Opencode with --verbose flag
Additionally, when in the Opencode terminal:
<C-h> Move to the window on the left
<C-j> Move to the window below
<C-k> Move to the window above
<C-l> Move to the window on the right
<C-f> Scroll full-page down
<C-b> Scroll full-page up
Note: After scrolling with <C-f> or <C-b>, you'll need to press the 'i' key
to re-enter insert mode so you can continue typing to Opencode.
You can customize these mappings in the configuration.
==============================================================================
7. CONTRIBUTING *opencode-contributing*
Contributions to Opencode are welcome! If you would like to contribute,
please check the CONTRIBUTING.md file in the repository for guidelines:
https://github.com/AuenKr/open-code.nvim/blob/main/CONTRIBUTING.md
==============================================================================
8. LICENSE *opencode-license*
MIT License
vim:tw=78:ts=8:ft=help:norl: