Skip to content

LSP plugin sends invalid JSON on Windows due to unescaped backslashes in rootUri / workspaceFolders #77

@marodriguezs

Description

@marodriguezs

Summary

On Windows, the Micro LSP plugin fails to start the Julia LanguageServer (and likely other LSP servers that use strict JSON parsers).
The LSP server loads, but never receives a valid initialize request.

This happens because Micro sends Windows paths using backslashes without escaping them (e.g. C:\temp\project).
These paths appear inside rootUri and/or workspaceFolders, causing the JSON to become invalid.

Example of the error returned by the Julia LanguageServer JSON parser:

Error: Invalid escape sequence
Around: .../C:\temp\microTest2013", "work...

This prevents the LSP from responding and results in:

  • no hover
  • no autosuggestions
  • no go-to-definition
  • no diagnostics

The LSP appears to be running, but Micro reports no available LSP server and the log never shows any message received from the server.

Expected Behavior

Micro should escape \ as \\ when constructing JSON messages, or use POSIX-style paths (C:/path/...) which are valid on Windows.

Steps to Reproduce

  1. Use Micro on Windows (any version).

  2. Open a folder using a normal Windows path:

    micro C:\temp\project
    
  3. Open a Julia file with the LSP plugin installed.

  4. LanguageServer.jl shows a JSON parsing error.

  5. Micro shows no LSP activity (Server Options list does not include Julia).

Actual Behavior

Micro sends JSON like:

"rootUri": "file:///C:\temp\project"

which is invalid JSON because \t becomes a tab escape.

The correct JSON should be either:

"rootUri": "file:///C:\\temp\\project"

or:

"rootUri": "file:///C:/temp/project"

If the user starts Micro from a folder using / instead of \, the LSP works correctly:

C:/temp/project
micro file.jl

Environment

  • Windows 10/11
  • Micro 2.0.15-dev (also reproducible in earlier releases)
  • LSP plugin 0.6.2
  • Julia LanguageServer.jl (but this affects any strict JSON parser)

Additional Notes

This issue makes Micro + LSP effectively unusable "out of the box" on Windows unless the user manually switches to POSIX-style paths.

A fix would greatly improve the Windows experience, especially for portable setups (Micro + Julia in USB).

Suggested Fix

Normalize all paths in LSP messages to use forward slashes:

strings.Replace(path, "\\", "/", -1)

or ensure valid JSON escaping:

strings.Replace(path, "\\", "\\\\", -1)

I'm willing to test any patch or development build.

Note: With the help of ChatGPT in several tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions