-
-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathjava.lua
More file actions
117 lines (88 loc) · 3.45 KB
/
java.lua
File metadata and controls
117 lines (88 loc) · 3.45 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
local decomple_watch = require('java.startup.decompile-watcher')
local mason_dep = require('java.startup.mason-dep')
local setup_wrap = require('java.startup.lspconfig-setup-wrap')
local startup_check = require('java.startup.startup-check')
local command_util = require('java.utils.command')
local test_api = require('java.api.test')
local dap_api = require('java.api.dap')
local runner_api = require('java.api.runner')
local settings_api = require('java.api.settings')
local profile_ui = require('java.ui.profile')
local global_config = require('java.config')
local M = {}
function M.setup(custom_config)
vim.api.nvim_exec_autocmds('User', { pattern = 'JavaPreSetup' })
local config =
vim.tbl_deep_extend('force', global_config, custom_config or {})
vim.g.nvim_java_config = config
vim.api.nvim_exec_autocmds(
'User',
{ pattern = 'JavaSetup', data = { config = config } }
)
if not startup_check() then
return
end
local is_installing = mason_dep.install(config)
if is_installing then
return
end
setup_wrap.setup(config)
decomple_watch.setup()
dap_api.setup_dap_on_lsp_attach()
vim.api.nvim_exec_autocmds(
'User',
{ pattern = 'JavaPostSetup', data = { config = config } }
)
end
---@param path string[]
---@param command fun()
---@param opts vim.api.keyset.user_command
function M.register_api(path, command, opts)
local name = command_util.path_to_command_name(path)
vim.api.nvim_create_user_command(name, command, opts or {})
local last_index = #path
local func_name = path[last_index]
table.remove(path, last_index)
local node = M
for _, v in ipairs(path) do
if not node[v] then
node[v] = {}
end
node = node[v]
end
node[func_name] = command
end
----------------------------------------------------------------------
-- DAP APIs --
----------------------------------------------------------------------
M.dap = {}
M.dap.config_dap = dap_api.config_dap
----------------------------------------------------------------------
-- Test APIs --
----------------------------------------------------------------------
M.test = {}
M.test.run_current_class = test_api.run_current_class
M.test.debug_current_class = test_api.debug_current_class
M.test.run_current_method = test_api.run_current_method
M.test.debug_current_method = test_api.debug_current_method
M.test.view_last_report = test_api.view_last_report
----------------------------------------------------------------------
-- Runner APIs --
----------------------------------------------------------------------
M.runner = {}
M.runner.built_in = {}
M.runner.built_in.run_app = runner_api.built_in.run_app
M.runner.built_in.toggle_logs = runner_api.built_in.toggle_logs
M.runner.built_in.stop_app = runner_api.built_in.stop_app
M.runner.built_in.switch_app = runner_api.built_in.switch_app
----------------------------------------------------------------------
-- Profile UI --
----------------------------------------------------------------------
M.profile = {}
M.profile.ui = profile_ui.ui
----------------------------------------------------------------------
-- Settings --
----------------------------------------------------------------------
M.settings = {}
M.settings.change_runtime = settings_api.change_runtime
return M