GithubHelp home page GithubHelp logo

Comments (8)

rraafays avatar rraafays commented on August 28, 2024 1

beautiful, centered, painless
Screenshot 2024-01-03 at 19 02 48
Screenshot 2024-01-03 at 19 03 00
Screenshot 2024-01-03 at 19 04 00
Screenshot 2024-01-03 at 19 04 20

from no-neck-pain.nvim.

shortcuts avatar shortcuts commented on August 28, 2024

Hey, thanks for the suggestion and using the plugin :D

So if I summarize, what you'd like is that NoNeckPain resizes to the width of the longest line in the buffer when entering in it?

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.

from no-neck-pain.nvim.

rraafays avatar rraafays commented on August 28, 2024

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

from no-neck-pain.nvim.

rraafays avatar rraafays commented on August 28, 2024

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 :-)

from no-neck-pain.nvim.

rraafays avatar rraafays commented on August 28, 2024

another thing i might add is that the arbitrary extra 8 width i'm adding to the result of the wc command is due to this plugin including the margin in the total width. I don't know if this is doable but I think this plugin would be perfect outside of my afformentioned weird usecase if the width accounted for the margin meaning that a width of 80 means 80 characters after the margin rather than it being 80 characters wide total including the margin if that makes sense.

Thanks,
:-)

from no-neck-pain.nvim.

rraafays avatar rraafays commented on August 28, 2024

update: hey, i kind of found my own solution by modifying my script, i have also made it cross platform by using the wc command via https://github.com/uutils/coreutils crate.

DOCUMENT_WIDTH = 80
RECEIPT_WIDTH = 60

vim.api.nvim_create_user_command("Center", function()
    local filetype = vim.bo.filetype
    if filetype == "xxd" or filetype == "alpha" then
        vim.cmd("NoNeckPainResize " .. DOCUMENT_WIDTH)
        return
    elseif filetype == "text" then
        vim.cmd("NoNeckPainResize " .. RECEIPT_WIDTH)
        return
    end
    local path = vim.fn.expand("%:p")
    local command = io.popen("coreutils wc -L " .. path:gsub(" ", "\\ "))
    if command ~= nil then
        local result = command:read("*a")
        for i in string.gmatch(result, "%S+") do
            if tonumber(i) ~= nil then vim.cmd("NoNeckPainResize " .. i + 2) end
        end
    end
end, {})

vim.api.nvim_create_autocmd("BufWritePost", {
    pattern = "",
    command = "Center",
})

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.
:-)

from no-neck-pain.nvim.

shortcuts avatar shortcuts commented on August 28, 2024

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!!!

from no-neck-pain.nvim.

chelsea6502 avatar chelsea6502 commented on August 28, 2024

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.

from no-neck-pain.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.