Skip to content

Commit 5f8aea9

Browse files
committed
chore: update types & readme
1 parent cef7f2f commit 5f8aea9

File tree

2 files changed

+123
-20
lines changed

2 files changed

+123
-20
lines changed

README.md

Lines changed: 112 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ https://github.com/nvim-java/nvim-java/assets/18459807/047c8c46-9a0a-4869-b342-d
1515
## :dizzy: Features
1616

1717
- :white_check_mark: Diagnostics & Auto Completion
18-
- :white_check_mark: Automatic [DAP](https://github.com/mfussenegger/nvim-dap) debug configuration
18+
- :white_check_mark: Automatic [DAP](https://github.com/mfussenegger/nvim-dap)
19+
debug configuration
1920
- :white_check_mark: Running tests
2021

2122
## :bulb: Why
@@ -35,10 +36,11 @@ https://github.com/nvim-java/nvim-java/assets/18459807/047c8c46-9a0a-4869-b342-d
3536

3637
<summary>:small_orange_diamond:details</summary>
3738

38-
### Distributions:
39+
### Distributions
40+
3941
- [Lazyvim](https://github.com/nvim-java/nvim-java/wiki/Lazyvim)
4042

41-
### Custom:
43+
### Custom
4244

4345
- Install the plugin
4446

@@ -90,7 +92,25 @@ Yep! That's all :)
9092

9193
<summary>:small_orange_diamond:details</summary>
9294

93-
- `JavaDapConfig` - DAP is autoconfigured on start up, but in case you want to force configure it again, you can use this API
95+
### Runner
96+
97+
- `JavaRunnerRunMain` - Runs the application or selected main class (if there
98+
multiple main classes)
99+
100+
```vim
101+
:JavaRunnerRunMain <arguments> <to> <pass>
102+
```
103+
104+
- `JavaRunnerStopMain` - Stops the running application
105+
- `JavaRunnerToggleLogs` - Toggle between show & hide runner log window
106+
107+
### DAP
108+
109+
- `JavaDapConfig` - DAP is autoconfigured on start up, but in case you want to
110+
force configure it again, you can use this API
111+
112+
### Test
113+
94114
- `JavaTestRunCurrentClass` - Run the test class in the active buffer
95115
- `JavaTestDebugCurrentClass` - Debug the test class in the active buffer
96116
- `JavaTestRunCurrentMethod` - Run the test method on the cursor
@@ -105,15 +125,38 @@ Yep! That's all :)
105125

106126
<summary>:small_orange_diamond:details</summary>
107127

108-
**DAP**
128+
### Runner
129+
130+
- `built_in.run_app` - Runs the application or selected main class (if there
131+
multiple main classes)
132+
133+
```lua
134+
require('java').built_in.run_app({})
135+
require('java').built_in.run_app({'arguments', 'to', 'pass', 'to', 'main'})
136+
```
137+
138+
- `built_in.stop_app` - Stops the running application
139+
140+
```lua
141+
require('java').built_in.stop_app()
142+
```
143+
144+
- `built_in.toggle_logs` - Toggle between show & hide runner log window
109145

110-
- `config_dap` - DAP is autoconfigured on start up, but in case you want to force configure it again, you can use this API
146+
```lua
147+
require('java').built_in.toggle_logs()
148+
```
149+
150+
### DAP
151+
152+
- `config_dap` - DAP is autoconfigured on start up, but in case you want to force
153+
configure it again, you can use this API
111154

112155
```lua
113156
require('java').dap.config_dap()
114157
```
115158

116-
**Test**
159+
### Test
117160

118161
- `run_current_class` - Run the test class in the active buffer
119162

@@ -153,10 +196,11 @@ require('java').test.view_last_report()
153196

154197
<summary>:small_orange_diamond:details</summary>
155198

156-
### Method 1:
199+
### Method 1
157200

158-
[Neoconf](https://github.com/folke/neoconf.nvim) can be used to manage LSP setting including jdtls. Neoconf allows
159-
global configuration as well as project vice configurations. Here is how you can set Jdtls setting on `neoconf.json`
201+
[Neoconf](https://github.com/folke/neoconf.nvim) can be used to manage LSP
202+
setting including jdtls. Neoconf allows global configuration as well as project
203+
vice configurations. Here is how you can set Jdtls setting on `neoconf.json`
160204

161205
```json
162206
{
@@ -174,7 +218,7 @@ global configuration as well as project vice configurations. Here is how you can
174218
}
175219
```
176220

177-
### Method 2:
221+
### Method 2
178222

179223
Pass the settings to Jdtls setup.
180224

@@ -198,15 +242,65 @@ require('lspconfig').jdtls.setup({
198242

199243
</details>
200244

245+
## :wrench: Configuration
246+
247+
<details>
248+
249+
<summary>:small_orange_diamond:details</summary>
250+
251+
For most users changing the default configuration is not necessary. But if you
252+
want, following options are available
253+
254+
```lua
255+
{
256+
-- list of file that exists in root of the project
257+
root_markers = {
258+
'settings.gradle',
259+
'settings.gradle.kts',
260+
'pom.xml',
261+
'build.gradle',
262+
'mvnw',
263+
'gradlew',
264+
'build.gradle',
265+
'build.gradle.kts',
266+
'.git',
267+
},
268+
269+
-- load java test plugins
270+
java_test = {
271+
enable = true,
272+
},
273+
274+
-- load java debugger plugins
275+
java_debug_adapter = {
276+
enable = true,
277+
},
278+
279+
jdk = {
280+
-- install jdk using mason.nvim
281+
auto_install = true,
282+
},
283+
284+
notifications = {
285+
-- enable 'Configuring DAP' & 'DAP configured' messages on start up
286+
dap = true,
287+
},
288+
}
289+
```
290+
291+
</details>
292+
201293
## :golf: Architecture
202294

203295
<details>
204296

205297
<summary>:small_orange_diamond:details</summary>
206298

207-
Following is the high level idea. Jdtls is the language server nvim-java communicates with. However,
208-
we don't have all the features we need just in Jdtls. So, we are loading java-test & java-debug-adapter extensions
209-
when we launch Jdtls. Once the language server is started, we communicate with the language server to do stuff.
299+
Following is the high level idea. Jdtls is the language server nvim-java
300+
communicates with. However, we don't have all the features we need just in
301+
Jdtls. So, we are loading java-test & java-debug-adapter extensions when we
302+
launch Jdtls. Once the language server is started, we communicate with the
303+
language server to do stuff.
210304

211305
For instance, to run the current test,
212306

@@ -218,7 +312,7 @@ For instance, to run the current test,
218312
- Parse the test results as they come in
219313
- Once the execution is done, open a window show the test results
220314

221-
```
315+
```text
222316
┌────────────┐ ┌────────────┐
223317
│ │ │ │
224318
│ Neovim │ │ VSCode │
@@ -259,6 +353,7 @@ For instance, to run the current test,
259353

260354
## :bookmark_tabs: Projects Acknowledgement
261355

262-
[nvim-jdtls](https://github.com/mfussenegger/nvim-jdtls) is a plugin that follows "Keep it simple, stupid!" approach.
263-
If you love customizing things by yourself, then give nvim-jdtls a try. I may or may not have copied some code :wink:
356+
[nvim-jdtls](https://github.com/mfussenegger/nvim-jdtls) is a plugin that follows
357+
"Keep it simple, stupid!" approach. If you love customizing things by yourself,
358+
then give nvim-jdtls a try. I may or may not have copied some code :wink:
264359
Beauty of Open source!

lua/java/config.lua

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---@class java.Config
2-
---@field root_markers string[] list of file that exists in root of the project
3-
---@field jdtls_plugins string[] what plugins to load
2+
---@field root_markers string[]
43
---@field java_test { enable: boolean }
54
---@field java_debug_adapter { enable: boolean }
65
---@field jdk { auto_install: boolean }
7-
6+
---@field notifications { dap: boolean }
87
local config = {
8+
-- list of file that exists in root of the project
99
root_markers = {
1010
'settings.gradle',
1111
'settings.gradle.kts',
@@ -17,16 +17,24 @@ local config = {
1717
'build.gradle.kts',
1818
'.git',
1919
},
20+
21+
-- load java test plugins
2022
java_test = {
2123
enable = true,
2224
},
25+
26+
-- load java debugger plugins
2327
java_debug_adapter = {
2428
enable = true,
2529
},
30+
2631
jdk = {
32+
-- install jdk using mason.nvim
2733
auto_install = true,
2834
},
35+
2936
notifications = {
37+
-- enable 'Configuring DAP' & 'DAP configured' messages on start up
3038
dap = true,
3139
},
3240
}

0 commit comments

Comments
 (0)