https://github.com/olacin/telescope-gitmoji.nvim
A Telescope integration of gitmoji.
https://github.com/olacin/telescope-gitmoji.nvim
gitmoji neovim telescope
Last synced: 3 months ago
JSON representation
A Telescope integration of gitmoji.
- Host: GitHub
- URL: https://github.com/olacin/telescope-gitmoji.nvim
- Owner: olacin
- License: mit
- Created: 2021-11-17T23:16:24.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-04-07T17:24:50.000Z (about 2 years ago)
- Last Synced: 2024-04-07T18:31:58.891Z (about 2 years ago)
- Topics: gitmoji, neovim, telescope
- Language: Lua
- Homepage:
- Size: 21.5 KB
- Stars: 12
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# telescope-gitmoji.nvim
A Telescope integration of [gitmoji](https://gitmoji.dev/).
## Installation
```lua
-- lazy
{
"olacin/telescope-gitmoji.nvim",
config = function()
require("telescope").load_extension("gitmoji")
end,
dependencies = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" }
}
-- vim-plug
Plug 'olacin/telescope-gitmoji.nvim'
-- packer
use 'olacin/telescope-gitmoji.nvim'
```
## Usage
```
# As a command
:Telescope gitmoji
# As a lua function
require('telescope').extensions.gitmoji.gitmoji()
```
## Configuration
You can customize action on selection within Telescope `setup()` function.
```lua
telescope.setup({
...
extensions = {
gitmoji = {
action = function(entry)
-- entry = {
-- display = "🐛 Fix a bug.",
-- index = 4,
-- ordinal = "Fix a bug.",
-- value = {
-- description = "Fix a bug.",
-- text = ":bug:",
-- value = "🐛"
-- }
-- }
local emoji = entry.value.value
vim.ui.input({ prompt = "Enter commit message: " .. emoji .. " "}, function(msg)
if not msg then
return
end
-- Insert text instead of emoji in message
local emoji_text = entry.value.text
vim.cmd(':G commit -m "' .. emoji_text .. ' ' .. msg .. '"')
end)
end,
},
},
})
telescope.load_extension("gitmoji")
```
### Default action
```lua
-- Default action (here with tpope vim-fugitive)
gm_actions.commit = function(entry)
local emoji = entry.value.value
vim.ui.input({ prompt = "Enter commit message: " .. emoji .. " " }, function(msg)
if not msg then
return
end
local git_tool = ":!git"
if vim.g.loaded_fugitive then
git_tool = ":G"
end
vim.cmd(string.format('%s commit -m "%s %s"', git_tool, emoji, msg))
end)
end
```