Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xml.format.tabSize and xml.format.insertSpaces have no effect in Neovim #1671

Open
on2e opened this issue Aug 25, 2024 · 1 comment
Open

Comments

@on2e
Copy link

on2e commented Aug 25, 2024

I am currently trying the lemminx server in Neovim and I'm having a hard time setting the tabSize option. My config looks like this:

settings = {
    xml = {
        format = {
            enabled = true,
            splitAttributes = false,
            spaceBeforeEmptyCloseTag = true,
            insertSpaces = true,
            tabSize = 10,
        },
    },
},

However, when I am formatting an XML file, the effective tabSize is 4, not 10 (or any other value I set). A tab size of 4 and the use of spaces are derived from my Neovim options. These options can been seen in the LSP logs for the lemminx server for formatting requests:

...
[DEBUG][2024-08-25 02:01:32] ...m/lsp/client.lua:676	"LSP[lemminx]"	"client.request"	1	"textDocument/formatting"	{  options = {    insertSpaces = true,    tabSize = 4  },  textDocument = {    uri = "file:///path/to/file.xml"  }}	<function 1>	13
[DEBUG][2024-08-25 02:01:32] .../vim/lsp/rpc.lua:286	"rpc.send"	{  id = 20,  jsonrpc = "2.0",  method = "textDocument/formatting",  params = {    options = {      insertSpaces = true,      tabSize = 4    },    textDocument = {      uri = "file:///path/to/file.xml"    }  }}
...

The xml.format.tabSize and xml.format.insertSpaces values do not end up in the formatting_options table and Neovim uses the global options for these fields, as documented, to format the file.

The options passed by the user in xml.format that are shared with FormattingOptions should override the latter.

I do not currently know if this is a lemminx issue or a Neovim LSP client issue.

The other options set in the xml.format seem to be working.


LemMinX: 0.27.1
Neovim: v0.10.0
OS: Ubuntu 22.04.4 LTS

@angelozerr
Copy link
Contributor

Here an LSP request in vscode when format is done

[Trace - 8:46:12 AM] Sending request 'textDocument/formatting - (41)'.

Params: {
    "textDocument": {
        "uri": "file:///c%3A/Users/azerr/Desktop/foo.xml"
    },
    "options": {
        "tabSize": 2,
        "insertSpaces": false,
        "trimFinalNewlines": true,
        "insertFinalNewline": true
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants