Skip to content

Commit 418bfbb

Browse files
cameronrsudo-tee
authored andcommitted
chore: emmylua_ls diagnostic cleanup
1 parent 0a60114 commit 418bfbb

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

lua/opencode/api_client.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ end
221221

222222
--- Create and send a new message to a session
223223
--- @param id string Session ID (required)
224-
--- @param message_data {messageID?: string, model?: {providerID: string, modelID: string}, agent?: string, system?: string, tools?: table<string, boolean>, parts: Part[]} Message creation data
224+
--- @param message_data {messageID?: string, model?: {providerID: string, modelID: string}, agent?: string, system?: string, tools?: table<string, boolean>, parts: OpencodeMessagePart[]} Message creation data
225225
--- @param directory string|nil Directory path
226226
--- @return Promise<{info: MessageInfo, parts: OpencodeMessagePart[]}>
227227
function OpencodeApiClient:create_message(id, message_data, directory)

lua/opencode/context.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ end
5656
---@param context_key string
5757
---@return boolean
5858
function M.is_context_enabled(context_key)
59-
local is_enabled = vim.tbl_get(config, 'context', context_key, 'enabled')
59+
local is_enabled = vim.tbl_get(config --[[@as table]], 'context', context_key, 'enabled')
6060
local is_state_enabled = vim.tbl_get(state, 'current_context_config', context_key, 'enabled')
6161

6262
if is_state_enabled ~= nil then
@@ -76,7 +76,7 @@ function M.get_diagnostics(buf)
7676
return {}
7777
end
7878

79-
local global_conf = vim.tbl_get(config, 'context', 'diagnostics') or {}
79+
local global_conf = vim.tbl_get(config --[[@as table]], 'context', 'diagnostics') or {}
8080
local diagnostic_conf = vim.tbl_deep_extend('force', global_conf, current_conf) or {}
8181

8282
local severity_levels = {}
@@ -264,7 +264,8 @@ function M.get_current_cursor_data(buf, win)
264264
end
265265

266266
local cursor_pos = vim.fn.getcurpos(win)
267-
local cursor_content = vim.trim(vim.api.nvim_buf_get_lines(buf, cursor_pos[2] - 1, cursor_pos[2], false)[1] or '')
267+
local start_line = (cursor_pos[2] - 1) --[[@as integer]]
268+
local cursor_content = vim.trim(vim.api.nvim_buf_get_lines(buf, start_line, cursor_pos[2], false)[1] or '')
268269
return { line = cursor_pos[2], column = cursor_pos[3], line_content = cursor_content }
269270
end
270271

@@ -384,7 +385,6 @@ end
384385
function M.format_message(prompt, opts)
385386
opts = opts or config.context
386387
local context = M.delta_context(opts)
387-
context.prompt = prompt
388388

389389
local parts = { { type = 'text', text = prompt } }
390390

@@ -430,7 +430,7 @@ end
430430

431431
--- Extracts context from an OpencodeMessage (with parts)
432432
---@param message { parts: OpencodeMessagePart[] }
433-
---@return { prompt: string, selected_text: string|nil, current_file: string|nil, mentioned_files: string[]|nil}
433+
---@return { prompt: string|nil, selected_text: string|nil, current_file: string|nil, mentioned_files: string[]|nil}
434434
function M.extract_from_opencode_message(message)
435435
local ctx = { prompt = nil, selected_text = nil, current_file = nil }
436436

lua/opencode/core.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ end
9999
--- @param prompt string The message prompt to send.
100100
--- @param opts? SendMessageOpts
101101
function M.send_message(prompt, opts)
102+
if not state.active_session or not state.active_session.id then
103+
return false
104+
end
105+
102106
local mentioned_files = context.context.mentioned_files or {}
103107
local allowed, err_msg = util.check_prompt_allowed(config.prompt_guard, mentioned_files)
104108

lua/opencode/types.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125

126126
---@class OpencodeDebugConfig
127127
---@field enabled boolean
128-
---@field capture_streamed_events any[]
128+
---@field capture_streamed_events boolean
129129

130130
--- @class OpencodeProviders
131131
--- @field [string] string[]

0 commit comments

Comments
 (0)