@@ -35,7 +35,11 @@ export class SveltePlugin
3535 CodeActionsProvider {
3636 private docManager = new Map < Document , SvelteDocument > ( ) ;
3737
38- constructor ( private configManager : LSConfigManager , private prettierConfig : any ) { }
38+ constructor (
39+ private configManager : LSConfigManager ,
40+ private prettierConfig : any ,
41+ private editorConfig ?: any ,
42+ ) { }
3943
4044 async getDiagnostics ( document : Document ) : Promise < Diagnostic [ ] > {
4145 if ( ! this . featureEnabled ( 'diagnostics' ) ) {
@@ -67,7 +71,13 @@ export class SveltePlugin
6771 const prettier = importPrettier ( filePath ) ;
6872 // Try resolving the config through prettier and fall back to possible editor config
6973 const config =
70- ( await prettier . resolveConfig ( filePath , { editorconfig : true } ) ) || this . prettierConfig ;
74+ ( await prettier . resolveConfig ( filePath , { editorconfig : true } ) ) ||
75+ this . prettierConfig ||
76+ // Be defensive here because IDEs other than VSCode might not have these settings
77+ ( this . editorConfig && this . editorConfig . tabSize && {
78+ tabWidth : this . editorConfig . tabSize ,
79+ useTabs : ! this . editorConfig . insertSpaces ,
80+ } ) ;
7181 // Take .prettierignore into account
7282 const fileInfo = await prettier . getFileInfo ( filePath , {
7383 ignorePath : this . prettierConfig ?. ignorePath ?? '.prettierignore' ,
0 commit comments