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

Bug: do not get completions anymore for issues and mentions #53

Open
chrisgrieser opened this issue Mar 2, 2023 · 17 comments
Open

Bug: do not get completions anymore for issues and mentions #53

chrisgrieser opened this issue Mar 2, 2023 · 17 comments

Comments

@chrisgrieser
Copy link

I haven't used the plugin in a while, but it seems that for some reason it stopped working for me, I don't get any completions anymore. Completions for commits ( : ) work, but not for mentions or issues ( # and @ ).

Given that at least on the surface level it looks like my previous problem ( #47 ), I already checked and confirmed the following:

  • pwd is set correctly
  • :CmpStatus correctly lists git as a ready source
  • filetype is correctly set to gitcommit
  • :lua print(require("cmp_git.utils").is_git_repo()) reports true
  • [I enabled cmp_git for the lua filetype](I enabled cmp_git for the lua filetype), and the same thing happens here.
  • I am still using the minimal config as before:
cmp.setup.filetype("gitcommit", {
	sources = cmp.config.sources {
		{name = "git"},
	},
})
require("cmp_git").setup()
@petertriho
Copy link
Owner

Is the repo hosted on gitlab or github?

@chrisgrieser
Copy link
Author

github

@rafamadriz
Copy link

Same problem here, adding minimal config to reproduce:

local on_windows = vim.loop.os_uname().version:match "Windows"

local function join_paths(...)
    local path_sep = on_windows and "\\" or "/"
    local result = table.concat({ ... }, path_sep)
    return result
end

vim.cmd [[set runtimepath=$VIMRUNTIME]]

local temp_dir = vim.loop.os_getenv "TEMP" or "/tmp"

vim.cmd("set packpath=" .. join_paths(temp_dir, "nvim", "site"))

local package_root = join_paths(temp_dir, "nvim", "site", "pack")
local install_path = join_paths(package_root, "packer", "start", "packer.nvim")
local compile_path = join_paths(install_path, "plugin", "packer_compiled.lua")

local function load_plugins()
    require("packer").startup {
        {
            "wbthomason/packer.nvim",
            "hrsh7th/nvim-cmp",
            { "petertriho/cmp-git", requires = "nvim-lua/plenary.nvim" },
        },
        config = {
            package_root = package_root,
            compile_path = compile_path,
        },
    }
end

_G.load_config = function()
    local cmp = require "cmp"

    cmp.setup {
        snippet = {
            expand = function(args) require("luasnip").lsp_expand(args.body) end,
        },
        mapping = cmp.mapping.preset.insert {
            ["<C-b>"] = cmp.mapping.scroll_docs(-4),
            ["<C-f>"] = cmp.mapping.scroll_docs(4),
            ["<C-Space>"] = cmp.mapping.complete(),
            ["<C-e>"] = cmp.mapping.abort(),
            ["<CR>"] = cmp.mapping.confirm { select = true },
        },
    }

    require("cmp_git").setup()
    cmp.setup.filetype("gitcommit", {
        sources = cmp.config.sources {
            { name = "git" }, -- You can specify the `cmp_git` source if you were installed it.
        },
    })
end

if vim.fn.isdirectory(install_path) == 0 then
    vim.fn.system { "git", "clone", "https://github.com/wbthomason/packer.nvim", install_path }
    load_plugins()
    require("packer").sync()
    vim.cmd [[autocmd User PackerComplete ++once lua load_config()]]
else
    load_plugins()
    require("packer").sync()
    _G.load_config()
end

@Curs3W4ll
Copy link
Contributor

Hi !

That's an amazing plugin! Thanks for your work.

But I have the same issue, only commits works, PR, issues, and mentions do nothing.

I used gh CLI and though I wrongly configured it so I tried token in env var but it did not work too.

@cseickel
Copy link

cseickel commented Aug 6, 2023

I have the same problem but only for the octo filetype. It works fine when editing a commit message. I also tried adding "*" to the filetypes and everything worked correctly in a lua file but still not in an octo buffer.

For me at least, this is purely an issue with the octo filetype.

@dpetka2001
Copy link

I also have problem with octo regarding mentions, issues, PRs etc. But you can use <C-x><C-o> omnifunc completion that octo provides to get around this problem.

@vitorf7
Copy link

vitorf7 commented Oct 5, 2023

I am having the same problem and I don't believe the cmp-git is even available and for some reason when I try to do ctrl + x I am not getting any octo completion either.

@dpetka2001
Copy link

Do you by any chance have <c-x> mapped to anything else?

@vitorf7
Copy link

vitorf7 commented Oct 5, 2023

I don't believe I do, however after looking at the octo documentation I saw that there was a section on how to add the onmifunc auto complete and it said to add this:

vim.keymap.set("i", "@", "@<C-x><C-o>", { silent = true, buffer = true })
vim.keymap.set("i", "#", "#<C-x><C-o>", { silent = true, buffer = true })

After I did that it started working.
Off course the end goal will be to get cmp-git to actually be loaded with octo files and get it to auto complete but as you said for now it is a workaround.

@dpetka2001
Copy link

Strange I didn't need to add these keymaps to my configuration. It just worked out of the box. Anyway, glad you solved this.

@dpetka2001
Copy link

Oh you said in your first post that you only do <c-x> for autocompletion. You should do <c-x><c-o>. First Ctrl-x and then Ctrl-o.

@vitorf7
Copy link

vitorf7 commented Oct 5, 2023

Oh 🤦‍♂️ Yeah this is what happens when you I don't pay attention and also am a noob at this

@GitMurf
Copy link
Contributor

GitMurf commented Dec 28, 2023

Has anyone figured this out? I am having the same issues.

GitMurf added a commit to GitMurf/cmp-git that referenced this issue Dec 29, 2023
- Seems to be caused by the Octo filetype
- See petertriho#53
GitMurf added a commit to GitMurf/cmp-git that referenced this issue Dec 29, 2023
Finally figured out the source of the problem. This commit 7b292e1 was pushed to account for GH Enterprise but Octo default settings leaves this blank. This fix accounts for that as well.

ref: petertriho#53
@GitMurf
Copy link
Contributor

GitMurf commented Dec 29, 2023

cc @chrisgrieser @vitorf7 @petertriho @dpetka2001 @cseickel @Curs3W4ll @rafamadriz

This should fix it. Can use my fork (https://github.com/GitMurf/cmp-git) until the PR gets merged: #61

petertriho pushed a commit that referenced this issue Dec 29, 2023
- Seems to be caused by the Octo filetype
- See #53
petertriho pushed a commit that referenced this issue Dec 29, 2023
Finally figured out the source of the problem. This commit 7b292e1 was pushed to account for GH Enterprise but Octo default settings leaves this blank. This fix accounts for that as well.

ref: #53
@petertriho
Copy link
Owner

Not sure if this will fix all the issues so I'll keep this open.

@GitMurf
Copy link
Contributor

GitMurf commented Dec 29, 2023

Another thing to note is that even with this fix above, I had an issue on another machine when I changed the default shell to powershell (instead of CMD). When i flipped it back to using cmd.exe as my default nvim terminal shell then it worked. In case any Windows users are still having problems.

rafamadriz added a commit to rafamadriz/dotfiles that referenced this issue Apr 27, 2024
Issues and mentions completion haven't work in a while
petertriho/cmp-git#53
@classabbyamp
Copy link

do any of you happen to have CLICOLOR_FORCE in your env? I had that set so tree would be coloured, but it seems gh also interprets that and that messes up this plugin's parsing of gh output

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

9 participants