@@ -13,11 +13,11 @@ import {existsVFS} from "@server/vfs/files-adapter"
1313import type { ClientOptions } from "@shared/config-scheme"
1414import {
1515 DocumentationAtPositionRequest ,
16+ SetToolchainVersionNotification ,
17+ SetToolchainVersionParams ,
1618 TypeAtPositionParams ,
1719 TypeAtPositionRequest ,
1820 TypeAtPositionResponse ,
19- SetToolchainVersionNotification ,
20- SetToolchainVersionParams ,
2121} from "@shared/shared-msgtypes"
2222import { Logger } from "@server/utils/logger"
2323import { clearDocumentSettings , getDocumentSettings , ServerSettings } from "@server/settings/settings"
@@ -78,8 +78,9 @@ import {
7878 provideTolkCompletionResolve ,
7979} from "@server/languages/tolk/completion"
8080import {
81- setProjectTolkStdlibPath ,
8281 InvalidToolchainError ,
82+ setProjectTolkStdlibPath ,
83+ tolkStdlibSearchPaths ,
8384} from "@server/languages/tolk/toolchain/toolchain"
8485import {
8586 provideTolkDocumentSymbols ,
@@ -185,7 +186,12 @@ async function findTolkStdlib(settings: ServerSettings, rootDir: string): Promis
185186 return settings . tolk . stdlib . path
186187 }
187188
188- const searchDirs = [ "node_modules/@ton/tolk-js/dist/tolk-stdlib" , "stdlib" ]
189+ const searchDirs = [
190+ `${ rootDir } /node_modules/@ton/tolk-js/dist/tolk-stdlib` ,
191+ `${ rootDir } /stdlib` ,
192+ `${ rootDir } /tolk-stdlib` ,
193+ ...tolkStdlibSearchPaths ( ) ,
194+ ]
189195
190196 const testStdlibOath = process . env [ "TEST_TOLK_STDLIB_PATH" ]
191197 if ( testStdlibOath ) {
@@ -194,17 +200,17 @@ async function findTolkStdlib(settings: ServerSettings, rootDir: string): Promis
194200
195201 async function findDirectory ( ) : Promise < string | null > {
196202 for ( const searchDir of searchDirs ) {
197- if ( await existsVFS ( globalVFS , filePathToUri ( path . join ( rootDir , searchDir ) ) ) ) {
203+ if ( await existsVFS ( globalVFS , filePathToUri ( searchDir ) ) ) {
198204 return searchDir
199205 }
200206 }
201207
202208 return null
203209 }
204210
205- const localFolder = await findDirectory ( )
211+ const stdlibPath = await findDirectory ( )
206212
207- if ( localFolder === null ) {
213+ if ( stdlibPath === null ) {
208214 console . error (
209215 "Tolk standard library not found! Searched in:\n" ,
210216 searchDirs . map ( dir => path . join ( rootDir , dir ) ) . join ( "\n" ) ,
@@ -216,7 +222,6 @@ async function findTolkStdlib(settings: ServerSettings, rootDir: string): Promis
216222 return null
217223 }
218224
219- const stdlibPath = path . join ( rootDir , localFolder )
220225 console . info ( `Using Tolk Standard library from ${ stdlibPath } ` )
221226 return stdlibPath
222227}
0 commit comments