@@ -18,10 +18,13 @@ class TypeScriptLanguageClient extends AutoLanguageClient {
18
18
19
19
startServerProcess ( projectPath ) {
20
20
this . supportedExtensions = atom . config . get ( 'ide-typescript.javascriptSupport' ) ? allExtensions : tsExtensions
21
+ const serverPath = this . getServerPath ( projectPath )
22
+ console . info ( `starting typescript server: ${ serverPath } ` )
23
+
21
24
return super . spawnChildNode ( [
22
25
'node_modules/typescript-language-server/lib/cli' ,
23
26
'--stdio' ,
24
- '--tsserver-path' , this . getServerPath ( projectPath )
27
+ '--tsserver-path' , serverPath
25
28
] , { cwd : path . join ( __dirname , '..' ) } )
26
29
}
27
30
@@ -44,6 +47,8 @@ class TypeScriptLanguageClient extends AutoLanguageClient {
44
47
45
48
shouldStartForEditor ( editor ) {
46
49
const projectPath = this . getProjectPath ( editor . getURI ( ) || '' ) ;
50
+ if ( ! projectPath ) return false
51
+
47
52
if ( atom . config . get ( 'ide-typescript.ignoreFlow' ) === true ) {
48
53
const flowConfigPath = path . join ( projectPath , '.flowconfig' )
49
54
if ( fs . existsSync ( flowConfigPath ) ) return false
@@ -79,12 +84,20 @@ class TypeScriptLanguageClient extends AutoLanguageClient {
79
84
}
80
85
81
86
getServerPath ( projectPath ) {
82
- const tsSpecifiedPath = atom . config . get ( 'ide-typescript.typeScriptServer.path' )
83
- const localPath = path . resolve ( projectPath , tsSpecifiedPath )
84
- if ( fs . existsSync ( localPath ) ) {
85
- return localPath
87
+ const relativePathSpecifiedByUser = atom . config . get ( 'ide-typescript.typeScriptServer.path' )
88
+ const relativePathDefault = 'node_modules/typescript/lib/tsserver.js'
89
+ const absPathLocal = path . resolve ( projectPath , relativePathSpecifiedByUser )
90
+ const absPathGlobal = path . resolve ( __dirname , '..' , relativePathSpecifiedByUser )
91
+ const absPathGlobalDefault = path . resolve ( __dirname , '..' , relativePathDefault )
92
+
93
+ if ( fs . existsSync ( absPathLocal ) ) {
94
+ return absPathLocal
86
95
}
87
- return path . resolve ( __dirname , '..' , tsSpecifiedPath )
96
+ if ( fs . existsSync ( absPathGlobal ) ) {
97
+ return absPathGlobal
98
+ }
99
+
100
+ return absPathGlobalDefault
88
101
}
89
102
90
103
createTimeoutPromise ( milliseconds , cancelPromise ) {
0 commit comments