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

lsp_diagnostics_{echo,float}_cursor don't seem to work? #1081

Closed
dhduvall opened this issue Mar 2, 2021 · 6 comments
Closed

lsp_diagnostics_{echo,float}_cursor don't seem to work? #1081

dhduvall opened this issue Mar 2, 2021 · 6 comments

Comments

@dhduvall
Copy link

dhduvall commented Mar 2, 2021

This is on vim 8.2.2550 (on MacOS, via brew), with ca2b527 of vim-lsp, and the code in question is Rust, using rust-analyzer (though rls had the same issue).

When I move the cursor onto a line where there's a diagnostics issue (there's a sign, and it shows up in :LspDocumentDiagnostics, if either g:lsp_diagnostics_echo_cursor or g:lsp_diagnostics_float_cursor is set to 1 (or both are), I don't get the expected behavior of seeing the diagnostic in the status line or in a popup.

@prabirshrestha
Copy link
Owner

Can you paste your vim-lsp logs (instructions in readme).

If you can repro in some open source project that would be great.

You might also want to checkout https://github.com/mattn/vim-lsp-settings for easy setup of lsp servers.

@duvall-eb
Copy link

Sure, here's a simple example (also at https://github.com/dhduvall/vim-lsp-1081):

fn main() {
    jj jj = 6;
}

This is what I have in my terminal:

  fn main() {
E>    jj jj = 6;
  }

so the error is definitely detected, but neither hitting j to go to the first column of the second line nor using <plug>(lsp-next-diagnostic) shows that diagnostic in either the status line or in a popup. Here's the contents of vim-lsp.log:

