Skip to content

Is it possible to use lsp-mode but exclude jdtls text formatting? #4824

Answered by steinarb
steinarb asked this question in Q&A
Discussion options

You must be logged in to vote

The lsp-java setup page at https://emacs-lsp.github.io/lsp-java/ had the answer:

  • lsp-java-format-enabled - Enable/disable default Java formatter

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 #'l…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by steinarb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant