Skip to content

Commit 75a1799

Browse files
committed
添加使用说明
1 parent bbcc337 commit 75a1799

File tree

1 file changed

+54
-3
lines changed

1 file changed

+54
-3
lines changed

README.md

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
![java-deps](https://javahello.github.io/dev/nvim-lean/images/java-deps.png)
77

8-
## 使用说明
8+
## 安装
99

1010
- lazy.nvim
1111

@@ -20,6 +20,57 @@
2020
end,
2121
}
2222

23-
-- jdtls lsp attach
24-
require("java-deps").attach(client, buffer, root_dir)
23+
```
24+
25+
- 手动编译 `vscode-java-dependency`
26+
27+
```sh
28+
git clone https://github.com/microsoft/vscode-java-dependency.git
29+
cd vscode-java-dependency
30+
npm install
31+
npm run build-server
32+
```
33+
34+
- 配置 `vscode-java-dependency` 到 jdtls_config["init_options"].bundles 中
35+
36+
```lua
37+
local jdtls_config = {}
38+
local bundles = {}
39+
-- ...
40+
local java_dependency_bundle = vim.split(
41+
vim.fn.glob(
42+
"/path?/vscode-java-dependency/jdtls.ext/com.microsoft.jdtls.ext.core/target/com.microsoft.jdtls.ext.core-*.jar"
43+
),
44+
"\n"
45+
)
46+
47+
if java_dependency_bundle[1] ~= "" then
48+
vim.list_extend(bundles, java_dependency_bundle)
49+
end
50+
51+
jdtls_config["init_options"] = {
52+
bundles = bundles,
53+
extendedClientCapabilities = extendedClientCapabilities,
54+
}
55+
```
56+
57+
- 添加 attach
58+
59+
```lua
60+
jdtls_config["on_attach"] = function(client, buffer)
61+
require("java-deps").attach(client, buffer)
62+
-- 添加命令
63+
local create_command = vim.api.nvim_buf_create_user_command
64+
create_command(buffer, "JavaProjects", require("java-deps").toggle_outline, {
65+
nargs = 0,
66+
})
67+
end
68+
```
69+
70+
- Usage
71+
72+
```vim
73+
:lua require('java-deps').toggle_outline()
74+
:lua require('java-deps').open_outline()
75+
:lua require('java-deps').close_outline()
2576
```

0 commit comments

Comments
 (0)