Skip to content

Commit

Permalink
feat: add Format command and mapping (#1378).
Browse files Browse the repository at this point in the history
  • Loading branch information
ayamir committed Dec 12, 2024
1 parent 38c3ee4 commit 3a33bf3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions lua/keymap/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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"),
}
bind.nvim_load_mapping(plug_map)

Expand Down
7 changes: 7 additions & 0 deletions lua/modules/configs/completion/formatting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3a33bf3

Please sign in to comment.