diff --git a/config/nvim/lua/fschauen/plugins/comment.lua b/config/nvim/lua/fschauen/plugins/comment.lua index 09b5a8b..b394aad 100644 --- a/config/nvim/lua/fschauen/plugins/comment.lua +++ b/config/nvim/lua/fschauen/plugins/comment.lua @@ -1,15 +1,16 @@ -local icon = require("fschauen.util.icons").ui.Comment - return { "tpope/vim-commentary", cmd = "Commentary", - keys = { - -- stylua: ignore start - { "gc", "Commentary", mode = {"n", "x", "o"}, desc = icon.." Comment in/out" }, - { "gcc", "CommentaryLine", desc = icon.." Comment in/out line" }, - { "gcu", "CommentaryCommentary", desc = icon.." Undo comment in/out" }, - -- stylua: ignore end - }, + keys = function() + local icon = require("fschauen.util.icons").ui.Comment + return { + -- stylua: ignore start + { "gc", "Commentary", mode = {"n", "x", "o"}, desc = icon.." Comment in/out" }, + { "gcc", "CommentaryLine", desc = icon.." Comment in/out line" }, + { "gcu", "CommentaryCommentary", desc = icon.." Undo comment in/out" }, + -- stylua: ignore end + } + end, } diff --git a/config/nvim/lua/fschauen/plugins/dial.lua b/config/nvim/lua/fschauen/plugins/dial.lua index 807929a..293f7d7 100644 --- a/config/nvim/lua/fschauen/plugins/dial.lua +++ b/config/nvim/lua/fschauen/plugins/dial.lua @@ -1,55 +1,57 @@ ----Create a right hand side for `dial` key maps. ----@param cmd string: name of a function from `dial.map`. ----@param suffix? string: keys to add after `dial`s mapping. ----@return function -local dial_cmd = function(cmd, suffix) - suffix = suffix or "" - return function() return require("dial.map")[cmd]() .. suffix end -end - ----Make a new augend that cycles over the given elements. ----@param elements string[]: the elements to cycle. ----@return table: @see `dial.types.Augend` -local cyclic_augend = function(elements) - return require("dial.augend").constant.new { - elements = elements, - word = true, - cyclic = true, - } -end - -local weekdays = { - "Monday", - "Tuesday", - "Wednesday", - "Thursday", - "Friday", - "Saturday", - "Sunday", -} - -local weekdays_short = vim.tbl_map(function(s) return s:sub(1, 3) end, weekdays) - -local ui = require("fschauen.util.icons").ui -local inc, dec = ui.Increment, ui.Decrement - return { "monaqa/dial.nvim", - keys = { - -- stylua: ignore start - { "", dial_cmd("inc_normal"), expr = true, desc = inc.." Increment" }, - { "", dial_cmd("dec_normal"), expr = true, desc = dec.." Decrement" }, + keys = function() + ---Create a right hand side for `dial` key maps. + ---@param cmd string: name of a function from `dial.map`. + ---@param suffix? string: keys to add after `dial`s mapping. + ---@return function + local dial_cmd = function(cmd, suffix) + suffix = suffix or "" + return function() return require("dial.map")[cmd]() .. suffix end + end - { "", dial_cmd("inc_visual", "gv"), expr = true, desc = inc.." Increment", mode = "v" }, - { "", dial_cmd("dec_visual", "gv"), expr = true, desc = dec.." Decrement", mode = "v" }, + local icons = require("fschauen.util.icons") + local inc, dec = icons.ui.Increment, icons.ui.Decrement - { "g", dial_cmd("inc_gvisual", "gv"), expr = true, desc = inc.." Increment", mode = "v" }, - { "g", dial_cmd("dec_gvisual", "gv"), expr = true, desc = dec.." Decrement", mode = "v" }, - -- stylua: ignore end - }, + return { + -- stylua: ignore start + { "", dial_cmd("inc_normal"), expr = true, desc = inc.." Increment" }, + { "", dial_cmd("dec_normal"), expr = true, desc = dec.." Decrement" }, + + { "", dial_cmd("inc_visual", "gv"), expr = true, desc = inc.." Increment", mode = "v" }, + { "", dial_cmd("dec_visual", "gv"), expr = true, desc = dec.." Decrement", mode = "v" }, + + { "g", dial_cmd("inc_gvisual", "gv"), expr = true, desc = inc.." Increment", mode = "v" }, + { "g", dial_cmd("dec_gvisual", "gv"), expr = true, desc = dec.." Decrement", mode = "v" }, + -- stylua: ignore end + } + end, config = function() + ---Make a new augend that cycles over the given elements. + ---@param elements string[]: the elements to cycle. + ---@return table: @see `dial.types.Augend` + local cycle = function(elements) + return require("dial.augend").constant.new { + elements = elements, + word = true, + cyclic = true, + } + end + + local weekdays = { + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", + "Saturday", + "Sunday", + } + + local weekdays_short = vim.tbl_map(function(s) return s:sub(1, 3) end, weekdays) + local augend = require("dial.augend") require("dial.config").augends:register_group { default = { @@ -61,8 +63,8 @@ return { augend.date.alias["%Y-%m-%d"], augend.date.alias["%d/%m/%Y"], augend.date.alias["%d.%m.%Y"], - cyclic_augend(weekdays), - cyclic_augend(weekdays_short), + cycle(weekdays), + cycle(weekdays_short), }, } end, diff --git a/config/nvim/lua/fschauen/plugins/fugitive.lua b/config/nvim/lua/fschauen/plugins/fugitive.lua index 2eaa3ce..aa5f69e 100644 --- a/config/nvim/lua/fschauen/plugins/fugitive.lua +++ b/config/nvim/lua/fschauen/plugins/fugitive.lua @@ -1,14 +1,15 @@ -local icon = require("fschauen.util.icons").ui.Git - return { "tpope/vim-fugitive", cmd = { "G", "Git" }, - keys = { - -- stylua: ignore start - { "gS", "tab Git", desc = icon.." [S]status (fugitive)" }, - { "gb", "Git blame", desc = icon.." [b]lame (fugitive)" }, - -- stylua: ignore end - }, + keys = function() + local icon = require("fschauen.util.icons").ui.Git + return { + -- stylua: ignore start + { "gS", "tab Git", desc = icon.." [S]status (fugitive)" }, + { "gb", "Git blame", desc = icon.." [b]lame (fugitive)" }, + -- stylua: ignore end + } + end, } diff --git a/config/nvim/lua/fschauen/plugins/git-messenger.lua b/config/nvim/lua/fschauen/plugins/git-messenger.lua index b70cb27..7e8fa62 100644 --- a/config/nvim/lua/fschauen/plugins/git-messenger.lua +++ b/config/nvim/lua/fschauen/plugins/git-messenger.lua @@ -1,14 +1,16 @@ -local icon = require("fschauen.util.icons").ui.Git return { "rhysd/git-messenger.vim", cmd = "GitMessenger", - keys = { - -- stylua: ignore start - { "gm", "GitMessenger", desc = icon.." [g]it [m]essenger" }, - -- stylua: ignore end - }, + keys = function() + local icon = require("fschauen.util.icons").ui.Git + return { + -- stylua: ignore start + { "gm", "GitMessenger", desc = icon.." [g]it [m]essenger" }, + -- stylua: ignore end + } + end, init = function() -- Disable default mappings, as I have my own for lazy-loading. diff --git a/config/nvim/lua/fschauen/plugins/gitlinker.lua b/config/nvim/lua/fschauen/plugins/gitlinker.lua index 1338db0..e993fbf 100644 --- a/config/nvim/lua/fschauen/plugins/gitlinker.lua +++ b/config/nvim/lua/fschauen/plugins/gitlinker.lua @@ -1,41 +1,42 @@ -local open_repo = function() - require("gitlinker").get_repo_url { - action_callback = require("gitlinker.actions").open_in_browser, - } -end - -local browser = function(mode) - return function() - require("gitlinker").get_buf_range_url(mode, { - action_callback = require("gitlinker.actions").open_in_browser, - }) - end -end - -local clipboard = function(mode) - return function() - require("gitlinker").get_buf_range_url(mode, { - action_callback = require("gitlinker.actions").copy_to_clipboard, - }) - end -end - -local icon = require("fschauen.util.icons").ui.Git - return { "ruifm/gitlinker.nvim", dependencies = "nvim-lua/plenary.nvim", - keys = { - -- stylua: ignore start - { "gr", open_repo, desc = icon.." open [r]epository in browser" }, - { "gl", clipboard("n"), desc = icon.." copy perma[l]ink to clipboard" }, - { "gl", clipboard("v"), desc = icon.." copy perma[l]ink to clipboard", mode = "v" }, - { "gL", browser("n"), desc = icon.." open perma[L]ink in browser" }, - { "gL", browser("v"), desc = icon.." open perma[L]ink in browser", mode = "v" }, - -- stylua: ignore end - }, + keys = function() + local open_repo = function() + require("gitlinker").get_repo_url { + action_callback = require("gitlinker.actions").open_in_browser, + } + end + + local browser = function(mode) + return function() + require("gitlinker").get_buf_range_url(mode, { + action_callback = require("gitlinker.actions").open_in_browser, + }) + end + end + + local clipboard = function(mode) + return function() + require("gitlinker").get_buf_range_url(mode, { + action_callback = require("gitlinker.actions").copy_to_clipboard, + }) + end + end + + local icon = require("fschauen.util.icons").ui.Git + return { + -- stylua: ignore start + { "gr", open_repo, desc = icon.." open [r]epository in browser" }, + { "gl", clipboard("n"), desc = icon.." copy perma[l]ink to clipboard" }, + { "gl", clipboard("v"), desc = icon.." copy perma[l]ink to clipboard", mode = "v" }, + { "gL", browser("n"), desc = icon.." open perma[L]ink in browser" }, + { "gL", browser("v"), desc = icon.." open perma[L]ink in browser", mode = "v" }, + -- stylua: ignore end + } + end, -- This really does need to be a function, because we need to defer requiring -- the `gitlinker.hosts` module until after the plugin is loaded. diff --git a/config/nvim/lua/fschauen/plugins/nerdy.lua b/config/nvim/lua/fschauen/plugins/nerdy.lua index 4ac1c77..2e6a262 100644 --- a/config/nvim/lua/fschauen/plugins/nerdy.lua +++ b/config/nvim/lua/fschauen/plugins/nerdy.lua @@ -1,6 +1,3 @@ -local helper = require("fschauen.plugins.telescope").keymap_helper -local lhs, desc = helper.lhs, helper.description - return { "2kabhishek/nerdy.nvim", @@ -11,7 +8,11 @@ return { "nvim-telescope/telescope.nvim", }, - keys = { - { lhs("i"), "Nerdy", desc = desc("Nerd [i]cons") }, - }, + keys = function() + local helper = require("fschauen.plugins.telescope").keymap_helper + local lhs, desc = helper.lhs, helper.description + return { + { lhs("i"), "Nerdy", desc = desc("Nerd [i]cons") }, + } + end, } diff --git a/config/nvim/lua/fschauen/plugins/nvim-lint.lua b/config/nvim/lua/fschauen/plugins/nvim-lint.lua index 413f68d..8970167 100644 --- a/config/nvim/lua/fschauen/plugins/nvim-lint.lua +++ b/config/nvim/lua/fschauen/plugins/nvim-lint.lua @@ -1,15 +1,15 @@ -local icon = require("fschauen.util.icons").ui.Lint - return { "mfussenegger/nvim-lint", - keys = { - { - "L", - function() require("lint").try_lint() end, - desc = icon .. " [L]int file", - }, - }, + keys = function() + return { + { + "L", + function() require("lint").try_lint() end, + desc = require("fschauen.util.icons").ui.Lint .. " [L]int file", + }, + } + end, config = function() require("lint").linters_by_ft = { diff --git a/config/nvim/lua/fschauen/plugins/nvim-notify.lua b/config/nvim/lua/fschauen/plugins/nvim-notify.lua index f5ee53b..980023f 100644 --- a/config/nvim/lua/fschauen/plugins/nvim-notify.lua +++ b/config/nvim/lua/fschauen/plugins/nvim-notify.lua @@ -1,32 +1,34 @@ -local helper = require("fschauen.plugins.telescope").keymap_helper -local lhs, desc = helper.lhs, helper.description - -local telescope_notifications = function() - local telescope = vim.F.npcall(require, "telescope") - if not telescope then - vim.notify("Telescope is not installed!", vim.log.levels.WARN) - return - end - - local theme = require("telescope.themes").get_dropdown { - results_title = " Results ", - prompt_title = "  Notifications ", - } - telescope.load_extension("notify").notify(theme) -end - -local dismiss_notifications = function() require("notify").dismiss() end - return { "rcarriga/nvim-notify", - keys = { - -- stylua: ignore start - { "n", "Notifications", desc = "Display notification history" }, - { "", dismiss_notifications, desc = "Dismiss notifications" }, - { lhs("n"), telescope_notifications, desc = desc("[n]otifications") }, - -- stylua: ignore end - }, + keys = function() + local telescope_notifications = function() + local telescope = vim.F.npcall(require, "telescope") + if not telescope then + vim.notify("Telescope is not installed!", vim.log.levels.WARN) + return + end + + local theme = require("telescope.themes").get_dropdown { + results_title = " Results ", + prompt_title = "  Notifications ", + } + telescope.load_extension("notify").notify(theme) + end + + local dismiss_notifications = function() require("notify").dismiss() end + + local helper = require("fschauen.plugins.telescope").keymap_helper + local lhs, desc = helper.lhs, helper.description + + return { + -- stylua: ignore start + { "n", "Notifications", desc = "Display notification history" }, + { "", dismiss_notifications, desc = "Dismiss notifications" }, + { lhs("n"), telescope_notifications, desc = desc("[n]otifications") }, + -- stylua: ignore end + } + end, lazy = false, diff --git a/config/nvim/lua/fschauen/plugins/openbrowser.lua b/config/nvim/lua/fschauen/plugins/openbrowser.lua index 573fcf8..a2c2c3d 100644 --- a/config/nvim/lua/fschauen/plugins/openbrowser.lua +++ b/config/nvim/lua/fschauen/plugins/openbrowser.lua @@ -1,5 +1,3 @@ -local icon = require("fschauen.util.icons").ui.Web - return { "tyru/open-browser.vim", @@ -9,14 +7,17 @@ return { "OpenBrowserSmartSearch", }, - keys = { - { - "o", - "(openbrowser-smart-search)", - desc = icon .. " [o]pen URL under cursor or search the web", - mode = { "n", "v" }, - }, - }, + keys = function() + local icon = require("fschauen.util.icons").ui.Web + return { + { + "o", + "(openbrowser-smart-search)", + desc = icon .. " [o]pen URL under cursor or search the web", + mode = { "n", "v" }, + }, + } + end, init = function() vim.g.openbrowser_default_search = "duckduckgo" end, } diff --git a/config/nvim/lua/fschauen/plugins/plantuml-previewer.lua b/config/nvim/lua/fschauen/plugins/plantuml-previewer.lua index e08a834..a8c361e 100644 --- a/config/nvim/lua/fschauen/plugins/plantuml-previewer.lua +++ b/config/nvim/lua/fschauen/plugins/plantuml-previewer.lua @@ -1,5 +1,3 @@ -local icon = require("fschauen.util.icons").ui.Graph - return { "weirongxu/plantuml-previewer.vim", @@ -25,6 +23,7 @@ return { end, config = function() + local icon = require("fschauen.util.icons").ui.Graph local group = vim.api.nvim_create_augroup("fschauen.plantuml", { clear = true }) vim.api.nvim_create_autocmd("FileType", { desc = "Create key map to toggle plantuml preview.", diff --git a/config/nvim/lua/fschauen/plugins/telescope-file-browser.lua b/config/nvim/lua/fschauen/plugins/telescope-file-browser.lua index 9bbfdf4..ca2f12b 100644 --- a/config/nvim/lua/fschauen/plugins/telescope-file-browser.lua +++ b/config/nvim/lua/fschauen/plugins/telescope-file-browser.lua @@ -1,18 +1,19 @@ -local helper = require("fschauen.plugins.telescope").keymap_helper -local lhs, desc = helper.lhs, helper.description - return { "nvim-telescope/telescope-file-browser.nvim", dependencies = "nvim-telescope/telescope.nvim", - keys = { - { - lhs("B"), - "Telescope file_browser theme=ivy", - desc = desc("file [B]rowser"), - }, - }, + keys = function() + local helper = require("fschauen.plugins.telescope").keymap_helper + local lhs, desc = helper.lhs, helper.description + return { + { + lhs("B"), + "Telescope file_browser theme=ivy", + desc = desc("file [B]rowser"), + }, + } + end, config = function() require("telescope").load_extension("file_browser") end, } diff --git a/config/nvim/lua/fschauen/plugins/text-case.lua b/config/nvim/lua/fschauen/plugins/text-case.lua index c5bab21..f0d9db8 100644 --- a/config/nvim/lua/fschauen/plugins/text-case.lua +++ b/config/nvim/lua/fschauen/plugins/text-case.lua @@ -1,8 +1,3 @@ -local icon = require("fschauen.util.icons").ui.Text -local description = icon .. " [c]hange text [c]ase" - -local theme = function() return require("telescope.themes").get_cursor() end - return { "johmsalas/text-case.nvim", @@ -15,38 +10,44 @@ return { "TextCaseStartReplacingCommand", }, - keys = { - { - "cc", - function() require("telescope").extensions.textcase.normal_mode(theme()) end, - mode = "n", - desc = description, - }, + keys = function() + local icon = require("fschauen.util.icons").ui.Text + local description = icon .. " [c]hange text [c]ase" + local theme = function() return require("telescope.themes").get_cursor() end - --[[ + return { + { + "cc", + function() require("telescope").extensions.textcase.normal_mode(theme()) end, + mode = "n", + desc = description, + }, - Ideally this would be the mapping for visual mode, but it doesn't work - due to bugs in textcase. + --[[ - { - "cc", - function() - require("telescope").extensions.textcase.visual_mode(theme()) - end, - mode = "v", - desc = description, - }, + Ideally this would be the mapping for visual mode, but it doesn't work + due to bugs in textcase. - The mapping below works, but I can't set the theme to `cursor`. + { + "cc", + function() + require("telescope").extensions.textcase.visual_mode(theme()) + end, + mode = "v", + desc = description, + }, - --]] - { - "cc", - "TextCaseOpenTelescope", - mode = "v", - desc = description, - }, - }, + The mapping below works, but I can't set the theme to `cursor`. + + --]] + { + "cc", + "TextCaseOpenTelescope", + mode = "v", + desc = description, + }, + } + end, config = function() require("textcase").setup { diff --git a/config/nvim/lua/fschauen/plugins/todo-comments.lua b/config/nvim/lua/fschauen/plugins/todo-comments.lua index 6274381..989e8b4 100644 --- a/config/nvim/lua/fschauen/plugins/todo-comments.lua +++ b/config/nvim/lua/fschauen/plugins/todo-comments.lua @@ -1,8 +1,3 @@ -local ui = require("fschauen.util.icons").ui - -local helper = require("fschauen.plugins.telescope").keymap_helper -local lhs, desc = helper.lhs, helper.description - return { "folke/todo-comments.nvim", @@ -13,25 +8,32 @@ return { event = { "BufReadPost", "BufNewFile" }, - keys = { - { lhs("t"), "TodoTelescope", desc = desc("[t]odos") }, - }, + keys = function() + local helper = require("fschauen.plugins.telescope").keymap_helper + local lhs, desc = helper.lhs, helper.description + return { + { lhs("t"), "TodoTelescope", desc = desc("[t]odos") }, + } + end, - opts = { - keywords = { - TODO = { icon = ui.Checkbox }, - FIX = { icon = ui.Bug }, - HACK = { icon = ui.Fire }, - WARN = { icon = ui.Warning }, - PERF = { icon = ui.Gauge }, - NOTE = { icon = ui.Note }, - TEST = { icon = ui.TestTube }, - }, - gui_style = { fg = "bold" }, - highlight = { - multiline = false, - keyword = "wide_fg", - after = "", - }, - }, + opts = function() + local ui = require("fschauen.util.icons").ui + return { + keywords = { + TODO = { icon = ui.Checkbox }, + FIX = { icon = ui.Bug }, + HACK = { icon = ui.Fire }, + WARN = { icon = ui.Warning }, + PERF = { icon = ui.Gauge }, + NOTE = { icon = ui.Note }, + TEST = { icon = ui.TestTube }, + }, + gui_style = { fg = "bold" }, + highlight = { + multiline = false, + keyword = "wide_fg", + after = "", + }, + } + end, } diff --git a/config/nvim/lua/fschauen/plugins/treesitter.lua b/config/nvim/lua/fschauen/plugins/treesitter.lua index 826ee42..d41a3eb 100644 --- a/config/nvim/lua/fschauen/plugins/treesitter.lua +++ b/config/nvim/lua/fschauen/plugins/treesitter.lua @@ -1,5 +1,3 @@ -local icon = require("fschauen.util.icons").ui.Tree - return { "nvim-treesitter/nvim-treesitter", @@ -15,13 +13,17 @@ return { event = "VeryLazy", - keys = { - -- stylua: ignore start - { "Tp", "TSPlaygroundToggle", desc = icon.." [T]reesitter [p]layground (toggle)" }, - { "Th", "TSHighlightCapturesUnderCursor", desc = icon.." [T]reesitter [h]ighlights" }, - { "Tn", "TSNodeUnderCursor", desc = icon.." [T]reesitter [n]ode under cursor" }, - -- stylua: ignore end - }, + keys = function() + local icon = require("fschauen.util.icons").ui.Tree + + return { + -- stylua: ignore start + { "Tp", "TSPlaygroundToggle", desc = icon.." [T]reesitter [p]layground (toggle)" }, + { "Th", "TSHighlightCapturesUnderCursor", desc = icon.." [T]reesitter [h]ighlights" }, + { "Tn", "TSNodeUnderCursor", desc = icon.." [T]reesitter [n]ode under cursor" }, + -- stylua: ignore end + } + end, config = function() require("nvim-treesitter.configs").setup { diff --git a/config/nvim/lua/fschauen/plugins/trouble.lua b/config/nvim/lua/fschauen/plugins/trouble.lua index 4ac4e58..f102c18 100644 --- a/config/nvim/lua/fschauen/plugins/trouble.lua +++ b/config/nvim/lua/fschauen/plugins/trouble.lua @@ -1,16 +1,18 @@ -local icon = require("fschauen.util.icons").ui.TrafficLight return { "folke/trouble.nvim", dependencies = "nvim-tree/nvim-web-devicons", - keys = { - -- stylua: ignore start - { "lt", "TroubleToggle", desc = icon.." trouble [t]toggle" }, - { "lw", "TroubleToggle workspace_diagnostics", desc = icon.." trouble [w]orkspace" }, - { "ld", "TroubleToggle document_diagnostics", desc = icon.." trouble [d]ocument" }, - -- stylua: ignore end - }, + keys = function() + local icon = require("fschauen.util.icons").ui.TrafficLight + return { + -- stylua: ignore start + { "lt", "TroubleToggle", desc = icon.." trouble [t]toggle" }, + { "lw", "TroubleToggle workspace_diagnostics", desc = icon.." trouble [w]orkspace" }, + { "ld", "TroubleToggle document_diagnostics", desc = icon.." trouble [d]ocument" }, + -- stylua: ignore end + } + end, opts = { padding = false, -- don't add an extra new line of top of the list diff --git a/config/nvim/lua/fschauen/plugins/undotree.lua b/config/nvim/lua/fschauen/plugins/undotree.lua index eaae20a..06bb036 100644 --- a/config/nvim/lua/fschauen/plugins/undotree.lua +++ b/config/nvim/lua/fschauen/plugins/undotree.lua @@ -1,5 +1,3 @@ -local icon = require("fschauen.util.icons").ui.Undo - return { "mbbill/undotree", @@ -13,7 +11,10 @@ return { vim.g.undotree_TreeReturnShape = "╲" end, - keys = { - { "u", "UndotreeToggle", desc = icon .. " toggle [u]ndo tree" }, - }, + keys = function() + local icon = require("fschauen.util.icons").ui.Undo + return { + { "u", "UndotreeToggle", desc = icon .. " toggle [u]ndo tree" }, + } + end, } diff --git a/config/nvim/lua/fschauen/plugins/virt-column.lua b/config/nvim/lua/fschauen/plugins/virt-column.lua index a47164d..9e2d7fa 100644 --- a/config/nvim/lua/fschauen/plugins/virt-column.lua +++ b/config/nvim/lua/fschauen/plugins/virt-column.lua @@ -1,11 +1,3 @@ -local toggle_colorcolumn = function() - if vim.o.colorcolumn == "" then - vim.o.colorcolumn = "+1" -- one after 'textwidth' - else - vim.o.colorcolumn = "" -- none - end -end - local ui = require("fschauen.util.icons").ui return { @@ -13,9 +5,19 @@ return { event = { "BufReadPost", "BufNewFile" }, - keys = { - { "sc", toggle_colorcolumn, desc = ui.Toggle .. " toggle virtual colunn" }, - }, + keys = function() + local toggle_colorcolumn = function() + if vim.o.colorcolumn == "" then + vim.o.colorcolumn = "+1" -- one after 'textwidth' + else + vim.o.colorcolumn = "" -- none + end + end + + return { + { "sc", toggle_colorcolumn, desc = ui.Toggle .. " toggle virtual colunn" }, + } + end, opts = { char = ui.LineMiddle, diff --git a/config/nvim/lua/fschauen/plugins/whitespace.lua b/config/nvim/lua/fschauen/plugins/whitespace.lua index b2b9494..9d87dad 100644 --- a/config/nvim/lua/fschauen/plugins/whitespace.lua +++ b/config/nvim/lua/fschauen/plugins/whitespace.lua @@ -1,5 +1,3 @@ -local icon = require("fschauen.util.icons").ui.Whitespace - return { "ntpeters/vim-better-whitespace", @@ -15,12 +13,15 @@ return { } end, - keys = { - -- stylua: ignore start - { "ww", "ToggleWhitespace", desc = icon.." toggle whitespace" }, - { "wj", "NextTrailingWhitespace", desc = icon.." next whitespace" }, - { "wk", "PrevTrailingWhitespace", desc = icon.." previous whitespace" }, - { "W", "StripWhitespace", desc = icon.." strip whitespace" }, - -- stylua: ignore end - }, + keys = function() + local icon = require("fschauen.util.icons").ui.Whitespace + return { + -- stylua: ignore start + { "ww", "ToggleWhitespace", desc = icon.." toggle whitespace" }, + { "wj", "NextTrailingWhitespace", desc = icon.." next whitespace" }, + { "wk", "PrevTrailingWhitespace", desc = icon.." previous whitespace" }, + { "W", "StripWhitespace", desc = icon.." strip whitespace" }, + -- stylua: ignore end + } + end, } diff --git a/config/nvim/lua/fschauen/util/icons.lua b/config/nvim/lua/fschauen/util/icons.lua index 5ee8c70..95347e9 100644 --- a/config/nvim/lua/fschauen/util/icons.lua +++ b/config/nvim/lua/fschauen/util/icons.lua @@ -88,7 +88,7 @@ M.ui = { Circle = "●", Comment = "", Comments = "", - Decrement = "", + Decrement = "", --  Diagnostic = "", EmptyFolder = "", EmptyFolderOpen = "", @@ -104,7 +104,7 @@ M.ui = { Gauge = "󰓅", --  Git = " ", Graph = "󱁊", - Increment = "", + Increment = "", --  LineLeft = "▏", LineLeftBold = "▎", LineMiddle = "│",