Giter VIP home page Giter VIP logo

Comments (5)

zuygui avatar zuygui commented on June 4, 2024 1

Thanks a lot bro

from telescope-cc.nvim.

zuygui avatar zuygui commented on June 4, 2024

for have commits like that : docs: :memo: update readme

from telescope-cc.nvim.

olacin avatar olacin commented on June 4, 2024

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:

from telescope-cc.nvim.

zuygui avatar zuygui commented on June 4, 2024

Thx you a lot, but gitmojis have to be in conventionnal commit but optionnaly. Thanks you for these links. Have a nice day !

from telescope-cc.nvim.

cscovino avatar cscovino commented on June 4, 2024

@zuygui If you still need gitmojis with conventional commits I created this keymap using both extensions: gitmoji and cc.

  1. Select the commit type
  2. Select the emoji
  3. Type scope (optional)
  4. Type commit message
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' })

from telescope-cc.nvim.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.