Comments (8)
from no-neck-pain.nvim.
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.
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.
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.
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.
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.
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.
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)
- Feature request: Add top padding for small files HOT 1
- With the right buffer disabled on vimEnter, text is cut/hidden. HOT 1
- NoNeckPain's buffer is not visible when using nvim, though it might be opened, just not visible? HOT 6
- Integration with Trouble HOT 6
- Opening new buffer after "NoNeckPain" causes line numbers to disappear HOT 5
- Change WinSeparator highlight group when on vertical split. HOT 5
- Wrong background color after resize HOT 5
- bug: calling `bd` changes buffer text color
- Disable this when *diffview* is activated HOT 2
- [bug] buftype incorrectly set for scratch pad HOT 6
- [feature] add support for Symbols Outline HOT 3
- (Help request) How to add custom integrations? (agitator) HOT 3
- Inconsistent resize behavior with window splits HOT 2
- Show opened tabs/buffers in NNP. HOT 2
- heyo, not an issue, what's the thing besides the `fish` and `tmux` thing? that ram thing like htop? HOT 2
- [feature] Option to keep the cursor out of the panel/s HOT 8
- Issue when used with alpha-nvim HOT 5
- The neo-tree integration seems to be broken on small window width HOT 3
- feat: top and bottom windows HOT 2
- Lualine not expanding across whole window, showing "dummy" buffers HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from no-neck-pain.nvim.