Skip to content
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

Server never initializes if no workspaceFolders are given #66

Closed
jwortmann opened this issue Sep 2, 2022 · 5 comments
Closed

Server never initializes if no workspaceFolders are given #66

jwortmann opened this issue Sep 2, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@jwortmann
Copy link

The server never responds to the initialize request from the client, if it contains workspaceFolders: null.

From the LSP specs:

        /**
	 * The workspace folders configured in the client when the server starts.
	 * This property is only available if the client supports workspace folders.
	 * It can be `null` if the client supports workspace folders but none are
	 * configured.
	 *
	 * @since 3.6.0
	 */
	workspaceFolders?: [WorkspaceFolder](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspaceFolder)[] | null;
@artempyanykh
Copy link
Owner

@jwortmann thanks for reporting! I think you may have hit the problem that #68 addresses (which is about initialization). Please try https://github.com/artempyanykh/marksman/releases/tag/2022-09-02 and let me know if the initialization issue is gone.

When it comes to 'single file mode', some functionality like document symbols and reference links can work in a single file mode but the rest (workspace symbols, renames, cross-links, etc) really needs a "folder".

However, the important bit here is that the 'single file mode' is not a part of the LSP spec. I'm not sure how things are configured in sublime, but I'd recommend setting a folder for you markdown -- this'll give the best experience.

If you do care about the 'single file mode' feel free to open a separate issue specifically about this. I'm generally OK with the idea of having some custom bits to emulate 'single file mode', but since it's not part of the spec it's not very high on my priority list.

@jfcherng
Copy link

jfcherng commented Sep 2, 2022

Hi @artempyanykh, with 2022-09-02 and single file mode, the server does start but I don't see it provide anything but just return [] and None for everything (Sublime Text). Could you point out the exact feature supported in single file mode from https://github.com/artempyanykh/marksman#demo?

@rwols
Copy link

rwols commented Sep 2, 2022

I believe by “single file mode” is meant that workspaceFolders is null in the initialize request, which by the spec is valid.

@jwortmann
Copy link
Author

I can confirm what @jfcherng wrote.

However, the important bit here is that the 'single file mode' is not a part of the LSP spec.

Right, this kind of expression is not explicitly mentioned in the LSP specs, but neither is 'project mode' or 'workspace mode' or whatever. But if you look at the description for the Workspace folders request, there it is written that it

Returns null in the response if only a single file is open in the tool. Returns an empty array if a workspace is open but no folders are configured.

So at least they describe the possibility that only a single file is open in the editor. And there are servers like Microsoft's vscode-css-languageserver or vscode-html-languageserver which seem to operate exclusively in 'single file mode', i.e. they apparently don't care whether workspaceFolders (or rootUri) are provided in the initialize request or not. Probably because CSS and HTML are languages which usually don't have any strict project structure or configuration files associated with the source code. And I would expect the same for Markdown. For example it is clear that relative links to other documents should be interpreted relative to the current document. And I think it should be possible to provide most of the features, e.g. "Document Symbols" even without workspaceFolders.

Anyway, since the latest server version correctly responds to the initialize request, we can close this now. Thanks for the fix!

@artempyanykh
Copy link
Owner

@jfcherng right now Marksman does need a root/folder and doesn't provide a single-file mode.

But now that I'm thinking a bit more about this, it seems that it'd be quite convenient and a better/less confusing UX overall. I've created a separate issue for this #69

@artempyanykh artempyanykh added the bug Something isn't working label Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants