lsp_signature.nvim icon indicating copy to clipboard operation
lsp_signature.nvim copied to clipboard

RPC[Error] code_name = ContentModified, message = "content modified"

Open Shatur opened this issue 2 years ago • 45 comments

I have the following error message when I use Rust Analyzer and lsp_signature.nvim:

RPC[Error] code_name = ContentModified, message = "content modified"

It happens very often. But I don't see a pattern.

My configuration:

  lsp_signature.on_attach({
    hint_enable = false,
  })

I don't have the error message If I disable this plugin.

Shatur avatar Feb 23 '22 23:02 Shatur

I do not use rust on daily basis. From the error log you send out, the plugin fire a signature_help() request, the rustanalyzer failed to respond. So it might be an upstream issue.

ray-x avatar Feb 24 '22 00:02 ray-x

Strange, the plugin works.

Shatur avatar Feb 24 '22 05:02 Shatur

@Shatur Did you find out what caused the error? I encounter the same issue, quite often, don't know where it comes from.

winkee01 avatar May 03 '22 08:05 winkee01

No, I just removed the plugin :(

Shatur avatar May 03 '22 08:05 Shatur

@Shatur ok, so you never see this error again? I search the source code, didn't find such an error message. I am not sure if it was caused by this plugin. or Maybe the error comes from rust_analyzer?

winkee01 avatar May 03 '22 08:05 winkee01

Yes, removing the plugin helps.

Shatur avatar May 03 '22 08:05 Shatur

I searched rust_analyzer's codebase, the error message "ContentModified" appears in there CleanShot 2022-05-03 at 16 45 23@2x

So it's weird that you never see the error again. Does InlayHint feature works in your case?

winkee01 avatar May 03 '22 08:05 winkee01

Does InlayHint feature works in your case?

No, I don't use it.

Shatur avatar May 03 '22 08:05 Shatur

@Shatur you can close the issue now, I just solved it by querying a rust_analyzer developer in here.

winkee01 avatar May 03 '22 09:05 winkee01

But I don't use InlayHint, the issue happened without it for me. Latest RA version doesn't trigger the issue for you?

Shatur avatar May 03 '22 09:05 Shatur

@Shatur I guess It's by default so I don't know how to disable InlayHint, it's a bit slow, so if I start to edit before the Hint appears, I get an error message. You can check the comments for more info.

winkee01 avatar May 03 '22 09:05 winkee01

Hello from the RA side. When loading a Rust project, we run the build scripts in order to compile and expand the proc macros used by the code, and to make sure that any generated files are fresh. The idea behind that error message is to delay responding to LSP requests until we are ready with this. On a first project load it might take a couple of minutes, but further ones should be more or less instant.

I'm not saying that returning this error is the best approach, but in VS Code they're just stashed away in a log window. The alternative would be flashing a bunch of X is unresolved errors / semantic token modifiers until everything gets loaded.

lnicola avatar May 03 '22 09:05 lnicola

Keep in mind that the LSP spec says:

if a server detects an internal state change (for example a project context changed) that invalidates the result of a request in execution the server can error these requests with ContentModified. If clients receive a ContentModified error, it generally should not show it in the UI for the end-user. Clients can resend the request if they know how to do so. It should be noted that for all position based requests it might be especially hard for clients to re-craft a request.

But this might be something that rust-tools or NVIM should be concerned with, not your plugin.

lnicola avatar May 03 '22 09:05 lnicola

I guess It's by default

No, it's not enabled by default. I mean it does if you use rust-tools extension (completely unrelated to this one), but I don't use it, I directly setup RA via built-in LSP.

When loading a Rust project, we run the build scripts in order to compile and expand the proc macros used by the code

Hm... It happened for me even after resolving and only if I have this plugin enabled. Let me double check with the latest version.

Shatur avatar May 03 '22 09:05 Shatur

Yep, double checked - happens only with this plugin right before a function signature is going to be displayed.

Shatur avatar May 03 '22 09:05 Shatur

But this might be something that rust-tools or NVIM should be concerned with, not your plugin.

Makes sense. But I assume that this plugin could be doing something wrong because it triggers ContentModified.

Shatur avatar May 03 '22 09:05 Shatur

I've given up on keeping my NVim dotfiles and plugins up to date. Can you say if:

  • this only happens on the first use, or even later
  • if it happens on every use, does it happen even in the same place?
  • is there a cargo process still running
  • can you get a LSP trace which includes the error and the notifications or requests that precede it?

lnicola avatar May 03 '22 09:05 lnicola

@lnicola is there a way to disable InlayHint temporarily?

winkee01 avatar May 03 '22 09:05 winkee01

@winkee01 maybe that's autoSetHints from https://github.com/simrat39/rust-tools.nvim/#configuration, also check out the comment above it.

lnicola avatar May 03 '22 09:05 lnicola

this only happens on the first use, or even later

Even later.

does it happen even in the same place?

Yes, it happens even in the same place.

is there a cargo process still running

Nope (I have LSP status in my statusbar).

can you get a LSP trace which includes the error and the notifications or requests that precede it?

How can I provide it?

Shatur avatar May 03 '22 09:05 Shatur

Correction: it happens when I have signature displaying and start typing a function argument.

Shatur avatar May 03 '22 09:05 Shatur

Ok, now I disabled InlayHint, but it still prompted errors when I open a file and start to edit immediately, so maybe @Shatur is right. But after I waited a period of time (e.g. 5 seconds), I didn't see the error.

winkee01 avatar May 03 '22 09:05 winkee01

Nope, I have LSP status in my statusbar.

I'd trust ps more here, but okay.

How can I provide it?

I honestly don't know. Most LSP clients will have a way to enable logging, but since the NVIM implementation is split between NVIM, nvim-lspconfig and rust-tools, I'm not sure where the toggle would be. I've previously resorted to running strace on the main rust-analyzer process, but that's not exactly user-friendly.

From the RA implementation, this error is only returned while the workspace is loading (as I said above). Either cargo is still running, or there's something weird going on.

But after I waited a period of time (e.g. 5 seconds), I didn't see the error.

Exactly. I think these errors should be hidden by the LSP client.

lnicola avatar May 03 '22 09:05 lnicola

I'd trust ps more here, but okay.

Right, double checked, no cargo processes when I trigger the error.

I honestly don't know. Most LSP clients will have a way to enable logging, but since the NVIM implementation is split between NVIM, nvim-lspconfig and rust-tools, I'm not sure where the toggle would be.

I don't use rust-tools, only nvim-lspconfig with built-in LSP. Will search for it.

From the RA implementation, this error is only returned while the workspace is loading (as I said above).

Strange, because I can trigger it when workspace is loaded and I simply typing argument. Somethings like this 100% triggers the error for me:

    let string = String::new();
    string.push_str("askjdhfjkashfd");

When I typing "askjdhfjkashfd" the error appears multiple times. So I suspecting a bug inside the plugin.

Exactly. I think these errors should be hidden by the LSP client.

Yes, it would be great. But It could be a bug in this case.

Shatur avatar May 03 '22 10:05 Shatur

Log when error happens: lsp.txt

Shatur avatar May 03 '22 10:05 Shatur

Ah, sorry, I was under the impression that the error message said waiting for cargo metadata or cargo check like in https://github.com/rust-lang/rust-analyzer/issues/12138.

content modified means that the LSP request was cancelled, probably because the user edited the document while the request was being processed. Looking at your log:

# this one worked
[DEBUG][2022-05-03 13:07:07] .../vim/lsp/rpc.lua:347	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didChange",  params = {    contentChanges = { {        range = {          end = {            character = 56,            line = 92          },          start = {            character = 20,            line = 92          }        },        rangeLength = 36,        text = ""      } },    textDocument = {      uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs",      version = 41    }  }}
[DEBUG][2022-05-03 13:07:07] .../lua/vim/lsp.lua:1023	"LSP[rust_analyzer]"	"client.request"	1	"textDocument/signatureHelp"	{  position = {    character = 20,    line = 92  },  textDocument = {    uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs"  }}	<function 1>	4
[DEBUG][2022-05-03 13:07:07] .../vim/lsp/rpc.lua:347	"rpc.send"	{  id = 27,  jsonrpc = "2.0",  method = "textDocument/signatureHelp",  params = {    position = {      character = 20,      line = 92    },    textDocument = {      uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs"    }  }}
[DEBUG][2022-05-03 13:07:07] .../vim/lsp/rpc.lua:454	"rpc.receive"	{  id = 27,  jsonrpc = "2.0",  result = {    activeParameter = 0,    activeSignature = 0,    signatures = { {        activeParameter = 0,        documentation = {          kind = "markdown",          value = 'Appends a given string slice onto the end of this `String`.\n\n# Examples\n\nBasic usage:\n\n```\nlet mut s = String::from("foo");\n\ns.push_str("bar");\n\nassert_eq!("foobar", s);\n```'        },        label = "fn push_str(&mut self, string: &str)",        parameters = { {            label = { 23, 35 }          } }      } }  }}

# this one too
[DEBUG][2022-05-03 13:07:07] .../vim/lsp/rpc.lua:454	"rpc.receive"	{  jsonrpc = "2.0",  method = "textDocument/publishDiagnostics",  params = {    diagnostics = { {        code = "mismatched-arg-count",        codeDescription = {          href = "https://rust-analyzer.github.io/manual.html#mismatched-arg-count"        },        message = "expected 1 argument, found 0",        range = {          end = {            character = 21,            line = 92          },          start = {            character = 19,            line = 92          }        },        severity = 1,        source = "rust-analyzer"      } },    uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs",    version = 41  }}
[DEBUG][2022-05-03 13:07:07] .../lua/vim/lsp.lua:1023	"LSP[rust_analyzer]"	"client.request"	1	"textDocument/signatureHelp"	{  position = {    character = 20,    line = 92  },  textDocument = {    uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs"  }}	<function 1>	4
[DEBUG][2022-05-03 13:07:07] .../vim/lsp/rpc.lua:347	"rpc.send"	{  id = 28,  jsonrpc = "2.0",  method = "textDocument/signatureHelp",  params = {    position = {      character = 20,      line = 92    },    textDocument = {      uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs"    }  }}
[DEBUG][2022-05-03 13:07:07] .../vim/lsp/rpc.lua:454	"rpc.receive"	{  id = 28,  jsonrpc = "2.0",  result = {    activeParameter = 0,    activeSignature = 0,    signatures = { {        activeParameter = 0,        documentation = {          kind = "markdown",          value = 'Appends a given string slice onto the end of this `String`.\n\n# Examples\n\nBasic usage:\n\n```\nlet mut s = String::from("foo");\n\ns.push_str("bar");\n\nassert_eq!("foobar", s);\n```'        },        label = "fn push_str(&mut self, string: &str)",        parameters = { {            label = { 23, 35 }          } }      } }  }}

# typing two quotes here
[DEBUG][2022-05-03 13:07:08] .../vim/lsp/rpc.lua:347	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didChange",  params = {    contentChanges = { {        range = {          end = {            character = 20,            line = 92          },          start = {            character = 20,            line = 92          }        },        rangeLength = 0,        text = '"'      } },    textDocument = {      uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs",      version = 42    }  }}
[DEBUG][2022-05-03 13:07:08] .../vim/lsp/rpc.lua:347	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didChange",  params = {    contentChanges = { {        range = {          end = {            character = 21,            line = 92          },          start = {            character = 21,            line = 92          }        },        rangeLength = 0,        text = '"'      } },    textDocument = {      uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs",      version = 43    }  }}

# textDocument/signatureChanged works
[DEBUG][2022-05-03 13:07:08] .../lua/vim/lsp.lua:1023	"LSP[rust_analyzer]"	"client.request"	1	"textDocument/signatureHelp"	{  position = {    character = 20,    line = 92  },  textDocument = {    uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs"  }}	<function 1>	4
[DEBUG][2022-05-03 13:07:08] .../vim/lsp/rpc.lua:347	"rpc.send"	{  id = 29,  jsonrpc = "2.0",  method = "textDocument/signatureHelp",  params = {    position = {      character = 20,      line = 92    },    textDocument = {      uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs"    }  }}
[DEBUG][2022-05-03 13:07:08] .../lua/vim/lsp.lua:1023	"LSP[rust_analyzer]"	"client.request"	1	"textDocument/signatureHelp"	{  position = {    character = 21,    line = 92  },  textDocument = {    uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs"  }}	<function 1>	4
[DEBUG][2022-05-03 13:07:08] .../vim/lsp/rpc.lua:347	"rpc.send"	{  id = 30,  jsonrpc = "2.0",  method = "textDocument/signatureHelp",  params = {    position = {      character = 21,      line = 92    },    textDocument = {      uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs"    }  }}
[DEBUG][2022-05-03 13:07:08] .../vim/lsp/rpc.lua:454	"rpc.receive"	{  id = 29,  jsonrpc = "2.0",  result = {    activeParameter = 0,    activeSignature = 0,    signatures = { {        activeParameter = 0,        documentation = {          kind = "markdown",          value = 'Appends a given string slice onto the end of this `String`.\n\n# Examples\n\nBasic usage:\n\n```\nlet mut s = String::from("foo");\n\ns.push_str("bar");\n\nassert_eq!("foobar", s);\n```'        },        label = "fn push_str(&mut self, string: &str)",        parameters = { {            label = { 23, 35 }          } }      } }  }}
[DEBUG][2022-05-03 13:07:08] .../vim/lsp/rpc.lua:454	"rpc.receive"	{  id = 30,  jsonrpc = "2.0",  result = {    activeParameter = 0,    activeSignature = 0,    signatures = { {        activeParameter = 0,        documentation = {          kind = "markdown",          value = 'Appends a given string slice onto the end of this `String`.\n\n# Examples\n\nBasic usage:\n\n```\nlet mut s = String::from("foo");\n\ns.push_str("bar");\n\nassert_eq!("foobar", s);\n```'        },        label = "fn push_str(&mut self, string: &str)",        parameters = { {            label = { 23, 35 }          } }      } }  }}

# typing a
[DEBUG][2022-05-03 13:07:08] .../vim/lsp/rpc.lua:347	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didChange",  params = {    contentChanges = { {        range = {          end = {            character = 21,            line = 92          },          start = {            character = 21,            line = 92          }        },        rangeLength = 0,        text = "a"      } },    textDocument = {      uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs",      version = 44    }  }}
[DEBUG][2022-05-03 13:07:08] .../lua/vim/lsp.lua:1023	"LSP[rust_analyzer]"	"client.request"	1	"textDocument/completion"	{  context = {    triggerKind = 1  },  position = {    character = 22,    line = 92  },  textDocument = {    uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs"  }}	<function 1>	4

# request 31
[DEBUG][2022-05-03 13:07:08] .../vim/lsp/rpc.lua:347	"rpc.send"	{  id = 31,  jsonrpc = "2.0",  method = "textDocument/completion",  params = {    context = {      triggerKind = 1    },    position = {      character = 22,      line = 92    },    textDocument = {      uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs"    }  }}

# typing k
[DEBUG][2022-05-03 13:07:08] .../vim/lsp/rpc.lua:347	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didChange",  params = {    contentChanges = { {        range = {          end = {            character = 22,            line = 92          },          start = {            character = 22,            line = 92          }        },        rangeLength = 0,        text = "k"      }, {        range = {          end = {            character = 23,            line = 92          },          start = {            character = 23,            line = 92          }        },        rangeLength = 0,        text = "l"      }, {        range = {          end = {            character = 24,            line = 92          },          start = {            character = 24,            line = 92          }        },        rangeLength = 0,        text = "s"      }, {        range = {          end = {            character = 25,            line = 92          },          start = {            character = 25,            line = 92          }        },        rangeLength = 0,        text = "j"      } },    textDocument = {      uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs",      version = 48    }  }}
[DEBUG][2022-05-03 13:07:08] .../lua/vim/lsp.lua:1023	"LSP[rust_analyzer]"	"client.request"	1	"textDocument/signatureHelp"	{  position = {    character = 20,    line = 92  },  textDocument = {    uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs"  }}	<function 1>	4

# request 32
[DEBUG][2022-05-03 13:07:08] .../vim/lsp/rpc.lua:347	"rpc.send"	{  id = 32,  jsonrpc = "2.0",  method = "textDocument/signatureHelp",  params = {    position = {      character = 20,      line = 92    },    textDocument = {      uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs"    }  }}

# failed request 31 here
[DEBUG][2022-05-03 13:07:08] .../vim/lsp/rpc.lua:454	"rpc.receive"	{  error = {    code = -32801,    message = "content modified"  },  id = 31,  jsonrpc = "2.0"}
[DEBUG][2022-05-03 13:07:08] .../lua/vim/lsp.lua:1023	"LSP[rust_analyzer]"	"client.request"	1	"textDocument/completion"	{  context = {    triggerKind = 1  },  position = {    character = 22,    line = 92  },  textDocument = {    uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs"  }}	<function 1>	4

# request 33
[DEBUG][2022-05-03 13:07:08] .../vim/lsp/rpc.lua:347	"rpc.send"	{  id = 33,  jsonrpc = "2.0",  method = "textDocument/completion",  params = {    context = {      triggerKind = 1    },    position = {      character = 22,      line = 92    },    textDocument = {      uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs"    }  }}
[DEBUG][2022-05-03 13:07:09] .../vim/lsp/rpc.lua:347	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didChange",  params = {    contentChanges = { {        range = {          end = {            character = 26,            line = 92          },          start = {            character = 26,            line = 92          }        },        rangeLength = 0,        text = "d"      }, {        range = {          end = {            character = 27,            line = 92          },          start = {            character = 27,            line = 92          }        },        rangeLength = 0,        text = "k"      }, {        range = {          end = {            character = 28,            line = 92          },          start = {            character = 28,            line = 92          }        },        rangeLength = 0,        text = "l"      }, {        range = {          end = {            character = 29,            line = 92          },          start = {            character = 29,            line = 92          }        },        rangeLength = 0,        text = "a"      } },    textDocument = {      uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs",      version = 52    }  }}

# failed requests 32, 33
[DEBUG][2022-05-03 13:07:09] .../vim/lsp/rpc.lua:454	"rpc.receive"	{  error = {    code = -32801,    message = "content modified"  },  id = 32,  jsonrpc = "2.0"}
[DEBUG][2022-05-03 13:07:09] .../vim/lsp/rpc.lua:454	"rpc.receive"	{  error = {    code = -32801,    message = "content modified"  },  id = 33,  jsonrpc = "2.0"}

[snip]

# starts working here
[DEBUG][2022-05-03 13:07:09] .../vim/lsp/rpc.lua:347	"rpc.send"	{  id = 43,  jsonrpc = "2.0",  method = "textDocument/completion",  params = {    context = {      triggerKind = 1    },    position = {      character = 22,      line = 92    },    textDocument = {      uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs"    }  }}
[DEBUG][2022-05-03 13:07:09] .../lua/vim/lsp.lua:1023	"LSP[rust_analyzer]"	"client.request"	1	"textDocument/signatureHelp"	{  position = {    character = 20,    line = 92  },  textDocument = {    uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs"  }}	<function 1>	4
[DEBUG][2022-05-03 13:07:09] .../vim/lsp/rpc.lua:347	"rpc.send"	{  id = 44,  jsonrpc = "2.0",  method = "textDocument/signatureHelp",  params = {    position = {      character = 20,      line = 92    },    textDocument = {      uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs"    }  }}
[DEBUG][2022-05-03 13:07:09] .../lua/vim/lsp.lua:1023	"LSP[rust_analyzer]"	"client.request"	1	"textDocument/signatureHelp"	{  position = {    character = 48,    line = 92  },  textDocument = {    uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs"  }}	<function 1>	4
[DEBUG][2022-05-03 13:07:09] .../vim/lsp/rpc.lua:347	"rpc.send"	{  id = 45,  jsonrpc = "2.0",  method = "textDocument/signatureHelp",  params = {    position = {      character = 48,      line = 92    },    textDocument = {      uri = "file:///mnt/Files/Git/gardum/src/core/mod.rs"    }  }}
[DEBUG][2022-05-03 13:07:09] .../vim/lsp/rpc.lua:454	"rpc.receive"	{  id = 45,  jsonrpc = "2.0",  result = {    activeParameter = 0,    activeSignature = 0,    signatures = { {        activeParameter = 0,        documentation = {          kind = "markdown",          value = 'Appends a given string slice onto the end of this `String`.\n\n# Examples\n\nBasic usage:\n\n```\nlet mut s = String::from("foo");\n\ns.push_str("bar");\n\nassert_eq!("foobar", s);\n```'        },        label = "fn push_str(&mut self, string: &str)",        parameters = { {            label = { 23, 35 }          } }      } }  }}
[DEBUG][2022-05-03 13:07:09] .../vim/lsp/rpc.lua:454	"rpc.receive"	{  id = 44,  jsonrpc = "2.0",  result = {    activeParameter = 0,    activeSignature = 0,    signatures = { {        activeParameter = 0,        documentation = {          kind = "markdown",          value = 'Appends a given string slice onto the end of this `String`.\n\n# Examples\n\nBasic usage:\n\n```\nlet mut s = String::from("foo");\n\ns.push_str("bar");\n\nassert_eq!("foobar", s);\n```'        },        label = "fn push_str(&mut self, string: &str)",        parameters = { {            label = { 23, 35 }          } }      } }  }}
[DEBUG][2022-05-03 13:07:09] .../vim/lsp/rpc.lua:454	"rpc.receive"	{  id = 43,  jsonrpc = "2.0",  result = {    isIncomplete = true,    items = {}  }}

So yeah, I don't see anything obviously wrong. Having this many failed requests when mashing against the keyboard is not surprising. I get them in Code too:

[Trace - 13:51:44] Received response 'textDocument/semanticTokens/full/delta - (726)' in 19ms. Request failed: content modified (-32801).
[Trace - 13:51:44] Received response 'textDocument/semanticTokens/full/delta - (729)' in 19ms. Request failed: content modified (-32801).
[Trace - 13:51:44] Received response 'textDocument/semanticTokens/full/delta - (728)' in 19ms. Request failed: content modified (-32801).
[Trace - 13:51:44] Received response 'textDocument/semanticTokens/full/delta - (727)' in 19ms. Request failed: content modified (-32801).
[Trace - 13:51:44] Received response 'textDocument/semanticTokens/full/delta - (723)' in 20ms. Request failed: content modified (-32801).
[Trace - 13:51:44] Received response 'textDocument/semanticTokens/full/delta - (722)' in 20ms. Request failed: content modified (-32801).
[Trace - 13:51:44] Received response 'textDocument/semanticTokens/full/delta - (724)' in 21ms. Request failed: content modified (-32801).
[Trace - 13:51:44] Received response 'textDocument/semanticTokens/full/delta - (721)' in 22ms. Request failed: content modified (-32801).
[Trace - 13:51:44] Received response 'textDocument/semanticTokens/full/delta - (725)' in 20ms. Request failed: content modified (-32801).

One difference is that Code seems to send fewer textDocument/signatureHelp, I only caught two in the test above. Looking at the code, we set:

        signature_help_provider: Some(SignatureHelpOptions {
            trigger_characters: Some(vec!["(".to_string(), ",".to_string(), "<".to_string()]),
            retrigger_characters: None,
            work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None },
        }),
  • These trigger characters are only active when signature help is already
  • showing. All trigger characters are also counted as re-trigger
  • characters.

lsp_signature.nvim doesn't seem to pass the context to the request, so we can't check triggerKind, but my guess is that you're ignoring the trigger characters and sending this request more often than expected.

TL;DR:

  • lsp_signature.nvim should respect triggerCharacters
  • the LSP implementation should ignore the ContentModified errors

lnicola avatar May 03 '22 10:05 lnicola

Thank you a lot for such deep analysis. @ray-x could you try to do something with this?

Once we done, I think it worth to open an issue in Neovim to not display ContentModified.

Shatur avatar May 03 '22 11:05 Shatur

CC https://github.com/neovim/neovim/issues/16900

The UI problem should be fixed in NVIM 0.7.0: https://github.com/neovim/neovim/releases/tag/v0.7.0.

lnicola avatar May 03 '22 11:05 lnicola

Strange, I use Neovim 0.7 and see the error.

Shatur avatar May 03 '22 11:05 Shatur

@lnicola my nvim version is NVIM v0.8.0-dev+10-ge73ef5c09, not fixed.

winkee01 avatar May 03 '22 11:05 winkee01

I'm seeing this error message in nvim 0.7 with my LunarVim config.lua using sumneko

I can help providing logs and/or code, although I dunno where to start

FelipeLema avatar May 30 '22 19:05 FelipeLema

I am not using rust in a daily base. It is a rust lsp issue. It is too slow to respond to the lsp signatureHelp request. One thing you can try is to increase this setting timer_interval = 200, -- default timer check interval I don't know what setting rust lsp is happy with, you can start with 500 to 1000. Again, LSP spec does not say you must send signatureHelp request only right after the trigger character. And the plugin is polling the signatureHelp response when you type.

ray-x avatar May 30 '22 22:05 ray-x

Should have been fixed. The signature will not pull info from lsp each time TextChanged

ray-x avatar Jul 13 '22 01:07 ray-x

I don’t think this issue has been resolved

On Wed, Jul 13, 2022 at 09:53 rayx @.***> wrote:

Closed #168 https://github.com/ray-x/lsp_signature.nvim/issues/168 as completed.

— Reply to this email directly, view it on GitHub https://github.com/ray-x/lsp_signature.nvim/issues/168#event-6982153369, or unsubscribe https://github.com/notifications/unsubscribe-auth/AL46EIKZC3SKOBUIWYHGDQDVTYOQJANCNFSM5PF2BYRQ . You are receiving this because you were mentioned.Message ID: @.***>

-- Chunhui Shi Senior Software Engineer, Cloud Security Sepcialist, Cloud Native 18221026626 | keypgo.net | @.*** @.***> 802 Yuanmmingyuan Rd https://maps.google.com/?q=802+Yuanmmingyuan+Rd

Create your own email signature https://www.wisestamp.com/create-own-email-signature/?utm_source=promotion&utm_medium=signature&utm_campaign=create_your_own&srcid=

winkee01 avatar Jul 13 '22 01:07 winkee01

https://user-images.githubusercontent.com/1681295/178638314-18583a7f-7936-4223-86c4-33390000aeda.mp4

I do not see the issue myself. Any one can send a code snippets that can reproduce this issue?

ray-x avatar Jul 13 '22 02:07 ray-x

I already removed this plugin and never see this error again, I am pretty sure you didn't fix the issue. But to double confirm, I reinstalled it again, and no surprise, the error appears again.

CleanShot 2022-07-13 at 14 26 53@2x

My suggestion is to carefully inspect @lnicola 's comment made on May 3, I think he might point out the cause.

winkee01 avatar Jul 13 '22 06:07 winkee01

Note that we've also worked around this in https://github.com/rust-lang/rust-analyzer/pull/12508. I don't know if it still happens during project load, but that's somewhat of a different situation anyway.

That said, I still believe that my findings about triggerCharacters were valid at the time.

lnicola avatar Jul 13 '22 06:07 lnicola

I don't know, but once I removed this plugin, I didn't see this annoying error message. Maybe it asked for some external info when loading? which caused the content modified?

winkee01 avatar Jul 13 '22 06:07 winkee01

Yeah, possibly (unless you were actually typing). I think some errors or failed requests during load are somewhat acceptable.

lnicola avatar Jul 13 '22 06:07 lnicola

see this

https://user-images.githubusercontent.com/49930785/178670382-090fdc10-d7db-4f82-ad14-3f302eaa43d5.mp4

winkee01 avatar Jul 13 '22 06:07 winkee01

Hmm, it looks like the error shows up right from the start, but NVim never clears it?

lnicola avatar Jul 13 '22 06:07 lnicola

To summarise the change I made. Only send a signature request when leading character is a trigger. e.g. myfuc(123, 456_ , the signature will only be triggered when myfunc(_ and myfunc(123,_

Regarding the comments @Inicola

  1. TriggerKind is an optional field. But I do not see from the response rust_analyzer support this feature (neovim may lie to me): This is server_capabilities of rust_analyzer:
  signatureHelpProvider = {                                                                                     
    triggerCharacters = { "(", ",", "<" }                                                                       
  },  

My neovim version is 7-13 and rust-analyzer version is 7-11

Also according to spec

/**
	 * The signature help context. This is only available if the client
	 * specifies to send this using the client capability
	 * `textDocument.signatureHelp.contextSupport === true`
	 */

And I do not see if context can help, as according to spec:

	/**
	 * Signature help was triggered by the cursor moving or by the document
	 * content changing.
	 */
	export const ContentChange: 3 = 3;

So cursor moving can also be triggerKind=3, which indicate all the request I sent should be kind 3.

ray-x avatar Jul 13 '22 10:07 ray-x