REditorSupport / vscode-R

R Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=REditorSupport.r
MIT License
1.06k stars 125 forks source link

Unable to auto-indent when maximum length is exceeded (using the auto-formatting provided by the LSP) #1407

Open hjnnjh opened 1 year ago

hjnnjh commented 1 year ago

Describe the bug When exceeding the max-line-length, the LSP raise a warning called "Lines should not be morn than your_max_line_length characters. line_length_linter"(See the following fig) image I tried to reformat the file using the format function provided by R LSP, but it didn't work for this issue. We know that in Python, there are some formatters like black and autopep8 which can handle this issue easily. Moreover, the formatter in RStudio can auto-indent too. So I' m wondering if I can do something to fix this issue?

Can you fix this issue by yourself? (We appreciate the help) Yes, I tried using a couple of packages used for formatting like formatR and styler. But it didn't work.

// R path for Mac OS X
"r.rterm.mac": "/opt/homebrew/bin/R",

// An optional encoding to pass to R when executing the file, i.e. 'source(FILE, encoding=ENCODING)'
"r.source.encoding": "UTF-8",

// Keeping focus when running
"r.source.focus": "editor",

// Use active terminal for all commands, rather than creating a new R terminal
"r.alwaysUseActiveTerminal": true,

// Use bracketed paste mode
"r.bracketedPaste": true,

// Enable R session watcher
"r.sessionWatcher": true,

// Delay in milliseconds before sending each line to rterm (only applies if r.bracketedPaste is false)
"r.rtermSendDelay": 5,

Expected behavior Auto-indent when maximum length is exceeded

hjnnjh commented 1 year ago

I found that this issue is because VSCode R uses styler to format code. However, styler doesn't support auto-indent when exceeding the max-line-length now.

github-actions[bot] commented 2 weeks ago

This issue is stale because it has been open for 365 days with no activity.