Skip to content
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

Handle some server requests #60

Merged
merged 11 commits into from
Mar 15, 2024
Merged

Handle some server requests #60

merged 11 commits into from
Mar 15, 2024

Conversation

pr2502
Copy link
Owner

@pr2502 pr2502 commented Mar 11, 2024

Supersedes #26. This handles some of the server -> client requests explicitly in ways which should be safe for that particular request and continues to ignore the rest like before.

So far I've implemented all requests I've noticed while using helix with rust-analyzer. I'll try more editors and language servers I'm familiar with when I have time. If anyone wants to try it with their editor please reply with your findings :)

@falcucci
Copy link
Contributor

falcucci commented Mar 14, 2024

@pr2502 amazing work, thank you!

could we map also some cargo.toml validation from rust-analyzer? if we add some wrong crate name for example and it doesn't compile, a generic error message is throw.

could we add some more info like this output example?

ERROR instance{pid=74513}: stderr line=    Updating crates.io index
ERROR instance{pid=74513}: stderr line=error: no matching package named `flexi_logger2` found
ERROR instance{pid=74513}: stderr line=location searched: registry `crates-io`
ERROR instance{pid=74513}: stderr line=required by package `neovide v0.12.2 (/Users/falcucci/neovide)`
ERROR instance{pid=74513}: stderr line=
ERROR instance{pid=74513}: stderr line=
ERROR instance{pid=74513}: stderr line=2024-03-14T10:35:38.426974Z ERROR flycheck: Flycheck failed to run the following command: CommandHandle { program: "/Users/falcucci/.rustup/toolchains/nightly-aarch64-apple-darwin/bin/cargo", arguments: ["clippy", "--workspace", "--message-format=json", "--manifest-path", "/Users/falcucci/neovide/Cargo.toml", "--all-targets"], current_dir: Some("/Users/falcucci/neovide") }

@pr2502
Copy link
Owner Author

pr2502 commented Mar 14, 2024

Oh, is that sent as a LSP message and we ignore it or is only logged by rust-analyzer?

We could try to emit a fake https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#window_showMessage message from log errors, but this is really something the language server should be doing.

@falcucci
Copy link
Contributor

falcucci commented Mar 14, 2024

I need to look deeper but I guess it's sent by rust-analyzer, we should probably just map it with more details. I've looked around and looks like zed have done something similar recently exposing those errors to their lsp properly: zed-industries/zed#8356

At neovim using coc.nvim it just shows a message "failed to load workspace"

@falcucci
Copy link
Contributor

falcucci commented Mar 14, 2024

"experimental/serverStatus" seems to be the specific status from rust-analyzer:

Task::FetchWorkspace(progress) => {
    let (state, msg) = match progress {
        ProjectWorkspaceProgress::Begin => (Progress::Begin, None),
        ProjectWorkspaceProgress::Report(msg) => (Progress::Report, Some(msg)),
        ProjectWorkspaceProgress::End(workspaces, force_reload_crate_graph) => {
            self.fetch_workspaces_queue
                .op_completed(Some((workspaces, force_reload_crate_graph)));
            if let Err(e) = self.fetch_workspace_error() {
                tracing::error!("FetchWorkspaceError:\n{e}");
            }
            self.switch_workspaces("fetched workspace".to_owned());
            (Progress::End, None)
        }
    };

    self.report_progress("Fetching", state, msg, None, None);
}

@falcucci
Copy link
Contributor

falcucci commented Mar 15, 2024

@pr2502 I've made this working here but probably needs to be refactored.

I couldn't find a way to join all errors to notify it only once tho, but at least we aren't blind anymore with cargo.toml generical notification.

do you have any idea of how improve this?

your PR looks already good to be merged, maybe we should treat this in another PR?

@pr2502
Copy link
Owner Author

pr2502 commented Mar 15, 2024

Yes definitely, please make a separate PR for it 🙏
I'll merge this one, it's big enough already.

@pr2502 pr2502 merged commit e47861a into main Mar 15, 2024
1 check passed
@pr2502 pr2502 deleted the handle-some-server-requests branch March 15, 2024 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants