Skip to content

Commit d545414

Browse files
committed
1 parent 828b2aa commit d545414

File tree

2 files changed

+44
-27
lines changed

2 files changed

+44
-27
lines changed

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Jokes aside, I could not find a plugin that fulfills my wish for both telescope
3030

3131
- Automatic updates of available emojis via GitHub actions ([emojis-api.com](https://emoji-api.com/) as source).
3232
- No dependencies (relies on `vim.ui.select`).
33+
- (Optional) [fzf-lua](https://github.com/ibhagwan/fzf-lua) integration with `require("fzf-lua").register_ui_select()` (register fzf-lua as the UI interface for vim.ui.select)
3334
- (Optional) [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) integration (emojis only).
3435
- (Optional) [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) integration (emojis only).
3536

@@ -40,7 +41,7 @@ Jokes aside, I could not find a plugin that fulfills my wish for both telescope
4041
4142
[![ui.png](https://s9.gifyu.com/images/SFndT.png)](https://gifyu.com/image/SFndT)
4243
43-
Please note that I use [dressing.nvim](https://github.com/stevearc/dressing.nvim) so your UI might look different!
44+
Please note that I use [dressing.nvim](https://github.com/stevearc/dressing.nvim) in this picture so your UI might look different!
4445
4546
</details>
4647

@@ -83,6 +84,8 @@ With [Lazy.nvim](https://github.com/folke/lazy.nvim):
8384
"hrsh7th/nvim-cmp",
8485
-- optional for telescope integration
8586
"nvim-telescope/telescope.nvim",
87+
-- optional for fzf-lua integration via vim.ui.select
88+
"ibhagwan/fzf-lua",
8689
},
8790
opts = {
8891
-- default is false
@@ -121,17 +124,19 @@ require("telescope").load_extension("emoji")
121124

122125
### Emojis
123126

124-
1. `:EmojiInsert` respective `lua require("emoji").insert()` or `:EmojiInsertByGroup` respective `lua require("emoji").insert_by_group()` allows you to select an emoji that is inserted at your cursor's current position.
125-
2. `:Telescope emoji` does the same but invokes Telescope instead of `vim.ui.select`. (if telescope.nvim is installed).
127+
1. `:Emoji` and `:Emoji insert` respective `lua require("emoji").insert()` or `:Emoji by-group` respective `lua require("emoji").insert_by_group()` allows you to select an emoji that is inserted at your cursor's current position.
128+
2. `:Telescope emoji` does the same but invokes Telescope instead of `vim.ui.select`. (if telescope.nvim is installed and the extension loaded).
126129
3. While in insert mode typing `:` triggers the auto-completion of nvim-cmp. (if nvim-cmp integration is enabled and configured).
127130

128131
### Kaomojis
129132

130-
1. `:KaomojiInsert` respective `lua require("emoji").insert_kaomoji()`
131-
2. `:KaomojiInsertByGroup` respective `lua require("emoji").insert_kaomoji_by_group()`
133+
1. `:Emoji kaomoji` respective `lua require("emoji").insert_kaomoji()`
134+
2. `:Emoji kaomoji-by-group` respective `lua require("emoji").insert_kaomoji_by_group()`
132135

133136
You can also create key bindings to your liking.
134137

138+
Auto-completion in command mode is supported.
139+
135140
## 💡 Similar plugins and inspiration
136141

137142
- [cmp-emoji](https://github.com/hrsh7th/cmp-emoji)

plugin/emoji.lua

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
1-
vim.api.nvim_create_user_command("EmojiInsert", function()
2-
require("emoji").insert()
3-
end, {
4-
desc = "Insert an Emoji at the cursor's current position",
5-
nargs = 0,
6-
})
1+
local utils = require("emoji.utils")
72

8-
vim.api.nvim_create_user_command("EmojiInsertByGroup", function()
9-
require("emoji").insert_by_group()
10-
end, {
11-
desc = "Insert an Emoji, filtered by group, at the cursor's current position",
12-
nargs = 0,
13-
})
3+
vim.api.nvim_create_user_command("Emoji", function(opts)
4+
if #opts.fargs == 0 then
5+
require("emoji").insert()
6+
return
7+
end
148

15-
vim.api.nvim_create_user_command("KaomojiInsert", function()
16-
require("emoji").insert_kaomoji()
17-
end, {
18-
desc = "Insert a Kaomoji at the cursor's current position",
19-
nargs = 0,
20-
})
9+
local subcommand = opts.fargs[1]
2110

22-
vim.api.nvim_create_user_command("KaomojiInsertByGroup", function()
23-
require("emoji").insert_kaomoji_by_group()
11+
if subcommand == "insert" then
12+
require("emoji").insert()
13+
elseif subcommand == "by-group" then
14+
require("emoji").insert_by_group()
15+
elseif subcommand == "kaomoji" then
16+
require("emoji").insert_kaomoji()
17+
elseif subcommand == "kaomoji-by-group" then
18+
require("emoji").insert_kaomoji_by_group()
19+
else
20+
utils.error("Unknown subcommand: " .. subcommand)
21+
end
2422
end, {
25-
desc = "Insert an Kaomoji, filtered by group, at the cursor's current position",
26-
nargs = 0,
23+
nargs = "*",
24+
complete = function(argLead)
25+
local subcommands = {
26+
"insert",
27+
"by-group",
28+
"kaomoji",
29+
"kaomoji-by-group",
30+
}
31+
32+
local filtered = vim.tbl_filter(function(option)
33+
return vim.startswith(option, argLead)
34+
end, subcommands)
35+
36+
return filtered
37+
end,
38+
desc = "Emoji.nvim",
2739
})

0 commit comments

Comments
 (0)