Summary
I use a command and it prints a message. When I create a user command that runs the same underlying function, I don't see the message.
Example
The command :Telescope git_status
from the Telescope plugin shows information about git status
. When there are no git changes, it will print the following message:
No changes found
[telescope.builtin.git_status]: No changes found
Press ENTER or type command to continue
I like this message and I want to see it.
Here is my custom user command:
local telescopeBuiltins = require('telescope.builtin')
vim.api.nvim_create_user_command('Gs',
function()
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<ESC>', true, false, true), 'n', false)
return telescopeBuiltins.git_status()
end,
{bang = true}
)
However, when I run :Gs
, I just see nothing on the cmdline. For some reason, the user command is executing "silently" and not showing the error message.
:Telescope git_status
though; what happens if you do that instead?vim.cmd(':Telescope git_status')
instead oftelescopeBuiltins.git_status()
, I get the same result. I should mention that the functionality works fine when there are actual git changes, i.e. I'm successfully calling the correct underlying function.