octo.nvim icon indicating copy to clipboard operation
octo.nvim copied to clipboard

Completion not working

Open lopi-py opened this issue 3 years ago • 15 comments

Issue Description

Type: bug report

Describe what happened (or what feature you want)

Completion seems to not work image

Describe what you expected to happen

I expect to have completion showing, I can't remember all subcommands (just installed)

How to reproduce it (as minimally and precisely as possible)

  1. have a completion plugin like nvim-cmp
  2. enter cmdline
  3. type Octo iss

Tell us your environment

I don't think this is related but I had issues with other plugins in the past by this: OS: Windows

Anything else we need to know?

Completion works on other plugins image Also when I enter a wrong command, nothing happens, would be nice to have a warning o error for this(vim.notify)

lopi-py avatar Oct 16 '22 22:10 lopi-py

I cant reproduce the issue, If I enter :Octo <tab> then I got this

image

Not sure if your OS is related with the issue, but unfortunately I dont have any windows machines to test this out on.

Also when I enter a wrong command, nothing happens, would be nice to have a warning o error for this(vim.notify)

That is a good point, will show an error

pwntester avatar Oct 17 '22 07:10 pwntester

Also when I enter a wrong command, nothing happens, would be nice to have a warning o error for this(vim.notify)

This should be fixed, now, please let me know otherwise

pwntester avatar Oct 17 '22 10:10 pwntester

Strange, I'll investigate later image

lopi-py avatar Oct 17 '22 11:10 lopi-py

This should be fixed, now, please let me know otherwise

Yeah it is thanks, I feel the message a little long

lopi-py avatar Oct 17 '22 11:10 lopi-py

Yeah it is thanks, I feel the message a little long

Yep you are right, too many actions. I shorted it a bit

pwntester avatar Oct 17 '22 13:10 pwntester

If it helps, command completion is handled here: https://github.com/pwntester/octo.nvim/blob/master/lua/octo/commands.lua#L15-L17

pwntester avatar Oct 17 '22 13:10 pwntester

I was testing and seems like { complete = require("octo.completion.")... } callback isn't being called, maybe its a neovim stuff, I'm running nightly(NVIM v0.9.0-dev-77-gf175ca9f7)

lopi-py avatar Oct 18 '22 03:10 lopi-py

Weird, just tried with NVIM v0.9.0-dev-bd7ca10 and it works for me? Does it work if you create you own command with your own completion function?

pwntester avatar Oct 18 '22 08:10 pwntester

I found something very odd, may look like a joke but image it just works if I change the command name in https://github.com/pwntester/octo.nvim/blob/5191478678356c9f1de9a4135bab6756f51dcb30/lua/octo/commands.lua#L15

lopi-py avatar Oct 18 '22 18:10 lopi-py

That is odd indeed, I have done a little refactor of the completion function. Not sure if it will fix your issue, but please give it a try and let me know if it works for you.

pwntester avatar Oct 18 '22 20:10 pwntester

Not sure if it will fix your issue, but please give it a try and let me know if it works for you.

I tried, even if I use another complete callback for Octo command, doesn't get called

~~I think I've found the reason, seems related to cmp-cmdline~~, check https://gyazo.com/c2601f1c2a2c42814627f551cb80a4af try the minimal config:

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

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

local package_root = join_paths(vim.env.TEMP or "/tmp", "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")

vim.o.runtimepath = vim.env.VIMRUNTIME
vim.o.packpath = vim.fs.dirname(package_root)

local function load_plugins()
  require("packer").startup {
    {
      "wbthomason/packer.nvim",
      -- plugins here
      "nvim-lua/plenary.nvim",
      "nvim-telescope/telescope.nvim",
      "pwntester/octo.nvim",
      "hrsh7th/nvim-cmp",
      "hrsh7th/cmp-cmdline",
    },
    config = {
      package_root = package_root,
      compile_path = compile_path,
    },
  }
  require("packer").sync()
end

local function load_config()
  -- config here
  require("octo").setup {}

  require("cmp").setup {
    snippet = function() end,
  }

  require("cmp").setup.cmdline(":", {
    sources = {
      { name = "cmdline" },
    },
  })
end

if vim.fn.isdirectory(install_path) == 0 then
 vim.fn.system { "git", "clone", "https://github.com/wbthomason/packer.nvim", install_path }
 load_plugins()
 vim.api.nvim_create_autocmd("User", {
   pattern = "PackerComplete",
   callback = load_config,
   once = true,
 })
else
   load_plugins()
   load_config()
end

Steps to reproduce

  • nvim -u minimal.lua
  • enter cmdline mode and type :Octo is

Completion wont work but if you trigger only :Octo and press tab, it will show proper completions, can you confirm please?

lopi-py avatar Oct 18 '22 22:10 lopi-py

Ah, again seems like changing the command name just works image this is very very odd

lopi-py avatar Oct 18 '22 22:10 lopi-py

Still works for me with your minimal conf. Both entering Octo is<tab> and Octo <tab>

Recording 2022-10-19 at 09 05 39

However, as you can see in the video, cmp-cmdline is showing some options (eg: starting with r) where none of them are and Octo options, and iterating through them with <tab> gives me the real Octo commands that starts with r

pwntester avatar Oct 19 '22 07:10 pwntester

Do you have a non-windows machine to test that out?

pwntester avatar Oct 19 '22 07:10 pwntester

Do you have a non-windows machine to test that out?

no :(

However, as you can see in the video, cmp-cmdline is showing some options (eg: starting with r) where none of them are and Octo options, and iterating through them with <tab> gives me the real Octo commands that starts with r

This is what I experience, it should show real completions even if you type :Octo is(wihout pressing tab), this is done if you change locally the octo command with something like Oct, which is weird

lopi-py avatar Oct 19 '22 18:10 lopi-py

This seems to be a cmp-cmdline bug since, if you remove that part of your minimal.lua config, the completion works as expected. But yep, this is really weird, chaning the command to Octa makes it work as expected so Im wondering what that plugin is doing that can be affected by the name of the command 🤔

pwntester avatar Oct 21 '22 08:10 pwntester

Well, I haven't touched my config for a good time, I just switched to lazy.nvim (package manager) and seems to work fine. To be honest, I have no idea what happened lol. Thanks for taking the time to respond to this joke-look issue @pwntester image

lopi-py avatar Aug 07 '23 03:08 lopi-py