9fans / acme-lsp

Language Server Protocol tools for the acme text editor
MIT License
193 stars 25 forks source link

Add support for FormattingOptions in config.toml #72

Open djmoch opened 4 months ago

djmoch commented 4 months ago

Currently, when acme-lsp sends a Formatting command to the server, it implicitly provides the zero-value for FormattingOptions, amounting to a TabSize = 0 and InsertSpaces = false.

When using the YAPF plugin with python-lsp-server, these values override the configured behavior. In my case, I'd like to adhere to the PEP-8 standard, which would require TabSize = 4 and InsertSpaces = true.

Given all of that, I'd like to propose adding per-server support for FormattingOptions. The result would be something like:

[Servers]
    [Servers.pylsp]
    Command = ["pylsp", "-vvv"]
    StderrFile = "pylsp.stderr.log"
    LogFile = "pylsp.log"

        # These settings get passed to pylsp
        [Servers.pylsp.Options]
        "pylsp.plugins.autopep8.enabled" = false
        "pylsp.plugins.yapf.enabled" = true

        # These settings get passed on Format
        [Servers.pylsp.FormattingOptions]
        TabSize = 4
        InsertSpaces = true

If this seems reasonable, I'd be happy to open a PR to add this.

Please let me know your thoughts.

farhaven commented 4 months ago

I'd love that. I'm running into a similar scenario when editing Typescript stuff, and my muscle memory trips me up about once a day on this.