quarto-dev / quarto

Quarto open-source scientific and technical publishing system
https://quarto.org
GNU Affero General Public License v3.0
343 stars 30 forks source link

VS Code extension: Rmd does not export symbols #488

Open artmg opened 4 months ago

artmg commented 4 months ago

The Quarto extension fails to provide symbols for an R Markdown document such as scratch.Rmd (content below). The issue prevents:

image

This occurs in Positron Version: 2024.07.0 (Universal) build 21 Code - OSS Version: 1.90.0 Commit: 82b335e27545e804b7fd806db00477a6eb49951d Date: 2024-07-09T04:32:26.804Z Electron: 29.4.0 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Darwin arm64 23.5.0

Also in Quarto v1.113.0 in VS Code

If I install REditorSupport.r extension then the R Markdown document symbols appear as normal, but not in the Quarto extension.

This issue was previously raised as Positron Issue #3982 and now transcribed here at the request of @juliasilge

Code for scratch.Rmd for testing is below:

---
title: "A wonderful R Markdown document"
output:
  html_document:
    math_method: katex
---

```{r echo = FALSE}
knitr::opts_chunk$set(echo = TRUE)

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

Here is some math:

$1 + 1$

When you render this file, a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars) 

Including Plots

You can also embed plots, for example:

plot(pressure)

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

juliasilge commented 4 months ago

If you check out https://github.com/posit-dev/positron/issues/3982, you will see that @artmg also observes this problem in VS Studio, not only Positron.

FWIW folks have not been able to reproduce this problem. We'll need to find a way to look at logs and/or debug what may be causing the Quarto extension not to contribute these symbols.

artmg commented 2 months ago

Looking through /apps/vscode/package.json for any obvious configuration issues at my end, I also tried using files with .Qmd and .qmd extensions, but the issue remains. Unfortunately when looking through the quarto-lsp at service providers for document and workspace symbols I feel somewhat lost.

@juliasilge If it helps I can use yarn dev-vscode to perform debugging in situ – if you could suggest either

  1. what setting to use to turn on the level of logs you require (my debug console remains fairly empty for now) or
  2. where I might place any breakpoints or other tests I can perform.

Happy to supply further diagnostics if you can offer me a little direction, please.

juliasilge commented 2 months ago

Can you check on a couple of things @artmg?

artmg commented 2 months ago

Thank you for your suggestions, I had a look at the config files...

find ~ -iname "*rprofile*"
find ~ -iname "settings.json"

but I had no .RProfile and I could not find anything obvious in any relevant settings.json. However this inspired me to try the perhaps desperate option to prove if it could work

purge and start again

I uninstalled Positron AND VSCode

I purged the following folders

just Positron - successfully see symbols

I went to Positron releases and installed Positron-2024.09.0-1.dmg

When I open the scratch.Rmd file I get symbols in the outline as hoped - πŸŽ‰

add vscode - fails in there

When I go back to try vscode:

❯ brew install visual-studio-code
❯ code --install-extension quarto.quarto
Installing extensions...
Installing extension 'quarto.quarto'...
Extension 'quarto.quarto' v1.114.0 was successfully installed.
❯ code .

I now get an empty outline with No symbols found in document 'scratch.Rmd' when I open it in vscode with quarto 😒

even dev version - fails in there too

❯ code --uninstall-extension quarto.quarto
❯ cd ..
❯ git clone git@github.com:quarto-dev/quarto.git
Cloning into 'quarto'...
[...] Receiving objects [...] done.
❯ cd quarto
Uninstalling quarto.quarto...
Extension 'quarto.quarto' was successfully uninstalled!
❯ corepack enable
❯ yarn
yarn install v1.22.22
[...]
[4/4] πŸ”¨  Building fresh packages...
✨  Done in xx.36s.
❯ code .
❯ yarn dev-vscode
yarn run v1.22.22
$ turbo run dev --filter quarto...
[...]
quarto-vscode-editor:dev: build started...
[...]
quarto-vscode-markdownit:dev: built in xx108ms.
quarto-vscode-markdownit:dev: [vite-plugin-static-copy] Copied 7 items.

Using Run and Debug to start up a new code instance as the 'extension development host' also gives No symbols found in document 'scratch.Rmd' 😭

Good news and bad

So it's great that I got Positron itself working ok, which was my original goal – and it still works after vscode was installed. Perhaps not so great that I did not get the quarto extension in vscode to work, nor that it's not clear why not.

Should I do further tests @juliasilge to see if I can remove everything and get just the quarto extension working in vscode? Even if it means putting off trying out Positron for the time being.

juliasilge commented 2 months ago

Wow, thank you so much for sharing what you tried here @artmg! Can you clarify here for me:

I now get an empty outline with No symbols found in document 'scratch.Rmd' 😒

Do I understand you correctly that after you install VS Code, you get no symbols found in Positron?

Next question from me: what happens if you install VS Code but not the Quarto extension in VS Code? Do you get the symbols in Positron?

Another question: what happens if you install VS Code from their official installers rather than via brew?

artmg commented 2 months ago

Sorry for the ambiguity - I hope I improved it above to clarify that the failures were all in vscode with quarto. Positron is still working just fine, even after vscode is installed. Next I can try removing everything and purging files, then just installing VS Code (officially) and try the quarto extension. Likely next week now :)

artmg commented 2 months ago

Try vscode and quarto alone

and this time use the official image to install

purge and start again

VS Code with Quarto extn

Installing Quarto extension does give the qmd file an icon, and both .qmd and .Rmd are recognised as Quarto language, but still no symbols can be found. image

Positron

Fortunately when I re-install Positron, opening the Rmd inside Positron works just fine and shows symbols both in the Outline and as breadcrumbs in the editor header image

Summary

Upon a totally clean install...

I am happy that I can carry on using Positron now that I have a clean install, but please do ask if you'd like any further diagnostics on the VS Code Quarto extension on its own

artmg commented 2 months ago

PS: I tried to add a comment to the original https://github.com/posit-dev/positron/issues/3982 but it has been locked - @juliasilge might it be worth adding a footnote in that issue, please, mentioning the resolution for Positron?

  1. uninstall any previous versions of Positron AND VS Code
  2. purge any user folders that may contain extensions or stray settings (e.g. ~/Library/Application Support/Positron/ ~/Library/Application Support/Code/ ~/.positron/ ~/.vscode-R/ ~/.vscode/ )
  3. reinstall Positron

Rmd files should now correctly show their symbols in Positron

Thanks