nvim: Deprecate buffer-option settings group for switches

Remove `<localleader>s` 'set' group of mappings (setting buffer wrapping
mode, setting colorizing) and replace it with explicit on/off mappings
via [o<setting> and ]o<setting>.

Wrapping can be set to soft with `[ow`, hard with `]ow`.
Colorizer can be disabled with `[oc`, enabled with `]oc`.
Colorizer can highlight virtual text with `[oC`, highlight background
with `]oC`.
This commit is contained in:
Marty Oehme 2024-08-15 08:53:30 +02:00
parent b574ba5947
commit 787c0b0fc4
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
3 changed files with 71 additions and 34 deletions

View file

@ -6,8 +6,9 @@ if is_available("which-key") then
prefix({
{ "<leader>v", group = "vim" },
{ "<leader>s", group = "show" },
{ "<localleader>s", group = "set" },
{ "<localleader>Z", group = "spelling" },
{ "]o", group = "options" },
{ "[o", group = "options" },
})
end

View file

@ -1,4 +1,19 @@
local writing_ft = { "quarto", "pandoc", "markdown", "text", "tex", "typst", "bib", "context", "rst", "vimwiki" }
local prose_ft = {
"asciidoc",
"bib",
"context",
"gitcommit",
"latex",
"mail",
"markdown",
"pandoc",
"quarto",
"rst",
"tex",
"text",
"typst",
"vimwiki",
}
local prose_plugs = {
-- UI improvements
@ -13,30 +28,29 @@ local prose_plugs = {
{
"andrewferrier/wrapping.nvim",
opts = {
create_keymappings = false,
notify_on_switch = false,
softener = { quarto = true, markdown = true, text = true, asciidoc = true },
auto_set_mode_filetype_allowlist = {
"asciidoc",
"gitcommit",
"latex",
"mail",
"markdown",
"rst",
"tex",
"text",
"quarto",
},
create_keymaps = false,
notify_on_switch = true,
-- softener = { quarto = true, markdown = true, text = true, asciidoc = true },
auto_set_mode_filetype_allowlist = prose_ft,
},
event = { "BufReadPre", "BufNewFile" },
-- event = { "BufReadPre", "BufNewFile" },
ft = prose_ft,
keys = {
{
"<localleader>sw",
"[ow",
function()
require("wrapping").toggle_wrap_mode()
require("wrapping").soft_wrap_mode()
end,
silent = true,
desc = "toggle wrap mode",
desc = "soft wrap",
},
{
"]ow",
function()
require("wrapping").hard_wrap_mode()
end,
silent = true,
desc = "hard wrap",
},
},
},
@ -46,15 +60,15 @@ local prose_plugs = {
main = "render-markdown",
opts = {
file_types = { "markdown", "quarto", "pandoc", "vimwiki", "norg", "rmd", "org" },
code = {
sign = false,
width = 'block',
right_pad = 1,
},
code = {
sign = false,
width = "block",
right_pad = 1,
},
},
name = "render-markdown", -- Only needed if you have another plugin named markdown.nvim
dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons" }, -- if you prefer nvim-web-devicons
ft = writing_ft,
ft = prose_ft,
cmd = "RenderMarkdown",
keys = {
{
@ -86,7 +100,7 @@ local prose_plugs = {
build = function()
vim.fn["mkdp#util#install"]()
end,
ft = writing_ft,
ft = prose_ft,
},
-- easy copy paste of images into markup files
@ -106,7 +120,7 @@ local prose_plugs = {
keys = {
{ "<leader>pi", "<cmd>PasteImage<cr>", desc = "Paste image from system clipboard" },
},
ft = writing_ft,
ft = prose_ft,
},
-- bring zettelkasten commands
@ -135,7 +149,7 @@ local prose_plugs = {
},
})
end,
ft = writing_ft,
ft = prose_ft,
cmd = {
"ZkBacklinks",
"ZkCd",
@ -173,7 +187,7 @@ local prose_plugs = {
},
-- syntax highlighting for markdown criticmarkup (comments, additions, ...)
{ "vim-pandoc/vim-criticmarkup", ft = writing_ft },
{ "vim-pandoc/vim-criticmarkup", ft = prose_ft },
-- create mindmaps from your markdown
{

View file

@ -143,11 +143,33 @@ return {
"ColorizerReloadAllBuffers",
},
keys = {
{ "<localleader>sc", "<cmd>ColorizerToggle<cr>", { silent = true, desc = "toggle colorizer" } },
{
"<localleader>sC",
'<cmd>lua require("colorizer").attach_to_buffer(0, {mode = "background"} )<cr>',
{ silent = true, desc = "colorize background" },
"[oc",
function()
require("colorizer").detach_from_buffer(0)
end,
{ silent = true, desc = "colorize disable" },
},
{
"]oc",
function()
require("colorizer").attach_to_buffer(0)
end,
{ silent = true, desc = "colorize enable" },
},
{
"]oC",
function()
require("colorizer").attach_to_buffer(0, { mode = "background" })
end,
{ silent = true, desc = "colorize bg" },
},
{
"[oC",
function()
require("colorizer").attach_to_buffer(0, { mode = "virtualtext" })
end,
{ silent = true, desc = "colorize eol" },
},
},
},