sublimelsp / LSP

Client implementation of the Language Server Protocol for Sublime Text
https://lsp.sublimetext.io/
MIT License
1.65k stars 180 forks source link

LSP doesn't seem to work in fenced markdown code blocks #958

Closed tzakharko closed 4 years ago

tzakharko commented 4 years ago

LSP does not work for me if I have documents with mixed scopes, such as code blocks within markdown documents. Specifically, I was playing around with Rmarkdown style documents, where you mix free text (using markdown) and data analysis code (using fenced code blocks). The code highlighting works as expected, but I don't get the LSP-provided hints. LSP works if I edit a standalone R file. I am a new Sublime user, so maybe my setup is wrong?

jfcherng commented 4 years ago

I think it's just simply not supported.

The code highlighting works as expected, but I don't get the LSP-provided hints.

LSP has nothing to do with syntax highlight at this moment. I believe LSP is bound to a view (I guess) and only takes the top scope (in your case, markdown's top scope: text.html.markdown) to determinate which LSP server(s) should be initiated.

tzakharko commented 4 years ago

Thanks for quick reply! So LSP is not relying on the actual scope but kicks in per-file instead?

If any LSP maintainers are reading this, what would it take for LSP to work per-scope? We are using multi-scope documents a lot and having auto-completion and analysis provided by LSP would be a great thing for us.

rchl commented 4 years ago

LSP, per specification, works per-file. You'd need a server that understands how to handle markdown to have things work the way you want. But I don't think there is a server that handles markdown and also all possible languages embedded in it.

tzakharko commented 4 years ago

Thanks for pointing this out. I have since learned that R LSP server supports this particular case, there was simply an issue with my config.

tbruckmaier commented 3 years ago

fyi: lsp in emacs supports this use case in org mode files (though it is still considered alpha): https://emacs-lsp.github.io/lsp-mode/page/lsp-org/

rchl commented 3 years ago

Cool although looks like a bit gimmicky feature. I would think that many code blocks are snippets that are not necessarily fully semantically correct and not necessarily part of the project's code. I can only see troubles with trying to support that.

tbruckmaier commented 3 years ago

Well, in orgmode code blocks can actually be evaluated inside the document for literate programming (https://orgmode.org/worg/org-contrib/babel/intro.html)

But you are probably right for markdown which this issue is about. Just wanted to throw that piece in here for future reference