Skip to content

Commit 1747802

Browse files
formatting after prettier managed to run
1 parent 066ca08 commit 1747802

File tree

3 files changed

+25
-26
lines changed

3 files changed

+25
-26
lines changed

schemas/fortls.schema.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,4 @@
184184
"type": "boolean"
185185
}
186186
}
187-
}
187+
}

src/lib/tools.ts

+12-11
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,16 @@ export async function pipInstall(pyPackage: string): Promise<string> {
150150

151151
/**
152152
* Checks whether python can be called from the shell.
153-
*
153+
*
154154
* Tries `python` on Windows and `python3` on other platforms.
155-
*
155+
*
156156
* TODO: this could also check for python version, which has to be > 3.7 for fortls.
157-
*
157+
*
158158
* @returns name of the command to run python on the current platform
159159
*/
160160
export async function checkPython(): Promise<string> {
161-
let py = "";
162-
if (os.platform() == "win32") {
161+
let py = '';
162+
if (os.platform() == 'win32') {
163163
py = 'python';
164164
} else {
165165
py = 'python3';
@@ -170,19 +170,20 @@ export async function checkPython(): Promise<string> {
170170
await shellTask(py, args, 'getting python version');
171171
return py;
172172
} catch (e) {
173-
let errMsg = "";
174-
if (os.platform() == "win32") {
175-
errMsg = py + " isn't callable from the shell. " +
176-
"Please make sure python is installed and added to the PATH.";
173+
let errMsg = '';
174+
if (os.platform() == 'win32') {
175+
errMsg =
176+
py +
177+
" isn't callable from the shell. " +
178+
'Please make sure python is installed and added to the PATH.';
177179
} else {
178180
errMsg = py + " isn't callable from the shell. Please make sure python is installed";
179-
}
181+
}
180182

181183
return await new Promise<string>((result, reject) => {
182184
reject(errMsg);
183185
});
184186
}
185-
186187
}
187188

188189
export async function shellTask(command: string, args: string[], name: string): Promise<string> {

src/lsp/client.ts

+12-14
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ export class FortlsClient {
7373
// restart this class
7474
this.deactivate();
7575
this.activate();
76-
7776
} catch (error) {
7877
this.logger.error(`[lsp.client] Error installing ${LS_NAME}: ${error}`);
7978
window.showErrorMessage(error);
@@ -83,7 +82,6 @@ export class FortlsClient {
8382
this.logger.info(`[lsp.client] ${LS_NAME} disabled in settings`);
8483
}
8584
});
86-
8785
} else {
8886
workspace.onDidOpenTextDocument(this.didOpenTextDocument, this);
8987
workspace.textDocuments.forEach(this.didOpenTextDocument, this);
@@ -100,7 +98,6 @@ export class FortlsClient {
10098
}
10199

102100
return;
103-
104101
}
105102

106103
public async deactivate(): Promise<void> {
@@ -296,11 +293,11 @@ export class FortlsClient {
296293

297294
/**
298295
* Tries to find fortls and saves its path to this.path.
299-
*
296+
*
300297
* If a user path is configured, then only use this.
301298
* If not, try running fortls globally, or from python user scripts folder on Windows.
302-
*
303-
* @returns true if fortls found, false if not
299+
*
300+
* @returns true if fortls found, false if not
304301
*/
305302
private getLSPath(): boolean {
306303
const config = workspace.getConfiguration(EXTENSION_ID);
@@ -311,29 +308,31 @@ export class FortlsClient {
311308
// if there's a user configured path to the executable, check if it's absolute
312309
if (configuredPath !== '') {
313310
if (!path.isAbsolute(configuredPath)) {
314-
window.showErrorMessage("The path to fortls (fortran.fortls.path) must be absolute.");
311+
window.showErrorMessage('The path to fortls (fortran.fortls.path) must be absolute.');
315312
return false;
316313
}
317314

318315
pathsToCheck.push(configuredPath);
316+
} else {
317+
// no user configured path => perform standard search for fortls
319318

320-
} else { // no user configured path => perform standard search for fortls
321-
322319
pathsToCheck.push('fortls');
323-
320+
324321
// On Windows, `pip install fortls --user` installs fortls to the userbase\PythonXY\Scripts path,
325322
// so we want to look for it in this path as well.
326323
if (os.platform() == 'win32') {
327-
const result = spawnSync('python', ['-c', 'import site; print(site.getusersitepackages())']);
324+
const result = spawnSync('python', [
325+
'-c',
326+
'import site; print(site.getusersitepackages())',
327+
]);
328328
const userSitePackagesStr = result.stdout.toString().trim();
329-
329+
330330
// check if the call above returned something, in case the site module in python ever changes...
331331
if (userSitePackagesStr) {
332332
const userScriptsPath = path.resolve(userSitePackagesStr, '../Scripts/fortls');
333333
pathsToCheck.push(userScriptsPath);
334334
}
335335
}
336-
337336
}
338337

339338
// try to run `fortls --version` for all the given paths
@@ -400,7 +399,6 @@ export class FortlsClient {
400399
return results.stdout.toString().trim();
401400
}
402401

403-
404402
/**
405403
* Restart the language server
406404
*/

0 commit comments

Comments
 (0)