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
647 stars 33 forks source link

Chunk NOT working with *.jsx & *.tsx #41

Closed npduykhoa closed 1 month ago

npduykhoa commented 1 year ago

Describe the bug I'm having issues with "chunk" in the filetypes: jsx and tsx. The chunks don't seem to work even though I've checked that the plugin supports both in support_filetypes.

I have tested it with file formats .lua or .js, and the chunking works fine in those cases.

Screenshots

Thank you, and I look forward to receiving a prompt response from you.

shellRaining commented 1 year ago

Sorry, but I was unable to reproduce how this issue occurred.

image

and the treesitter parser for jsx is same as javascript, so I am not sure what cause this problem...

shellRaining commented 1 year ago

Could you record a video or GIF to demonstrate this bug? and can you provide the config file about how to config chunk

shellRaining commented 1 year ago

I will close this issue for now, and if there are any new developments, I will reopen it~

npduykhoa commented 1 year ago

Hi @shellRaining,

I have fixed this problem by remove (rm -rf) folder plugged/ (where contain plugins installed) and then re-install all plugins.

So, I think the issue I encountered before was due to "hlchunk" conflicting with one or some plugins (may be nvim-treesitter old version), resulting in the chunks not working as expected in JSX and TSX files.

Now, chunk has been worked in JSX and TSX.

**Working in JSX https://github.com/shellRaining/hlchunk.nvim/assets/55375876/99313790-a6b0-4851-a608-f3b22f147002

**Working in TSX CleanShot 2023-06-02 at 05 14 09

Thank you for creating this wonderful plugin, @shellRaining .

shellRaining commented 1 year ago

Glad to know that you have solved the problem. If you encounter any new bugs, please feel free to let me know at any time.

ic-768 commented 3 months ago

image

Chunk is highlighting the sibling relationship here instead of the whole scope of the parent tag. I've seen it does this a lot in .tsx files, is this normal?

shellRaining commented 3 months ago

@ic-768 seems not correct... can you provide this piece of code, I write a test code but not reproduce this bug, and can you share the config of hlchunk (include version)

ic-768 commented 3 months ago

@ic-768 seems not correct... can you provide this piece of code, I write a test code but not reproduce this bug, and can you share the config of hlchunk (include version)

here's a simpler example:

image

const Test = () => {
  return (
    <div>
      <span>test</span>
      <span>test</span>
    </div>
  );
};

hlchunk installation using lazy.nvim:

plugin.lua:

return  {
    "shellRaining/hlchunk.nvim",
    event = { "BufReadPre", "BufNewFile" },
    config = function()
      require("hlchunk").setup({
        chunk = {
          enable = true,
          chars = {
            horizontal_line = "─",
            vertical_line = "│",
            left_top = "╭",
            left_bottom = "╰",
            right_arrow = ">",
          },
          style = "#806d9c",
        },
      })
    end
  },

not sure how to get the version, but I just installed it today

shellRaining commented 3 months ago

oh I found why cause this, I was using the JSX file type earlier, which prevented the bug from being reproduced. I will attempt to fix it~

shellRaining commented 3 months ago

The behavior of the TSX parser and the JSX parser is different.

tsx:

image

jsx:

image

for the code you provide, tsx mark the jsx_element node start from 18-19, but jsx mark from 19-19. The former's judgment includes spaces and line breaks, but this behavior is quite strange, leading to your bug.

so it's hard to fix unless tsx parser become more precise...

ic-768 commented 3 months ago

The behavior of the TSX parser and the JSX parser is different.

tsx: image

jsx: image

for the code you provide, tsx mark the jsx_element node start from 18-19, but jsx mark from 19-19. The former's judgment includes spaces and line breaks, but this behavior is quite strange, leading to your bug.

so it's hard to fix unless tsx parser become more precise...

Ahh that makes sense.. Thanks for all your work anyway :)

lazydeveloper commented 3 months ago

thanks for the beautiful plugin, coming from indent-blankline.nvim for me chunk not working for me for .java file - reinstalling hlchunk didn't work

any one else have problem with .java files? any fixes or work arounds?

shellRaining commented 3 months ago

@lazydeveloper maybe you should reinstall java treesitter parser, It works for me

https://github.com/user-attachments/assets/62a42cdf-9b81-4a3f-93fd-c36d060b83e3

lazydeveloper commented 2 months ago

@shellRaining Installing Treesitter fixed my problem. Cheers!

Here's my config - might come handy if someone else having the same issue.

{
    'nvim-treesitter/nvim-treesitter',
    run = ':TSUpdate',
    config = function()
      require'nvim-treesitter.configs'.setup {
        ensure_installed = {
          "java", "python", "javascript", "html", "css"
        },
        sync_install = false,
        auto_install = true,
        highlight = {
          enable = true,
          additional_vim_regex_highlighting = false,
        },
      }
    end
  },
dhruvindsd-dev commented 2 months ago

The behavior of the TSX parser and the JSX parser is different.

tsx: image

jsx: image

for the code you provide, tsx mark the jsx_element node start from 18-19, but jsx mark from 19-19. The former's judgment includes spaces and line breaks, but this behavior is quite strange, leading to your bug.

so it's hard to fix unless tsx parser become more precise...

@shellRaining, do you think anything can be done about this? It just updated all the plugins today (after around 8months) and suddenly this issue popped up.

Thanks for this awesome plugin!!!

shellRaining commented 2 months ago

@dhruvindsd-dev I'm sorry, I don't have a good solution to this problem yet, and I've recently started an internship and found some other things that interest me, so it might be a long time before this issue gets resolved.

dhruvindsd-dev commented 2 months ago

No worries @shellRaining , thanks for the update!

For anyone else facing this issue, I've found the older version of nvim-treesitter-textobjects and treesitter work.

You can use these specific commits:

  {
    "nvim-treesitter/nvim-treesitter-textobjects",
    commit = "95933e762e28f9d38b572d65e7e4da9d2f4d90cb",
  },
  {
    "nvim-treesitter/nvim-treesitter",
    commit = "62b0bb4f24ad09f535efe44cc9d088f90dcd2498",
  },
shellRaining commented 1 month ago

now seems work properly, close temporarily