Closed zuygui closed 1 year ago
for have commits like that : docs: :memo: update readme
Hi, gitmoji is unfortunately not part of the conventional commits spec.
I'm inviting you to test other plugins which could be ok for your use case:
Thx you a lot, but gitmojis have to be in conventionnal commit but optionnaly. Thanks you for these links. Have a nice day !
@zuygui If you still need gitmojis with conventional commits I created this keymap using both extensions: gitmoji and cc.
local function create_conventional_commit(opts)
opts = opts or {}
local pickers = require('telescope.pickers')
local actions_state = require('telescope.actions.state')
local finders = require('telescope.finders')
local conf = require('telescope.config').values
local cc_actions = require('telescope._extensions.conventional_commits.actions')
local cc_types = require('telescope._extensions.conventional_commits.types')
local frecency = require('telescope._extensions.gitmoji.frecency')
pickers
.new(opts, {
prompt_title = 'Conventional Commits',
finder = finders.new_table({
results = cc_types,
entry_maker = function(cc_entry)
return {
value = cc_entry.value,
display = string.format('%-10s %s', cc_entry.value, cc_entry.description),
ordinal = cc_entry.value,
}
end,
}),
sorter = conf.generic_sorter(opts),
attach_mappings = function(cc_prompt_bufnr, cc_map)
actions.select_default:replace(function()
local cc_type = actions_state.get_selected_entry()
actions.close(cc_prompt_bufnr)
pickers
.new(opts, {
prompt_title = 'Gitmojis',
finder = finders.new_dynamic({
fn = function()
return frecency:get_sorted_emojis()
end,
entry_maker = function(gm_entry)
return {
value = gm_entry,
display = gm_entry.value .. ' ' .. gm_entry.description,
ordinal = gm_entry.description,
}
end,
}),
sorter = conf.generic_sorter(opts),
attach_mappings = function(gm_prompt_bufnr, gm_map)
actions.select_default:replace(function()
local gm = actions_state.get_selected_entry()
local emoji = gm.value.value
actions.close(gm_prompt_bufnr)
-- Execute gm action
frecency:record(emoji)
-- Execute cc action
local inputs = {}
vim.ui.input({ prompt = 'Is there a scope ? (optional) ' }, function(scope)
inputs['scope'] = scope
vim.ui.input({ prompt = 'Enter commit message: ' }, function(msg)
if not msg then
return
end
inputs['msg'] = emoji .. ' ' .. msg
cc_actions.commit(cc_type.value, inputs)
end)
end)
end)
return true
end,
})
:find()
end)
return true
end,
})
:find()
end
vim.keymap.set('n', 'cc', create_conventional_commit, { desc = 'Create conventional commit' })
Thanks a lot bro
Please add (optionnaly) gitmojis, https://gitmoji.dev/