mirror of
https://github.com/pnx/dotfiles
synced 2026-06-16 11:24:55 +02:00
nvim/lua/user/extras.lua: create Format command.
This commit is contained in:
parent
5d4bb95508
commit
25599c77b2
1 changed files with 17 additions and 0 deletions
|
|
@ -3,3 +3,20 @@
|
|||
if user.highlight_yank.enable or false then
|
||||
require('user.utils.misc').highlight_yank(user.highlight_yank)
|
||||
end
|
||||
|
||||
-- Default formatter. will select the whole file and use formatexpr to format the file.
|
||||
-- this is slow and ugly, but works.
|
||||
if user.formatter == nil then
|
||||
user.formatter = [[mfgggqG`f=zz]]
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command('Format', function()
|
||||
if type(user.formatter) == "string" then
|
||||
local cmd = vim.api.nvim_replace_termcodes(user.formatter, true, false, true)
|
||||
vim.api.nvim_feedkeys(cmd, 'n', false)
|
||||
elseif type(user.formatter) == "function" then
|
||||
user.formatter()
|
||||
else
|
||||
vim.api.nvim_err_writeln("No formatter found")
|
||||
end
|
||||
end, {})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue