Skip to content
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

Default language-specific settings #19733

Closed
Tyriar opened this issue Feb 2, 2017 · 6 comments
Closed

Default language-specific settings #19733

Tyriar opened this issue Feb 2, 2017 · 6 comments
Assignees
Labels
feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@Tyriar
Copy link
Member

Tyriar commented Feb 2, 2017

Now that we have language specific settings we should consider enabling default language-specific settings to work around some of the annoyances for particular languages:

Markdown: Disable intellisense by default:

"[markdown]": {
"editor.quickSuggestions": false
}

Makefile: Always use tabs for indentation since spaces are invalid (related: #4815)

YAML: Always use spaces for indentation since tabs are invalid.

@rmunn
Copy link
Contributor

rmunn commented Feb 3, 2017

Python: default to spaces since PEP 8 recommends spaces as the standard Python coding style.

F#: default to spaces since the F# code formatting guidelines forbid using tabs.

@Tyriar
Copy link
Member Author

Tyriar commented Feb 3, 2017

@rmunn Python might be going a bit far since it still works with tabs right?

@rmunn
Copy link
Contributor

rmunn commented Feb 3, 2017

@Tyriar Yes, Python does allow tabs, even though its official style guide recommends spaces. But setting spaces as the default in VS Code wouldn't prevent anyone from overriding them with tabs if they choose. I believe that if a language has an official style guide, then any editor capable of per-language settings should default to following that style guide, so that out of the box, the editor will produce code that complies with the style guide. And for Python, that means space indentation, and 4-space indents (https://www.python.org/dev/peps/pep-0008/#id17). Therefore, that's what VS Code should default to for Python files.

@kieferrm kieferrm mentioned this issue Feb 6, 2017
38 tasks
@rmunn
Copy link
Contributor

rmunn commented Feb 6, 2017

Two questions that will probably come up regarding language-specific defaults:

  • If the language default specifies space indentation but you open a file that uses tab indentation, which one wins? The language default, or the file's previous indentation?
  • If the language default specifies one setting but an .editorconfig file in the project folder specifies a different setting (and the user has installed the EditorConfig plugin), which should win?

My personal opinion is that the second answer is obvious: .editorconfig is a way to specify a project-specific set of coding standards, and more specific settings should always override less specific settings. Therefore, the .editorconfig file should trump the language default settings if the two conflict.

The first answer is less obvious, but I think in the case of editing an existing file that does not match the language-specific settings, the file's existing indentation style could be considered a "more specific setting", specific to that file. E.g., if the Python standards say "uses spaces for indentation", but I'm working on someone else's code where the other coder used tabs, the editor should default to using tabs for this one file, because that creates consistent indentation. (This is also in line with what PEP 8 says, which is "Tabs should be used solely to remain consistent with code that is already indented with tabs.")

So I think the following set of rules would be good ones to use regarding language-specific defaults:

  • If the language-specific settings for indentation conflict with what can easily be autodetected from the file (e.g., spaces vs. tabs), then the file's existing indentation style should trump the language-specific default settings.
  • If the language-specific settings for indentation conflict with an .editorconfig file in the project folder, then the .editorconfig file should trump the language-specific default settings.

@sandy081
Copy link
Member

sandy081 commented Feb 7, 2017

@rmunn Good questions and suggestions.

Agreed that .editorconfig always takes the precedence over defaults/user/workspace settings which is also true currently.

Regarding file specific conflicts, you can always say detect the indentation from the file using the property editor.detectIndentation: true. By setting this, editor will always take the indentation from the file which overrides defaults/user/workspace/editorconfig settings. This would be same for default language based editor settings. With this new feature, language extensions can also register this setting to true which will let indentation from file takes the precedence above all.

@sandy081 sandy081 modified the milestones: February 2017, Backlog Feb 7, 2017
sandy081 added a commit that referenced this issue Feb 7, 2017
- Extend configuration extension to override default settings for a language
- Update configuration registry with overrides
- Adopt Defaults config model to read default overrides
- Tests
sandy081 added a commit that referenced this issue Feb 7, 2017
sandy081 added a commit that referenced this issue Feb 8, 2017
- Define a new extension point `configurationDefaults` for contributing default language specific editor settings
@sandy081
Copy link
Member

sandy081 commented Feb 9, 2017

Here is how an extension can contribute default language specific editor configurations. A new contribution point configurationDefaults is introduced in extension's package.json.

Sample:

"configurationDefaults": {
	"[markdown]": {
		"editor.wrappingColumn": 0,
	        "editor.quickSuggestions": false
	}
}

@sandy081 sandy081 closed this as completed Feb 9, 2017
@sandy081 sandy081 added the verification-needed Verification of issue is requested label Feb 9, 2017
sandy081 added a commit that referenced this issue Feb 9, 2017
@roblourens roblourens added the verified Verification succeeded label Feb 24, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

4 participants