Repository navigation
fix: default R indentation to two spaces - #1884
renkun-ken wants to merge 1 commit into
Conversation
eitsupi
left a comment
There was a problem hiding this comment.
I'm not convinced that overriding editor.tabSize is the right solution here.
In other languages, linting and editor formatting are generally kept separate.
For example,
- TypeScript uses ESLint separately
- Python has dedicated linting extensions such as Ruff
- rust-analyzer does not enable Clippy by default
These tools do not require the editor's indentation settings to match the linter's defaults.
More importantly, adding a language-specific editor.tabSize default overrides users' existing general editor.tabSize settings for R files, even if they explicitly chose a different indentation width.
I think the underlying issue is that languageserver enables lintr by default, including its opinionated style rules.
Rather than changing editor behavior to accommodate those rules, perhaps we should reconsider how linting is integrated into languageserver.
|
Thanks, @eitsupi. After investigating how other language extensions and servers handle indentation, I agree with preserving users' existing editor preferences and reconsidering the default style-lint policy instead of merging this override as the fix for #1883. I compared current upstream extension manifests and formatting implementations. The results are mixed, rather than a universal rule:
Ruby and Dart are direct precedents for the mechanism proposed here, so language-specific indentation defaults are an established approach. However, those precedents do not establish that we should change existing R editing behavior merely to accommodate lintr's default rules. Prettier is a useful counterexample: a two-space formatting default does not require overriding the editor's indentation setting. The compatibility issue is decisive for me: under VS Code's settings precedence, this PR's language-specific default overrides even an explicitly configured general user or workspace R languageserver already respects the client's formatting width, similarly to the built-in TypeScript integration and JDT LS. I would keep that behavior and leave the editor default unchanged here. For #1883, I favor a separate discussion about which opinionated style rules languageserver should enable by default, and whether those should be opt-in or independently configurable, while preserving useful correctness diagnostics and explicitly configured Users who want two-space R editing can explicitly configure |
New R files inherit VS Code's four-space indentation, which triggers lintr's default two-space indentation diagnostic. Set
editor.tabSizeto2in the existing[r]configuration defaults so editor indentation and languageserver formatting align with lintr's default.Add a changelog note explaining that this language-specific default overrides general indentation settings and that users can select another width in
[r]user or workspace settings. Automatic indentation detection still applies to existing files.Fixes #1883.
Validation:
pnpm exec vsce package --no-dependencies.git diff --checkpassed.