1- *nvim-java.txt* For Neovim >= 0.9.4 Last change: 2023 November 15
1+ *nvim-java.txt* For Neovim >= 0.9.4 Last change: 2023 December 08
22
33==============================================================================
44Table of Contents *nvim-java-table-of-contents*
55
661. nvim-java | nvim-java-nvim-java |
7+ - Demo | nvim-java-demo |
78 - Features | nvim-java-features |
89 - Why | nvim-java-why |
9- - How to Use | nvim-java-how-to-use |
10+ - How to Install | nvim-java-how-to-install |
11+ - Commands | nvim-java-commands |
1012 - APIs | nvim-java-apis |
13+ - Architecture | nvim-java-architecture |
1114 - Projects Acknowledgement | nvim-java-projects-acknowledgement |
1215
1316==============================================================================
@@ -20,6 +23,17 @@ nonsense anymore. Just install and start writing `public static void
2023main(String[] args)`.
2124
2225
26+ [!WARNING ] This is a WIP but we are so close to v1.0.0. So it could be rough
27+ around the edges and documents might not be up to date. You can check the
28+ progress we are making here
29+ https://github.com/orgs/nvim-java/projects/1/views/2 .
30+
31+ DEMO *nvim-java-demo*
32+
33+
34+ https://github.com/nvim-java/nvim-java/assets/18459807/047c8c46-9a0a-4869-b342-d5c2e15647bc
35+
36+
2337FEATURES *nvim-java-features*
2438
2539- Diagnostics & Auto Completion
@@ -31,39 +45,54 @@ WHY *nvim-java-why*
3145
3246- Uses nvim-lspconfig <https://github.com/neovim/nvim-lspconfig > to setup `jdtls`
3347- Realtime server settings updates is possible using neoconf <https://github.com/folke/neoconf.nvim >
34- - Everything necessary will be installed automatically (except JDKs)
48+ - Everything necessary will be installed automatically
3549- Uses `jdtls` and auto loads `jdtls` plugins from mason.nvim <https://github.com/williamboman/mason.nvim >
3650 - Supported plugins are,
3751 - `lombok`
3852 - `java- test`
3953 - `java- debug - adapter`
4054- Typed & documented APIs
41- - No callback hells I promise <https://github.com/pyericz/promise-lua >
4255
4356
44- HOW TO USE *nvim-java-how-to-use *
57+ HOW TO INSTALL *nvim-java-how-to-install *
4558
59+ details ~
4660
47- INSTALL THE PLUGIN ~
61+ - Install the plugin
4862
4963Using lazy.nvim <https://github.com/folke/lazy.nvim >
5064
5165>lua
5266 return {
5367 'nvim-java/nvim-java',
5468 dependencies = {
69+ 'nvim-java/lua-async-await',
5570 'nvim-java/nvim-java-core',
71+ 'nvim-java/nvim-java-test',
72+ 'nvim-java/nvim-java-dap',
73+ 'MunifTanjim/nui.nvim',
5674 'neovim/nvim-lspconfig',
57- 'williamboman/mason.nvim',
5875 'mfussenegger/nvim-dap',
76+ {
77+ 'williamboman/mason.nvim',
78+ opts = {
79+ registries = {
80+ 'github:nvim-java/mason-registry',
81+ 'github:mason-org/mason-registry',
82+ },
83+ },
84+ }
5985 },
60- event = 'VeryLazy',
61- opts = {},
6286 }
6387<
6488
89+ - Setup nvim-java before `lspconfig`
6590
66- SETUP JDTLS LIKE YOU WOULD USUALLY DO ~
91+ >lua
92+ require('java' ).setup()
93+ <
94+
95+ - Setup jdtls like you would usually do
6796
6897>lua
6998 require('lspconfig' ).jdtls.setup({})
@@ -72,30 +101,118 @@ SETUP JDTLS LIKE YOU WOULD USUALLY DO ~
72101Yep! That’s all :)
73102
74103
104+ COMMANDS *nvim-java-commands*
105+
106+ details ~
107+
108+ - `JavaDapConfig` - DAP is autoconfigured on start up, but in case you want to force configure it again, you can use this API
109+ - `JavaTestRunCurrentClass` - Run the test class in the active buffer
110+ - `JavaTestDebugCurrentClass` - Debug the test class in the active buffer
111+ - `JavaTestRunCurrentMethod` - Run the test method on the cursor
112+ - `JavaTestDebugCurrentMethod` - Debug the test method on the cursor
113+ - `JavaTestViewLastReport` - Open the last test report in a popup window
114+
115+
75116APIS *nvim-java-apis*
76117
118+ details ~
77119
78- DAP ~
120+ ** DAP**
79121
80122- `config_dap` - DAP is autoconfigured on start up, but in case you want to force configure it again, you can use this API
81123
82124>lua
83125 require('java' ).dap.config_dap()
84126<
85127
128+ **Test**
129+
130+ - `run_current_class` - Run the test class in the active buffer
131+
132+ >lua
133+ require('java' ).test.run_current_class()
134+ <
135+
136+ - `debug_current_class` - Debug the test class in the active buffer
86137
87- TEST ~
138+ >lua
139+ require('java' ).test.debug_current_class()
140+ <
88141
89- - `run_current_test_class ` - Run the test class in the active buffer
142+ - `run_current_method ` - Run the test method on the cursor
90143
91144>lua
92- require('java' ).test.run_current_test_class ()
145+ require('java' ).test.run_current_method ()
93146<
94147
95- - `debug_current_test_class ` - Debug the test class in the active buffer
148+ - `debug_current_method ` - Debug the test method on the cursor
96149
97150>lua
98- require('java' ).test.debug_current_test_class()
151+ require('java' ).test.debug_current_method()
152+ <
153+
154+ - `view_report` - Open the last test report in a popup window
155+
156+ >lua
157+ require('java' ).test.view_last_report()
158+ <
159+
160+
161+ ARCHITECTURE *nvim-java-architecture*
162+
163+ details ~
164+
165+ Following is the high level idea. Jdtls is the language server nvim-java
166+ communicates with. However, we don’t have all the features we need just in
167+ Jdtls. So, we are loading java-test & java-debug-adapter extensions when we
168+ launch Jdtls. Once the language server is started, we communicate with the
169+ language server to do stuff.
170+
171+ For instance, to run the current test,
172+
173+ - Request Jdtls for test classes
174+ - Request Jdtls for class paths, module paths, java executable
175+ - Request Jdtls to start a debug session and send the port of the session back
176+ - Prepare TCP connections to listen to the test results
177+ - Start nvim-dap and let user interactions to be handled by nvim-dap
178+ - Parse the test results as they come in
179+ - Once the execution is done, open a window show the test results
180+
181+ >
182+ ┌────────────┐ ┌────────────┐
183+ │ │ │ │
184+ │ Neovim │ │ VSCode │
185+ │ │ │ │
186+ └─────▲──────┘ └──────▲─────┘
187+ │ │
188+ │ │
189+ │ │
190+ │ │
191+ ┌───────▼───────┐ ┌──────────────▼──────────────┐
192+ │ │ │ │
193+ │ nvim-java │ │ Extension Pack for Java │
194+ │ │ │ │
195+ └───────▲───────┘ └──────────────▲──────────────┘
196+ │ │
197+ │ │
198+ │ │
199+ │ │
200+ │ │
201+ │ ┌───────────┐ │
202+ │ │ │ │
203+ └──────────────► JDTLS ◄────────────┘
204+ │ │
205+ └───▲───▲───┘
206+ │ │
207+ │ │
208+ │ │
209+ │ │
210+ │ │
211+ ┌───────────────┐ │ │ ┌────────────────────────┐
212+ │ │ │ │ │ │
213+ │ java-test ◄────────┘ └─────────► java-debug-adapter │
214+ │ │ │ │
215+ └───────────────┘ └────────────────────────┘
99216<
100217
101218
@@ -104,7 +221,7 @@ PROJECTS ACKNOWLEDGEMENT *nvim-java-projects-acknowledgement*
104221nvim-jdtls <https://github.com/mfussenegger/nvim-jdtls > is a plugin that
105222follows "Keep it simple, stupid!" approach. If you love customizing things by
106223yourself, then give nvim-jdtls a try. I may or may not have copied some code
107- ;-) Open source is beautiful !
224+ Beautyof Open source!
108225
109226==============================================================================
1102272. Links *nvim-java-links*
0 commit comments