fannheyward / coc-rust-analyzer

rust-analyzer extension for coc.nvim
MIT License
1.13k stars 39 forks source link

coc-codeaction-line and coc-fix-current not working #1191

Closed linde12 closed 11 months ago

linde12 commented 11 months ago

What's the output of :CocInfo

## versions

vim version: NVIM v0.9.1
node version: v19.7.0
coc.nvim version: 0.0.82-2a73b9dc 2023-09-21 23:24:13 +0800
coc.nvim directory: /home/olinde/.local/share/nvim/lazy/coc.nvim
term: alacritty
platform: linux

## Log of coc.nvim

2023-10-12T11:22:37.141 INFO (pid:6629) [plugin] - coc.nvim initialized with node: v19.7.0 after 238
2023-10-12T11:22:37.980 INFO (pid:6629) [services] - LanguageClient Rust Analyzer Language Server state change: stopped => starting
2023-10-12T11:22:37.990 INFO (pid:6629) [language-client-index] - Language server "rust-analyzer" started with 6672
2023-10-12T11:22:38.005 INFO (pid:6629) [services] - LanguageClient Rust Analyzer Language Server state change: starting => running
2023-10-12T11:22:38.053 INFO (pid:6629) [services] - service rust-analyzer started
2023-10-12T11:22:38.193 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:22:43.026 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:22:44.573 INFO (pid:6629) [attach] - receive notification: doHover []
2023-10-12T11:22:44.827 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:22:49.773 ERROR (pid:6629) [provider-manager] - Provider error on provideHover: Dg [Error]: canceled by client
    at it (/home/olinde/.local/share/nvim/lazy/coc.nvim/build/index.js:27:234)
    at zn (/home/olinde/.local/share/nvim/lazy/coc.nvim/build/index.js:26:7395)
    at uo (/home/olinde/.local/share/nvim/lazy/coc.nvim/build/index.js:26:7518)
    at Immediate.<anonymous> (/home/olinde/.local/share/nvim/lazy/coc.nvim/build/index.js:26:7282)
    at process.processImmediate (node:internal/timers:475:21) {
  code: -32800,
  data: undefined
}
2023-10-12T11:22:50.103 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:22:51.156 INFO (pid:6629) [attach] - Request action: diagnosticList []
2023-10-12T11:22:53.069 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:22:53.907 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:22:54.842 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:22:55.003 INFO (pid:6629) [attach] - receive notification: doHover []
2023-10-12T11:22:55.270 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:22:56.019 INFO (pid:6629) [attach] - receive notification: doHover []
2023-10-12T11:22:56.723 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:22:58.135 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:22:59.713 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:01.943 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:01.949 INFO (pid:6629) [attach] - receive notification: doHover []
2023-10-12T11:23:02.206 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:02.713 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:03.072 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:04.837 INFO (pid:6629) [attach] - Request action: diagnosticList []
2023-10-12T11:23:05.065 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:05.458 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:06.075 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:06.102 INFO (pid:6629) [attach] - Request action: diagnosticList []
2023-10-12T11:23:06.549 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:07.398 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:07.983 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:10.686 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:12.238 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:13.358 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:14.383 INFO (pid:6629) [attach] - Request action: diagnosticList []
2023-10-12T11:23:14.988 INFO (pid:6629) [attach] - Request action: diagnosticList []
2023-10-12T11:23:15.172 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:15.196 INFO (pid:6629) [attach] - Request action: diagnosticList []
2023-10-12T11:23:16.900 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:17.320 INFO (pid:6629) [attach] - receive notification: codeAction [ 'currline' ]
2023-10-12T11:23:17.579 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:18.187 INFO (pid:6629) [attach] - receive notification: doQuickfix []
2023-10-12T11:23:18.446 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:19.291 INFO (pid:6629) [attach] - receive notification: codeAction [ 'cursor' ]
2023-10-12T11:23:21.215 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:21.807 INFO (pid:6629) [attach] - receive notification: codeAction [ 'cursor' ]
2023-10-12T11:23:22.856 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:23.305 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:24.335 INFO (pid:6629) [attach] - receive notification: codeAction [ 'cursor' ]
2023-10-12T11:23:24.595 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:25.289 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:25.878 INFO (pid:6629) [attach] - receive notification: codeAction [ 'cursor' ]
2023-10-12T11:23:35.972 INFO (pid:6629) [attach] - Request action: diagnosticList []
2023-10-12T11:23:36.010 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:37.163 INFO (pid:6629) [attach] - Request action: diagnosticList []
2023-10-12T11:23:37.358 INFO (pid:6629) [attach] - Request action: diagnosticList []
2023-10-12T11:23:37.368 INFO (pid:6629) [attach] - receive notification: highlight []
2023-10-12T11:23:37.451 INFO (pid:6629) [attach] - Request action: diagnosticList []
2023-10-12T11:24:09.444 INFO (pid:6629) [attach] - receive notification: showInfo []

What's the output of :CocCommand rust-analyzer.serverVersion rust-analyzer 0.3.1689-standalone What's your coc-rust-analyzer version? You can get it from :CocList extensions 0.73.0

Hi! :smiley:

I am unable to get the coc-codeaction-line and coc-fix-current - i am unsure if this is related to coc-rust-analyzer or rust-analyzer itself not support it? coc-codeaction-cursor is working but i am very lazy and would prefer to not move my cursor to e.g. the missing import and would also prefer not to get the popup menu only to select the first result most of the time. coc-fix-current is usually my go-to and i do coc-codeaction-line if that does not work out.

Maybe someone can shed some light on this? Thanks!

fannheyward commented 11 months ago
  1. coc requests server for codeActions with document and range
  2. coc-codeaction-line and coc-fix-current uses the same line range
  3. coc-codeaction-cursor uses the cursor position as range
  4. server responses codeActions for the request

In your case, coc-codeaction-line and coc-fix-current didn't work for your request, this means server didn't returns codeActions for line range you requesting.

linde12 commented 11 months ago

Figured this was the case, just weird. But rust-analyzer issue then. Thanks!