-
Notifications
You must be signed in to change notification settings - Fork 79
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
Outline view: Support nested sections in R scripts #3822
Comments
Thanks for the response. For R, I can't see the outlines of the sections in the editor so I can navigate between them. |
Just to highlight this request a bit further, my outlines in RStudio made heavy use of emoji and that made it very easy to navigate. I'm missing it quite a bit in Positron
And for anyone curious, this is my legend
|
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
When we add support for sections in the outline view (LSP provides document symbols), let's also provide folding ranges. Discussed a little bit in #4174. |
+1 to supporting both structural comments and folding ranges! One way that structural comments in Positron could be improved over RStudio's behavior would be to introduce a notion of hierarchy in the comments. As hinted at in @rjake's comment above, R developers currently go through some odd contortions to create (the appearance of) nested sections. It'd be very helpful if we could support nested comments directly. Also drawing from @rjake's comment, I like the idea of using leading hashes to indicate the "level" of the section heading and trailing characters to activate the section comment behavior. For example: # UI --------------------------------------------------------------------------
## Main Content ####
### Sidebar ----
### Inputs ----
### Cards ----
## Page Two ####
# Server ---------------------------------------------------------------------- would translate to
Where the leading hashes indicate level 1 ( |
This comment is just to link to #1427 and a note to say it's easy to miss that Positron even has an outline view. |
I want to add that code cells does not appear neither in the outline view, which made me think that outline should be configurable by the user:
|
I note that the vscode-R extension (https://github.com/REditorSupport/vscode-R) supports the comment section formating. Hope that helps and am really looking forward to this functionality. |
Partially addressed by @kv9898 in posit-dev/ark#571. The sections will now appear in the outline. Thanks for the contribution! Keeping the issue open as this needs more work to support nested sections in the outline which currently are displayed flat. |
Updating title |
Thanks for adding this feature! Would it be possible to add support for this within lists? For example, the code below shows the sections in the outline view within the function but not within the list. RStudio shows sections within lists, and this is useful, e.g., when creating long pipelines with the targets package.
|
You are welcome, @julianmatthewman! Aha, I thought it would be an easy one and tried to mimic our detection of functions and it turned out that things are not as easy. I believe that list is not currently one of the existing node types and including list involves changes to the treesitter. I believe @DavisVaughan is the expert on this! In the meantime, we are trying to add the nested outline feature (posit-dev/ark#593). This involves a lot of changes to the existing code and maybe it is a better time to include the list feature after the everything gets sorted. |
Thanks for the feature! Some sequences of characters seem to break the section outline. I often use something like this as section divider:
This makes all section titles disappear. So this works fine:
But adding
These do not:
|
Thanks for the detailed description, @weverthonmachado ! I actually filed this problem at #5036 (the description is not as detailed as yours). The problem is already fixed by posit-dev/ark#590. However, you may need to wait until the next ark/positron release. If you are impatient, you can build the development version of ark from source by following the instruction here: https://github.com/posit-dev/ark/blob/main/BUILDING.md If you trust me, you can use my custom release version of ark (https://github.com/kv9898/ark/releases/tag/0.1.145.1) which fixes this bug. You are also welcome to try the experimental version which supports the nested sections (https://github.com/kv9898/ark/releases/tag/0.1.145.2). To use either of the custom releases, replace the binary in |
Thanks @kv9898, that's great! |
For posit-dev/ark#611: nested comment sections in outline by @kv9898. Addresses #3822
Now ready for verification thanks to @kv9898! QA notes: We now support markdown-like sections in R comments. They must have this form: # title ----
# title #### The number of leading # title0 ----
a <- 1
## title1 ----
foo <- function() {
# title2 ----
b <- 2
} A tricky part of the implementation was to "pop" section nodes when going from a more nested to less nested section: # foo ----
### child of foo ----
#### child of bar ----
## child of foo ---- We have unit tests for this functionality on the Ark side. |
@lionel- Thanks for the summary! I want to add that trailing # title ==== You can also have more than four trailing signs: # title -----
# title ######
# title ======= |
@midleman Thank you for the testing. However, ideally the code above should (and it does on my Windows and Mac devices) render an outline like this: |
@kv9898 you are correct! my apologies, I took a screenshot from the wrong window. 😅 |
So in Rstudio, I can type
ctrl+shift+R
to put sections in my R script so I can track my work. Is this feature available for Positron? For R and Python?The text was updated successfully, but these errors were encountered: