Skip to content

Feature/disable-warnings #304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [2.6.2]

### Added

- Adds Don't Show Again option when failing to spawn `fortls`, Fortran Intellisense
pop-up has already been removed
([#303](https://github.com/krvajal/vscode-fortran-support/issues/303))

## [2.6.1]

### Fixed
Expand Down Expand Up @@ -336,7 +344,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- Initial release

[unreleased]: https://github.com/krvajal/vscode-fortran-support/compare/v2.6.1...HEAD
[unreleased]: https://github.com/krvajal/vscode-fortran-support/compare/v2.6.2...HEAD
[2.6.2]: https://github.com/krvajal/vscode-fortran-support/compare/v2.6.1...v2.6.2
[2.6.1]: https://github.com/krvajal/vscode-fortran-support/compare/v2.6.0...v2.6.1
[2.6.0]: https://github.com/krvajal/vscode-fortran-support/compare/v2.5.0...v2.6.0
[2.5.0]: https://github.com/krvajal/vscode-fortran-support/compare/v2.4.3...v2.5.0
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "linter-gfortran",
"displayName": "Modern Fortran",
"description": "Modern Fortran language support, including syntax highlighting and error detection.",
"version": "2.6.1",
"version": "2.6.2",
"publisher": "krvajalm",
"license": "MIT",
"author": {
Expand Down Expand Up @@ -221,6 +221,11 @@
"uppercase"
],
"description": "Specify the word case to use when suggesting autocomplete options (One of 'lowercase' or 'upercase')"
},
"fortran.ignoreWarning.fortls": {
"type": "boolean",
"default": false,
"description": "Hide error message when the fortran-language-server is not detected"
}
}
},
Expand Down
14 changes: 13 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ export function activate(context: vscode.ExtensionContext) {
enable hover, peeking, gotos and many more.
For a full list of features the language server adds see:
https://github.com/hansec/fortran-language-server`;
promptForMissingTool(LANG_SERVER_TOOL_ID, msg, 'Python', loggingService);

if (!extensionConfig.get('ignoreWarning.fortls')) {
promptForMissingTool(
LANG_SERVER_TOOL_ID,
msg,
'Python',
['Install', "Don't Show Again"],
loggingService,
() => {
extensionConfig.update('ignoreWarning.fortls', true);
}
);
}
}
}
30 changes: 13 additions & 17 deletions src/features/formatting-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,14 @@ export class FortranFormattingProvider implements vscode.DocumentFormattingEditP

const formatterName = 'fprettify';
const formatterPath: string = this.getFormatterPath();
// If no formatter path is present check that formatter is present in $PATH
if (!formatterPath) {
if (!which.sync(formatterName, { nothrow: true })) {
this.logger.logWarning(`Formatter: ${formatterName} not detected in your system.
const formatter: string = path.join(formatterPath, formatterName);
// If no formatter is detected try and install it
if (!which.sync(formatter, { nothrow: true })) {
this.logger.logWarning(`Formatter: ${formatterName} not detected in your system.
Attempting to install now.`);
const msg = `Installing ${formatterName} through pip with --user option`;
promptForMissingTool(formatterName, msg, 'Python');
}
const msg = `Installing ${formatterName} through pip with --user option`;
promptForMissingTool(formatterName, msg, 'Python', ['Install'], this.logger);
}
const formatter: string = path.join(formatterPath, formatterName);

const args: string[] = [document.fileName, ...this.getFormatterArgs()];
// args.push('--silent'); // TODO: pass?
Expand Down Expand Up @@ -86,16 +84,14 @@ export class FortranFormattingProvider implements vscode.DocumentFormattingEditP
private doFormatFindent(document: vscode.TextDocument) {
const formatterName = 'findent';
const formatterPath: string = this.getFormatterPath();
// If no formatter path is present check that formatter is present in $PATH
if (!formatterPath) {
if (!which.sync(formatterName, { nothrow: true })) {
this.logger.logWarning(`Formatter: ${formatterName} not detected in your system.
Attempting to install now.`);
const msg = `Installing ${formatterName} through pip with --user option`;
promptForMissingTool(formatterName, msg, 'Python');
}
}
let formatter: string = path.join(formatterPath, formatterName);
// If no formatter is detected try and install it
if (!which.sync(formatter, { nothrow: true })) {
this.logger.logWarning(`Formatter: ${formatterName} not detected in your system.
Attempting to install now.`);
const msg = `Installing ${formatterName} through pip with --user option`;
promptForMissingTool(formatterName, msg, 'Python', ['Install'], this.logger);
}

// Annoyingly findent only outputs to a file and not to a stream so
// let us go and create a temporary file
Expand Down
52 changes: 29 additions & 23 deletions src/lib/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,39 +47,43 @@ export function FortranDocumentSelector(folder?: vscode.WorkspaceFolder) {
* e.g 'hansec.fortran-ls'
*
* @param tool name of the tool e.g. fortran-language-server
* @param msg optional message for installing said package
* @param msg message for installing said package
* @param toolType type of tool, supports `Python` (through pip) and 'VSExt'
* @param opts options for the prompt. "Install" and "Don't Show Again" are coded
* @param logger log channel output
* @param action a void function for an action to perform when "Don't Show Again" is pressed
*/
export function promptForMissingTool(
tool: string,
msg: string,
toolType: string,
logger?: LoggingService
opts: string[],
logger?: LoggingService,
action?: () => void
) {
const items = ['Install'];
return new Promise((resolve, reject) => {
resolve(
vscode.window.showInformationMessage(msg, ...items).then(selected => {
if (selected === 'Install') {
switch (toolType) {
case 'Python':
installPythonTool(tool, logger);
break;
return vscode.window.showInformationMessage(msg, ...opts).then(selected => {
if (selected === 'Install') {
switch (toolType) {
case 'Python':
installPythonTool(tool, logger);
break;

case 'VSExt':
logger.logInfo(`Installing VS Marketplace Extension with id: ${tool}`);
vscode.commands.executeCommand('extension.open', tool);
vscode.commands.executeCommand('workbench.extensions.installExtension', tool);
logger.logInfo(`Extension ${tool} successfully installed`);
break;
case 'VSExt':
logger.logInfo(`Installing VS Marketplace Extension with id: ${tool}`);
vscode.commands.executeCommand('extension.open', tool);
vscode.commands.executeCommand('workbench.extensions.installExtension', tool);
logger.logInfo(`Extension ${tool} successfully installed`);
break;

default:
logger.logError(`Failed to install tool: ${tool}`);
break;
}
}
})
);
default:
logger.logError(`Failed to install tool: ${tool}`);
vscode.window.showErrorMessage(`Failed to install tool: ${tool}`);
break;
}
} else if (selected === "Don't Show Again") {
action();
}
});
}

Expand All @@ -100,6 +104,8 @@ export function installPythonTool(pyPackage: string, logger?: LoggingService) {
logger.logError(
`Python package ${pyPackage} failed to install with code: ${code}, signal: ${signal}`
);
} else {
logger.logInfo(`Successfully installed ${pyPackage}.`);
}
});
installProcess.on('error', err => {
Expand Down