Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to use a different filetype than "gitcommit" #5

Open
Terseus opened this issue Jun 10, 2024 · 1 comment
Open

Allow to use a different filetype than "gitcommit" #5

Terseus opened this issue Jun 10, 2024 · 1 comment

Comments

@Terseus
Copy link

Terseus commented Jun 10, 2024

Right now the source is hard coded to work only with the filetype gitcommit, here:

function source:is_available() return vim.bo.filetype == "gitcommit" end

This prevents to use this plugin source with other filetypes, which for example the one used by Neogit in its commit window, which is "NeogitCommitMessage".

Given that it's the user who has to configure the source using cmp.setup.filetype using nvim-cmp API I see no reason to lock it to a given filetype.

Please correct me if I'm wrong.

@lemarsu
Copy link

lemarsu commented Jun 11, 2024

I was facing the same issue, no completion in Neogit commit buffers.

Until this is fixed, I made this very hackish workaround.

Add this to your config:

local source = require('cmp-conventionalcommits')
function source:is_available()
  return vim.list_contains({'gitcommit', 'NeogitCommitMessage'}, 'gitcommit')
end

And then, in after/ftplugin/NeogitCommitMessage.lua, copy the content of gitcommit.lua:

if vim.g.cmp_conventionalcommits_source_id ~= nil then
    require('cmp').unregister_source(vim.g.cmp_conventionalcommits_source_id)
end
vim.g.cmp_conventionalcommits_source_id = require('cmp').register_source('conventionalcommits', require('cmp-conventionalcommits').new())

It's hackish as hell, but well, it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants