Skip to content

Commit 4a44347

Browse files
committed
chore: more emmylua_ls / diag clean up
1 parent 8c0bdc9 commit 4a44347

File tree

5 files changed

+21
-12
lines changed

5 files changed

+21
-12
lines changed

lua/opencode/api_client.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ end
384384
--- Subscribe to events (streaming)
385385
--- @param directory string|nil Directory path
386386
--- @param on_event fun(event: table) Event callback
387-
--- @return Job The streaming job handle
387+
--- @return table The streaming job handle
388388
function OpencodeApiClient:subscribe_to_events(directory, on_event)
389389
self:_ensure_base_url()
390390
local url = self.base_url .. '/event'

lua/opencode/promise.lua

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ function Promise.new()
3030
end
3131

3232
---@generic T
33-
---@param self Promise<T>
3433
---@param value T
3534
---@return Promise<T>
3635
function Promise:resolve(value)
@@ -50,8 +49,7 @@ function Promise:resolve(value)
5049
end
5150

5251
---@generic T
53-
---@param self Promise<T>
54-
---@param error any
52+
---@param err any
5553
---@return self
5654
function Promise:reject(err)
5755
if self._resolved then
@@ -70,7 +68,6 @@ function Promise:reject(err)
7068
end
7169

7270
---@generic T, U
73-
---@param self Promise<T>
7471
---@param callback fun(value: T): U | Promise<U>
7572
---@return Promise<U>
7673
function Promise:and_then(callback)
@@ -116,7 +113,6 @@ function Promise:and_then(callback)
116113
end
117114

118115
---@generic T
119-
---@param self Promise<T>
120116
---@param error_callback fun(err: any): any | Promise<any>
121117
---@return Promise<T>
122118
function Promise:catch(error_callback)
@@ -161,7 +157,6 @@ function Promise:catch(error_callback)
161157
end
162158

163159
---@generic T
164-
---@param self Promise<T>
165160
---@param timeout integer|nil Timeout in milliseconds (default: 5000)
166161
---@param interval integer|nil Interval in milliseconds to check (default: 20)
167162
---@return T

lua/opencode/provider.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ function M._get_models()
44
local config_file = require('opencode.config_file')
55
local response = config_file.get_opencode_providers()
66

7+
if not response then
8+
return {}
9+
end
10+
711
local models = {}
812
for _, provider in ipairs(response.providers) do
913
for _, model in pairs(provider.models) do

lua/opencode/ui/input_window.lua

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function M._build_input_win_config()
1616
col = 2,
1717
style = 'minimal',
1818
zindex = 41,
19-
}
19+
} --[[@as vim.api.keyset.win_config]]
2020
end
2121

2222
function M.create_window(windows)
@@ -41,6 +41,7 @@ function M.close()
4141
if not M.mounted() then
4242
return
4343
end
44+
---@cast state.windows { input_win: integer, input_buf: integer }
4445

4546
pcall(vim.api.nvim_win_close, state.windows.input_win, true)
4647
pcall(vim.api.nvim_buf_delete, state.windows.input_buf, { force = true })
@@ -51,6 +52,8 @@ function M.handle_submit()
5152
if not windows or not M.mounted(windows) then
5253
return
5354
end
55+
---@cast windows { input_buf: integer }
56+
5457
local input_content = table.concat(vim.api.nvim_buf_get_lines(windows.input_buf, 0, -1, false), '\n')
5558
vim.api.nvim_buf_set_lines(windows.input_buf, 0, -1, false, {})
5659
vim.api.nvim_exec_autocmds('TextChanged', {
@@ -177,6 +180,11 @@ function M.recover_input(windows)
177180
end
178181

179182
function M.focus_input()
183+
if not M.mounted() then
184+
return
185+
end
186+
---@cast state.windows { input_win: integer, input_buf: integer }
187+
180188
vim.api.nvim_set_current_win(state.windows.input_win)
181189

182190
local lines = vim.api.nvim_buf_get_lines(state.windows.input_buf, 0, -1, false)
@@ -192,6 +200,7 @@ function M.set_content(text, windows)
192200
if not M.mounted(windows) then
193201
return
194202
end
203+
---@cast windows { input_win: integer, input_buf: integer }
195204

196205
local lines = type(text) == 'table' and text or vim.split(tostring(text), '\n')
197206

@@ -212,6 +221,7 @@ function M.remove_mention(mention_name, windows)
212221
if not M.mounted(windows) then
213222
return
214223
end
224+
---@cast windows { input_buf: integer }
215225

216226
local lines = vim.api.nvim_buf_get_lines(windows.input_buf, 0, -1, false)
217227
for i, line in ipairs(lines) do
@@ -228,12 +238,12 @@ function M.remove_mention(mention_name, windows)
228238
end
229239

230240
function M.is_empty()
231-
local windows = state.windows
232-
if not windows or not M.mounted() then
241+
if not M.mounted() then
233242
return true
234243
end
244+
---@cast state.windows { input_buf: integer }
235245

236-
local lines = vim.api.nvim_buf_get_lines(windows.input_buf, 0, -1, false)
246+
local lines = vim.api.nvim_buf_get_lines(state.windows.input_buf, 0, -1, false)
237247
return #lines == 0 or (#lines == 1 and lines[1] == '')
238248
end
239249

lua/opencode/ui/output.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Output.__index = Output
33

44
---@class Output
55
---@field lines string[]
6-
---@field extmarks table<number, OutputExtmark>
6+
---@field extmarks table<number, OutputExtmark[]>
77
---@field actions OutputAction[]
88
---@field add_line fun(self: Output, line: string, fit?: boolean): number
99
---@field get_line fun(self: Output, idx: number): string?

0 commit comments

Comments
 (0)