zen
This commit is contained in:
@@ -187,6 +187,7 @@ local builtin_plugins = {
|
||||
{ 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' },
|
||||
{ 'nvim-telescope/telescope.nvim', dependencies = { 'nvim-lua/plenary.nvim' } },
|
||||
{ 'neovim/nvim-lspconfig' },
|
||||
{ 'folke/zen-mode.nvim' },
|
||||
|
||||
|
||||
|
||||
@@ -314,3 +315,33 @@ cmp.setup({
|
||||
['<CR>'] = require('cmp').mapping.confirm({ select = true }),
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
-- zen-mode max-width helper
|
||||
local M = {}
|
||||
|
||||
-- configuration: change these to taste
|
||||
M.zen_ratio = 0.90 -- try to use 80% of the editor width
|
||||
M.zen_max = 100 -- but never wider than 100 columns
|
||||
M.zen_min = 60 -- optional: never narrower than 60 columns
|
||||
|
||||
function M.open_zen_with_max()
|
||||
local cols = vim.o.columns or vim.api.nvim_get_option('columns')
|
||||
local desired = math.floor(cols * M.zen_ratio)
|
||||
-- clamp between min and max (optional min)
|
||||
local width = math.max(M.zen_min, math.min(desired, M.zen_max))
|
||||
|
||||
require("zen-mode").toggle({
|
||||
window = {
|
||||
width = width,
|
||||
-- keep your usual window options if you like
|
||||
options = {
|
||||
number = false,
|
||||
relativenumber = false,
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
-- map keys (change mapping as you prefer)
|
||||
vim.keymap.set("n", "<leader>z", function() M.open_zen_with_max() end, { noremap = true, silent = true })
|
||||
|
||||
Reference in New Issue
Block a user