From 3a33bf3fb12b10195ced1fbb7e558480a068476f Mon Sep 17 00:00:00 2001 From: ayamir Date: Thu, 12 Dec 2024 15:24:53 +0800 Subject: [PATCH] feat: add Format command and mapping (#1378). --- lua/keymap/completion.lua | 1 + lua/modules/configs/completion/formatting.lua | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lua/keymap/completion.lua b/lua/keymap/completion.lua index d67f775a3..3b0628a0c 100644 --- a/lua/keymap/completion.lua +++ b/lua/keymap/completion.lua @@ -5,6 +5,7 @@ local map_callback = bind.map_callback local plug_map = { ["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"), } bind.nvim_load_mapping(plug_map) diff --git a/lua/modules/configs/completion/formatting.lua b/lua/modules/configs/completion/formatting.lua index 0ab4f696a..6b804343d 100644 --- a/lua/modules/configs/completion/formatting.lua +++ b/lua/modules/configs/completion/formatting.lua @@ -12,6 +12,13 @@ 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, {}) + local block_list = settings.formatter_block_list vim.api.nvim_create_user_command("FormatterToggleFt", function(opts) if block_list[opts.args] == nil then