Lemminx configuration

Hi, I’m using lemminx as Language Server.

Every time, it creates its cache directory in ~/.lemminx. I don’t want to pollute my $HOME, so following the XDG Specification, that folder should go inside ~/.cache/lemminx.

After investigation I ended up with the following snippet to configure that directory location:

{
	"initializationOptions": {
		"settings": {
			"xml": {
				"server": {
					"workDir": "~/.cache/lemminx"
				}
			}
		}
	}
}

What’s not clear is, how or where this configuration should be applied. The Lemminx documentation wasn’t very helpful with this.

Does anybody have any idea how to achieve this?

How do you set up your lsp? If you use nvim-lspconfig then it should be somethig like this:

require('lspconfig').lemminx.setup({
    settings = {
        xml = {
            server = {
                workDir = "~/.cache/lemminx",
            }
        }
    }
})

I set up my servers exactly like that. It seems like it worked, thanks!

I’m facing a similar issue, trying to provide a custom xsd file to lemminx to parse. The header of xml file (They have arxml extension though)

<?xml version="1.0" encoding="UTF-8"?>
<AUTOSAR xmlns="http://autosar.org/schema/r4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://autosar.org/schema/r4.0 AUTOSAR_00049.xsd">

If I copy the AUTOSAR_00049.xsd beside the arxml file, lemminx parses it and gives the documention and hovering stuff. To avoid copying the xsd file every where, I’m trying to configure the lemminx to pick it up from a common place. As documented here : lemminx/docs/Configuration.md at main · eclipse/lemminx · GitHub
So I configured lspconfig in neovim like :

require('lspconfig').lemminx.setup {
    handlers = conf.handlers,
    on_attach = conf.on_attach,
    capabilities = conf.capabilities,
    autostart = true,
    settings = {
        xml = {
            fileAssociations = {
                systemId = "~/.cache/lemminx/AUTOSAR_MMOD_XMLSchema/AUTOSAR_00049.xsd",
                pattern = "arxml"
            },
            server = {
                workDir = "~/.cache/lemminx",
            }
        }
    }
}

I also tried :

            fileAssociations = { {
                ["systemId"] = "~/.cache/lemminx/AUTOSAR_MMOD_XMLSchema/AUTOSAR_00049.xsd",
                ["pattern"] = "arxml"
            } },

But it doesn’t work, any idea ?

I’m having a similar problem, I can’t work out how to define fileAssociations either.

I found this documentation on the VSCode integration for this LSP: vscode-xml/docs/Preferences.md at main · redhat-developer/vscode-xml · GitHub

I tried:

settings = {
  xml = {
    fileAssociations = {
      {
        systemId = "/path",
        pattern = "*.ext",
      },
    },
  },
},

I don’t really know how I could go about debugging this, is there a way to see the LSP messages being sent?

I worked it out:

  • systemId has to be an absolute path, and it can’t contain environment variables or ~.
  • Also, globs seem to have to be two asterisks rather than one.

So I did this which worked for my use case:

settings = {
  xml = {
    fileAssociations = {
      {
        systemId = vim.env.HOME .. "/.config/blah/blah/blah",
        pattern = "**.ext",
      },
    },
  },
},