Skip to content

Commit 62bf7f7

Browse files
authored
feat: add commands for lua APIs (nvim-java#43)
1 parent 0edb02c commit 62bf7f7

File tree

4 files changed

+39
-8
lines changed

4 files changed

+39
-8
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,21 @@ Yep! That's all :)
8282

8383
</details>
8484

85+
## :keyboard: Commands
86+
87+
<details>
88+
89+
<summary>:pushpin: details</summary>
90+
91+
- `JavaDapConfig` - DAP is autoconfigured on start up, but in case you want to force configure it again, you can use this API
92+
- `JavaTestRunCurrentClass` - Run the test class in the active buffer
93+
- `JavaTestDebugCurrentClass` - Debug the test class in the active buffer
94+
- `JavaTestRunCurrentMethod` - Run the test method on the cursor
95+
- `JavaTestDebugCurrentMethod` - Debug the test method on the cursor
96+
- `JavaTestViewLastReport` - Open the last test report in a popup window
97+
98+
</details>
99+
85100
## :computer: APIs
86101

87102
<details>
@@ -125,7 +140,7 @@ require('java').test.debug_current_method()
125140
- `view_report` - Open the last test report in a popup window
126141

127142
```lua
128-
require('java').test.view_report()
143+
require('java').test.view_last_report()
129144
```
130145

131146
</details>

lua/java.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ M.test.debug_current_class = test.debug_current_class
4040
M.test.run_current_method = test.run_current_method
4141
M.test.debug_current_method = test.debug_current_method
4242

43-
M.test.view_report = test.view_report
43+
M.test.view_last_report = test.view_last_report
4444

4545
----------------------------------------------------------------------
4646
-- Manipulate --

lua/java/api/test.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function M.run_current_method()
5959
.run()
6060
end
6161

62-
function M.view_report()
62+
function M.view_last_report()
6363
if M.last_report then
6464
M.last_report:show_report()
6565
end

plugin/java.lua

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
1-
-- vim.api.nvim_create_user_command(
2-
-- 'MyFirstFunction',
3-
-- require('plugin_name').hello,
4-
-- {}
5-
-- )
1+
local java = require('java')
2+
3+
local function c(cmd, callback, opts)
4+
vim.api.nvim_create_user_command(cmd, callback, opts or {})
5+
end
6+
7+
local cmd_map = {
8+
JavaDapConfig = { java.dap.config_dap },
9+
10+
JavaTestRunCurrentClass = { java.test.run_current_class },
11+
JavaTestDebugCurrentClass = { java.test.debug_current_class },
12+
13+
JavaTestRunCurrentMethod = { java.test.run_current_method },
14+
JavaTestDebugCurrentMethod = { java.test.debug_current_method },
15+
16+
JavaTestViewLastReport = { java.test.view_last_report },
17+
}
18+
19+
for cmd, details in pairs(cmd_map) do
20+
c(cmd, details[1], details[2])
21+
end

0 commit comments

Comments
 (0)