Skip to content

Commit

Permalink
fix(java): use jdtls for formatting instead of clang-format (#888)
Browse files Browse the repository at this point in the history
* 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 <micah@mehalter.com>

---------

Co-authored-by: Juniar Rakhman <juniar@almende.org>
Co-authored-by: Micah Halter <micah@mehalter.com>
  • Loading branch information
3 people authored Apr 16, 2024
1 parent ea92faa commit 70754e5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 24 deletions.
19 changes: 12 additions & 7 deletions lua/astrocommunity/pack/java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
},
},
},
},
},
}
```
18 changes: 1 addition & 17 deletions lua/astrocommunity/pack/java/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
},
Expand Down Expand Up @@ -162,13 +155,4 @@ return {
})
end,
},
{
"stevearc/conform.nvim",
optional = true,
opts = {
formatters_by_ft = {
java = { "clang-format" },
},
},
},
}

1 comment on commit 70754e5

@jay-babu
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! This is great

Please sign in to comment.