Skip to content

Instantly share code, notes, and snippets.

@SalahEddineGhamri
Created December 16, 2025 15:02
Show Gist options
  • Select an option

  • Save SalahEddineGhamri/25f8c6872725470f1f5a23b74bfd79c5 to your computer and use it in GitHub Desktop.

Select an option

Save SalahEddineGhamri/25f8c6872725470f1f5a23b74bfd79c5 to your computer and use it in GitHub Desktop.
custom command in neovim with arguments
local function greet_function(opts)
local name = opts.args or "World"
print("Hello, " .. name .. "!")
end
vim.api.nvim_create_user_command('Greet', greet_function, {
nargs = '?', -- Optional argument
desc = "Greet someone" -- Description for :help
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment