echasnovski / mini.nvim

Library of 40+ independent Lua modules improving overall Neovim (version 0.8 and higher) experience with minimal effort
MIT License
4.47k stars 175 forks source link

mini.git: completion hangs and option completion does not work on MacOS #918

Closed aikow closed 1 month ago

aikow commented 1 month ago

Contributing guidelines

Module(s)

mini.git

Description

This is a 2 fold problem, and was originally discussed in the beta testing thread for the mini.git module.

The first issue is that the completion hangs, and eventually times out. This is because I have the MANPAGER environment variable set to nvim +Man!, although I would assume similar behavior for other slightly more obscure pagers. This can easily be fixed by overriding the MANPAGER environment variable in the envs table that is passed to H.cli_run. I've copied your code snippet here for completeness’s sake.

  local command = { MiniGit.config.job.git_executable, '--no-pager', unpack(args) }
  local custom_env = { NO_COLOR = 1, PAGER = 'cat', MANPAGER = 'cat' }
  local environ = vim.tbl_deep_extend('force', vim.loop.os_environ(), custom_env)
  local env = {}
  for k, v in pairs(environ) do
    table.insert(env, string.format('%s=%s', k, tostring(v)))
  end
  local res = H.cli_run(command, cwd, nil, { env = env }).out

Once the first issue was fixed, the second issue that arose is what you explained in this comment.

Those x\bx (and possible _\bx) is an "old" way to format character as bold (and italic). The origin of this on Mac seems to be groff / grotty / or something like that. It seems to still try to format it with these symbols.

The behavior this results in using the current (main branch) implementation of `mini.git is that regular completion of subcommands and git objects, like branches and tags works fine, but completion for options is broken.

I just tried your git-completion-man branch and that fixes the issue. I can now get completions on MacOS.

Neovim version

v0.11.0-dev+g0e9c92a90

Steps to reproduce

minimal.lua can theoretically be empty, it just needs to add mini.git as a module.

  1. MANPAGER='nvim +Man!' nvim -nu minimal.lua
  2. Type :Git -
  3. Neovim hangs and eventually completion times out

Or

  1. MANPAGER=cat nvim -nu minimal.lua
  2. Type :Git -
  3. No completion for options are shown

Expected behavior

See completions for options

Actual behavior

Current main branch just hangs until it times out. This is due to my custom MANPAGER environment variable. Without that, it still doesn't show completions for options, due to the way MacOS formats man pages, causing the section headers to be formatted in a way that the parsing logic for options inside mini.git can't pick up.

aikow commented 1 month ago

if I need to clarify or test anything else, just let me know :) and thanks again for your time and help!

echasnovski commented 1 month ago

Thank you so much for this!

I just tried your git-completion-man branch and that fixes the issue. I can now get completions on MacOS.

This also makes me happy :) I'll try to finalize this into main tomorrow.

echasnovski commented 1 month ago

This now should be fixed on latest main.

Thanks for your time and trying to make 'mini.git' a better module!