astoff / digestif

A language server for TeX and friends
Other
256 stars 6 forks source link

eglot returns "Server not initialized!" #30

Closed junyi-hou closed 3 years ago

junyi-hou commented 3 years ago

Thank you so much for this great package.

I use a nix-based system which means digestif and texlive are installed in non-conventional places. digestif -h suggests that I need to set DIGESTIF_DATA, DIGESTIF_TEXMF, and DIGESTIF_TLPDB variables. However, I do not know what those variables are and for. I was hoping you can show me an example of the values of these variables.

P.S., the installed path of texlive is /nix/store/2mvi6sz0q96kbrz6p8zh2nsn7ays1nwq-texlive-combined-full-2020.20210109 and (the wrapper script) digestif is /nix/store/hckcnvihrgpzkfx166yhpljdsj78bhns-digestif

astoff commented 3 years ago

Is something broken? I believe no extra configuration should be necessary if you are either using the self-installing script or have the kpsewhich command in the PATH.

junyi-hou commented 3 years ago

Thanks for the quick response! Actually this is not about the environment variables. (sorry about the confusion, I should have dig a bit more before I open the issue!) When I connected digestif to a tex file using eglot, I got the following error:

[server-reply] (id:44) ERROR Fri Jan 22 12:01:55 2021:
(:result :json-false :id 44 :jsonrpc "2.0" :error
         (:message "/home/lactaid/.digestif/digestif/langserver.lua:26: Server not initialized!" :code 1))
[internal] (id:44) ERROR Fri Jan 22 12:01:55 2021:
(:message "error ignored, status set (/home/lactaid/.digestif/digestif/langserver.lua:26: Server not initialized!)" :id 44 :error 1)
[server-reply] (id:45) ERROR Fri Jan 22 12:01:55 2021:
(:result :json-false :id 45 :jsonrpc "2.0" :error
         (:message "/home/lactaid/.digestif/digestif/langserver.lua:26: Server not initialized!" :code 1))
[internal] (id:45) ERROR Fri Jan 22 12:01:55 2021:
(:message "error ignored, status set (/home/lactaid/.digestif/digestif/langserver.lua:26: Server not initialized!)" :id 45 :error 1)

My environment is

Linux 5.10.8-arch1-1
emacs-28.0.50
eglot-1.7

The full message is

[client-request] (id:1) Fri Jan 22 11:56:39 2021:
(:jsonrpc "2.0" :id 1 :method "initialize" :params
          (:processId 467 :rootPath "/home/lactaid/projects/switch-to-digestif/" :rootUri "file:///home/lactaid/projects/switch-to-digestif/" :initializationOptions #s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data
                                                                                                                                                                                   ())
                      :capabilities
                      (:workspace
                       (:applyEdit t :executeCommand
                                   (:dynamicRegistration :json-false)
                                   :workspaceEdit
                                   (:documentChanges :json-false)
                                   :didChangeWatchedFiles
                                   (:dynamicRegistration t)
                                   :symbol
                                   (:dynamicRegistration :json-false)
                                   :configuration t)
                       :textDocument
                       (:synchronization
                        (:dynamicRegistration :json-false :willSave t :willSaveWaitUntil t :didSave t)
                        :completion
                        (:dynamicRegistration :json-false :completionItem
                                              (:snippetSupport t)
                                              :contextSupport t)
                        :hover
                        (:dynamicRegistration :json-false :contentFormat
                                              ["markdown" "plaintext"])
                        :signatureHelp
                        (:dynamicRegistration :json-false :signatureInformation
                                              (:parameterInformation
                                               (:labelOffsetSupport t)))
                        :references
                        (:dynamicRegistration :json-false)
                        :definition
                        (:dynamicRegistration :json-false)
                        :declaration
                        (:dynamicRegistration :json-false)
                        :implementation
                        (:dynamicRegistration :json-false)
                        :typeDefinition
                        (:dynamicRegistration :json-false)
                        :documentSymbol
                        (:dynamicRegistration :json-false :hierarchicalDocumentSymbolSupport t :symbolKind
                                              (:valueSet
                                               [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26]))
                        :documentHighlight
                        (:dynamicRegistration :json-false)
                        :codeAction
                        (:dynamicRegistration :json-false :codeActionLiteralSupport
                                              (:codeActionKind
                                               (:valueSet
                                                ["quickfix" "refactor" "refactor.extract" "refactor.inline" "refactor.rewrite" "source" "source.organizeImports"]))
                                              :isPreferredSupport t)
                        :formatting
                        (:dynamicRegistration :json-false)
                        :rangeFormatting
                        (:dynamicRegistration :json-false)
                        :rename
                        (:dynamicRegistration :json-false)
                        :publishDiagnostics
                        (:relatedInformation :json-false))
                       :experimental #s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data
                                                   ()))))
