andrewferrier / wrapping.nvim

Plugin to make it easier to switch between 'soft' and 'hard' line wrapping in NeoVim
MIT License
127 stars 4 forks source link

Add indicators for lines that have been wrapped #43

Closed avih7531 closed 5 months ago

avih7531 commented 8 months ago

I think a nice feature to add would be indicators if a line is wrapped.

Non-Wrapped
1       public static void main(String[] args) {
2              System.out.println("Wow. Wrapping text is so, so cool")
3       }

Wrapped
1       public static void main(String[] args) {
2              System.out.println("Wow. Wrapping text
        is so, so cool")
3       }

Wrapped Indicated 1st Way
1       public static void main(String[] args) {
2              System.out.println("Wow. Wrapping text
        󱞩 is so, so cool")
3       }

Wrapped Indicated 2nd Way
1       public static void main(String[] args) {
2              System.out.println("Wow. Wrapping text
               󱞩 is so, so cool")
3       }

I used this type of wrapping in Jupyter Notebook a while ago in school, and I found it to be the best way to recognize a wrapped line (Jupyter Notebook uses the 2nd way I proposed). If for some reason you can't see it, that icon is NerdFont md-arrow_right_bottom.

I think there could be options for indicator icon, color, and whether or not to put it in the first character spot on the new line where the wrapped line starts (like in my 1st example), or under the first character under the line that is being wrapped (like in my 2nd example) .

I'd totally make this, but I'm useless at Lua :) 
avih7531 commented 8 months ago

Sorry for the code block. It was the only way I could get Github to recognize my weird formatting.

andrewferrier commented 8 months ago

This is an interesting idea. I think to implement this would probably need NeoVim extmarks. It's not easy though, as they'll move around as the text is edited.

I'll leave this open here in case anyone wants to take this on, but right I'm not sure it's something I can spend any time on, it's probably non-trivial. I think this would ultimately be better as a built-in NeoVim feature.

avih7531 commented 8 months ago

Thanks for your interest, Andrew!

I definitely agree that it won't be trivial to implement, but I forked this repo and I'll give it my best shot with a buddy over the next week or so, but by all means if someone wants to save me :wink:

I'd like to propose one more wrapping type where instead of an empty line-number on the line that is wrapped, a symbol is added:

Wrapped Indicated 3rd Way
1       public static void main(String[] args) {
2              System.out.println("Wow. Wrapping text
󱞩       is so, so cool")
3       }

Wrapped Indicated 4th Way
1       public static void main(String[] args) {
2              System.out.println("Wow. Wrapping text
󱞩              is so, so cool")
3       }
andrewferrier commented 8 months ago

The symbol would be much easier to achieve using the new 'status column' feature in NeoVim 0.10; worth looking into...

avih7531 commented 8 months ago

Thanks for your advice. I’ll try that as a first step. Thanks!

avih7531 commented 6 months ago

Hi! Now that Nvim 0.10 is out and has the status column feature, could this feature be implemented in the next update?

andrewferrier commented 5 months ago

There's no easy way to do this in the general sense; the vim.opt.statuscolumn option is typically used for a number of things, such as customizing line numbers, diagnostic marks, etc. Everyone uses it differently (or will), so an implementation in wrapping.nvim by itself wouldn't really make sense and would probably out of the scope of this plugin. It would probably make more sense to request this as a feature in a status column plugin like https://github.com/luukvbaal/statuscol.nvim, since there is nothing specific to wrapping.nvim about the lines that are wrapped; it's NeoVim itself that does the wrapping, not this plugin.

For now, I'm going to close this issue. Thanks for your thoughts and input.