Skip to content

Commit 0a2f3fb

Browse files
Danilo Verde RibeiroDanilo Verde Ribeiro
authored andcommitted
fix(opencode): extend context and types for MCP integration
1 parent a5d89d3 commit 0a2f3fb

3 files changed

Lines changed: 12 additions & 108 deletions

File tree

lua/opencode/config.lua

Lines changed: 7 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,6 @@ M.defaults = {
184184
enabled = false,
185185
limit = 20,
186186
},
187-
cursor_data = {
188-
enabled = false,
189-
limit = 20,
190-
},
191187
cursor_data = {
192188
enabled = true,
193189
},
@@ -207,10 +203,6 @@ M.defaults = {
207203
selection = {
208204
enabled = true,
209205
},
210-
marks = {
211-
enabled = true,
212-
limit = 5,
213-
},
214206
jumplist = {
215207
enabled = true,
216208
limit = 5,
@@ -280,79 +272,8 @@ M.defaults = {
280272
session_duration = {
281273
enabled = false,
282274
},
283-
marks = {
284-
enabled = true,
285-
limit = 5,
286-
},
287-
jumplist = {
288-
enabled = true,
289-
limit = 5,
290-
},
291-
recent_buffers = {
292-
enabled = true,
293-
limit = 3,
294-
symbols_only = true,
295-
},
296-
undo_history = {
297-
enabled = true,
298-
limit = 3,
299-
},
300-
windows_tabs = {
301-
enabled = true,
302-
},
303-
highlights = {
304-
enabled = false,
305-
},
306-
session_info = {
307-
enabled = false,
308-
},
309-
registers = {
310-
enabled = true,
311-
include = { '"', '/', 'q', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '%', '#', '.' },
312-
},
313-
command_history = {
314-
enabled = true,
315-
limit = 3,
316-
},
317-
search_history = {
318-
enabled = true,
319-
limit = 3,
320-
},
321-
debug_data = {
322-
enabled = true,
323-
},
324-
lsp_context = {
325-
enabled = false,
326-
diagnostics_limit = 10,
327-
code_actions = false,
328-
},
329-
git_info = {
330-
enabled = false,
331-
diff_limit = 5,
332-
changes_limit = 5,
333-
},
334-
fold_info = {
335-
enabled = true,
336-
},
337-
cursor_surrounding = {
338-
enabled = true,
339-
lines_above = 4,
340-
lines_below = 4,
341-
},
342-
quickfix_loclist = {
343-
enabled = true,
344-
limit = 5,
345-
},
346-
macros = {
347-
enabled = false,
348-
register = 'q',
349-
},
350-
terminal_buffers = {
351-
enabled = true,
352-
},
353-
session_duration = {
354-
enabled = false,
355-
},
275+
-- Remove duplicate configurations above - keeping only the final instances
276+
-- All configurations below this point are unique and should be kept as-is
356277
vectorcode_snippets = {
357278
enabled = true,
358279
n = 3,
@@ -483,6 +404,11 @@ function M.normalize_keymap(legacy_config, filter_functions)
483404
return converted
484405
end
485406

407+
---@return OpencodeConfig
408+
function M.get()
409+
return M.values
410+
end
411+
486412
---@export Config
487413
return setmetatable(M, {
488414
__index = function(_, key)

lua/opencode/context.lua

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ end
77
local state = require('opencode.state')
88
local context_cache = require('opencode.context_cache')
99
local Promise = require('opencode.promise')
10-
-- local context_mcphub = require('opencode.context_mcphub')
11-
1210

1311
local M = {}
1412

@@ -367,27 +365,10 @@ function M.load()
367365
-- Concurrency: Run independent heavy ops in parallel using multiple defers
368366
-- Parallel group 1: LSP and Git (independent)
369367
vim.defer_fn(function()
370-
-- Use MCPHub for LSP context if enabled
371-
local cfg = get_config()
372-
-- if cfg.context.mcphub.enabled and context_mcphub.is_available() then
373-
-- context_mcphub
374-
-- .get_lsp_diagnostics_mcphub()
375-
-- :and_then(function(result)
376-
-- -- Parse MCPHub diagnostics result and convert to OpenCode format
377-
-- M.context.lsp_context = M.parse_mcphub_diagnostics(result)
378-
-- end)
379-
-- :catch(function(err)
380-
-- if cfg.context.mcphub.fallback_to_native then
381-
-- M.get_lsp_context():and_then(function(result)
382-
-- M.context.lsp_context = result
383-
-- end)
384-
-- end
385-
-- end)
386-
-- else
387-
-- M.get_lsp_context():and_then(function(result)
388-
-- M.context.lsp_context = result
389-
-- end)
390-
-- end
368+
-- Use native LSP context
369+
M.get_lsp_context():and_then(function(result)
370+
M.context.lsp_context = result
371+
end)
391372

392373
M.get_git_info():and_then(function(result)
393374
M.context.git_info = result

lua/opencode/types.lua

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,7 @@
8585
---@field permission_accept_all string
8686
---@field permission_deny string
8787

88-
---@class OpencodeKeymapPermission
89-
---@field accept string
90-
---@field accept_all string
91-
---@field deny string
88+
---@class OpencodeKeymapPermission is already defined above at line 60
9289

9390

9491
---@class OpencodeKeymap

0 commit comments

Comments
 (0)