anuvyklack / pretty-fold.nvim

Foldtext customization in Neovim
Apache License 2.0
441 stars 21 forks source link

FR: highlight 'content' #32

Open guoang opened 1 year ago

guoang commented 1 year ago

Great Plugin!

Is there a way to highlight the 'content'? It'll make the function signature looks better

image image
anurag3301 commented 1 year ago

Same, would it be possible to have some simple colours in fold signature, it looks pretty dull right now

image

anurag3301 commented 1 year ago

Seems like work the discussion has been going on for quite a while on neovim

Here are few threads

  1. Issue #12649
  2. PR #23471
  3. PR #20750
stevanmilic commented 11 months ago

This could be implemented now, since https://github.com/neovim/neovim/pull/25209 has been merged.

alexveden commented 8 months ago

I managed to do this in C, however it's nothing to do with pretty-fold plugin. If you do, tree sitter folding plugin this is an option: https://github.com/nvim-treesitter/nvim-treesitter/issues/1564

You need to add the following into config file:

      vim.treesitter.query.set(
        "c",
        "folds",
        [[
          [
           (switch_statement)
           (case_statement)
           (comment)
          ] @fold
          (function_definition
            type: (type_identifier)  @fold
          )
          (function_definition
            body: (compound_statement)  @fold
          )
          ]]
      )

      vim.treesitter.query.set(
        "cpp",
        "folds",
        [[
          [
           (switch_statement)
           (case_statement)
           (comment)
           (function_definition)
          ] @fold
          ]]
      )

The above code folds this code: image

Into: image

Duologic commented 7 months ago

An alternative approach was choosen upstream to support this: https://github.com/neovim/neovim/pull/20750/