apache / apache/netbeans

Trailing slash for rootUri in custom languange server

Open
#7,166 0 comments 0 reactions 0 assignees View on GitHub
kind:bug LSP needs:triage
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Apache NetBeans version

Apache NetBeans 21

### What happened

When using [Lua Language Server](https://github.com/LuaLS/lua-language-server) I encountered a problem that I had to repeat the NetBeans Project folder name inside the project folder to store "workspace" related config files (=`.luarc.json`). The logs of LuaLS showed that these "duplicate folder" config file is read correctly. This is not done when stored in the Netbeans Project folder. (What is expected)

I checked the same language server with VSCode and there is no "folder duplication" is needed. The config is read from the project folder as a workspace.

The main (?) difference from the server logs files is that NetBeans sends a trailing slash to "`rootUri`" while "`rootPath`" does not have a trailing path separator. In VSCode none of these config entries has a trailing separator
The [Language Server Protocol Specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/) does not give any hint if a trailing slash is needed or must be prevented.

### Language / Project Type / NetBeans Component

Language Server Client

### How to reproduce

- Configure Lua Language Server as a custom LS (Grammar file: e.g: https://github.com/LuaLS/lua.tmbundle)
- Create a Project of any type in Netbeans
- Create a file `.luarc.json` in that project's folder. Content: ```{
"runtime":{
"version":"Lua 5.1"
}
}```
- create an empty `.lua` file in the project

The language server should open a new (and empty) LS-Output-Window. In the "`log`" subfolder of the LuaLS installation is a new log file `file_*.log` with the project folders path as file name. That logfile has some log lines of interest:

```
[15:18:53.775][info] [#0:script\workspace\workspace.lua:38]: Workspace init root: file:///D:/nigjo/projekte/luademo/
[15:18:53.807][warn] [#0:script\files.lua:111]: Fix real file uri: file:///d%3A/nigjo/projekte/luademo/ -> file:///d%3A/nigjo/projekte/luademo/luademo
[15:18:53.807][info] [#0:script\workspace\workspace.lua:48]: Workspace create: file:///d%3A/nigjo/projekte/luademo/luademo
```
followed by two lines with `No config?` entries.

After create a folder "luademo" inside of "luademo", copy the `.luarc.json` to that subfolder and restart the language server (kill the lua-language-server.exe via Task Manager) the server log will show that the config is found now:

```
[15:25:28.014][info] [#0:script\provider\provider.lua:53]: Load config from .luarc.json/.luarc.jsonc file:///d%3A/nigjo/projekte/luademo/luademo
```

### Did this work correctly in an earlier version?

No / Don't know

### Operating System

Windows 10

### JDK

17

### Apache NetBeans packaging

Apache NetBeans binary zip

### Anything else

_No response_

### Are you willing to submit a pull request?

No

Contributor guide

Open the contributing guide

Research direction

Start in the Language Server Client handling of the rootUri and rootPath values, then reproduce the issue with the Lua Language Server using the project-level .luarc.json described in the report. Compare the logged URIs and verify that removing the trailing slash from rootUri allows the configuration to load from the NetBeans project folder.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, lua
Domain
developer-experience, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.