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:
parent
b574ba5947
commit
787c0b0fc4
3 changed files with 71 additions and 34 deletions
|
@ -6,8 +6,9 @@ if is_available("which-key") then
|
||||||
prefix({
|
prefix({
|
||||||
{ "<leader>v", group = "vim" },
|
{ "<leader>v", group = "vim" },
|
||||||
{ "<leader>s", group = "show" },
|
{ "<leader>s", group = "show" },
|
||||||
{ "<localleader>s", group = "set" },
|
|
||||||
{ "<localleader>Z", group = "spelling" },
|
{ "<localleader>Z", group = "spelling" },
|
||||||
|
{ "]o", group = "options" },
|
||||||
|
{ "[o", group = "options" },
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -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 = {
|
local prose_plugs = {
|
||||||
-- UI improvements
|
-- UI improvements
|
||||||
|
@ -13,30 +28,29 @@ local prose_plugs = {
|
||||||
{
|
{
|
||||||
"andrewferrier/wrapping.nvim",
|
"andrewferrier/wrapping.nvim",
|
||||||
opts = {
|
opts = {
|
||||||
create_keymappings = false,
|
create_keymaps = false,
|
||||||
notify_on_switch = false,
|
notify_on_switch = true,
|
||||||
softener = { quarto = true, markdown = true, text = true, asciidoc = true },
|
-- softener = { quarto = true, markdown = true, text = true, asciidoc = true },
|
||||||
auto_set_mode_filetype_allowlist = {
|
auto_set_mode_filetype_allowlist = prose_ft,
|
||||||
"asciidoc",
|
|
||||||
"gitcommit",
|
|
||||||
"latex",
|
|
||||||
"mail",
|
|
||||||
"markdown",
|
|
||||||
"rst",
|
|
||||||
"tex",
|
|
||||||
"text",
|
|
||||||
"quarto",
|
|
||||||
},
|
},
|
||||||
},
|
-- event = { "BufReadPre", "BufNewFile" },
|
||||||
event = { "BufReadPre", "BufNewFile" },
|
ft = prose_ft,
|
||||||
keys = {
|
keys = {
|
||||||
{
|
{
|
||||||
"<localleader>sw",
|
"[ow",
|
||||||
function()
|
function()
|
||||||
require("wrapping").toggle_wrap_mode()
|
require("wrapping").soft_wrap_mode()
|
||||||
end,
|
end,
|
||||||
silent = true,
|
silent = true,
|
||||||
desc = "toggle wrap mode",
|
desc = "soft wrap",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"]ow",
|
||||||
|
function()
|
||||||
|
require("wrapping").hard_wrap_mode()
|
||||||
|
end,
|
||||||
|
silent = true,
|
||||||
|
desc = "hard wrap",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -48,13 +62,13 @@ local prose_plugs = {
|
||||||
file_types = { "markdown", "quarto", "pandoc", "vimwiki", "norg", "rmd", "org" },
|
file_types = { "markdown", "quarto", "pandoc", "vimwiki", "norg", "rmd", "org" },
|
||||||
code = {
|
code = {
|
||||||
sign = false,
|
sign = false,
|
||||||
width = 'block',
|
width = "block",
|
||||||
right_pad = 1,
|
right_pad = 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
name = "render-markdown", -- Only needed if you have another plugin named markdown.nvim
|
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
|
dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons" }, -- if you prefer nvim-web-devicons
|
||||||
ft = writing_ft,
|
ft = prose_ft,
|
||||||
cmd = "RenderMarkdown",
|
cmd = "RenderMarkdown",
|
||||||
keys = {
|
keys = {
|
||||||
{
|
{
|
||||||
|
@ -86,7 +100,7 @@ local prose_plugs = {
|
||||||
build = function()
|
build = function()
|
||||||
vim.fn["mkdp#util#install"]()
|
vim.fn["mkdp#util#install"]()
|
||||||
end,
|
end,
|
||||||
ft = writing_ft,
|
ft = prose_ft,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- easy copy paste of images into markup files
|
-- easy copy paste of images into markup files
|
||||||
|
@ -106,7 +120,7 @@ local prose_plugs = {
|
||||||
keys = {
|
keys = {
|
||||||
{ "<leader>pi", "<cmd>PasteImage<cr>", desc = "Paste image from system clipboard" },
|
{ "<leader>pi", "<cmd>PasteImage<cr>", desc = "Paste image from system clipboard" },
|
||||||
},
|
},
|
||||||
ft = writing_ft,
|
ft = prose_ft,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- bring zettelkasten commands
|
-- bring zettelkasten commands
|
||||||
|
@ -135,7 +149,7 @@ local prose_plugs = {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
ft = writing_ft,
|
ft = prose_ft,
|
||||||
cmd = {
|
cmd = {
|
||||||
"ZkBacklinks",
|
"ZkBacklinks",
|
||||||
"ZkCd",
|
"ZkCd",
|
||||||
|
@ -173,7 +187,7 @@ local prose_plugs = {
|
||||||
},
|
},
|
||||||
|
|
||||||
-- syntax highlighting for markdown criticmarkup (comments, additions, ...)
|
-- 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
|
-- create mindmaps from your markdown
|
||||||
{
|
{
|
||||||
|
|
|
@ -143,11 +143,33 @@ return {
|
||||||
"ColorizerReloadAllBuffers",
|
"ColorizerReloadAllBuffers",
|
||||||
},
|
},
|
||||||
keys = {
|
keys = {
|
||||||
{ "<localleader>sc", "<cmd>ColorizerToggle<cr>", { silent = true, desc = "toggle colorizer" } },
|
|
||||||
{
|
{
|
||||||
"<localleader>sC",
|
"[oc",
|
||||||
'<cmd>lua require("colorizer").attach_to_buffer(0, {mode = "background"} )<cr>',
|
function()
|
||||||
{ silent = true, desc = "colorize background" },
|
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" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue