diff --git a/nvim/lua/plugins/autocompletion.lua b/nvim/lua/plugins/autocompletion.lua index 28b6ed85..bd2942bf 100644 --- a/nvim/lua/plugins/autocompletion.lua +++ b/nvim/lua/plugins/autocompletion.lua @@ -160,9 +160,11 @@ return { }, }) + require('user.cmp-nvim.gitcommit') cmp.setup.filetype('gitcommit', { sources = cmp.config.sources({ { name = 'git' }, + { name = 'gitcommit' }, }, { { name = 'buffer' }, }), diff --git a/nvim/lua/user/cmp-nvim/gitcommit.lua b/nvim/lua/user/cmp-nvim/gitcommit.lua new file mode 100644 index 00000000..8f9a9196 --- /dev/null +++ b/nvim/lua/user/cmp-nvim/gitcommit.lua @@ -0,0 +1,63 @@ +local cc = { + { + label = 'build', + documentation = 'Changes that affect the build system or external dependencies', + }, + { + label = 'chore', + documentation = 'Other changes that dont modify src or test files', + }, + { + label = 'ci', + documentation = 'Changes to our CI configuration files and scripts', + }, + { + label = 'docs', + documentation = 'Documentation only changes', + }, + { + label = 'feat', + documentation = 'A new feature', + }, + { + label = 'fix', + documentation = 'A bug fix', + }, + { + label = 'perf', + documentation = 'A code change that improves performance', + }, + { + label = 'refactor', + documentation = 'A code change that neither fixes a bug nor adds a feature', + }, + { + label = 'style', + documentation = 'Changes that do not affect the meaning of the code', + }, + { + label = 'test', + documentation = 'Adding missing tests or correcting existing tests', + }, +} + +local items = {} +for k, v in ipairs(cc) do + items[k] = { + label = v.label, + kind = require('cmp').lsp.CompletionItemKind.Keyword, + documentation = v.documentation, + } +end + +local source = {} + +function source:is_available() + return vim.bo.filetype == 'gitcommit' +end + +function source:complete(request, callback) + callback(items) +end + +require('cmp').register_source('gitcommit', source)