From c198eb888808131b36de45791192172aba27b8c0 Mon Sep 17 00:00:00 2001 From: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Date: Sun, 19 Jan 2025 23:33:53 +0800 Subject: [PATCH] chore(keymap.fmt): replace manual map_cmd with map_cr (#1401) Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Signed-off-by: ayamir Co-authored-by: ayamir --- lua/keymap/completion.lua | 5 ++--- lua/modules/configs/completion/formatting.lua | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lua/keymap/completion.lua b/lua/keymap/completion.lua index 870f7663d..634a6e961 100644 --- a/lua/keymap/completion.lua +++ b/lua/keymap/completion.lua @@ -1,12 +1,11 @@ local bind = require("keymap.bind") local map_cr = bind.map_cr -local map_cmd = bind.map_cmd local map_callback = bind.map_callback local mappings = { fmt = { - ["n|"] = map_cmd("FormatToggle"):with_noremap():with_desc("formatter: Toggle format on save"), - ["n|"] = map_cmd("Format"):with_noremap():with_desc("formatter: Format buffer manually"), + ["n|"] = map_cr("FormatToggle"):with_noremap():with_silent():with_desc("formatter: Toggle format on save"), + ["n|"] = map_cr("Format"):with_noremap():with_silent():with_desc("formatter: Format buffer manually"), }, } bind.nvim_load_mapping(mappings.fmt) diff --git a/lua/modules/configs/completion/formatting.lua b/lua/modules/configs/completion/formatting.lua index 6b804343d..a64cfe686 100644 --- a/lua/modules/configs/completion/formatting.lua +++ b/lua/modules/configs/completion/formatting.lua @@ -8,10 +8,6 @@ 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, @@ -19,6 +15,10 @@ vim.api.nvim_create_user_command("Format", function() }) 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