From 70754e5af8cc827d8858f441ec24d4d194d3bc8d Mon Sep 17 00:00:00 2001 From: Juniar P Rakhman Date: Tue, 16 Apr 2024 23:08:32 +0700 Subject: [PATCH] fix(java): use `jdtls` for formatting instead of `clang-format` (#888) * fix(pack-java): remove unnecessary clang-formatter * fix(pack-java): update pack-java readme * Update lua/astrocommunity/pack/java/README.md Co-authored-by: Micah Halter --------- Co-authored-by: Juniar Rakhman Co-authored-by: Micah Halter --- lua/astrocommunity/pack/java/README.md | 19 ++++++++++++------- lua/astrocommunity/pack/java/init.lua | 18 +----------------- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/lua/astrocommunity/pack/java/README.md b/lua/astrocommunity/pack/java/README.md index b22d0ce74..dcd08e4b9 100644 --- a/lua/astrocommunity/pack/java/README.md +++ b/lua/astrocommunity/pack/java/README.md @@ -11,20 +11,18 @@ This plugin pack does the following: - Adds `jdtls` language server - Adds `lemminx` language server (XML) - Adds [nvim-jdtls](https://github.com/mfussenegger/nvim-jdtls) for language specific tooling - - Enables [hot reloading](https://github.com/mfussenegger/nvim-jdtls/issues/80) -- Adds `clang_format` through null-ls +- Enables [hot reloading](https://github.com/mfussenegger/nvim-jdtls/issues/80) - Adds `javadbg` and `javatest` debug adapters for nvim-dap ## Note -We require that the root folder of your projects inlude one of these files/folders([Reference](https://github.com/AstroNvim/astrocommunity/blob/49e9a3961bba079d7f413b8d5567382dd6f55392/lua/astrocommunity/pack/java/java.lua#LL37C96-L37C96)): +We require that the root folder of your projects include one of these files/folders([Reference](https://github.com/AstroNvim/astrocommunity/blob/49e9a3961bba079d7f413b8d5567382dd6f55392/lua/astrocommunity/pack/java/java.lua#LL37C96-L37C96)): `.git`, `mvnw`, `gradlew`, `pom.xml`, `build.gradle` or `.project` - - ## Tips -`jdtls` requires Java 11+ but can be used to develop on any Java version. If you develop using different Java runtimes, you can set the runtimes you have available in the settings of `jdtls`. Here is a simple example: +`jdtls` requires Java 11+ but can be used to develop on any Java version. If you develop using different Java runtimes, you can set the runtimes you have available in the settings of `jdtls`. +Here is a simple example: ```lua "AstroNvim/astrocommunity", @@ -43,7 +41,14 @@ We require that the root folder of your projects inlude one of these files/folde }, }, }, + format = { + enabled = true, + settings = { -- you can use your preferred format style + url = "https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml", + profile = "GoogleStyle", + }, + }, }, }, - }, + } ``` diff --git a/lua/astrocommunity/pack/java/init.lua b/lua/astrocommunity/pack/java/init.lua index 23a7d2891..5eca7a904 100644 --- a/lua/astrocommunity/pack/java/init.lua +++ b/lua/astrocommunity/pack/java/init.lua @@ -15,13 +15,6 @@ return { opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "jdtls", "lemminx" }) end, }, - { - "jay-babu/mason-null-ls.nvim", - optional = true, - opts = function(_, opts) - opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "clang_format" }) - end, - }, { "jay-babu/mason-nvim-dap.nvim", optional = true, @@ -35,7 +28,7 @@ return { opts = function(_, opts) opts.ensure_installed = require("astrocore").list_insert_unique( opts.ensure_installed, - { "jdtls", "lemminx", "clang-format", "java-debug-adapter", "java-test" } + { "jdtls", "lemminx", "java-debug-adapter", "java-test" } ) end, }, @@ -162,13 +155,4 @@ return { }) end, }, - { - "stevearc/conform.nvim", - optional = true, - opts = { - formatters_by_ft = { - java = { "clang-format" }, - }, - }, - }, }