shellRaining / hlchunk.nvim

This is the lua implementation of nvim-hlchunk, you can use this neovim plugin to highlight your indent line and the current chunk (context) your cursor stayed
MIT License
472 stars 29 forks source link

Line num (maybe indent too) not behaving properly #115

Closed daUnknownCoder closed 1 month ago

daUnknownCoder commented 1 month ago

Describe the bug Actually i recently started using an autocmd which goes as follows:

_G.augroup = function(name)
  return vim.api.nvim_create_augroup("NeutronVim" .. name, { clear = true })
end
_G.au = function(events, ptn, cb, group)
  local cmd = { pattern = ptn, [type(cb) == "function" and "callback" or "command"] = cb }
  if group then
    cmd.group = augroup(group)
  end
  vim.api.nvim_create_autocmd(events, cmd)
end

-- Relative number in Normal mode only
au(
  {
    "InsertEnter",
    "InsertLeave",
    "BufEnter",
    "BufLeave",
    "WinEnter",
    "WinLeave",
    "CmdlineEnter",
    "CmdlineLeave",
    "VimEnter",
    "VimLeave",
    "ModeChanged",
  },
  "*",
  function()
    local mode = vim.api.nvim_get_mode().mode
    if mode == "n" or mode == "v" or mode == "V" then
      vim.wo.number = true
      vim.wo.relativenumber = true
    else
      vim.wo.number = true
      vim.wo.relativenumber = false
    end
  end,
  "numbertoggle"
)

so what happens is the autocmd is doing its work and line_num too but after switching modes, i am not having the orange highlight...

To Reproduce Steps to reproduce the behavior:

  1. Switch modes from normal to insert and back to normal

Expected behavior I should see the orange highlight

Screenshots Normal: image image Insert: image image Back to normal: image image

See the orange highlight? it vanished into eternity Additional context my config:

return {
  {
    "shellRaining/hlchunk.nvim",
    event = { "LazyFile" },
    lazy = true,
    dependencies = {
      {
        "https://gitlab.com/HiPhish/rainbow-delimiters.nvim",
        name = "rainbow-delimiters.nvim",
        url = "https://gitlab.com/HiPhish/rainbow-delimiters.nvim",
        event = "VeryLazy",
        lazy = true,
      },
    },
    config = function()
      local hlchunk_status_ok, hlchunk = pcall(require, "hlchunk")
      if not hlchunk_status_ok then
        print("hlchunk not found!")
      end
      hlchunk.setup({
        chunk = {
          enable = true,
          priority = 15,
          notify = true,
          style = {
            "#5ef33e",
            "#c21f30",
          },
          chars = {
            horizontal_line = "─",
            vertical_line = "│",
            left_top = "╭",
            left_bottom = "╰",
            right_arrow = ">",
          },
          textobject = "ic",
          duration = 250,
          error_sign = true,
          exclude_filetypes = {
            aerial = true,
            dashboard = true,
            fidget = true,
            NvimTree = true,
            TelescopePrompt = true,
            cmp = true,
            cmp_docs = true,
          },
        },
        indent = {
          enable = true,
          chars = {
            "▎",
          },
          style = {
            "#E06C75",
            "#E5C07B",
            "#61AFEF",
            "#D19A66",
            "#98C379",
            "#C678DD",
            "#56B6C2",
          },
          exclude_filetypes = {
            aerial = true,
            dashboard = true,
            fidget = true,
            NvimTree = true,
            TelescopePrompt = true,
            cmp = true,
            cmp_docs = true,
          },
        },
        line_num = {
          enable = true,
          style = "#C678DD",
          use_treesitter = true,
          exclude_filetypes = {
            aerial = true,
            dashboard = true,
            fidget = true,
            NvimTree = true,
            TelescopePrompt = true,
            cmp = true,
            cmp_docs = true,
          },
        },
        blank = { enable = false },
      })

      local rainbow_delimiters_status_ok, rainbow_delimiters = pcall(require, "rainbow-delimiters")
      if not rainbow_delimiters_status_ok then
        print("rainbow-delimiters not found!")
      end
      vim.g.rainbow_delimiters = {
        strategy = {
          [""] = rainbow_delimiters.strategy["global"],
          vim = rainbow_delimiters.strategy["local"],
          commonlisp = rainbow_delimiters.strategy["local"],
          html = rainbow_delimiters.strategy["local"],
          latex = function(bufnr)
            local line_count = vim.api.nvim_buf_line_count(bufnr)
            if line_count > 10000 then
              return nil
            elseif line_count > 1000 then
              return rainbow_delimiters.strategy["global"]
            end
            return rainbow_delimiters.strategy["local"]
          end,
        },
        query = {
          [""] = "rainbow-delimiters",
          lua = "rainbow-blocks",
          latex = "rainbow-blocks",
          query = function(bufnr)
            local is_nofile = vim.bo[bufnr].buftype == "nofile"
            return is_nofile and "rainbow-blocks" or "rainbow-delimiters"
          end,
        },
        priority = {
          [""] = 110,
          lua = 210,
        },
        highlight = {
          "RainbowDelimiterRed",
          "RainbowDelimiterYellow",
          "RainbowDelimiterBlue",
          "RainbowDelimiterOrange",
          "RainbowDelimiterGreen",
          "RainbowDelimiterViolet",
          "RainbowDelimiterCyan",
        },
      }
    end,
  },
}

something i also noticed: theres this chunk which does not get the selected indent char: image image idk why but it recurs every 4-5 indents

shellRaining commented 1 month ago

the first bug I can't reproduce, my config below

vim.api.nvim_create_autocmd({
    "InsertEnter",
    "InsertLeave",
    "BufEnter",
    "BufLeave",
    "WinEnter",
    "WinLeave",
    "CmdlineEnter",
    "CmdlineLeave",
    "VimEnter",
    "VimLeave",
    "ModeChanged",
}, {
    callback = function()
        local mode = vim.api.nvim_get_mode().mode
        if mode == "i" or mode == "ic" then
            vim.opt_local.relativenumber = false
        else
            vim.opt_local.relativenumber = true
        end
    end,
})
line_num = {
    enable = true,
},

Kapture 2024-06-16 at 23 22 23

as for the second issue, I'm sorry that not sure what are you mentioned... can you provide more info?

daUnknownCoder commented 1 month ago

For the second I mean see the indent chars, every 4-5 indents the char specified is not used, instead a normal bar (|) is used (ig?)

daUnknownCoder commented 1 month ago
callback = function()
        local mode = vim.api.nvim_get_mode().mode
        if mode == "i" or mode == "ic" then
            vim.opt_local.relativenumber = false
        else
            vim.opt_local.relativenumber = true
        end
    end,

This might be a better one, mines from chatgpt so it is doomed to fail lmao ill test with this config when I go home

shellRaining commented 1 month ago

For the second I mean see the indent chars, every 4-5 indents the char specified is not used, instead a normal bar (|) is used (ig?)

I still can't reproduce 😭, what would happened if you disable indent mod

This might be a better one, mines from chatgpt so it is doomed to fail lmao ill test with this config when I go home

as for this code, maybe you can search for some plugin specializing in line_num, my code still has bug, when use dashboard and telescope will render line_num wrongly

shellRaining commented 1 month ago

Temporarily close this issue, please feel free to reopen if there are any problems.