yaegassy / coc-ansible

ansible-language-server extension for coc.nvim
https://www.npmjs.com/package/@yaegassy/coc-ansible
MIT License
71 stars 3 forks source link

Command failed error appears when running ansible-lint (This is a specification) #1

Closed yaegassy closed 2 years ago

yaegassy commented 2 years ago

Description

If there are syntax errors problems, you will get a very unimpressive error message. I was surprised to see a bright red error screen. :(

It would be nice if the language server side, could handle it properly... :(

coc-ansible

1_coc-ansible-error

Same for "VSCode" (vscode-ansible)

2_vscode-ansible-error
yaegassy commented 2 years ago

I think if you can get ansible-language-server's ansibleLint.ts to handle it properly without using window.showErrorMessage, this problem will be solved.

https://github.com/ansible/ansible-language-server/blob/main/src/services/ansibleLint.ts#L133-L135

// ...snip
      } catch (error) {
        if (error instanceof Error) {
          const execError = error as ExecException & {
            // according to the docs, these are always available
            stdout: string;
            stderr: string;
          };
          if (execError.code === 2) {
            diagnostics = this.processReport(
              execError.stdout,
              await ansibleLintConfigPromise,
              workingDirectory
            );
          } else {
            // Here
            this.connection.window.showErrorMessage(execError.message); // <-- Here
          }

          if (execError.stderr) {
            this.connection.console.info(`[ansible-lint] ${execError.stderr}`);
          }
        } else {
          this.connection.console.error(
            `Exception in AnsibleLint service: ${JSON.stringify(error)}`
          );
        }
      }
// ...snip
yaegassy commented 2 years ago

I reported an issue (feature request) to ansible-language-server

yaegassy commented 2 years ago

It is likely to be adjusted in the future.