Auto center on screen code #458
Replies: 15 comments
-
Hey, thanks for the suggestion and using the plugin :D So if I summarize, what you'd like is that Do you also expect a resize if the line gets deleted/shortened/extended? This seems pretty specific but I can indeed understand the motivation especially if you rarely change buffers etc. |
Beta Was this translation helpful? Give feedback.
-
Hey, no problem I love your plugin. Yeah so either provide a command to resize to longest line (ill just call it center) or even better if you could create an automatic center command that would be incredible I hadn't even thought of that, I actually use my center function then I have '-' & '=' bound to your width up & down |
Beta Was this translation helpful? Give feedback.
-
I would love the automatic resizing you suggested if that's possible that's pretty much a perfect solution but even centering on BufEnter would be cool with me :-) |
Beta Was this translation helpful? Give feedback.
-
another thing i might add is that the arbitrary extra 8 width i'm adding to the result of the Thanks, |
Beta Was this translation helpful? Give feedback.
-
update: hey, i kind of found my own solution by modifying my script, i have also made it cross platform by using the
the most notable changes are the uses of either document width or receipt width as arbitrary values to fall back on as well as autocmd to center against a newly written buffer's file. this implementation also works with file paths that include spaces and it also assumes that no gutter, numberline or symbols line is being used as per my new config. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Hey, that's awesome and looks super clean! I'll definitely look for a native implementation in Neovim in order to provide this as an option, thanks!!! |
Beta Was this translation helpful? Give feedback.
-
This auto-centering is super cool! What would make it even better is to set a maximum width, in case there are any rare super-long lines. |
Beta Was this translation helpful? Give feedback.
-
huge update! figured out how to auto center it works by saving a temporary file in the users .local dir (currently assumes youre using lunarvim) and then runs wc on that file and passing the result to NoNeckPainResize with an arbitrary addition of 2 which seems to make the centering perfect. there are 4 autocmds used to achieve this, both CursorMoved and CursorMovedI to constantly center while editing as well as after writing with BufWritePost since formatters might change the max width of the code.
|
Beta Was this translation helpful? Give feedback.
-
2024-05-15.21-55-45.mp4 |
Beta Was this translation helpful? Give feedback.
-
2024-05-15.21-56-24.mp4 |
Beta Was this translation helpful? Give feedback.
-
2024-05-15.21-58-11.mp4 |
Beta Was this translation helpful? Give feedback.
-
This is awesome @rraafays!!!!!!! I love the idea and the outcome, I've started some work on the next branch in order to make nnp more responsive and extensible, if this can't be done natively with nvim until then, I'll make sure to ease your autocmds registering! |
Beta Was this translation helpful? Give feedback.
-
Hey how's it going? I've not stopped using your plugin at all doubly so because of my auto center script, I was wondering if you got any progress on this? I'm not the best at lua but I'd love to contribute if I can! (this plugin with my auto center shenanigans has been so insanely robust, eye pleasing and most importantly pain free. I even get compliments about how clean my auto centering editor looks when I share my screen at work lol) |
Beta Was this translation helpful? Give feedback.
-
Wonderful and you?
Congrats and thanks for keeping up with the plugin!! That's cool to hear If you want to tackle this feature addition, please go ahead! I've planned to add it in the next major but there's still quite a lot of work to do, and I have a bit less time right now with my newborn But your idea will definitely land in the plugin, it's super nice to use!
❤️🔥❤️🔥 love to hear that, if you'd like any help to get started on contributing let me know |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the problem
I tend to code on narrow displays (4:3, 5:4) out of preference but for my on the go setup I use your plugin to auto center code using a function I wrote. At the moment the function I wrote only works on mac os due to the way
wc
outputs on osx.Describe the solution
I would love it if you could natively include this in a more proper way rather than my 5 minute scripting job, I'm not very good with lua but here is the function.
Essentially all I am doing is getting the length of the longest line of the current buffer via
wc
cutting out any irellevant output other than that value viacut
and then resizing via your plugin + some extra width to be certain and account for the numberline (another thing I think your plugin should take into account by default).Thanks :-)
Beta Was this translation helpful? Give feedback.
All reactions