Vscode-r: [Feature request] Support for code sections

Created on 17 Jun 2018  路  14Comments  路  Source: Ikuyadeu/vscode-R

See this on RStudio support for code sections, which is a great way to navigate in script.

# Section One ---------------------------------

# Section Two =================================

### Section Three ############################# 
feature-request help wanted

All 14 comments

@psychelzh Thank you for your issue!
Looks interesting!
Also, Latex has similar function https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop .
I add this issue as help wanted.

Could be done using a DocumentSymbolProvider.

More detail on how this could be done: When a file is saved, look for section lines using a regex. Add these as symbols using DocumentSymbolProvider. They would then appear in the Outline and Breadcrumbs sections.

The language server also provides symbols, so it would be necessary to check that the language server symbols and the section symbols don鈥檛 conflict.

If anyone wants to have a go at implementing this, I鈥檓 happy to provide assistance.

@andycraig I'm not sure if DocumentSymbolProvider is suitable for this because it does not seem to preserve order.

@renkun-ken Oh! Then that might not be a good approach after all.

Markdown document sections are shown in the VSCode Outline in order: https://code.visualstudio.com/docs/languages/markdown#_outline-view The approach used for that might be more suitable.

Just notice that the sorting order can be easily changed to position order so DocumentSymbolProvider should be the solution to this but user needs to use position order.

image

This should be easy to implement. Do we prefer this to be implemented on vscode-R side or languageserver side? If languageserver is supposed to be pure about the language itself, then vscode-R should be the place this is implemented.

If you鈥檙e keen to implement code sections that would be great!

I鈥檓 inclined to agree that vscode-R seems like the more natural place than languageserver. @randy3k What do you think?

I am open to this.

193 is a very initial implementation of code section support. Known issues include:

  • Both R LSP Client and vscode-R provides document symbols, and the outline could become

image

This can be changed using DocumentSymbolProviderMetadata, but I'm not sure if we should merge the symbols provided by different symbol providers somehow, or maybe we should implement this in languageserver?

  • As a starting point, the code section symbol uses a position which only contains the line number of the section line. However, it could also use the range that starts from the section line and ends before the next section.

To provide unified document symbols, we better implement it in languageserver. https://github.com/REditorSupport/languageserver/pull/163 is the PR for this in languageserver which addresses all above issues.

As requested, moving my comments to REditorSupport/languageserver#163

@mik3y64 Glad to know it works for you. Would you mind putting your comments at https://github.com/REditorSupport/languageserver/pull/163 which seems to be the place we discuss it further since we'll implement this feature in languageserver?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

michaelHL picture michaelHL  路  4Comments

michaelHL picture michaelHL  路  3Comments

LePeti picture LePeti  路  4Comments

Nightwingg picture Nightwingg  路  6Comments

Dee-L picture Dee-L  路  5Comments