Skip to content

Commit

Permalink
fix: nil error when trying to invoke some subcommands
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb committed Sep 20, 2024
1 parent 78fdf0c commit e7a5bdb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lua/haskell-tools/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,18 @@ local function register_subcommand_tbl(name, subcmd_tbl)
command_tbl[name] = {
impl = function(args, ...)
local subcmd = subcmd_tbl[table.remove(args, 1)]
subcmd.impl(args, ...)
if subcmd then
subcmd.impl(args, ...)
else
vim.notify(
([[
Haskell %s: Expected subcommand.
Avaiable subcommands:
%s
]]):format(name, table.concat(vim.tbl_keys(subcmd_tbl), ', ')),
vim.log.levels.ERROR
)
end
end,
complete = function(subcmd_arg_lead)
local subcmd, next_arg_lead = subcmd_arg_lead:match('^(%S+)%s(.*)$')
Expand Down

0 comments on commit e7a5bdb

Please sign in to comment.