-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve location of external tools (#91)
* Extract intrisinc list into its own file * Add type attributes completion gif * Add a basic language server implementation * Update the minum supported version of vscode to 1.22.0 * Update changelog * Locate bin tools by path * Improve bin tools lookup * Add command for install the fortran lang server
- Loading branch information
Showing
7 changed files
with
128 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import * as fs from 'fs' | ||
import * as path from 'path' | ||
import { toolBinNames } from './tools' | ||
|
||
let binPathCache: { [tool: string]: string } = {} | ||
|
||
export const envPath = | ||
process.env['PATH'] || | ||
(process.platform === 'win32' ? process.env['Path'] : null) | ||
|
||
// checks in the PATH defined in the PATH env variables | ||
// for the specified tools and returns its complete path | ||
export default function getBinPath(tool: string): string | null { | ||
if (binPathCache[tool]) return binPathCache[tool] | ||
const binDirPaths = envPath.split(path.delimiter) | ||
const binName = getBinName(tool) | ||
const possiblePaths = binDirPaths.map(binDirPath => | ||
path.join(binDirPath, binName) | ||
) | ||
for (let p of possiblePaths) { | ||
if (fileExists(p)) { | ||
// save in cache | ||
binPathCache[tool] = p | ||
return p | ||
} | ||
} | ||
return null | ||
} | ||
|
||
function getBinName(tool: string): string { | ||
return toolBinNames[tool] | ||
} | ||
|
||
function fileExists(filePath: string): boolean { | ||
try { | ||
return fs.statSync(filePath).isFile() | ||
} catch (e) { | ||
return false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export const LANG_SERVER_TOOL_ID = 'fortran-langserver' | ||
import * as cp from 'child_process' | ||
export const toolBinNames = { | ||
[LANG_SERVER_TOOL_ID]: 'fortls', | ||
'gnu-compiler': 'gfortran', | ||
} | ||
|
||
export function installTool(toolname) { | ||
if (toolname === LANG_SERVER_TOOL_ID) { | ||
const installProcess = cp.spawn( | ||
'pip', | ||
'install fortran-language-server'.split(' ') | ||
) | ||
installProcess.on('exit', (code, signal) => { | ||
if (code !== 0) { | ||
// extension failed to install | ||
} | ||
}) | ||
installProcess.on('error', err => { | ||
//failed to install | ||
}) | ||
} | ||
} |