Skip to content

Commit

Permalink
chore(keymap.fmt): replace manual map_cmd with map_cr
Browse files Browse the repository at this point in the history
Signed-off-by: Jint-lzxy <[email protected]>
  • Loading branch information
Jint-lzxy committed Jan 19, 2025
1 parent a02472d commit 74d63de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions lua/keymap/completion.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
local bind = require("keymap.bind")
local map_cr = bind.map_cr
local map_cmd = bind.map_cmd
local map_callback = bind.map_callback

local plug_map = {
["n|<A-f>"] = map_cmd("<Cmd>FormatToggle<CR>"):with_noremap():with_desc("formatter: Toggle format on save"),
["n|<A-S-f>"] = map_cmd("<Cmd>Format<CR>"):with_noremap():with_desc("formatter: Format buffer manually"),
["n|<A-f>"] = map_cr("FormatToggle"):with_noremap():with_silent():with_desc("formatter: Toggle format on save"),
["n|<A-S-f>"] = map_cr("Format"):with_noremap():with_silent():with_desc("formatter: Format buffer manually"),
}
bind.nvim_load_mapping(plug_map)

Expand Down
8 changes: 4 additions & 4 deletions lua/modules/configs/completion/formatting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ local format_modifications_only = settings.format_modifications_only
local server_formatting_block_list = settings.server_formatting_block_list
local format_timeout = settings.format_timeout

vim.api.nvim_create_user_command("FormatToggle", function()
M.toggle_format_on_save()
end, {})

vim.api.nvim_create_user_command("Format", function()
M.format({
timeout = format_timeout,
filter = M.format_filter,
})
end, {})

vim.api.nvim_create_user_command("FormatToggle", function()
M.toggle_format_on_save()
end, {})

local block_list = settings.formatter_block_list
vim.api.nvim_create_user_command("FormatterToggleFt", function(opts)
if block_list[opts.args] == nil then
Expand Down

0 comments on commit 74d63de

Please sign in to comment.