editorconfig / editorconfig-vscode Goto Github PK
View Code? Open in Web Editor NEWThis project forked from microsoft/vscode-editorconfig
EditorConfig extension for Visual Studio Code
Home Page: http://editorconfig.org/
License: MIT License
This project forked from microsoft/vscode-editorconfig
EditorConfig extension for Visual Studio Code
Home Page: http://editorconfig.org/
License: MIT License
I would like for a "standard" editorconfig file for many projects that have different files.
I want by default to have indent_style = space
and indent_size = 4
for all files, except for a couple, most notably makefiles, that are broken if TAB is not used. But I don't want to override the tab width for the makefiles, I want to use the user's default (as the beauty of using tabs is anyone can configure their editor to show as many spaces as they like for a tab).
The problem is if I include the indent_size = 4
in [*]
I get the default tab_width = 4
too and there is no way to say for example tab_width = undefined
.
insert_final_newline = true
.A final newline is inserted and the cursor moves to the end of the file.
Note: I'm not sure what should happen with multiple cursors. Open to suggestions.
A final newline is inserted; however, it's also highlighted. Furthermore, the cursor remains where it was before the save.
Microsoft's official docs only mention .vsix files, there is no ext
command in $PATH when Visual Studio Code is installed. How do people actually install this? Thanks.
From @paulirish
I'm seeing this message but I think my two configs actually agree....
Checking to see if i'm running the latest version…
The latest insider build has this new event called onWillSaveTextDocument. This allows us to return a TextEdit
array which will be applied to the document.
I already made the switch in my vscode-final-newline plugin. Works really great and this also works with the Save All
option, which isn't the case with the current implementation.
I will have a look when I find the time.
fs.exists is used to check if a .editorconfig
file already exists. But fs.exists
is deprecated. Guess we better use path-exists.
# editorconfig.org
root = true
# Common rules
[*]
indent_size = 4
indent_style = space
end_of_line = lf
charset = utf-8
tab_width = 4
trim_trailing_whitespace = true
insert_final_newline = true
# Matches the exact files either *.json, *.yml or .htaccess
[*.jade]
indent_style = space
indent_size = 2
[package.json]
indent_style = space
indent_size = 2
Jade and package.json still use 4 spaces but they should use 2 spaces by default.
In the new (insiders) build, the detected indentation method (tab vs. space) and the indentation size is shown in the bottom right corner. No need for this plugin to show it anymore.
https://github.com/editorconfig/editorconfig-vscode/blob/master/src/DocumentWatcher.ts#L177-L180
At least, the tab settings don't apply.
Hi guys!
I noticed that with the editorconfig extension the detectIndentation on vscode is not working until i triggered manually.
Steps to reproduce:
Tested without having an .editorconfig in the project.
Thanks! excellent work with this extension!
My configuration is:
[*]
indent_size = 2
tab_width = 8
What I see in opened files is that both indentation size and tab width are set to 2.
I think, EditorConfig can't work properly because of microsoft/vscode#10339.
This is a copy of this issue.
It seems with VSC 1.6.1 the EditorConfig plugin touches any files automatically. How I can disable this behavior?
If the user defined files.trimTrailingWhitespace
as true
in the VSCode settings, we cannot prevent trimming the whitespaces if the user set trim_trailing_whitespace = false
in his .editorconfig
file. That's why we should show a warning message if the global setting overrides the .editorconfig
setting.
Possible candidates
The currently opened folder contains workspace settings that may override EditorConfig settings.
Workspace settings may be overriding EditorConfig settings. It is recommended that you remove the workspace settings in favor of EditorConfig.
The currently opened file contains workspace settings that may override EditorConfig settings.
The files.trimTrailingWhitespace workspace setting may be overriding the EditorConfig trim_trailing_whitespace setting for this file. It is recommended that you remove workspace settings that might override EditorConfig settings.
I think we should keep the message small and clear. The last one is too long and won't fit into the popup box I'm afraid. Although we can make it a little shorter and use something like this
The files.trimTrailingWhitespace workspace setting is overriding the EditorConfig trim_trailing_whitespace setting for this file.
It's up to the user to decide what they want to do in that case.
With this extension, the file preview stops to work.
Each clicked file is immediately marked as changed.
I'm using the insiders edition.
Editorconfig changes the line ending of every file I open. Driving me crazy with git.
How do I know? Does it when editorconfig extension is installed. Doesn't when I remove it.
No such problem in regular VS Code.
VSCode Version: 1.3.1
Steps to Reproduce:
The plugin doesn't seem to insert a final newline anymore after the latest update.
This is my .editorconfig file:
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,py}]
charset = utf-8
#4 space indentation
[*.py]
indent_style = space
indent_size = 4
# Tab indentation (no size specified)
[Makefile]
indent_style = tab
# Indentation override for all JS under lib directory
[lib/**.js]
indent_style = space
indent_size = 2
# Matches the exact files either package.json or .travis.yml
[{package.json,.travis.yml}]
indent_style = space
indent_size = 2
Is this by design?
I've been creating new files in my project and they always get created with CRLF line endings, when the .editorconfig
file explicitly states that it should use LF line endings.
If the file already has multiple empty lines at the end, it would be great to trim all but the last one. Would that be possible?
Original post from @glen-84
My .editorconfig file looks like this:
root = true [*] charset = utf-8 indent_style = space indent_size = 4 end_of_line = lf trim_trailing_whitespace = true insert_final_newline = true [package.json] indent_size = 2If I save it, a final newline is not added.
I think we should refactor the code a bit. Extract the Utils class to Utils.ts
.
Maybe even extract each transform function (trim, final new line) to individual files. I think it would increase readability a lot and would make it easier to test separate small functions.
VSCode Version: 1.3.1
OS Version: Win 7
Steps to Reproduce:
This leaves a trail of all opened files which are marked as unsaved. To close them you have to individually click the "Dont save" button on prompt.
I think it would be a nice addition if the editor showed suggestions while editing a .editorconfig
file. It's just something that came to my mind of nice to have
.
I've found that editorconfig changes to tabs as specified in the project's .editorconfig
when I edit my settings.json file which is located away from the root open folder in ~/.config
. It should instead not apply the editorconfig settings in this case.
Can we have an option to only tabify before a line starts (all tabs leading up to first char)? Ideally spaces that occur inside a line would be left alone (treated like deliberate formatting).
I'm not sure how this can happen and I recorded a screen capture.
The file is indented with spaces and has a tab width of 2.
At first, everything is detected like it should Spaces: 2
.
I change the .editorconfig
to tab_width = 4
and the file detects that it is 4 Spaces: 4
.
I remove that line from the .editorconfig
file and it should go back to Spaces: 2
, but it still is Spaces: 4
.
VSCode Version: 1.6.0
OS Version: Windows 10 Build 14393.222
Steps to Reproduce:
Open a JSON or HTML file (might apply to more files types)
Change something
Save and look at VSCode going crazy.
Then, if you try to close the file, it will ask if you want to save the file, if you discard the change, sometime it will replace the whole file content with null. Haven't been able to reproduce this one, happened one time when I record the video.
There's no error in the dev console. Disabling or removing EditorConfig extension make the issue vanish.
Closed issue on VSCode repo : microsoft/vscode#13512
this block tries to use the defaults of the texteditor and in my case, in most circumstances, it works. But not always. Let's assume we have this .editorconfig
file.
root = true
[{package.json,*.yml}]
indent_style = space
If my VS Code settings of insertSpaces
is set to auto
, it should auto-detect the the indentation type (spaces or tabs). This means that if I open index.js
, (which uses tabs) it should detect the tabs
and use that is indent style.
package.json
as the FIRST file (this will set spaces
as default indent type)index.js
(which uses tabs) and it will use spaces as current indent typeI will create an issue in the VSCode issue tracker and link this one. They have to refactor the API in order for us to support automatically detected defaults by VS Code.
The fixed TextEditorOptions
PR was merged into the new release. So our custom options interface can be removed now.
https://github.com/editorconfig/editorconfig-vscode/blob/master/src/interfaces/editorSettings.ts
They're working on it to bring that functionality via an API so we can use that. But it's not possible at the moment though.
From @Tyriar on July 5, 2016 3:43
Steps to Reproduce:
Copied from original issue: microsoft/vscode#8744
Hi,
I noticed a behaviour in VSCode after installing this plugin. If I open a clean file (i.e. already committed), the file gets automatically marked as dirty. I suspect this has something to do with line ending conversions. I did not have this problem with the earlier plugin from Microsoft (from Chris Dias) which has now been deprecated in favour of this one.
I am on Windows 7 SP1 and using VS Code 1.3.0
Thanks
( ported from Microsoft/vscode-editorconfig#24 )
Repro'd on editorconfig v0.2.7:
files.trimTrailingWhitespace
.trim_trailing_whitespace = true
Type some code with spaces, then rest (wait for autosave delay).
Expected: Caret position remains, trailing whitespace preceding the caret is not trimmed
Actual: All trailing whitespace is trimmed, causing the caret to move and the code (whitespace) that was under composition to be deleted.
Note, this caused me to stop using trim_trailing_whitespace
for a while, before I realised that enabling the matching VS Code option overrode the behaviour to be correct. However, figured it was worth reporting so that this could be improved for new users.
could you please add a support for global config in home directory? it would be conventient, because dont't need to create config everywhere
thanks
I have the EditorConfig plugin installed and my .editorconfig file in my project, however VS Code on Mac is not respecting the definitions. If I switch over to Windows in Parallels for the exact same project, VS Code uses the EditorConfig settings.
Let me know if there is any other info need to help diagnose the problems or if I'm missing some other setup on the Mac side.
From @rdumont on June 15, 2016 21:8
A max_line_length
property would be nice to have, as described in https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#max_line_length.
Copied from original issue: Microsoft/vscode-editorconfig#27
I've been sent a link to this saying it might be useful, but I can't find anything that says what it actually.
Seems like forces could join together for one super effort?
The Generate EditorConfig
command is broken. Probably because of this block. The command is meant to be used when no .editorconfig
file is present. But when using fs.stat
, it throws an error that the file does not exist.
Sometimes, the build throws an error. It looks like it is failing at this line https://github.com/Microsoft/vscode-extension-vscode/blob/master/bin/install#L66
Travis: https://travis-ci.org/editorconfig/editorconfig-vscode/jobs/108735221
@bpasero any idea?
I tried installing this in VS Code several times and each time the package.json is missing from ~.vscode\extensions\EditorConfig.EditorConfig-0.2.6
I finally just created it myself and took the contents from the repo to get it working.
I have VS Code 0.10.11 on Windows 7
Would be helpful to be able to explicitly set EOL default - for example, set to LF when you're developing on Windows but know that most of your deployments will be on Linux.
Per discussion with Alex, would need to first add the relevant extension API in vscode (to change document EOL) and then add support for it in the editorconfig extension.
Original issue: https://github.com/Microsoft/vscode-editorconfig/issues/11
If the last line in your file only has one space, it will add an extra new empty line because insertFinalNewlineTransform
and trimTrailingWhitespaceTransform
aren't waiting for each other because of this.
When #1 lands, we are able to refactor those two lines to something like this.
trimTrailingWhitespaceTransform(editorconfig, editor, textDocument)
.then(() => insertFinalNewlineTransform(editorconfig, editor, textDocument));
Or we can change this block to
if(lastLine.isEmptyOrWhitespace) {
return;
}
Which will do nothing and the last space gets trimmed by the trimTrailingWhitespaceTransform
method.
The second option might not be a good idea though. What if trim_trailing_whitespace
is set to false
for a file and the last line of the file consists of one or more spaces? This means the last line is not (really) empty but it will keep those spaces in the last line. So then it might be a good idea to add another empty line. Not quite sure what the expected behaviour is for such use case.
The trim_trailing_whitespace
does not seem to be respected in VSCode. I noticed this issue when disabling "files.trimTrailingWhitespace"
in settings.json
due to #33. VSCode was opened within a folder containing a .editorconfig
file.
Here's my .editorconfig
:
root = true
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.go]
indent_style = tab
[*.sql]
indent_style = tab
[*.yml]
indent_style = space
indent_size = 2
For some reason the autocomplete for new typescript files is not working when I have the .editorconfig
file in my project. When I remove it the intellisense starts working as expected.
Steps to reproduce
.ts
file. Type "mod" and try the autocomplete, nothing happens..editorconfig
and the new file and restart the IDE.The typescript output view displays as follow
Sending request: completions (16). Response expected: yes. Current queue length: 0
Response received: completions (16). Request took 4 ms. Success: false . Message: Error processing request. Cannot read property 'lineNumberToInfo' of undefined
would it be possible to skip applying styles to files that are ignored via .gitignore?
I think this
"icon": "./EditorConfig_icon.png"
should be replaced by
"icon": "EditorConfig_icon.png"
in package.json
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.