From 98f052a785fcb3e4f7fd7de6cc4305002f3adbe6 Mon Sep 17 00:00:00 2001 From: Thomas Alcala Schneider Date: Sat, 27 May 2023 08:59:28 +0200 Subject: [PATCH] feat: format html --- lua/custom/plugins/languages/html.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 lua/custom/plugins/languages/html.lua diff --git a/lua/custom/plugins/languages/html.lua b/lua/custom/plugins/languages/html.lua new file mode 100644 index 00000000..348023fe --- /dev/null +++ b/lua/custom/plugins/languages/html.lua @@ -0,0 +1,18 @@ +function FormatHTML() + -- Check if the current file type is HTML + if vim.bo.filetype == 'html' then + vim.cmd [[s/<[^>]*>/\r&\r/g]] + vim.cmd [[g/^$/d]] + vim.cmd [[normal gg=G]] + else + print 'This command is applicable only for HTML files.' + end +end + +-- Mapping as a command +vim.cmd [[command! FormatHTML lua FormatHTML()]] + +-- Mapping as a shortcut +vim.api.nvim_set_keymap('n', 'p', ':lua FormatHTML()', { silent = true }) + +return {}