Skip to content

Does not format/indent Switch statements correctly #143

@bradyt

Description

@bradyt

The Google Java Style Guide re: switch statements, says "As with any other block, the contents of a switch block are indented +2."

So I would presume that if I have the following,

(add-hook 'java-mode-hook (defun my-set-java-tab-width () (setq tab-width 2)))
(setq lsp-java-format-settings-url "https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml")
(setq lsp-java-format-settings-profile "GoogleStyle")

Then M-x lsp-format-buffer should indent the switch statements as described.

That is, I would expect

switch(expression) {
    case x:
        // code block
        break;
    case y:
        // code block
        break;
    default:
        // code block
}

But instead, I see

switch(expression) {
case x:
    // code block
    break;
case y:
    // code block
    break;
default:
    // code block
}

I created a reproduce in a Docker recipe at https://github.com/bradyt/docker-emacs/tree/lsp-java.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions