Skip to content

Commit caf2d46

Browse files
committed
Removes paths.ts which checks if binary is in PATH
This has now been replaced with `which` which is also platform agnostic. The only difference is that `which` does not cache the result of the query. However, realistically speaking calling which once per new file being opened is a trivial cost. Moreover, already opened files are cached automatically so no `which` calls are made when changing between opened files.
1 parent 901bcb3 commit caf2d46

File tree

6 files changed

+14
-69
lines changed

6 files changed

+14
-69
lines changed

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/extension.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// src/extension.ts
2+
import * as which from 'which'
23
import * as vscode from 'vscode'
34

45
import FortranLintingProvider from './features/linter-provider'
@@ -53,7 +54,10 @@ export function activate(context: vscode.ExtensionContext) {
5354
loggingService.logInfo('Symbol Provider is not enabled')
5455
}
5556

56-
if (checkForLangServer(extensionConfig)) {
57+
// Our interface with `fortls` has been disabled in favour of the @hansec's
58+
// VS Code extension Fortran IntelliSense
59+
const useInternalFLInterface = false;
60+
if (useInternalFLInterface) {
5761
const langServer = new FortranLangServer(context, extensionConfig)
5862
langServer.start()
5963
langServer.onReady().then(() => {

src/lang-server.ts

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import {
33
LanguageClientOptions,
44
Executable,
55
} from 'vscode-languageclient'
6+
import * as which from 'which'
67
import * as vscode from 'vscode'
78
import {
8-
getBinPath,
99
FORTRAN_FREE_FORM_ID,
10-
promptForMissingTool,
1110
} from './lib/helper'
1211
import { LANG_SERVER_TOOL_ID } from './lib/tools'
1312

@@ -18,7 +17,7 @@ export class FortranLangServer {
1817
let langServerFlags: string[] = config.get('languageServerFlags', [])
1918

2019
const serverOptions: Executable = {
21-
command: getBinPath(LANG_SERVER_TOOL_ID),
20+
command: which.sync(LANG_SERVER_TOOL_ID),
2221
args: [...langServerFlags],
2322
options: {},
2423
}
@@ -48,23 +47,3 @@ export class FortranLangServer {
4847
return capabilities
4948
}
5049
}
51-
52-
export function checkForLangServer(config) {
53-
const useLangServer = false //config.get('useLanguageServer')
54-
if (!useLangServer) return false
55-
if (process.platform === 'win32') {
56-
vscode.window.showInformationMessage(
57-
'The Fortran language server is not supported on Windows yet.'
58-
)
59-
return false
60-
}
61-
let langServerAvailable = getBinPath(LANG_SERVER_TOOL_ID)
62-
if (!langServerAvailable) {
63-
promptForMissingTool(LANG_SERVER_TOOL_ID)
64-
vscode.window.showInformationMessage(
65-
'Reload VS Code window after installing the Fortran language server'
66-
)
67-
}
68-
return true
69-
}
70-

src/lib/helper.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ let saveKeywordToJson = keyword => {
115115
});
116116
};
117117

118-
export { default as getBinPath } from './paths'
119118

120119
export function promptForMissingTool(tool: string) {
121120
const items = ['Install'];

src/lib/paths.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/lib/tools.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
export const LANG_SERVER_TOOL_ID = 'fortran-langserver';
22
import * as cp from 'child_process';
3-
export const toolBinNames = {
4-
[LANG_SERVER_TOOL_ID]: 'fortls',
5-
'gnu-compiler': 'gfortran',
6-
};
3+
74

85
export function installTool(toolname) {
96
if (toolname === LANG_SERVER_TOOL_ID) {

0 commit comments

Comments
 (0)