dense-analysis / ale

Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support
BSD 2-Clause "Simplified" License
13.59k stars 1.44k forks source link

Getting `no code action received from server` from ALECodeAction #3523

Open refaelsh opened 3 years ago

refaelsh commented 3 years ago

Information

VIM version

NVIM v0.4.4 Build type: Release

Operating System: Arch Linux

What went wrong

No matter what/when/how, I always get no code action received from server from ALECodeAction.

:ALEInfo

Current Filetype: rust Available Linters: ['analyzer', 'cargo', 'rls', 'rustc'] Enabled Linters: ['analyzer'] Ignored Linters: [] Suggested Fixers: 'remove_trailing_lines' - Remove all blank lines at the end of a file. 'rustfmt' - Fix Rust files with Rustfmt. 'trim_whitespace' - Remove all trailing whitespace characters at the end of every line. Linter Variables:

let g:ale_rust_analyzer_config = {} let g:ale_rust_analyzer_executable = 'rust-analyzer' let g:ale_rust_rustfmt_executable = 'rustfmt' let g:ale_rust_rustfmt_options = '' Global Variables:

let g:ale_cache_executable_check_failures = v:null let g:ale_change_sign_column_color = 0 let g:ale_command_wrapper = '' let g:ale_completion_delay = 100 let g:ale_completion_enabled = 1 let g:ale_completion_max_suggestions = 50 let g:ale_disable_lsp = 0 let g:ale_echo_cursor = 1 let g:ale_echo_msg_error_str = 'Error' let g:ale_echo_msg_format = '%code: %%s' let g:ale_echo_msg_info_str = 'Info' let g:ale_echo_msg_warning_str = 'Warning' let g:ale_enabled = 1 let g:ale_fix_on_save = 1 let g:ale_fixers = {'*': ['remove_trailing_lines', 'trim_whitespace'], 'yaml': ['prettier'], 'rust': ['rustfmt']} let g:ale_history_enabled = 1 let g:ale_history_log_output = 1 let g:ale_keep_list_window_open = 0 let g:ale_lint_delay = 200 let g:ale_lint_on_enter = 1 let g:ale_lint_on_filetype_changed = 1 let g:ale_lint_on_insert_leave = 1 let g:ale_lint_on_save = 1 let g:ale_lint_on_text_changed = 'normal' let g:ale_linter_aliases = {} let g:ale_linters = {'vim': ['vimls'], 'rust': ['analyzer'], 'yaml': ['yamllint'], 'gitcommit': ['gitlint']} let g:ale_linters_explicit = 0 let g:ale_linters_ignore = {} let g:ale_list_vertical = 0 let g:ale_list_window_size = 10 let g:ale_loclist_msg_format = '%code: %%s' let g:ale_lsp_root = {} let g:ale_max_buffer_history_size = 20 let g:ale_max_signs = -1 let g:ale_maximum_file_size = v:null let g:ale_open_list = 1 let g:ale_pattern_options = v:null let g:ale_pattern_options_enabled = v:null let g:ale_set_balloons = 1 let g:ale_set_highlights = 1 let g:ale_set_loclist = 1 let g:ale_set_quickfix = 0 let g:ale_set_signs = 1 let g:ale_sign_column_always = 1 let g:ale_sign_error = '>>' let g:ale_sign_info = '--' let g:ale_sign_offset = 1000000 let g:ale_sign_style_error = '>>' let g:ale_sign_style_warning = '--' let g:ale_sign_warning = '--' let g:ale_sign_highlight_linenrs = 0 let g:ale_statusline_format = v:null let g:ale_type_map = {} let g:ale_use_global_executables = v:null let g:ale_virtualtext_cursor = 0 let g:ale_warn_about_trailing_blank_lines = 1 let g:ale_warn_about_trailing_whitespace = 1 Command History:

(executable check - success) rust-analyzer (started) ['/bin/bash', '-c', '''rust-analyzer'''] (finished - exit code 0) ['/bin/bash', '-c', '''rustfmt'' < ''/tmp/nvimCqKdWS/3/left_overs_deleter.rs''']

jmou commented 3 years ago

I was looking into this myself. It looks like ALE would need custom support for rust-analyzer: https://github.com/dense-analysis/ale/issues/1466#issuecomment-724203512

jelly commented 3 years ago

Does anyone know how to debug the LSP support in vim-ale (as in seeing what is send from/to rust-analyzer) I'd be willing to help out get this issue resolved.

jmcantrell commented 3 years ago

@jelly I wasn't able to find a better way to do this, but it works.

You can put something like the following somewhere in your PATH with the file name rust-analyzer, and it will log the output of rust-analyzer to ~/rust-analyzer.out. It just wraps the real rust-analyzer command and adds an environment variable and logging options.

#!/usr/bin/env sh

export RA_LOG=info
exec /usr/bin/rust-analyzer --no-log-buffering --log-file ~/rust-analyzer.out "$@"
jelly commented 3 years ago

Thanks, I did something similar but without RA_LOG=info, all I get is:

[INFO rust_analyzer::main_loop] handle_event(Request(Request { id: RequestId(I32(2)), method: "textDocument/codeAction", params: Object({"context": Object({"diagnostics": Array([])}), "range": Object({"end": Object({"character": Number(1), "line": Number(2)}), "start": Object({"character": Number(0), "line": Number(2)})}), "textDocument": Object({"uri": String("file:///tmp/lol/src/main.rs")})}) }))
[INFO rust_analyzer::main_loop] handle_event(Response { id: RequestId(I32(2)), error: None })
[INFO rust_analyzer::global_state] handled textDocument/codeAction - (2) in 447.73µs

I'll have to check a different LSP implementation if that even has a code action

hsanson commented 3 years ago

Adding this to vim configuration would create a log file with all LSP interactions. Good for debugging issues with LSP linters:

call ch_logfile(expand('/tmp/chlogfile.log'), 'w')

Inspect the chlogfile.log for the logs.

This does not work on NeoVim unfortunatelly.