pragmagic / vscode-nim

An extension for VS Code which provides support for the Nim language.
Other
235 stars 38 forks source link

Indentation should use 4 spaces. #26

Closed mpcjanssen closed 7 years ago

mpcjanssen commented 8 years ago

When editing blocks, 4 spaces are used. According to the style guide, 2 spaces should be used instead.

https://github.com/nim-lang/Nim/wiki/Style-Guide-for-Nim-Code

I don't know VSCode enough yet to know if this can be configured in the extension or needs to be as user setting.

kosz78 commented 8 years ago

Please, open IDE menu File->Preferences->Workspace Settings and define the following:

"editor.tabSize": 2,
mpcjanssen commented 8 years ago

together with

"editor.detectIndentation": false

This indeed works.

@kosz78 this can't be overridden in the extension itself? I don't want to use tabsize=2 for every language.

endragor commented 8 years ago

@mpcjanssen There are two levels of settings in VSCode: User Settings and Workspace Settings. Workspace Settings override User Settings. You can define "editor.tabSize": 2 for your Nim projects, and something else for projects based on other languages.

mpcjanssen commented 8 years ago

@endragor I know that, my point is that I don't want to set it at all. tabSize=2 should be set for all nim files (and possibly be overridden in user or workspace settings.

kosz78 commented 8 years ago

I guess it is possible to add this functionality to the extension, as I can see in https://github.com/editorconfig/editorconfig-vscode

endragor commented 8 years ago

I'm not sure if it's a good idea for an extension to silently override user settings. Yeah, Nim Style Guide suggests 2 spaces per ident, but it's not mandatory, and some people may prefer another number for whatever reason. If user has tabSize: 4 in their settings, and they always get 2 space ident in .nim files, it would surprise them.

haiodo commented 8 years ago

Can we ask on first usage and modify workspace settings?

oderwat commented 8 years ago

It is a bad idea to override it and vscode also can auto adapt to what sources you load. So setting anything fixed seems wrong to me. The mentioned editorconfig plugin is already doing strange things which makes my code in the indent-rainbow plugin behaving wrong (https://github.com/oderwat/vscode-indent-rainbow/issues/12).

I also have an experimental setting fixed spaces / tabs per file type (so you get your 2 spaces for all nim files) in my plugin and it is very experimental and at the time I was writing the code it did not always did what one would expect from it. So I basically stopped trying to force it and just "set it" per project if needed.

kobi2187 commented 7 years ago

it can now be done per language: (in settings.json)

    "[nim]": {
        "editor.insertSpaces": true,
        "editor.tabSize": 2
    },
mpcjanssen commented 7 years ago

Whether or not this should be done in the extension setting can be discussed, but language specific setting is enough for me.