[server-reply] (id:1) Fri Jan 22 11:56:39 2021:
(:result
 (:capabilities
  (:definitionProvider t :documentSymbolProvider t :referencesProvider t :hoverProvider t :completionProvider
                       (:triggerCharacters
                        ["\\" "{" "[" "," "="])
                       :textDocumentSync
                       (:openClose t :change 2)
                       :signatureHelpProvider
                       (:triggerCharacters
                        ["{" "[" "="])))
 :id 1 :jsonrpc "2.0")
[client-notification] Fri Jan 22 11:56:39 2021:
(:jsonrpc "2.0" :method "initialized" :params #s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data
                                                            ()))
[client-notification] Fri Jan 22 11:56:39 2021:
(:jsonrpc "2.0" :method "textDocument/didOpen" :params
          (:textDocument
           (:uri "file:///home/lactaid/projects/switch-to-digestif/foo.tex" :version 0 :languageId "latex" :text "\\documentclass[11pt]{article}\n\n% to keep graphs and tables in the very section to which they belong\n\\usepackage[section]{placeins}\n\n% formatting\n\\usepackage{setspace}\n\\onehalfspacing\n\\usepackage[top=1in,bottom=1in,left=1in,right=1in]{geometry}\n\n% to include the landscape environment\n\\usepackage{pdflscape}\n\n% tables\n\\usepackage{longtable,multirow,multicol,booktabs}\n\n% math\n\\usepackage{amsmath,amsthm,amsfonts,amssymb}\n\n% graphics\n\\usepackage{graphicx,rotating}\n\n% bib\n\\usepackage{natbib}\n\n% color and hyperlinks\n\\usepackage{color}\n\\usepackage{hyperref}\n\\hypersetup{colorlinks, citecolor=blue}\n\n% font and indent\n\\usepackage{mathpazo}\n\\usepackage{indentfirst}\n\n% smaller section\n\\usepackage{titlesec}\n\n\\begin{document}\n\n$1-a$\n\n\\section{Section A}\\label{section-a}\n\n\\re\n\n\\end{document}\n")))
[client-notification] Fri Jan 22 11:56:39 2021:
(:jsonrpc "2.0" :method "workspace/didChangeConfiguration" :params
          (:settings nil))
[server-message] ERROR Fri Jan 22 11:56:39 2021:
(:result :json-false :jsonrpc "2.0" :error
         (:message "/home/lactaid/.digestif/digestif/util.lua:446: bad argument #1 to 'open' (string expected, got nil)" :code 1))
[server-message] ERROR Fri Jan 22 11:56:39 2021:
(:result :json-false :jsonrpc "2.0" :error
         (:message "/home/lactaid/.digestif/digestif/langserver.lua:26: Server not initialized!" :code 1))
astoff commented 3 years ago

You can try setting (and exporting) DIGESTIF_TEXMF to a suitable directory, which in a more traditional Linux distro would be /usr/share/texlive/texmf-dist.

Can you paste the output of the command kpsewhich -var-brace-value=TEXMF? Thanks!

junyi-hou commented 3 years ago

I set DIGESTIF_TEXMF to /nix/store/2mvi6sz0q96kbrz6p8zh2nsn7ays1nwq-texlive-combined-full-2020.20210109/share/texmf-dist and run kpsewhich -var-brace-value=TEXMF, the output is

/home/lactaid/.texlive2020/texmf-config:/home/lactaid/.texlive2020/texmf-var:/home/lactaid/texmf:!!/nix/store/2mvi6sz0q96kbrz6p8zh2nsn7ays1nwq-texlive-combined-full-2020.20210109/share/texmf-local:!!/nix/store/2mvi6sz0q96kbrz6p8zh2nsn7ays1nwq-texlive-combined-full-2020.20210109/share/texmf-config:!!/nix/store/2mvi6sz0q96kbrz6p8zh2nsn7ays1nwq-texlive-combined-full-2020.20210109/share/texmf-var:!!/nix/store/2mvi6sz0q96kbrz6p8zh2nsn7ays1nwq-texlive-combined-full-2020.20210109/share/texmf
junyi-hou commented 3 years ago

actually, if I remove all the DIGESTIF_* variables, the Server not initialized! error is gone and everything works! I was assuming that I need to set those variables since I installed stuffs in non-conventional ways! :)