fannheyward / coc-rust-analyzer

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

Performance issues, for a large number of header comments #1236

Closed A4-Tacks closed 4 months ago

A4-Tacks commented 5 months ago

src/main.rs

// some comment
// ... (5000 lines)
// some comment

// enter `o` on new line insert `struct Foo;`, It froze for 2 seconds

fn main() {
    todo!()
}

vscode rust-analyzer and other language server on coc.nvim will not experience this situation

What's the output of :CocInfo

## versions

vim version: VIM - Vi IMproved 9.1 9010000
node version: v21.6.1
coc.nvim version: 0.0.82-d1568d56 2023-09-29 19:43:34 +0800
coc.nvim directory: /home/lrne/.vim/plugged/coc.nvim
term: dumb
platform: linux

## Log of coc.nvim

2024-03-07T10:47:20.275 INFO (pid:17917) [plugin] - coc.nvim initialized with node: v21.6.1 after 871
2024-03-07T10:47:20.277 INFO (pid:17917) [services] - LanguageClient Rust Analyzer Language Server state change: stopped => starting
2024-03-07T10:47:20.300 INFO (pid:17917) [language-client-index] - Language server "rust-analyzer" started with 17934
2024-03-07T10:47:20.474 INFO (pid:17917) [services] - LanguageClient Rust Analyzer Language Server state change: starting => running
2024-03-07T10:47:20.492 INFO (pid:17917) [services] - service rust-analyzer started
2024-03-07T10:47:23.285 INFO (pid:17917) [attach] - receive notification: highlight []
2024-03-07T10:47:30.417 INFO (pid:17917) [attach] - receive notification: highlight []
2024-03-07T10:47:33.845 INFO (pid:17917) [attach] - receive notification: showInfo []

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

[coc.nvim] rust-analyzer 1.76.0 (07dca48 2024-02-04)

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

* coc-rust-analyzer 0.75.0
fannheyward commented 5 months ago

Reproduced, o to insert new line, O on fn main to insert new line above, froze vim/nvim. o on fn main to insert new line bellow, no frozen.

A4-Tacks commented 5 months ago

Reproduced, o to insert new line, O on fn main to insert new line above, froze vim/nvim. o on fn main to insert new line bellow, no frozen.

on // enter ..., is not on fn main

fannheyward commented 5 months ago

Yes, o on // enter ... frozen vim. O (big o) on fn main, to insert new line above, frozen too.

But o on fn main to insert new line bellow, no frozen.

Strange performance issue.

fannheyward commented 5 months ago

coc.nvim related, working on this.

fannheyward commented 5 months ago
  1. nvim --clean -u NONE reproduced, without coc.nvim plugins
  2. vim --clean -u NONE, no delay or frozen
  3. vim with coc.nvim, reproduced, still working on this
fannheyward commented 4 months ago

vim's indent issue, add let did_indent_on = 1 to your vimrc, won't reproduce this with or without coc.nvim.

let did_indent_on = 1 will prevent to source rust.vim.

A4-Tacks commented 4 months ago

vim's indent issue, add let did_indent_on = 1 to your vimrc, won't reproduce this with or without coc.nvim.

This option doesn't seem to have any effect, nor is it builtin Vim But you're right, this is not caused by coc.nvim

fannheyward commented 4 months ago

@A4-Tacks let did_indent_on = 1 will prevent to source rust.vim

A4-Tacks commented 4 months ago

@A4-Tacks let did_indent_on = 1 will prevent to source rust.vim

I don't understand

A4-Tacks commented 4 months ago

@A4-Tacks let did_indent_on = 1 will prevent to source rust.vim

disable rust indentexpr?

fannheyward commented 4 months ago

let did_indent_on = 1 stops /opt/homebrew/share/vim/vim91/indent.vim to source /opt/homebrew/share/vim/vim91/indent/rust.vim, won't set indentexpr anymore.

A4-Tacks commented 4 months ago

let did_indent_on = 1 stops /opt/homebrew/share/vim/vim91/indent.vim to source /opt/homebrew/share/vim/vim91/indent/rust.vim

Its name seems to be b:did_indent. This works, but indentexpr is needed, but at least we know the source of the problem