File tree 2 files changed +53
-0
lines changed
2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ local M = {}
2
+
3
+ --- @param opts { once : boolean , group : number , callback : fun ( client : vim.lsp.Client ) }
4
+ function M .on_jdtls_attach (opts )
5
+ local id
6
+
7
+ id = vim .api .nvim_create_autocmd (' LspAttach' , {
8
+ group = opts .group ,
9
+ callback = function (args )
10
+ local client = vim .lsp .get_client_by_id (args .data .client_id )
11
+
12
+ if client and client .name == ' jdtls' then
13
+ opts .callback (client )
14
+
15
+ vim .api .nvim_del_autocmd (id )
16
+ end
17
+ end ,
18
+ })
19
+ end
20
+
21
+ return M
Original file line number Diff line number Diff line change
1
+ local M = {}
2
+
3
+ --- @return vim.lsp.Client
4
+ function M .get_client ()
5
+ local clients = vim .lsp .get_clients ({ name = ' jdtls' })
6
+
7
+ if # clients < 1 then
8
+ local message = ' No jdtls client found!'
9
+ require (' java-core.utils.notify' ).error (message )
10
+ require (' java.utils.log' ).error (message )
11
+ error (message )
12
+ end
13
+
14
+ return clients [1 ]
15
+ end
16
+
17
+ function M .get_jdtls ()
18
+ local JdtlsClient = require (' java-core.ls.clients.jdtls-client' )
19
+ return JdtlsClient (M .get_client ())
20
+ end
21
+
22
+ function M .get_debug ()
23
+ local DebugClient = require (' java-core.ls.clients.java-debug-client' )
24
+ return DebugClient (M .get_client ())
25
+ end
26
+
27
+ function M .get_test ()
28
+ local TestClient = require (' java-core.ls.clients.java-test-client' )
29
+ return TestClient (M .get_client ())
30
+ end
31
+
32
+ return M
You can’t perform that action at this time.
0 commit comments