Coder Social home page Coder Social logo

editorconfig / editorconfig-vscode Goto Github PK

View Code? Open in Web Editor NEW

This project forked from microsoft/vscode-editorconfig

1.2K 23.0 116.0 848 KB

EditorConfig extension for Visual Studio Code

Home Page: http://editorconfig.org/

License: MIT License

TypeScript 100.00%
vscode-extension editorconfig

editorconfig-vscode's Introduction

GitHub Actions Gitter

This plugin attempts to override user/workspace settings with settings found in .editorconfig files. No additional or vscode-specific files are required. As with any EditorConfig plugin, if root=true is not specified, EditorConfig will continue to look for an .editorconfig file outside of the project.

This repository is specific to the EditorConfig Extension for Visual Studio Code. Internally, it uses the editorconfig npm package, which is one of a few EditorConfig cores available.

See also:

Feel free to submit any issues you may have via the issue tracker.

Installation

When identifying an extension, provide the full name of the form publisher.extension. For this extension, that's editorconfig.editorconfig.

See Extension Marketplace for more information on the multiple ways of installing VSCode extensions.

Supported Properties

  • indent_style
  • indent_size
  • tab_width
  • end_of_line (on save)
  • insert_final_newline (on save)
  • trim_trailing_whitespace (on save)

On the backlog

  • charset

How it works

This extension is activated whenever you open a new text editor, switch tabs into an existing one or focus into the editor you already have open. When activated, it uses editorconfig to resolve the configuration for that particular file and applies any relevant editor settings.

Note: some settings can only be applied on file save, as indicated above.

A new .editorconfig file can be created via the Explorer sidebar's context menu by right-clicking in the folder where you'd like it to be and selecting Generate .editorconfig.

Known Issues

editorconfig-vscode's People

Contributors

alexdima avatar ark120202 avatar bbosman avatar bobbrow avatar cathook avatar chrisdias avatar christian-bromann avatar coliff avatar dgileadi avatar dinhani avatar edgardmessias avatar egamma avatar emilmelnikov avatar febley avatar hobbsd avatar jedmao avatar jednano avatar jimic avatar jrieken avatar msftgits avatar nrayburn-cyber avatar nrayburn-tech avatar peterblazejewicz avatar rdumont avatar samverschueren avatar slartibardfast avatar tgfjt avatar torarvid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

editorconfig-vscode's Issues

Configuration is not working with `.coffee` files.

We have the following .editorconfig file at the root of our project:

[*.jade]
indent_style = space
indent_size = 4

[*.coffee]
ident_style = space
ident_size = 2

However, the configuration is not applied correctly to .coffee files. See this screenshot:

Screenshot

Tabs added in middle of line

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).

No automatic final newline insertion anymore

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

Switch to onWillSaveTextDocument

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.

add support for `charset`

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.

typescript autocomplete not working for new files with editorconfig

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

  1. Install the editorconfig plugin
  2. Open an existent typescript application and create the .editorconfig file
  3. Restart vscode and create a new .ts file. Type "mod" and try the autocomplete, nothing happens.
  4. Remove .editorconfig and the new file and restart the IDE.
  5. Repeat step 3, it will work as expected.

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

Previewing files in folder marks them as unsaved

microsoft/vscode#9308

VSCode Version: 1.3.1
OS Version: Win 7

Steps to Reproduce:

  1. Open a folder
  2. Randomly select files to view their contents.
  3. Files get marked as unsaved - even though nothing was changed.

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.

What does it do?

I've been sent a link to this saying it might be useful, but I can't find anything that says what it actually.

Support for file names/types overrides

# 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.

Refactor

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.

skip .gitignored files

would it be possible to skip applying styles to files that are ignored via .gitignore?

Show warning if user has set `files.trimTrailingWhitespace` globally

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.

icon not shown in marketplace

I think this

"icon": "./EditorConfig_icon.png"

should be replaced by

"icon": "EditorConfig_icon.png"

in package.json.

Settings aren't applied correctly after removing them

I'm not sure how this can happen and I recorded a screen capture.

editorconfig

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.

editorconfig is breaking the detectIndentation on vscode

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.

  1. Open a package.json (indent=2) with the extension installed and the indentation of the editor is 4.
  2. Remove the extension and try again the first step. The detectIndentation works again.

Thanks! excellent work with this extension!

package.json missing when installed

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

Add a way to undefine the tab_width property

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.

Defaults not always correct

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

Expected behaviour

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.

Current behaviour

  1. Open a project and open package.json as the FIRST file (this will set spaces as default indent type)
  2. Open index.js (which uses tabs) and it will use spaces as current indent type

I 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.

Opening clean files in VSCode automatically marks it as dirty

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

Invoke `trimTrailingWhitespace` before `insertFinalNewline`

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.

Option 1

When #1 lands, we are able to refactor those two lines to something like this.

trimTrailingWhitespaceTransform(editorconfig, editor, textDocument)
    .then(() => insertFinalNewlineTransform(editorconfig, editor, textDocument));

Option 2

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.

But...

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.

Doesn't seem to work on Mac

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.

add support for end_of_line

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

Not trimming whitespace when `trim_trailing_whitespace` is set to true

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

insert_final_newline into editorconfig file

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 = 2

If I save it, a final newline is not added.

v0.3.4 highlights final newline after save

Steps to reproduce

  1. Open a file for which insert_final_newline = true.
  2. Place your cursor at the end of the file w/o a final newline.
  3. Save the file.

Expected Behavior

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.

Actual Behavior

A final newline is inserted; however, it's also highlighted. Furthermore, the cursor remains where it was before the save.

Spuriously changes line endings in VS Code Insiders v1.3.0

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.

EditorConfig make VSCode 1.6.0 go crazy on save

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.

Quick video here :
formatonsavefreakoutlight

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

Saving huge files flashes the dirty circle indicator in open editors rapidly until it is saved to disk

From @Tyriar on July 5, 2016 3:43

  • VSCode Version: Code - Insiders 1.3.0-insider (0c5f6e8867fb117b6fa41cc647dc650bb9856dc4, 2016-07-04T09:39:57.773Z)
  • OS Version: Linux x64 4.4.0-28-generic, Ubuntu 16.04

Steps to Reproduce:

  1. Turn on open editors if not already
  2. Open a huge file (mine was 18000 lines)
  3. Dirty
  4. Save, observe the circle indicator flashing rapidly, presumably until it is actually saved to disk. I saw this on an SSD, it will probably be a lot worse on a HDD. I also noticed that the save trimmed a bunch of whitespace, so that may be related.

Copied from original issue: microsoft/vscode#8744

insert_final_newline breaks typing flow when auto-save enabled

  • I have auto-save enabled (1 sec delay).
  • I have insert_final_newline = true in my editorconfig

When typing on the last line of a file, when that file is autosaved (and the newline added) it also moves the cursor position to the end of the file. Which also closes intellisense.

See this image:

animation

trim_trailing_whitespace moves caret

( ported from Microsoft/vscode-editorconfig#24 )

Repro'd on editorconfig v0.2.7:

  1. Enable autosave in VS Code (e.g. in user settings) - great for users who are used to using Git to back up their code.
  2. Open up a workspace that lacks VS Code workspace settings for files.trimTrailingWhitespace.
  3. In the same workspace, create a .editorconfig, setting 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.