Skip to content

disrupted/blink-cmp-conventional-commits

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

blink-cmp-conventional-commits

Conventional Commits source for blink.cmp completion plugin.

It provides the different types of conventional commits when writing a new Git commit message. Mainly because I am just starting to adopt conventional commits and can never remember the commonly used types.

screenshot showing completion in gitcommit buffer

Installation

example using Lazy plugin manager

{
    'saghen/blink.cmp',
    dependencies = {
        { 'disrupted/blink-cmp-conventional-commits' },
    },
    opts = {
        sources = {
            default = {
                'conventional_commits', -- add it to the list
                'lsp',
                'buffer',
                'path',
            },
            providers = {
                conventional_commits = {
                    name = 'Conventional Commits',
                    module = 'blink-cmp-conventional-commits',
                    enabled = function()
                        return vim.bo.filetype == 'gitcommit'
                    end,
                    ---@module 'blink-cmp-conventional-commits'
                    ---@type blink-cmp-conventional-commits.Options
                    opts = {
                        -- See Configuration section below for available options
                    },
                },
            },
        },
    },
}

Scope Completion

The plugin automatically discovers scopes used in the repository by scanning recent non-merge commits. When you type feat( or any other type followed by an opening parenthesis, completions for previously used scopes will appear.

Scopes are discovered at plugin load time from git log. The number of commits to scan can be configured via git_log_count (default: 200):

opts = {
    git_log_count = 500, -- scan last 500 non-merge commits for scopes
}

To disable scope completion entirely:

opts = {
    scopes = false,
}

Configuration

The plugin provides several configuration options to customize the conventional commit types:

Default Behavior

By default, the plugin provides the following conventional commit types:

  • feat - A new feature for the user
  • fix - A bug fix for the user
  • docs - Documentation changes
  • style - Changes that do not affect the meaning of the code (white-space, formatting, etc.)
  • refactor - A code change that neither fixes a bug nor adds a feature
  • perf - A code change that improves performance
  • test - Adding missing tests or correcting existing tests
  • chore - Changes to the build process or auxiliary tools and libraries
  • ci - Changes to CI/CD pipelines
  • revert - Reverts a specific commit

Options

opts = {
    completion = {
        -- Add custom commit types (will be merged with defaults)
        items = {
            { type = 'custom', doc = 'My custom commit type' },
        },
        -- Set to false to disable default types and only use your custom ones
        use_defaults = true, -- default: true
    },
}

Examples

Extending Defaults

Add your own custom types while keeping the defaults:

opts = {
    completion = {
        items = {
            { type = 'wip', doc = 'Work in progress' },
            { type = 'build', doc = 'Changes to build system' },
        },
    },
}

Overriding Defaults

Override specific default types with your own descriptions:

opts = {
    completion = {
        items = {
            { type = 'feat', doc = 'A new feature (customized description)' },
            { type = 'fix', doc = 'A bug fix (customized description)' },
        },
    },
}

Using Only Custom Types

Disable all defaults and provide your own complete set:

opts = {
    completion = {
        use_defaults = false,
        items = {
            { type = 'add', doc = 'Add new functionality' },
            { type = 'change', doc = 'Change existing functionality' },
            { type = 'remove', doc = 'Remove functionality' },
            { type = 'fix', doc = 'Fix a bug' },
        },
    },
}

About

Conventional Commits source for blink.cmp

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages