diff --git a/nvim/.config/nvim/after/ftplugin/markdown.lua b/nvim/.config/nvim/after/ftplugin/markdown.lua index 9e73cee..d5ff55f 100644 --- a/nvim/.config/nvim/after/ftplugin/markdown.lua +++ b/nvim/.config/nvim/after/ftplugin/markdown.lua @@ -1,8 +1 @@ -local o = vim.opt_local - -o.wrap = true -o.linebreak = true -o.breakindent = true -o.textwidth = 0 -o.colorcolumn = "" -o.formatoptions:remove({ "t" }) +require("romanzy.custom.wrap").toggle(true) diff --git a/nvim/.config/nvim/after/ftplugin/text.lua b/nvim/.config/nvim/after/ftplugin/text.lua new file mode 100644 index 0000000..d5ff55f --- /dev/null +++ b/nvim/.config/nvim/after/ftplugin/text.lua @@ -0,0 +1 @@ +require("romanzy.custom.wrap").toggle(true) diff --git a/nvim/.config/nvim/after/ftplugin/txt.lua b/nvim/.config/nvim/after/ftplugin/txt.lua new file mode 100644 index 0000000..d5ff55f --- /dev/null +++ b/nvim/.config/nvim/after/ftplugin/txt.lua @@ -0,0 +1 @@ +require("romanzy.custom.wrap").toggle(true) diff --git a/nvim/.config/nvim/after/ftplugin/typst.lua b/nvim/.config/nvim/after/ftplugin/typst.lua new file mode 100644 index 0000000..d5ff55f --- /dev/null +++ b/nvim/.config/nvim/after/ftplugin/typst.lua @@ -0,0 +1 @@ +require("romanzy.custom.wrap").toggle(true) diff --git a/nvim/.config/nvim/lua/romanzy/custom/tabline.lua b/nvim/.config/nvim/lua/romanzy/custom/tabline.lua index aacc39b..f7a6895 100644 --- a/nvim/.config/nvim/lua/romanzy/custom/tabline.lua +++ b/nvim/.config/nvim/lua/romanzy/custom/tabline.lua @@ -16,6 +16,9 @@ function M.render() return table.concat(parts) end -_G.RomanzyTabline = M.render +function M.setup() + _G.RomanzyTabline = M.render + vim.opt.tabline = "%!v:lua.RomanzyTabline()" +end return M diff --git a/nvim/.config/nvim/lua/romanzy/custom/wrap.lua b/nvim/.config/nvim/lua/romanzy/custom/wrap.lua new file mode 100644 index 0000000..940355f --- /dev/null +++ b/nvim/.config/nvim/lua/romanzy/custom/wrap.lua @@ -0,0 +1,17 @@ +local M = {} + +--- Toggle wrapping, or force it to the provided state. +--- @param enabled? boolean +function M.toggle(enabled) + if enabled == nil then + enabled = not vim.wo.wrap + end + + vim.wo.wrap = enabled + vim.wo.linebreak = enabled + vim.wo.breakindent = enabled + vim.bo.textwidth = enabled and 80 or 0 + vim.bo.wrapmargin = 0 +end + +return M diff --git a/nvim/.config/nvim/lua/romanzy/keymaps.lua b/nvim/.config/nvim/lua/romanzy/keymaps.lua index e66f17a..b94528a 100644 --- a/nvim/.config/nvim/lua/romanzy/keymaps.lua +++ b/nvim/.config/nvim/lua/romanzy/keymaps.lua @@ -26,12 +26,7 @@ map("n", "fg", telescope_picker("live_grep"), { desc = "live grep" }) map("n", "fb", telescope_picker("buffers"), { desc = "find buffers" }) map("n", "fh", telescope_picker("help_tags"), { desc = "help tags" }) map("n", "lg", "LazyGit", { desc = "open lazygit" }) -map("n", "tw", function() - local wrap = not vim.wo.wrap - vim.wo.wrap = wrap - vim.wo.linebreak = wrap - vim.wo.breakindent = wrap -end, { desc = "toggle soft wrap" }) +map("n", "tw", require("romanzy.custom.wrap").toggle, { desc = "toggle soft wrap" }) map("n", "sv", "vs", { desc = "split vertical" }) map("n", "sh", "sp", { desc = "split horizontal" }) diff --git a/nvim/.config/nvim/lua/romanzy/options.lua b/nvim/.config/nvim/lua/romanzy/options.lua index 7f5daac..b088850 100644 --- a/nvim/.config/nvim/lua/romanzy/options.lua +++ b/nvim/.config/nvim/lua/romanzy/options.lua @@ -12,7 +12,6 @@ o.textwidth = 80 -- Wraps inserted text after 80 columns when formatting o.scrolloff = 8 -- Keeps context lines visible around the cursor. o.signcolumn = "yes" -- Always reserves space for signs in the gutter. o.colorcolumn = "+1" -- Highlights the preferred maximum line width. -o.wrap = false -- Prevents long lines from wrapping on screen. o.list = true -- Displays whitespace characters using listchars. o.listchars = { tab = "ยป ", @@ -35,7 +34,6 @@ o.pumheight = 8 -- Limits the compl o.updatetime = 50 -- Reduces idle delay for swap and CursorHold events. o.spelllang = { "en_us" } -- Uses US English for spell checking. o.shell = "bash" -- Runs shell commands through bash. -o.tabline = "%!v:lua.RomanzyTabline()" -- Shows native tabs with custom labels. -- Only show the invisible characters inside the code editing buffers vim.cmd([[autocmd BufWinEnter * if &buftype != '' | setlocal nolist | endif]]) diff --git a/nvim/.config/nvim/lua/romanzy/plugins.lua b/nvim/.config/nvim/lua/romanzy/plugins.lua index fbe9996..265d260 100644 --- a/nvim/.config/nvim/lua/romanzy/plugins.lua +++ b/nvim/.config/nvim/lua/romanzy/plugins.lua @@ -7,6 +7,4 @@ require("romanzy.plugins.nvim-treesitter") require("romanzy.plugins.conform") require("romanzy.plugins.lsp") require("romanzy.plugins.codamheader") - --- custom "plugins" -require("romanzy.custom.tabline") +require("romanzy.plugins.romanzy") diff --git a/nvim/.config/nvim/lua/romanzy/plugins/romanzy.lua b/nvim/.config/nvim/lua/romanzy/plugins/romanzy.lua new file mode 100644 index 0000000..c70befc --- /dev/null +++ b/nvim/.config/nvim/lua/romanzy/plugins/romanzy.lua @@ -0,0 +1,2 @@ +require("romanzy.custom.tabline").setup() +require("romanzy.custom.wrap").toggle(false)