nvim: ft keymaps via ftplugin/

This commit is contained in:
js0ny 2025-11-17 16:54:15 +00:00
parent 51e6343b9e
commit 32429308f3
22 changed files with 112 additions and 213 deletions

View file

@ -1,8 +1,8 @@
vim.keymap.set("n", "<leader>mp", '<cmd>!jq<CR>', {
desc = "Pretiffy json",
buffer = true
})
vim.keymap.set("i", "<C-m>p", '<cmd>%!jq<CR>', {
desc = "Pretiffy json",
buffer = true
})
local prefmap = {
{ keys = "p", cmd = "<cmd>%!jq<CR>", opts = { desc = "Mark the file as executable" } },
}
local set_buf_keymaps_prefix = require("keymaps.utils").set_buf_keymaps_prefix
-- local set_buf_keymaps = require("keymaps.utils").set_buf_keymaps
set_buf_keymaps_prefix(prefmap)

View file

@ -1,8 +1,8 @@
vim.keymap.set("n", "<leader>mp", '<cmd>!jq<CR>', {
desc = "Pretiffy json",
buffer = true
})
vim.keymap.set("i", "<C-m>p", '<cmd>%!jq<CR>', {
desc = "Pretiffy json",
buffer = true
})
local prefmap = {
{ keys = "p", cmd = "<cmd>%!jq<CR>", opts = { desc = "Mark the file as executable" } },
}
local set_buf_keymaps_prefix = require("keymaps.utils").set_buf_keymaps_prefix
-- local set_buf_keymaps = require("keymaps.utils").set_buf_keymaps
set_buf_keymaps_prefix(prefmap)

View file

@ -1,3 +1,16 @@
vim.bo.shiftwidth = 2
vim.bo.softtabstop = 2
vim.bo.expandtab = true
local bufmap = {
{ mode = "x", keys = "i", cmd = 'c*<C-r>"*', opt = { desc = "Add italic to selected text" } },
{ mode = "x", keys = "b", cmd = 'c**<C-r>"**', opt = { desc = "Add bold to selected text" } },
{ mode = "x", keys = "c", cmd = 'c`<CR><C-r>"<CR>`', opt = { desc = "Add code block to selected text" } },
{ mode = "x", keys = "d", cmd = 'c~~<C-r>"~~', opt = { desc = "Add strikethrough to selected text" } },
{ mode = "x", keys = "h", cmd = 'c==<C-r>"==', opt = { desc = "Add highlight to selected text" } },
}
-- local set_buf_keymaps_prefix = require("keymaps.utils").set_buf_keymaps_prefix
local set_buf_keymaps = require("keymaps.utils").set_buf_keymaps
set_buf_keymaps(bufmap)

View file

@ -0,0 +1,11 @@
local prefmap = {
{ mode = "x", keys = "i", cmd = 'c/<C-r>/"', opt = { desc = "Add italic to selected text" } },
{ mode = "x", keys = "b", cmd = 'c*<C-r>"*', opt = { desc = "Add bold to selected text" } },
{ mode = "x", keys = "d", cmd = 'c+<C-r>"+', opt = { desc = "Add strikethrough to selected text" } },
{ mode = "x", keys = "h", cmd = 'c~<C-r>"~', opt = { desc = "Add highlight to selected text" } },
}
local set_buf_keymaps_prefix = require("keymaps.utils").set_buf_keymaps_prefix
-- local set_buf_keymaps = require("keymaps.utils").set_buf_keymaps
set_buf_keymaps_prefix(prefmap)

View file

@ -1,16 +1,9 @@
vim.keymap.set("n", "<leader>mx", '<cmd>!chmod +x "%"<CR>', {
desc = "Mark the file as executable",
buffer = true
})
vim.keymap.set("i", "<C-m>x", '<cmd>!chmod +x "%"<CR>', {
desc = "Mark the file as executable",
buffer = true
})
vim.keymap.set("n", "<leader>mX", '<cmd>!chmod u+x "%"<CR>', {
desc = "Mark the file as executable (current user only)",
buffer = true
})
vim.keymap.set("i", "<C-m>X", '<cmd>!chmod u+x "%"<CR>', {
desc = "Mark the file as executable (current user only)",
buffer = true
})
local prefmap = {
{ keys = "x", cmd = '<cmd>!chmod +x "%"<CR>', opts = { desc = "Mark the file as executable" } },
{ keys = "X", cmd = '<cmd>!chmod u+x "%"<CR>', opts = { desc = "Mark the file as executable (current user only)" } },
}
local set_buf_keymaps_prefix = require("keymaps.utils").set_buf_keymaps_prefix
-- local set_buf_keymaps = require("keymaps.utils").set_buf_keymaps
set_buf_keymaps_prefix(prefmap)

View file

@ -0,0 +1,17 @@
local bufmap = {
{ mode = "x", keys = "i", cmd = 'c\\textit{<C-r>"}', opt = { desc = "Add italic to selected text" } },
{ mode = "x", keys = "b", cmd = 'c\\textbf{<C-r>"}', opt = { desc = "Add bold to selected text" } },
{
mode = "x",
keys = "c",
cmd = 'c\\begin{verbatim}<CR><C-r>"<CR>\\end{verbatim}',
opt = { desc = "Add code block to selected text" },
},
{ mode = "x", keys = "d", cmd = 'c\\sout{<C-r>"}', opt = { desc = "Add strikethrough to selected text" } },
{ mode = "x", keys = "h", cmd = 'c\\hl{<C-r>"}', opt = { desc = "Add highlight to selected text" } },
{ mode = "n", keys = "<leader>cc", cmd = "<cmd>w<CR>", opt = { desc = "Save and compile tex file" } },
}
local set_buf_keymaps = require("keymaps.utils").set_buf_keymaps
set_buf_keymaps(bufmap)