-
I am trying to use lsp-mode (lsp-java 20250228.2147 from melpa on emacs 30.1 on debian 12.11 "bookworm"). Is it possible to keep other stuff like code navigation and auto-expansion, but to exclude text formatting done by the jdtls and use the native emacs java-ts-mode text formatting instead? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
It is possible that setting lsp-enable-indentation to nil will do what I want? I am currently using editorconfig to align emacs and eclipse formatting so having jdtls use editorconfig would take me part of the way. But I think what I primarily want is plain emacs language formatting. |
Beta Was this translation helpful? Give feedback.
-
The lsp-java setup page at https://emacs-lsp.github.io/lsp-java/ had the answer:
It had the value of t, and I set the value to nil in my ~/.emacs java treesitter and lsp-java setup, which made emacs use java-ts-mode formatting: (when (treesit-language-available-p 'java)
(add-to-list 'major-mode-remap-alist '(java-mode . java-ts-mode))
(when (locate-library "lsp-java")
(require 'lsp-java)
(setq lsp-java-format-enabled nil)
(add-hook 'java-ts-mode-hook #'lsp))
(when (locate-library "lsp-java-boot")
(require 'lsp-java-boot)
(add-hook 'lsp-mode-hook #'lsp-lens-mode)
(add-hook 'java-ts-mode-hook #'lsp-java-boot-lens-mode))) |
Beta Was this translation helpful? Give feedback.
The lsp-java setup page at https://emacs-lsp.github.io/lsp-java/ had the answer:
It had the value of t, and I set the value to nil in my ~/.emacs java treesitter and lsp-java setup, which made emacs use java-ts-mode formatting: