briangwaltney / paren-hint.nvim

MIT License
49 stars 1 forks source link

Opening paren on next line #3

Open Perry3D opened 6 months ago

Perry3D commented 6 months ago

Hello,

great plugin. I love it.

Some of my projects force the opening paren in cpp files on the next line. The result looks like this: image

Is it possible to show the if line (69) instead of the opening paren (70)?

briangwaltney commented 6 months ago

I thought about that too. Certain filetypes have the same issue quite frequently. One challenge around that is when the line above doesn't have any useful information or information you don't want in it.

{
  "key1": "val1",
},
{
  "key1": "val2",
},

This for example would fall into the same category, but wouldn't be solved by grabbing the line above.

One possible solution would be to check the line above for length > 1 if the length of the match is 1 and then return the line above if it is.

if len(matchingLine) == 1 {
  if len(lineAbove) > 1 {
    return lineAbove
  }
  return matchingLine
}

Something like that as the test. Do you have a better idea how to logically and correctly pick the correct line to display?

Perry3D commented 6 months ago

Why are you not using treesitter? It should show you the correct line without worrying about formatting.

briangwaltney commented 6 months ago

The latest version does not use treesitter, but I was using it to check for the correct filetype so that the plugin doesn't activate on non-code buffers. The latest version just checks for the filetype directly.