Skip to content

Commit 449673d

Browse files
authored
make lsp-java-format-tab-size compatible with java-ts-mode (#456)
fix#447, fix#451 Currently `lsp-java-format-tab-size` is `c-basic-offset`. By default c-basic-offset is a special value `set-from-style. When java-mode starts it will get set c-basic-offset to a number such as 4 or 2. java-ts-mode won't do anything with c-basic-offset. So lsp will fail to generate the initializationOptions json because tabSize is set-from-style. This MR turn lsp-java-format-tab-size to a function to return correct indent setting depending whether java-ts-mode is on or not. This s a fancy solution. A simple and fool proof one can be a number value ```elisp (lsp-defcustom lsp-java-format-tab-size 4 "The basic offset" :type 'number :lsp-path "java.format.tabSize") ```
1 parent bc89297 commit 449673d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lsp-java.el

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,11 @@ example 'java.awt.*' will hide all types from the awt packages."
385385
:type '(lsp-repeatable-vector string)
386386
:lsp-path "java.completion.filteredTypes")
387387

388-
(lsp-defcustom lsp-java-format-tab-size 'c-basic-offset
388+
(lsp-defcustom lsp-java-format-tab-size (lambda () (if (equal major-mode 'java-ts-mode)
389+
java-ts-mode-indent-offset
390+
c-basic-offset))
389391
"The basic offset"
390-
:type 'symbol
392+
:type 'function
391393
:lsp-path "java.format.tabSize")
392394

393395
(lsp-defcustom lsp-java-format-insert-spaces (lambda () (not indent-tabs-mode))

0 commit comments

Comments
 (0)