maksimr/vim-jsbeautify

.editorconfig for typescript

esanzgar opened this issue · 7 comments

Two questions:

I use jsbeautify from typescript files. In my .vimrc, I have:
autocmd FileType typescript vnoremap <buffer> <c-f> :call RangeJsBeautify()<cr>

How can I setup my .editorconfig for typescript? These rules are ignored for typescript files in my .editorconfig:

[**.ts]
charset = utf-8
indent_style = space
indent_size = 3
insert_final_newline = true
trim_trailing_whitespace = true

Thanks

@esanzgar now plugin supports only 'js', 'css', 'html', 'jsx', 'json' types.

Does js-beautify support typescript?

Thanks!

@esanzgar try to rename [**.ts] to [**.js]

[**.js]
charset = utf-8
indent_style = space
indent_size = 3
insert_final_newline = true
trim_trailing_whitespace = true

In general, js-beautify works pretty well with typescript. I found just a couple of corner cases were js-beautify doesn't format typescript correctly.

Renaming all [**.ts] to [**.js] doesn't work. Changing all the extension .ts to .js is not an option.

Thank you anyway.

@esanzgar No problem,

I have checked it for typescript and it works for me

P.S. I have used JsBeautify instead RangeJsBeautify

I have JsBeautify and v1.7.5 of js-beautify:

autocmd FileType typescript noremap <buffer> <c-f> :call JsBeautify()<cr>

but still it doesn't pick up the .editorconfig rules under [**.js].

@maksimr You are right, it works for typescript files when the .editorconfig is explicitly set.

My issue was that the .editorconfig is found and parsed through the editorconfig-vim plugin. That was my particular scenario and it didn't work me.

I have resolved the issue with this simple if statement:
master...esanzgar:master

@esanzgar Thanks