pwntester / octo.nvim

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

Error executing vim.schedule lua .... octo.nvim/lua/octo/ui/colors.lua:189: attempt to index local 'rgb_hex #429

Closed simanga-dev closed 8 months ago

simanga-dev commented 9 months ago

Issue Description

when I open a Octo buffer I get this error, includeing on telescope

Error executing vim.schedule lua callback: .../.local/share/nvim/lazy/octo.nvim/lua/octo/ui/colors.lua:189: attempt to index local 'rgb_hex' (a nil value)
stack traceback:
        .../.local/share/nvim/lazy/octo.nvim/lua/octo/ui/colors.lua:189: in function 'create_highlight'
        ....local/share/nvim/lazy/octo.nvim/lua/octo/ui/bubbles.lua:23: in function 'make_user_bubble'
        ....local/share/nvim/lazy/octo.nvim/lua/octo/ui/writers.lua:264: in function 'write_details'
        ...lazy/octo.nvim/lua/octo/pickers/telescope/previewers.lua:42: in function 'cb'
        ...ry/.local/share/nvim/lazy/octo.nvim/lua/octo/gh/init.lua:119: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

Describe what you expected to happen

I expected not to see errors on opening Octo buffers

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

  1. Open Neovim
  2. Run :Octo pr list press enter to any pull request
  3. When You open that buffer, You will see an error.

Tell us your environment

OS: Arch linux

NVIM v0.10.0-dev-1338+gebe489d8f-dirty
Build type: Release
LuaJIT 2.1.1696795921
Run "nvim -V1 -v" for more info

Anything else we need to know?

I build my own neovim, so I am running the latest neovim.

I check the code, it appers to be this line, and it complain that that vim.api.nvim_get_hl_by_name(highlight_group_name, true) is deprecated

function M.get_background_color_of_highlight_group(highlight_group_name)
  local highlight_group = vim.api.nvim_get_hl_by_name(highlight_group_name, true)
  local highlight_group_normal = vim.api.nvim_get_hl_by_name("Normal", true)
  local background_color = highlight_group.background or highlight_group_normal.background
  if background_color then
    return string.format("#%06x", background_color)
  end
end
pwntester commented 9 months ago

Thanks for reporting the issue, can you check if https://github.com/pwntester/octo.nvim/pull/433 fixes the issue for you?

simanga-dev commented 8 months ago

Thank you for your response. I attempted to switch to that branch, but the problem still persists. I will try launching a clean neovim instance with only the Octo plugin installed to determine if another plugin that I installed is causing the issue.

pwntester commented 8 months ago

Thanks, In that PR, I will just updating to the newest API. Will take a look and see why you get the Nil value. What are your highlight groups for:

I think the problem is that get_background_color_of_highlight_group is not returning a default color if background_color cannot be determined, but I would like to know why its not determined in your case

simanga-dev commented 8 months ago

The only highlight group I have is the normal one, I don't have the other two. I have alter with my highlight group to make my neovim transparent

vim.cmd([[
    se stl:— fcs=stl:─,stlnc:—

    hi LineNrAbove guifg=#665c54
    hi LineNr guifg=#fd8019
    hi LineNrBelow guifg=#665c54

    hi Cursorline guibg=#665c54

    hi FoldColumn guibg=NONE
    " hi GitSignsAdd guibg=NONE
    " hi GitSignsChange guibg=NONE
    " hi GitSignsDelete guibg=NONE

    hi SignColumn guibg=NONE ctermbg=NONE
    hi Folded guibg=NONE ctermbg=NONE
    hi NormalFloat guibg=NONE ctermbg=NONE
    hi FloatBorder guibg=NONE ctermbg=NONE

    hi WinSeparator guibg=NONE ctermbg=NONE
    hi WinBar guibg=NONE ctermbg=NONE
    hi WinBarNC guibg=NONE ctermbg=NONE

    hi Normal guibg=NONE ctermbg=NONE
    hi PMenuSel guibg=#665c54 ctermbg=NONE guifg=#fd8019
    hi PMenu guibg=NONE ctermbg=NONE
    hi PMenuSBar guibg=NONE  ctermbg=NONE
    hi PMenuThumb guibg=NONE ctermbg=NONE
    hi WildMenu guibg=NONE ctermbg=NONE
    hi VertSplit ctermbg=NONE guibg=NONE

    hi StatusLine gui=NONE guifg=#665c54 guibg=NONE
    hi StatusLineNC gui=NONE guifg=#665c54 guibg=NONE

    " hi Search guifg=#665c54 guibg=white

    hi TabLineFill guifg=NONE guibg=NONE
    hi TabLine guifg=#665c54  guibg=NONE
    hi TabLineSel guifg=#fd8019 guibg=NONE

    hi GitSignsAdd guifg=#b8bb26 guibg=NONE
    hi GitSignsDelete guifg=#fb4934 guibg=NONE
    hi GitSignsChange guifg=#8ec07c guibg=NONE
    hi DiagnosticSign guibg=NONE

    " hi IncSearch gui=NONE guifg=#82a597 guibg=#504945
    " hi CurSearch gui=NONE guifg=#504945 guibg=#82a597

    " autocmd InsertEnter * set cul
    " autocmd InsertLeave * set nocul
    set exrc
    set secure

]])
pwntester commented 8 months ago

Please try the PR again, it should be fixed

simanga-dev commented 8 months ago

I am very happy as I write this comment inside neovim using the Octo plugins. The error appears to be fixed on this branch fix_429.