Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
notomo committed Sep 18, 2024
1 parent f26022a commit 8a62db3
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 7 deletions.
11 changes: 11 additions & 0 deletions lua/cmdbuf/core/buffer.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
local _buffers = {}

--- @class CmdbufHandler
--- @field parse fun(self:CmdbufHandler,line:string)
--- @field histories fun(self:CmdbufHandler)
--- @field cmdline fun(self:CmdbufHandler,line:string)
--- @field add_history fun(self:CmdbufHandler,line:string)
--- @field delete_histories fun(self:CmdbufHandler,lines:string[])
--- @field execute fun(self:CmdbufHandler,line:string)
--- @field filetype string

--- @class CmdbufBuffer
--- @field private _bufnr integer
--- @field private _handler CmdbufHandler
local Buffer = {}
Buffer.__index = Buffer

Expand Down
2 changes: 2 additions & 0 deletions lua/cmdbuf/core/window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ local _windows = {}

--- @class CmdbufWindow
--- @field private _buffer CmdbufBuffer
--- @field private _window_id integer
--- @field private _origin_window_id integer
local Window = {}
Window.__index = Window

Expand Down
4 changes: 3 additions & 1 deletion lua/cmdbuf/handler/lua/cmd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ function M.delete_histories(_, lines)
end

function M.execute(self, line)
local ok, msg = pcall(vim.cmd, self._lua(line))
local ok, msg = pcall(function()
vim.cmd(self._lua(line))
end)
if not ok then
messagelib.user_vim_error(msg)
return
Expand Down
6 changes: 4 additions & 2 deletions lua/cmdbuf/handler/lua/variable/buffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ local parse = function(cmd)
return nil
end
local line = cmd:sub(e + 1)
local splitted = vim.split(line, "%s*=%s*", false)
local splitted = vim.split(line, "%s*=%s*", { plain = false })
if #splitted < 2 then
return nil
end
Expand Down Expand Up @@ -78,7 +78,9 @@ function M.delete_histories(self, lines)
end

function M.execute(self, line)
local ok, msg = pcall(vim.cmd, self._lua(line))
local ok, msg = pcall(function()
vim.cmd(self._lua(line))
end)
if not ok then
messagelib.user_vim_error(msg)
return
Expand Down
6 changes: 4 additions & 2 deletions lua/cmdbuf/handler/lua/variable/global.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ local parse = function(cmd)
return nil
end
local line = cmd:sub(e + 1)
local splitted = vim.split(line, "%s*=%s*", false)
local splitted = vim.split(line, "%s*=%s*", { plain = false })
if #splitted < 2 then
return nil
end
Expand Down Expand Up @@ -71,7 +71,9 @@ function M.delete_histories(self, lines)
end

function M.execute(self, line)
local ok, msg = pcall(vim.cmd, self._lua(line))
local ok, msg = pcall(function()
vim.cmd(self._lua(line))
end)
if not ok then
messagelib.user_vim_error(msg)
return
Expand Down
4 changes: 3 additions & 1 deletion lua/cmdbuf/handler/vim/cmd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ function M.delete_histories(_, lines)
end

function M.execute(_, line)
local ok, result = pcall(vim.cmd, line)
local ok, result = pcall(function()
vim.cmd(line)
end)
if not ok then
messagelib.user_vim_error(result)
return
Expand Down
2 changes: 1 addition & 1 deletion lua/cmdbuf/test/helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function helper.search(pattern)
if result == 0 then
local info = debug.getinfo(2)
local pos = ("%s:%d"):format(info.source, info.currentline)
local lines = table.concat(vim.fn.getbufline("%", 1, "$"), "\n")
local lines = table.concat(vim.api.nvim_buf_get_lines(0, 0, -1, false), "\n")
local msg = ("on %s: `%s` not found in buffer:\n%s"):format(pos, pattern, lines)
assert(false, msg)
end
Expand Down

0 comments on commit 8a62db3

Please sign in to comment.