zen-mode.nvim icon indicating copy to clipboard operation
zen-mode.nvim copied to clipboard

feature: option to add left padding

Open idelice opened this issue 1 year ago • 1 comments

Did you check the docs?

  • [X] I have read all the zen-mode.nvim docs

Is your feature request related to a problem? Please describe.

no

Describe the solution you'd like

I would like to have an option where I can add left padding to the view which would enable me to move the view to my own needs e.g. I would like to have my view start at the very center of my screen.

Describe alternatives you've considered

n/a

Additional context

No response

idelice avatar Apr 29 '24 11:04 idelice

@idelice

If you hack zen-mode like so

diff --git a/lua/zen-mode/view.lua b/lua/zen-mode/view.lua
index 2d170c5..c9c88bb 100644
--- a/lua/zen-mode/view.lua
+++ b/lua/zen-mode/view.lua
@@ -114,9 +114,10 @@ end
 function M.layout(opts)
   local width = M.resolve(vim.o.columns, opts.window.width)
   local height = M.resolve(M.height(), opts.window.height)
+  local shift_amount = opts.window.shift_amount or 0
 
   return {
-    width = M.round(width),
+    width = M.round(width) - shift_amount,
     height = M.round(height),
     col = M.round((vim.o.columns - width) / 2),
     row = M.round((M.height() - height) / 2),
@@ -125,6 +126,7 @@ end
 
 -- adjusts col/row if window was resized
 function M.fix_layout(win_resized)
+  local shift_amount = M.opts.window.shift_amount or 0
   if M.is_open() then
     if win_resized then
       local l = M.layout(M.opts)
@@ -140,7 +142,7 @@ function M.fix_layout(win_resized)
     local wcol = type(cfg.col) == "number" and cfg.col or cfg.col[false]
     local wrow = type(cfg.row) == "number" and cfg.row or cfg.row[false]
     if wrow ~= row or wcol ~= col then
-      vim.api.nvim_win_set_config(M.win, { col = col, row = row, relative = "editor" })
+      vim.api.nvim_win_set_config(M.win, { col = col + shift_amount, row = row, relative = "editor" })
     end
   end
 end

then you can add a config shift_amount that does what you're looking for

    {
        'folke/zen-mode.nvim', 
        event = "VeryLazy",
        version = "*",
        config = function(_plugin, _opts)
            local old_normal_nc
            local basic_options = {
                window = {
                    shift_amount = 0,   ---- <--- add this
                    backdrop = 0.2, 

   --- etc

reverendpaco avatar Jun 27 '24 02:06 reverendpaco

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jul 28 '24 01:07 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Aug 04 '24 01:08 github-actions[bot]

This feature is actually needed for text writer, and not only "left padding" but "padding" in both sides:

Image

Without the padding, all text seems to be truncated (actually not) on the right side of the screen.

I know this is not a big thing for programmer, as 120 line width will allow most lines. But text editing is a different scenario

xarthurx avatar Oct 20 '25 12:10 xarthurx