--- source https://boltlessengineer.github.io/posts/neovim-config-without-plugins/ --- ---@param trigger string trigger string for snippet ---@param body string snippet text that will be expanded ---@param opts? vim.keymap.set.Opts --- ---Refer to ---for the specification of valid body. function vim.snippet.add( trigger, body, opts ) vim.keymap.set( 'ia', trigger, function () -- If abbrev is expanded with keys like "(", ")", "", "", -- don't expand the snippet. Only accept "" as trigger key. local c = vim.fn.nr2char( vim.fn.getchar( 0 ) ) if c ~= '' then vim.api.nvim_feedkeys( trigger .. c, 'i', true ) return end vim.snippet.expand( body ) end, opts ) end