pwntester / octo.nvim

Edit and review GitHub issues and pull requests from the comfort of your favorite editor
MIT License
2.28k stars 125 forks source link

Completion not working #337

Closed lopi-py closed 12 months ago

lopi-py commented 1 year ago

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)

pwntester commented 1 year ago

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 commented 1 year ago

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

lopi-py commented 1 year ago

Strange, I'll investigate later image

lopi-py commented 1 year ago

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

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

pwntester commented 1 year ago

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

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

pwntester commented 1 year ago

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

lopi-py commented 1 year ago

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)

pwntester commented 1 year ago

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?

lopi-py commented 1 year ago

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

pwntester commented 1 year ago

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.

lopi-py commented 1 year ago

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

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

lopi-py commented 1 year ago

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

pwntester commented 1 year ago

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 commented 1 year ago

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

lopi-py commented 1 year ago

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

pwntester commented 1 year ago

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 🤔

lopi-py commented 12 months ago

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