-
Notifications
You must be signed in to change notification settings - Fork 14
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
[feat] add lsp/diagnostics support for embedded languages #2
Comments
Let's follow up on the discussion at quarto-dev/quarto-vim#11 (comment) here. TLDR: we need to fork the treesitter markdown grammar to create a quarto/pandoc grammar and also invent a new plugin for embedded languages.
(neo)vim does not have a dedicated mode for buffers with multiple languages (like emacs polymode). Instead, we will have to rely on the same trick that the quarto VS Code extension uses: We create a (hidden) buffer for each embedded language that contains just the code in that language with all other lines set to whitespace (this way line number still match). Then an lsp client attaches to this buffer and the challenge is now to synchronize between completions, hovers etc. between the hidden buffer and the quarto buffer (see this script for current experiments with this: https://github.com/quarto-dev/quarto-nvim/blob/dev/examples/run.lua note: Now about potential upstream contributions: This grammar is also used for example by the recommended commenting plugin (https://github.com/numToStr/Comment.nvim), which set's the comment string depending on the language context provided by treesitter. And here is the thing. It would be the most elegant solution if we had a general and abstract implementation of exactly what the commenting plugin does: provide a different context for the document depending on the language type provided by treesitter. I would imagine a quarto document as having windows through which you can see into other buffers with the embedded languages. In it's most general form, this would allow us to get all the goodies you get from single file-type buffers such as lsp, completion, diagnostics, hover etc. in one quarto buffer. But I don't know how to build these windows, yet, which is why the last two bullet points are not checked. On a side note, this would essentially be emacs polymode in neovim, so it might be useful for non-quarto users as well. |
Plugins with which we have to interface:
|
https://github.com/jose-elias-alvarez/null-ls.nvim might be what we need |
diagnostics added via #6 |
@jmbuhr Thanks for the fantastic work. This plugin may be helpful for this integration: https://github.com/AckslD/nvim-FeMaco.lua It creates a floating window for the code block, sets the correct file type, and synchronizes the contents into the current buffer. |
Thank you! This looks amazing and already so close to what we need! I will see what is missing (not sure if it takes into account that code blocks might refer to code in earlier blocks for example) and how I can contribute there :) |
* .. * turning type annotation into string * ..
current best idea: improve https://github.com/AckslD/nvim-FeMaco.lua to use these language buffers
The text was updated successfully, but these errors were encountered: