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

It'd be nice if we could show the line number of the context #40

Closed
lourenci opened this issue Feb 3, 2020 · 9 comments · Fixed by #81
Closed

It'd be nice if we could show the line number of the context #40

lourenci opened this issue Feb 3, 2020 · 9 comments · Fixed by #81

Comments

@lourenci
Copy link

lourenci commented Feb 3, 2020

Thanks for the plugin.

Sometimes, I'm reading a lot of specs and want to jump right to that context. Is there some way to do that? Maybe if we had the line number on the left of the context?

@wellle
Copy link
Owner

wellle commented Feb 3, 2020

Hey, thanks for the issue! I agree that would be great! There are a few caveats though:

  1. Setting 'number' in the context popup doesn't work as it can only show the line numbers within the buffer, so it would be just 1, 2, 3, ... instead of the corresponding line numbers. And this would also only work well (without breaking the alignment) if you buffer has 'number' set too.

  2. I could prefix the lines with the line number, but that breaks syntax highlighting (at least in most languages). So this would be a pretty big sacrifice.

  3. I could append the line numbers to the context lines. I could probably even align them on the right. I actually already have some debugging code I sometimes use which does include the line number. It looks like this:

    Screenshot 2020-02-03 22 42 22

    But that has a problem with syntax highlighting too. My debugging code has hardcoded // in it. For production use I'd need a way to use proper comment delimiters in order to not break highlighting (for example it would be # in bash etc.)

So for now I'm not sure what the best way would be to go about this. What do you think?

As for navigating to the context lines. If you just want to just to the beginning of the current function try [[. There's also [m. And if you use this plugin you can jump between the different context levels by typing [-: https://github.com/jeetsukumaran/vim-indentwise

@lourenci
Copy link
Author

lourenci commented Feb 4, 2020

Sorry, I'm a layman in vimscript. 😔

In the alternatives above, I think I'd stick with the third option, but you'd have a hard work figuring out what is the right comment symbol for the language. What if you start with a simple naive implementation mapping the most commons languages these days? I would be a simple MPV for the feature.

Anyway, your lib is awesome. Thanks for it.

@zsugabubus
Copy link

I could prefix the lines with the line number, but that breaks syntax highlighting (at least in most languages). So this would be a pretty big sacrifice.

Note that you can do something like this and this by forgetting about filetype and just “simply” copying highlights and manually constructing a line-looking line.

@wellle
Copy link
Owner

wellle commented May 3, 2020

@zsugabubus: That looks very nice! Can you help me with how that could be done?

@zsugabubus
Copy link

zsugabubus commented May 3, 2020

Of course. Just finished with it today, so… may contain bug… but it seems working. Code.

If you have any questions let me know, but I think it can be easily ported with not too much effort.

@wellle
Copy link
Owner

wellle commented May 3, 2020

Wow, that's awesome! Thank you so much for sharing this! ❤️

Btw, did you manage to improve the performance in your implementation in comparison to context.vim? Or did you find anything else you think could be improved in here? Please feel free to open new issues, I'd be very interested in your feedback 👍

@zsugabubus
Copy link

zsugabubus commented May 3, 2020

Wow, that's awesome! Thank you so much for sharing this

Wait at least one day until you start digging yourself into it. I just now saw another little bug.

UPDATE: This one eliminated.

did you manage to improve the performance

I wouldn’t say so, but I think there is not too much room for improvements since search() is itself consumes (at least) 25-30% CPU (~half). Other things are negligible compared to this.

UPDATE: Pressing j continuously: context.vim: 100%; mine: 70-80% CPU usage.

Please feel free to open new issues, I'd be very interested in your feedback

Okay…

@lourenci
Copy link
Author

I'm very excited to see that somebody have been working on that. I've got a little few plugins in my dotfile, context is one of my favorite ones.

Thank for that.

@wellle
Copy link
Owner

wellle commented Aug 24, 2020

@lourenci @zsugabubus @toddyamakawa @christopher-francisco @scarfacedeb @wmusial:
This has been done in #81 🎉

Huge thanks again to @zsugabubus for helping out with their ideas (and reference implementation!) of how to do highlights manually. I basically took their approach and integrated it to context.vim. I'm very happy with the result. Here's a new screenshot:

context-example

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

Successfully merging a pull request may close this issue.

3 participants