From bb99923be4b5bcda58031ccea3d7f7d289ca611d Mon Sep 17 00:00:00 2001 From: Oscar Wallberg Date: Fri, 23 Aug 2024 16:05:48 +0200 Subject: [PATCH] feat(lemminx): change formatter to xmlformatter --- lua/lsp/config/lemminx.lua | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/lua/lsp/config/lemminx.lua b/lua/lsp/config/lemminx.lua index 59f1fb9..417508b 100644 --- a/lua/lsp/config/lemminx.lua +++ b/lua/lsp/config/lemminx.lua @@ -1,10 +1,40 @@ -- spec: https://github.com/eclipse/lemminx/blob/main/docs/Configuration.md +local utils = require("utils") + return { enable = true, mason = { name = "lemminx", - -- version = "", + dependencies = { "xmlformatter" }, + }, + keymaps = { + { + mode = "n", + lhs = "lf", + rhs = function() + utils.format({ + cmd = { + "xmlformat", + "-", + }, + output = "stdout", + }) + end, + }, + { + mode = "x", + lhs = "lf", + rhs = function() + utils.format({ + cmd = { + "xmlformat", + "-", + }, + output = "stdout", + }) + end, + }, }, lspconfig = { filetypes = { @@ -20,7 +50,7 @@ return { settings = { xml = { format = { - enabled = true, -- is able to format document + enabled = false, -- is able to format document splitAttributes = true, -- each attribute is formatted onto new line joinCDATALines = false, -- normalize content inside CDATA joinCommentLines = false, -- normalize content inside comments