Tue Mar  2 13:11:47 2021:["<---","s:on_request",1,{"id":0,"jsonrpc":"2.0","method":"workspace/configuration","params":{"items":[{"section":"rust-analyzer"}]}}]
Tue Mar  2 13:11:47 2021:["--->",1,"rust-analyzer",{"id":0,"result":[null]}]
Tue Mar  2 13:11:47 2021:["<---","s:on_request",1,{"id":1,"jsonrpc":"2.0","method":"workspace/configuration","params":{"items":[{"section":"rust-analyzer"}]}}]
Tue Mar  2 13:11:47 2021:["--->",1,"rust-analyzer",{"id":1,"result":[null]}]
Tue Mar  2 13:11:47 2021:["<---",1,"rust-analyzer",{"response":{"id":2,"jsonrpc":"2.0","error":{"code":-32801,"message":"Rust Analyzer is still loading..."}},"request":{"id":2,"jsonrpc":"2.0","method":"textDocument/foldingRange","params":{"textDocument":{"uri":"file:///private/tmp/foo/src/main.rs"}}}}]
Tue Mar  2 13:11:47 2021:[{"response":{"data":{"__data__":"vim-lsp","server_name":"rust-analyzer"},"message":"server already started"}}]
Tue Mar  2 13:11:47 2021:[{"response":{"data":{"__data__":"vim-lsp","init_result":{"id":1,"jsonrpc":"2.0","result":{"capabilities":{"documentHighlightProvider":true,"hoverProvider":true,"typeDefinitionProvider":true,"definitionProvider":true,"referencesProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"foldingRangeProvider":true,"callHierarchyProvider":true,"codeActionProvider":{"resolveProvider":true,"codeActionKinds":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite"]},"textDocumentSync":{"save":{},"change":2,"openClose":true},"codeLensProvider":{"resolveProvider":true},"workspace":{"fileOperations":{"willRename":{"filters":[{"pattern":{"glob":"**/*.rs","matches":"file"},"scheme":"file"},{"pattern":{"glob":"**","matches":"folder"},"scheme":"file"}]}}},"implementationProvider":true,"documentOnTypeFormattingProvider":{"moreTriggerCharacter":[".",">"],"firstTriggerCharacter":"="},"workspaceSymbolProvider":true,"selectionRangeProvider":true,"semanticTokensProvider":{"legend":{"tokenTypes":["comment","keyword","string","number","regexp","operator","namespace","type","struct","class","interface","enum","enumMember","typeParameter","function","method","property","macro","variable","parameter","angle","attribute","boolean","brace","bracket","builtinType","comma","colon","dot","escapeSequence","formatSpecifier","generic","constParameter","lifetime","label","parenthesis","punctuation","selfKeyword","semicolon","typeAlias","union","unresolvedReference"],"tokenModifiers":["documentation","declaration","definition","static","abstract","deprecated","readonly","constant","controlFlow","injected","mutable","consuming","unsafe","attribute","callable"]},"range":true,"full":{"delta":true}},"documentFormattingProvider":true,"documentSymbolProvider":true,"experimental":{"parentModule":true,"onEnter":true,"runnables":{"kinds":["cargo"]},"ssr":true,"joinLines":true},"renameProvider":{"prepareProvider":true},"completionProvider":{"resolveProvider":true,"triggerCharacters":[":","."]}},"serverInfo":{"version":"fde4a86","name":"rust-analyzer"}}},"server_name":"rust-analyzer"},"message":"lsp server already initialized"}}]
Tue Mar  2 13:11:47 2021:["--->",1,"rust-analyzer",{"method":"workspace/didChangeConfiguration","params":{"settings":{}}}]
Tue Mar  2 13:11:47 2021:[{"response":{"data":{"__data__":"vim-lsp","server_name":"rust-analyzer"},"message":"configuration sent"}}]
Tue Mar  2 13:11:47 2021:[{"response":{"data":{"path":"file:///private/tmp/foo/src/main.rs","__data__":"vim-lsp","server_name":"rust-analyzer"},"message":"already opened"}}]
Tue Mar  2 13:11:47 2021:[{"response":{"data":{"path":"file:///private/tmp/foo/src/main.rs","__data__":"vim-lsp","server_name":"rust-analyzer"},"message":"not dirty"}}]
Tue Mar  2 13:11:47 2021:["--->",1,"rust-analyzer",{"method":"textDocument/documentHighlight","on_notification":"---funcref---","params":{"textDocument":{"uri":"file:///private/tmp/foo/src/main.rs"},"position":{"character":0,"line":0}}}]
Tue Mar  2 13:11:47 2021:["<---","s:on_request",1,{"id":2,"jsonrpc":"2.0","method":"workspace/configuration","params":{"items":[{"section":"rust-analyzer"}]}}]
Tue Mar  2 13:11:47 2021:["--->",1,"rust-analyzer",{"id":2,"result":[null]}]
Tue Mar  2 13:11:47 2021:["<---",1,"rust-analyzer",{"response":{"id":3,"jsonrpc":"2.0","error":{"code":-32801,"message":"Rust Analyzer is still loading..."}},"request":{"id":3,"jsonrpc":"2.0","method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///private/tmp/foo/src/main.rs"},"position":{"character":0,"line":0}}}}]
Tue Mar  2 13:11:48 2021:["<---",1,"rust-analyzer",{"response":{"method":"textDocument/publishDiagnostics","jsonrpc":"2.0","params":{"uri":"file:///private/tmp/foo/src/main.rs","diagnostics":[{"source":"rustc","range":{"end":{"character":9,"line":1},"start":{"character":7,"line":1}},"message":"expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `jj`\nexpected one of 8 possible tokens","severity":1}],"version":1}}}]
Tue Mar  2 13:11:52 2021:[{"response":{"data":{"__data__":"vim-lsp","server_name":"rust-analyzer"},"message":"server already started"}}]
Tue Mar  2 13:11:52 2021:[{"response":{"data":{"__data__":"vim-lsp","init_result":{"id":1,"jsonrpc":"2.0","result":{"capabilities":{"documentHighlightProvider":true,"hoverProvider":true,"typeDefinitionProvider":true,"definitionProvider":true,"referencesProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"foldingRangeProvider":true,"callHierarchyProvider":true,"codeActionProvider":{"resolveProvider":true,"codeActionKinds":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite"]},"textDocumentSync":{"save":{},"change":2,"openClose":true},"codeLensProvider":{"resolveProvider":true},"workspace":{"fileOperations":{"willRename":{"filters":[{"pattern":{"glob":"**/*.rs","matches":"file"},"scheme":"file"},{"pattern":{"glob":"**","matches":"folder"},"scheme":"file"}]}}},"implementationProvider":true,"documentOnTypeFormattingProvider":{"moreTriggerCharacter":[".",">"],"firstTriggerCharacter":"="},"workspaceSymbolProvider":true,"selectionRangeProvider":true,"semanticTokensProvider":{"legend":{"tokenTypes":["comment","keyword","string","number","regexp","operator","namespace","type","struct","class","interface","enum","enumMember","typeParameter","function","method","property","macro","variable","parameter","angle","attribute","boolean","brace","bracket","builtinType","comma","colon","dot","escapeSequence","formatSpecifier","generic","constParameter","lifetime","label","parenthesis","punctuation","selfKeyword","semicolon","typeAlias","union","unresolvedReference"],"tokenModifiers":["documentation","declaration","definition","static","abstract","deprecated","readonly","constant","controlFlow","injected","mutable","consuming","unsafe","attribute","callable"]},"range":true,"full":{"delta":true}},"documentFormattingProvider":true,"documentSymbolProvider":true,"experimental":{"parentModule":true,"onEnter":true,"runnables":{"kinds":["cargo"]},"ssr":true,"joinLines":true},"renameProvider":{"prepareProvider":true},"completionProvider":{"resolveProvider":true,"triggerCharacters":[":","."]}},"serverInfo":{"version":"fde4a86","name":"rust-analyzer"}}},"server_name":"rust-analyzer"},"message":"lsp server already initialized"}}]
Tue Mar  2 13:11:52 2021:["--->",1,"rust-analyzer",{"method":"workspace/didChangeConfiguration","params":{"settings":{}}}]
Tue Mar  2 13:11:52 2021:[{"response":{"data":{"__data__":"vim-lsp","server_name":"rust-analyzer"},"message":"configuration sent"}}]
Tue Mar  2 13:11:52 2021:[{"response":{"data":{"path":"file:///private/tmp/foo/src/main.rs","__data__":"vim-lsp","server_name":"rust-analyzer"},"message":"already opened"}}]
Tue Mar  2 13:11:52 2021:[{"response":{"data":{"path":"file:///private/tmp/foo/src/main.rs","__data__":"vim-lsp","server_name":"rust-analyzer"},"message":"not dirty"}}]
Tue Mar  2 13:11:52 2021:["--->",1,"rust-analyzer",{"method":"textDocument/documentHighlight","on_notification":"---funcref---","params":{"textDocument":{"uri":"file:///private/tmp/foo/src/main.rs"},"position":{"character":0,"line":1}}}]
Tue Mar  2 13:11:52 2021:["<---","s:on_request",1,{"id":3,"jsonrpc":"2.0","method":"workspace/configuration","params":{"items":[{"section":"rust-analyzer"}]}}]
Tue Mar  2 13:11:52 2021:["--->",1,"rust-analyzer",{"id":3,"result":[null]}]
Tue Mar  2 13:11:52 2021:["<---",1,"rust-analyzer",{"response":{"method":"textDocument/publishDiagnostics","jsonrpc":"2.0","params":{"uri":"file:///private/tmp/foo/src/main.rs","diagnostics":[{"source":"rust-analyzer","range":{"end":{"character":6,"line":1},"start":{"character":6,"line":1}},"message":"Syntax Error: expected SEMICOLON","severity":1},{"source":"rustc","range":{"end":{"character":9,"line":1},"start":{"character":7,"line":1}},"message":"expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `jj`\nexpected one of 8 possible tokens","severity":1}],"version":1}}}]
Tue Mar  2 13:11:52 2021:["<---",1,"rust-analyzer",{"response":{"id":4,"jsonrpc":"2.0","result":null},"request":{"id":4,"jsonrpc":"2.0","method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///private/tmp/foo/src/main.rs"},"position":{"character":0,"line":1}}}}]
Tue Mar  2 13:11:54 2021:[{"response":{"data":{"__data__":"vim-lsp","server_name":"rust-analyzer"},"message":"server already started"}}]
Tue Mar  2 13:11:54 2021:[{"response":{"data":{"__data__":"vim-lsp","init_result":{"id":1,"jsonrpc":"2.0","result":{"capabilities":{"documentHighlightProvider":true,"hoverProvider":true,"typeDefinitionProvider":true,"definitionProvider":true,"referencesProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"foldingRangeProvider":true,"callHierarchyProvider":true,"codeActionProvider":{"resolveProvider":true,"codeActionKinds":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite"]},"textDocumentSync":{"save":{},"change":2,"openClose":true},"codeLensProvider":{"resolveProvider":true},"workspace":{"fileOperations":{"willRename":{"filters":[{"pattern":{"glob":"**/*.rs","matches":"file"},"scheme":"file"},{"pattern":{"glob":"**","matches":"folder"},"scheme":"file"}]}}},"implementationProvider":true,"documentOnTypeFormattingProvider":{"moreTriggerCharacter":[".",">"],"firstTriggerCharacter":"="},"workspaceSymbolProvider":true,"selectionRangeProvider":true,"semanticTokensProvider":{"legend":{"tokenTypes":["comment","keyword","string","number","regexp","operator","namespace","type","struct","class","interface","enum","enumMember","typeParameter","function","method","property","macro","variable","parameter","angle","attribute","boolean","brace","bracket","builtinType","comma","colon","dot","escapeSequence","formatSpecifier","generic","constParameter","lifetime","label","parenthesis","punctuation","selfKeyword","semicolon","typeAlias","union","unresolvedReference"],"tokenModifiers":["documentation","declaration","definition","static","abstract","deprecated","readonly","constant","controlFlow","injected","mutable","consuming","unsafe","attribute","callable"]},"range":true,"full":{"delta":true}},"documentFormattingProvider":true,"documentSymbolProvider":true,"experimental":{"parentModule":true,"onEnter":true,"runnables":{"kinds":["cargo"]},"ssr":true,"joinLines":true},"renameProvider":{"prepareProvider":true},"completionProvider":{"resolveProvider":true,"triggerCharacters":[":","."]}},"serverInfo":{"version":"fde4a86","name":"rust-analyzer"}}},"server_name":"rust-analyzer"},"message":"lsp server already initialized"}}]
Tue Mar  2 13:11:54 2021:["--->",1,"rust-analyzer",{"method":"workspace/didChangeConfiguration","params":{"settings":{}}}]
Tue Mar  2 13:11:54 2021:[{"response":{"data":{"__data__":"vim-lsp","server_name":"rust-analyzer"},"message":"configuration sent"}}]
Tue Mar  2 13:11:54 2021:[{"response":{"data":{"path":"file:///private/tmp/foo/src/main.rs","__data__":"vim-lsp","server_name":"rust-analyzer"},"message":"already opened"}}]
Tue Mar  2 13:11:54 2021:[{"response":{"data":{"path":"file:///private/tmp/foo/src/main.rs","__data__":"vim-lsp","server_name":"rust-analyzer"},"message":"not dirty"}}]
Tue Mar  2 13:11:54 2021:["--->",1,"rust-analyzer",{"method":"textDocument/documentHighlight","on_notification":"---funcref---","params":{"textDocument":{"uri":"file:///private/tmp/foo/src/main.rs"},"position":{"character":6,"line":1}}}]
Tue Mar  2 13:11:54 2021:["<---","s:on_request",1,{"id":4,"jsonrpc":"2.0","method":"workspace/configuration","params":{"items":[{"section":"rust-analyzer"}]}}]
Tue Mar  2 13:11:54 2021:["--->",1,"rust-analyzer",{"id":4,"result":[null]}]
Tue Mar  2 13:11:54 2021:["<---",1,"rust-analyzer",{"response":{"id":5,"jsonrpc":"2.0","result":null},"request":{"id":5,"jsonrpc":"2.0","method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///private/tmp/foo/src/main.rs"},"position":{"character":6,"line":1}}}}]
Tue Mar  2 13:11:56 2021:["s:on_text_document_did_close()",1]

I already use vim-lsp-settings.

@prabirshrestha
Copy link
Owner

I do see the diagnostics correctly in the statusline and on list. Here is the screenshot of all 3 showing. Can you let me know what the issue is?

when on line 2 and col 7.
image

when on line 2 and col 8.
image

@dhduvall
Copy link
Author

dhduvall commented Mar 3, 2021

The issue is that I see neither. Thanks for confirming that it works for you. I'll spend some time trimming my vim configuration down to see if I can figure out what there is causing it, and report back.

@dhduvall
Copy link
Author

dhduvall commented Mar 3, 2021

I had

let g:lsp_diagnostics_float_cursor = 1
let g:lsp_diagnostics_echo_cursor = 1

inside a function that got called on lsp_install. Other settings like g:lsp_log_* are there and work fine, and I put g:markdown_fenced_languages there to good effect, but there's no particular reason any of those should be there.

I did note in stripping my .vimrc down that vim-lsp doesn't work when C is in cpoptions. I can file a separate bug for that if you'd like.

@dhduvall dhduvall closed this as completed Mar 3, 2021
@ernstki
Copy link

ernstki commented Oct 9, 2024

inside a function that got called on lsp_install. Other settings like g:lsp_log_* are there and work fine, and I put g:markdown_fenced_languages there to good effect, but there's no particular reason any of those should be there.

In my case—because I just had absolutely no clue, not the faintest idea where to put the let statements—I had them inside the

function! s:on_lsp_buffer_enabled() abort
    setlocal omnifunc=lsp#complete
    "
    let g:lsp_format_sync_timeout = 1000
    autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync')
endfunction

that I copy-pasted from the vim-lsp setup instructions.

Although the buffer would have the correct value if you checked with echo, I guess this happens in the wrong order for the expected thing to take effect.

Moving

let g:lsp_diagnostics_echo_cursor = 1
let g:lsp_diagnostics_virtual_text_enabled = 0

inside

augroup lsp_install
    au!
    " call s:on_lsp_buffer_enabled only for languages that has the server registered
    autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
    "
augroup END

(also copy-pasted from the vim-lsp setup instructions) finally produced the correct results for me.

Edit: There was, in fact a resolved discussion about this, where @prabirshrestha provided the answer.

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

No branches or pull requests

4 participants