Skip to content

Commit

Permalink
style: better formatting in default-keymaps
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgrieser committed Jun 18, 2024
1 parent 0fecc1c commit bde0481
Showing 1 changed file with 16 additions and 42 deletions.
58 changes: 16 additions & 42 deletions lua/various-textobjs/default-keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,50 +29,24 @@ local oneMaps = {
lastChange = "g;", -- consistent with g; movement
}
local ftMaps = {
{
map = { mdlink = "l" },
fts = { "markdown", "toml" },
},
{
map = { mdEmphasis = "e" },
fts = { "markdown" },
},
{
map = { pyTripleQuotes = "y" },
fts = { "python" },
},
{
map = { mdFencedCodeBlock = "C" },
fts = { "markdown" },
},
{
map = { doubleSquareBrackets = "D" },
fts = { "lua", "norg", "sh", "fish", "zsh", "bash", "markdown" },
},
{
map = { cssSelector = "c" },
fts = { "css", "scss" },
},
{
map = { cssColor = "#" },
fts = { "css", "scss" },
},
{
map = { shellPipe = "P" },
fts = { "sh", "bash", "zsh", "fish" },
},
{
map = { htmlAttribute = "x" },
fts = { "html", "css", "scss", "xml", "vue" },
},
{ map = { mdlink = "l" }, fts = { "markdown", "toml" } },
{ map = { mdEmphasis = "e" }, fts = { "markdown" } },
{ map = { pyTripleQuotes = "y" }, fts = { "python" } },
{ map = { mdFencedCodeBlock = "C" }, fts = { "markdown" } },
-- stylua: ignore
{ map = { doubleSquareBrackets = "D" }, fts = { "lua", "norg", "sh", "fish", "zsh", "bash", "markdown" } },
{ map = { cssSelector = "c" }, fts = { "css", "scss" } },
{ map = { cssColor = "#" }, fts = { "css", "scss" } },
{ map = { shellPipe = "P" }, fts = { "sh", "bash", "zsh", "fish" } },
{ map = { htmlAttribute = "x" }, fts = { "html", "css", "scss", "xml", "vue" } },
}

function M.setup(disabled_keymaps)
--------------------------------------------------------------------------------

function M.setup(disabledKeymaps)
local function keymap(...)
local args = { ... }
if vim.tbl_contains(disabled_keymaps, args[2]) then
return -- Disabled keymap
end
if vim.tbl_contains(disabledKeymaps, args[2]) then return end
vim.keymap.set(...)
end

Expand Down Expand Up @@ -107,10 +81,10 @@ function M.setup(disabled_keymaps)
keymap( { "o", "x" }, "aI" , "<cmd>lua require('various-textobjs').indentation('outer', 'outer')<CR>", { desc = "outer-outer indentation textobj" })
-- stylua: ignore end

vim.api.nvim_create_augroup("VariousTextobjs", {})
local group = vim.api.nvim_create_augroup("VariousTextobjs", {})
for _, textobj in pairs(ftMaps) do
vim.api.nvim_create_autocmd("FileType", {
group = "VariousTextobjs",
group = group,
pattern = textobj.fts,
callback = function()
for objName, map in pairs(textobj.map) do
Expand Down

0 comments on commit bde0481

Please sign in to comment.