You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -75,89 +75,194 @@ To get started with Java, click the `edit debug.json` button in the Debug menu,
75
75
76
76
You should then be able to start a new Debug Session with the "Launch Debugger" scenario from the debug menu.
77
77
78
+
### Single-File Debugging
79
+
80
+
If you're working a lot with single file debugging, you can use the following `debug.json` config instead:
81
+
```jsonc
82
+
[
83
+
{
84
+
"label":"Debug $ZED_STEM",
85
+
"adapter":"Java",
86
+
"request":"launch",
87
+
"mainClass":"$ZED_STEM",
88
+
"build": {
89
+
"command":"javac -d . $ZED_FILE",
90
+
"shell": {
91
+
"with_arguments": {
92
+
"program":"/bin/sh",
93
+
"args": ["-c"]
94
+
}
95
+
}
96
+
}
97
+
}
98
+
]
99
+
```
100
+
This will compile and launch the debugger using the currently selected file as the entry point.
101
+
Ideally, we would implement a run/debug option directly in the runnables (similar to how the Rust extension does it), which would allow you to easily start a debugging session without explicitly updating the entry point.
102
+
Note that integrating the debugger with runnables is currently limited to core languages in Zed, so this is the best workaround for now.
103
+
78
104
## Launch Scripts (aka Tasks) in Windows
79
105
80
106
This extension provides tasks for running your application and tests from within Zed via little play buttons next to tests/entry points. However, due to current limitiations of Zed's extension interface, we can not provide scripts that will work across Maven and Gradle on both Windows and Unix-compatible systems, so out of the box the launch scripts only work on Mac and Linux.
81
107
82
108
There is a fairly straightforward fix that you can apply to make it work on Windows by supplying your own task scripts. Please see [this Issue](https://github.com/zed-extensions/java/issues/94) for information on how to do that and read the [Tasks section in Zeds documentation](https://zed.dev/docs/tasks) for more information.
JDTLS provides many configuration options that can be passed via the `initialize` LSP-request. The extension will pass the JSON-object from `lsp.jdtls.settings.initialization_options` in your settings on to JDTLS. Please refer to the [JDTLS Configuration Wiki Page](https://github.com/eclipse-jdtls/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request) for the available options and values. Below is an example `settings.json` that would pass on the example configuration from the above wiki page to JDTLS:
111
+
JDTLS provides many configuration options that can be passed via the `initialize` LSP-request. The extension will pass the JSON-object from `lsp.jdtls.initialization_options` in your settings on to JDTLS. Please refer to the [JDTLS Configuration Wiki Page](https://github.com/eclipse-jdtls/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request) for the available options and values. Below is an opinionated example configuration for JDTLS with most options enabled:
86
112
87
113
```jsonc
88
-
{
89
-
"lsp": {
90
-
"jdtls": {
114
+
"lsp": {
115
+
"jdtls": {
116
+
"initialization_options": {
117
+
"bundles": [],
118
+
"workspaceFolders": [
119
+
"file:///home/snjeza/Project"
120
+
],
91
121
"settings": {
92
-
// this will be sent to JDTLS as initializationOptions:
93
-
"initialization_options": {
94
-
"bundles": [],
95
-
// use this if your zed project root folder is not the same as the java project root:
If you're working without a Gradle or Maven project, and the following error `The declared package "Example" does not match the expected package ""` pops up, consider adding these settings under
246
+
247
+
```
248
+
MyProject/
249
+
├── .zed/
250
+
│ └── settings.json
251
+
```
252
+
253
+
```jsonc
254
+
"lsp": {
255
+
"jdtls": {
256
+
"initialization_options": {
257
+
"project": {
258
+
"sourcePaths": [
259
+
".",
260
+
"src"
261
+
]
262
+
},
263
+
}
264
+
}
265
+
}
266
+
```
267
+
268
+
If changes are not picked up, clean JDTLS' cache (from a java file run the task `Clear JDTLS cache`) and restart the language server
0 commit comments