Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opening paren on next line #3

Open
Perry3D opened this issue Mar 3, 2024 · 3 comments
Open

Opening paren on next line #3

Perry3D opened this issue Mar 3, 2024 · 3 comments

Comments

@Perry3D
Copy link

Perry3D commented Mar 3, 2024

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
Copy link
Owner

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
Copy link
Author

Perry3D commented Mar 3, 2024

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

@briangwaltney
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants