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

Further improvements to bibtex actions #22

Closed
clason opened this issue Jun 21, 2019 · 7 comments
Closed

Further improvements to bibtex actions #22

clason opened this issue Jun 21, 2019 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@clason
Copy link
Contributor

clason commented Jun 21, 2019

I noticed a few issues with references (let me know if these should be made into separate issues):

  1. The server doesn't work with BibTeX if the bibliography file doesn't contain the extension (this is required by biblatex, but not by bibtex), e.g., \bibliography{bibfile}.
  2. Actions on references (hover, rename, goto definitions) do not work if a cite command contains multiple references (e.g., \cite{A,B}).

I also couldn't reformat if I use https://github.com/prabirshrestha/vim-lsp to call the client (it works with the vscode extension); all I get is Failed to document format for texlab: j.
I suspect that the server answers this request with a non-standard response; let me know what I can do to get to the bottom of this.

(This is with the rust branch, FWIW.)

@clason
Copy link
Contributor Author

clason commented Jun 24, 2019

  1. and 2. works on the rust branch, 3. doesn't throw an error, but doesn't work (calling the function synchronously freezes the editor). Let me know if I should open a new issue for the last one and close this one.

@efoerster efoerster added the bug Something isn't working label Jun 25, 2019
@clason
Copy link
Contributor Author

clason commented Jun 27, 2019

@pfoerster Here's the texlab log for the failed reformat action:

{"jsonrpc":"2.0","method":"workspace/configuration","params":{"items":[{"section":"bibtex. formatting"}]},"id":1}Content-Length: 89

{"jsonrpc":"2.0","error":{"code":-32700,"message":"Could not parse the input"},"id":null}

(I get the same -32700 error when I don't get the expected completions for \documentclass{ and \usepackage{, by the way.)
Let me know if I should open a new issue and close this one (or just edit the issue to focus on the renaming).

@clason
Copy link
Contributor Author

clason commented Jun 27, 2019

Here's the stderr log with -vvvv:

[2019-06-27 14:40:55] TRACE - Received message:
[2019-06-27 14:40:55] {"id": 2, "jsonrpc": "2.0", "method": "textDocument/formatting", "params": {"options": {"insertSpaces": true, "tabSize": 8}, "textDocument": {"uri": "file:///home/clason/Dropbox/tex/NonsmoothBook/nonsmooth.bib"}}}
[2019-06-27 14:40:55] TRACE - Sent message:
[2019-06-27 14:40:55] Content-Length: 112
[2019-06-27 14:40:55] 
[2019-06-27 14:40:55] {"jsonrpc":"2.0","method":"workspace/configuration","params":{"items":[{"section":"bibtex.formatting"}]},"id":1}
[2019-06-27 14:40:55] TRACE - Received message:
[2019-06-27 14:40:55] {"id": 1, "jsonrpc": "2.0", "error": {"code": -32601, "message": "Method not found"}}
[2019-06-27 14:40:55] TRACE - Sent message:
[2019-06-27 14:40:55] Content-Length: 89
[2019-06-27 14:40:55] 
[2019-06-27 14:40:55] {"jsonrpc":"2.0","error":{"code":-32700,"message":"Could not parse the input"},"id":null}

and here's the corresponding vim-lsp log for reference:

Thu 27 Jun 2019 02:40:55 PM CEST:["--->", 5, "texlab", {"method": "textDocument/formatting", "on_notification": "---funcref---", "sync": 0, "params": {"options": {"insertSpaces": true, "tabSize": 8}, "textDocument": {"uri": "file:///home/clason/Dropbox/tex/NonsmoothBook/nonsmooth.bib"}}}]
Thu 27 Jun 2019 02:40:55 PM CEST:["<---", 5, {"method": "workspace/configuration", "jsonrpc": "2.0", "id": 1, "params": {"items": [{"section": "bibtex.formatting"}]}}]
Thu 27 Jun 2019 02:40:55 PM CEST:["--->", 5, "texlab", {"id": 1, "error": {"code": -32601, "message": "Method not found"}}]
Thu 27 Jun 2019 02:40:55 PM CEST:["<---(stderr)", 5, "texlab", ["TRACE - Received message:", "{\"id\": 2, \"jsonrpc\": \"2.0\", \"method\": \"textDocument/formatting\", \"params\": {\"options\": {\"insertSpaces\": true, \"tabSize\": 8}, \"textDocument\": {\"uri\": \"file:///home/clason/Dropbox/tex/NonsmoothBook/nonsmooth.bib\"}}}", "TRACE - Sent message:", "Content-Length: 112\r", "\r", "{\"jsonrpc\":\"2.0\",\"method\":\"workspace/configuration\",\"params\":{\"items\":[{\"section\":\"bibtex.formatting\"}]},\"id\":1}", ""]]
Thu 27 Jun 2019 02:40:55 PM CEST:["invalid response id. ignoring message", {"id": null, "jsonrpc": "2.0", "error": {"code": -32700, "message": "Could not parse the input"}}]
Thu 27 Jun 2019 02:40:55 PM CEST:["<---(stderr)", 5, "texlab", ["TRACE - Received message:", "{\"id\": 1, \"jsonrpc\": \"2.0\", \"error\": {\"code\": -32601, \"message\": \"Method not found\"}}", "TRACE - Sent message:", "Content-Length: 89\r", "\r", "{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32700,\"message\":\"Could not parse the input\"},\"id\":null}", ""]]

@efoerster
Copy link
Member

efoerster commented Jun 27, 2019

Thu 27 Jun 2019 02:40:55 PM CEST:["--->", 5, "texlab", {"id": 1, "error": {"code": -32601, "message": "Method not found"}}]

This message from vim-lsp does not conform to the JSONRPC 2.0 spec because its missing the mandatory jsonrpc field.

Anyway, the server does not sent the workspace/configuration request anymore, if the client does not support it. Therefore formatting should work now.

@clason
Copy link
Contributor Author

clason commented Jun 27, 2019

Indeed, that works, thank you! I really appreciate the support.

And sorry for blaming the server in the issue when I should have blamed the client...

In fact, a better solution might be to report this issue at the client repo. Any suggestions how to formulate this most constructively would be welcome.

(This also fixes my other issues I had with vim-lsp not providing completions for \usepackage and \documentclass, so there's already a natural point to discuss this.)

@clason clason closed this as completed Jun 27, 2019
@clason
Copy link
Contributor Author

clason commented Jun 27, 2019

One related question, if I may: Do you have plans for providing a DocumentFormat for LaTeX files as well? (I know that's highly non-trivial, so I don't want to make a feature request.)

@pfoerster
Copy link
Member

At the moment, implementing a formatter for LaTeX has a low priority since it is highly non-trivial. Maybe we can use the code from LaTeXIndent as a starting point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants