Skip to content

添加使用说明 #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 56 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

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

## 使用说明
## 安装

[English](https://github.com/JavaHello/java-deps.nvim/issues/2)

- lazy.nvim

Expand All @@ -20,6 +22,57 @@
end,
}

-- jdtls lsp attach
require("java-deps").attach(client, buffer, root_dir)
```

- 手动编译 `vscode-java-dependency`

```sh
git clone https://github.com/microsoft/vscode-java-dependency.git
cd vscode-java-dependency
npm install
npm run build-server
```

- 将 `vscode-java-dependency` 编译后的 `jar` 添加到 jdtls_config["init_options"].bundles 中

```lua
local jdtls_config = {}
local bundles = {}
-- ...
local java_dependency_bundle = vim.split(
vim.fn.glob(
"/path?/vscode-java-dependency/jdtls.ext/com.microsoft.jdtls.ext.core/target/com.microsoft.jdtls.ext.core-*.jar"
),
"\n"
)

if java_dependency_bundle[1] ~= "" then
vim.list_extend(bundles, java_dependency_bundle)
end

jdtls_config["init_options"] = {
bundles = bundles,
extendedClientCapabilities = extendedClientCapabilities,
}
```

- 添加 attach

```lua
jdtls_config["on_attach"] = function(client, buffer)
require("java-deps").attach(client, buffer)
-- 添加命令
local create_command = vim.api.nvim_buf_create_user_command
create_command(buffer, "JavaProjects", require("java-deps").toggle_outline, {
nargs = 0,
})
end
```

- Usage

```vim
:lua require('java-deps').toggle_outline()
:lua require('java-deps').open_outline()
:lua require('java-deps').close_outline()
```