forked from nvim-java/nvim-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdap.lua
More file actions
45 lines (35 loc) · 1.08 KB
/
dap.lua
File metadata and controls
45 lines (35 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
local JavaDap = require('java.dap')
local log = require('java.utils.log')
local get_error_handler = require('java.handlers.error')
local jdtls = require('java.utils.jdtls')
local async = require('java-core.utils.async').sync
local notify = require('java-core.utils.notify')
local M = {}
---Setup dap config & adapter on jdtls attach event
function M.setup_dap_on_lsp_attach()
log.info('add LspAttach event handlers to setup dap adapter & config')
vim.api.nvim_create_autocmd('LspAttach', {
pattern = '*',
callback = M.on_jdtls_attach,
once = true,
group = vim.api.nvim_create_augroup('nvim-java-dap-config', {}),
})
end
function M.config_dap()
log.info('configuring dap')
return async(function()
notify.warn('Configuring DAP')
JavaDap:new(jdtls()):config_dap()
notify.info('DAP configured')
end)
.catch(get_error_handler('dap configuration failed'))
.run()
end
function M.on_jdtls_attach(ev)
local client = vim.lsp.get_client_by_id(ev.data.client_id)
if client.name == 'jdtls' then
log.info('setup java dap config & adapter')
M.config_dap()
end
end
return M