hlchunk.nvim icon indicating copy to clipboard operation
hlchunk.nvim copied to clipboard

Chunk NOT working with *.jsx & *.tsx

Open npduykhoa opened this issue 2 years ago • 14 comments

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

  • Chunk working with .lua and .js: CleanShot 2023-05-29 at 12 35 43 CleanShot 2023-05-29 at 12 36 36

  • Chunk NOT working with .jsx and .tsx: CleanShot 2023-05-29 at 12 37 49 CleanShot 2023-05-29 at 12 38 25

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

npduykhoa avatar May 29 '23 05:05 npduykhoa

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 avatar May 29 '23 06:05 shellRaining

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

shellRaining avatar May 29 '23 15:05 shellRaining

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

shellRaining avatar May 30 '23 12:05 shellRaining

Hi @shellRaining,

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

  • My dot-files: https://github.com/npduykhoa/dot-files/blob/master/lua/plugins/indent_blankline.lua

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 .

npduykhoa avatar Jun 01 '23 22:06 npduykhoa

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.

shellRaining avatar Jun 01 '23 23:06 shellRaining

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?

ic-768 avatar Jul 15 '24 06:07 ic-768

@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)

shellRaining avatar Jul 15 '24 07:07 shellRaining

@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

ic-768 avatar Jul 15 '24 08:07 ic-768

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 avatar Jul 15 '24 08:07 shellRaining

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 avatar Jul 15 '24 10:07 shellRaining

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 :)

ic-768 avatar Jul 15 '24 10:07 ic-768

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?

lazydeveloper avatar Aug 05 '24 03:08 lazydeveloper

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

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

shellRaining avatar Aug 05 '24 12:08 shellRaining

@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
  },

lazydeveloper avatar Aug 05 '24 16:08 lazydeveloper

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!!!

dhruvindsd-dev avatar Aug 20 '24 15:08 dhruvindsd-dev

@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.

shellRaining avatar Aug 20 '24 15:08 shellRaining

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",
  },

dhruvindsd-dev avatar Aug 20 '24 17:08 dhruvindsd-dev

now seems work properly, close temporarily

shellRaining avatar Oct 01 '24 09:10 shellRaining