Create xml.lua
This commit is contained in:
parent
bf0db95c19
commit
f8f5663962
|
@ -0,0 +1,23 @@
|
||||||
|
local function setup_format_xml_command()
|
||||||
|
local python_code = [[
|
||||||
|
import vim
|
||||||
|
import xml.dom.minidom
|
||||||
|
|
||||||
|
def format_xml():
|
||||||
|
buf = vim.current.buffer
|
||||||
|
xml_data = '\n'.join(buf)
|
||||||
|
dom = xml.dom.minidom.parseString(xml_data)
|
||||||
|
pretty_xml = dom.toprettyxml()
|
||||||
|
formatted_lines = pretty_xml.split('\n')
|
||||||
|
buf[:] = formatted_lines
|
||||||
|
|
||||||
|
format_xml()
|
||||||
|
]]
|
||||||
|
|
||||||
|
vim.api.nvim_command("command! FormatXML :py3 " .. python_code)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Call the function to set up the command
|
||||||
|
setup_format_xml_command()
|
||||||
|
|
||||||
|
return {}
|
Loading…
Reference in New Issue