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

second line of file is replaced with the name of the crate upon :w #1176

Open
petrovito opened this issue Sep 6, 2023 · 4 comments
Open
Assignees

Comments

@petrovito
Copy link

What's the output of :CocInfo

## versions

vim version: NVIM v0.8.3
node version: v18.15.0
coc.nvim version: 0.0.82-b7375d5f 2023-01-30 05:09:03 +0800
coc.nvim directory: ~~~~~~
term: xterm-256color
platform: linux

## Log of coc.nvim

2023-09-06T19:40:49.727 INFO (pid:11955) [plugin] - coc.nvim initialized with node: v18.15.0 after 129
2023-09-06T19:40:49.727 INFO (pid:11955) [services] - LanguageClient Rust Analyzer Language Server state change: stopped => starting
2023-09-06T19:40:49.734 INFO (pid:11955) [language-client-index] - Language server "rust-analyzer" started with 11980
2023-09-06T19:40:49.743 INFO (pid:11955) [services] - LanguageClient Rust Analyzer Language Server state change: starting => running
2023-09-06T19:40:49.772 INFO (pid:11955) [services] - service rust-analyzer started
2023-09-06T19:40:49.955 INFO (pid:11955) [attach] - receive notification: highlight []
2023-09-06T19:40:52.284 INFO (pid:11955) [attach] - receive notification: highlight []
2023-09-06T19:40:53.598 INFO (pid:11955) [attach] - receive notification: highlight []
2023-09-06T19:40:54.589 INFO (pid:11955) [attach] - receive notification: highlight []
2023-09-06T19:40:56.181 INFO (pid:11955) [attach] - receive notification: highlight []
2023-09-06T19:40:56.743 INFO (pid:11955) [attach] - receive notification: highlight []
2023-09-06T19:40:57.153 INFO (pid:11955) [attach] - receive notification: highlight []
2023-09-06T19:40:58.285 INFO (pid:11955) [attach] - receive notification: highlight []
2023-09-06T19:40:58.987 INFO (pid:11955) [attach] - receive notification: highlight []
2023-09-06T19:41:01.724 INFO (pid:11955) [attach] - receive notification: showInfo []

What's the output of :CocCommand rust-analyzer.serverVersion
rust-analyzer 0.3.1649-standalone

What's your coc-rust-analyzer version? You can get it from :CocList extensions
0.73.0

I have a weird and annoying problem: every time I save a .rs file using :w or :wa the second line of file will be replaced with the name of the library:

Before

use backgammon::{Game, rules::{Roll, Move}};
fn main() {
    let mut game = Game::new();
}

After :w

use backgammon::{Game, rules::{Roll, Move}};
backgammon-bot
    let mut game = Game::new();
}

with backgammon-bot being the name of the crate

Any ideas?

I have never seen this before with any other language, also when I :CocUninstall coc-rust-analyzer this problem disappears, but comes back again upon reinstalling .

@fannheyward
Copy link
Owner

@petrovito can you make a test, set "codeLens.position": "eol" in your coc-settings.json and try again.

@petrovito
Copy link
Author

that didn't help.
but I have played a bit more with it now, and it seems like this behavior only happens if the code in the buffer is syntactically correct: if there are compile errors then everything is good (besides the compile errors of course :D).

a bit more info:

  • I have to press "u" (undo) 3 times in order to undo the overwritten line, the first 2 "u"s seem to have no effect
  • (I am new to coc-rust-analyzer so might be doing something wrong but) I only get code analysis after I save the file, fx errors won't show up before :w

@fannheyward
Copy link
Owner

only get code analysis after I save the file

Yes, rust-analyzer only analyze on-saving.

Debugging on this.

@fannheyward
Copy link
Owner

I can't reproduce this, upgrade your nvim and try again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants