latex-lsp / texlab

An implementation of the Language Server Protocol for LaTeX
GNU General Public License v3.0
1.51k stars 52 forks source link

LanguageClient-Neovim configuration #123

Closed kwon-young closed 3 years ago

kwon-young commented 4 years ago

Hi, I'm using the LanguageClient-Neovim as a language client plugin for vim. The problem is quite simple: In order to configure the texlab language server:

It would be nice if texlab could support the workspace/didChangeConfiguration request so that all features of texlab can be used together with LanguageClient-Neovim!

Here is the mirrored issue on the LanguageClient-neovim repo: https://github.com/autozimu/LanguageClient-neovim/issues/923

pfoerster commented 4 years ago

Can you try the latest v1.10.0 release, please? I added some basic support for push-based configuration using workspace/didChangeConfiguration.

kwon-young commented 4 years ago

Thank you so much for working on this! I compiled the code from source to actually try this right now. But I can't seem to make it work, so here is what I did:

OS: Manjaro Linux editor: Neovim v0.4.3 language client plugin: LanguageClient-Neovim (commit 7c741d0a609d252f50a6dc0d79b1799a5025ca86) language server: texlab v1.10 (compiled from source)

.vimrc:

let g:LanguageClient_serverCommands = {
      \ 'tex': ['/home/kwon-young/prog/texlab/target/release/texlab', '-vvv']
      \ }
let g:LanguageClient_settingsPath = ".vim/settings.json"
let g:LanguageClient_loadSettings = 1
let g:LanguageClient_autoStart = 1
let g:LanguageClient_windowLogMessageLevel = "Log"
let g:LanguageClient_loggingFile = expand('/tmp/LanguageClient.log')
let g:LanguageClient_trace = 'verbose'
let g:LanguageClient_loggingLevel = 'DEBUG'
let g:LanguageClient_serverStderr = '/tmp/LanguageServer.log'

function! Print(message)
  echo a:message
endfunction

function! TexLabForwardSearch()
  let tex_file = fnameescape(expand("%:p"))
  call LanguageClient#Call('textDocument/forwardSearch', {"textDocument":{"uri":"file://" . tex_file}, "position": {"line": line("."), "character": 1}}, 'Print')
endfunction

My latex project is found in /home/kwon-young/prog/thesis, so my language server setting file is in /home/kwon-young/prog/thesis/.vim/setting.json and here is the content:

{
  "latex.forwardSearch": {
    "executable": "okular",
    "args": "%p"
  }
}

Now, I launch neovim in /home/kwon-young/prog/thesis and call :call TexLabForwardSearch(). The results I see is {'id': 2, 'jsonrpc': '2.0', 'result': {'status': 3}} which I think means that the configuration did not happen.

So here is the client log:

#######
LanguageClient 0.1.156 
#######
10:01:02 DEBUG unnamed src/language_client.rs:65 state: null ==> {"autoStart":true,"capabilities":{},"change_throttle":null,"code_lens":{},"completionPreferTextEdit":false,"diagnostics":{},"diagnosticsDisplay":{"1":{"name":"Error","signText":"✖","signTexthl":"ALEErrorSign","texthl":"ALEError","virtualTexthl":"Error"},"2":{"name":"Warning","signText":"⚠","signTexthl":"ALEWarningSign","texthl":"ALEWarning","virtualTexthl":"Todo"},"3":{"name":"Information","signText":"ℹ","signTexthl":"ALEInfoSign","texthl":"ALEInfo","virtualTexthl":"Todo"},"4":{"name":"Hint","signText":"➤","signTexthl":"ALEInfoSign","texthl":"ALEInfo","virtualTexthl":"Todo"}},"diagnosticsEnable":true,"diagnosticsList":"Quickfix","diagnosticsSignsMax":null,"diagnostics_max_severity":4,"documentHighlightDisplay":{"1":{"name":"Text","texthl":"SpellCap"},"2":{"name":"Read","texthl":"SpellLocal"},"3":{"name":"Write","texthl":"SpellRare"}},"document_highlight_source":null,"echo_project_root":true,"highlight_match_ids":[],"highlight_source":null,"highlights":{},"highlights_placed":{},"hoverPreview":"Auto","is_nvim":false,"last_cursor_line":0,"last_line_diagnostic":" ","loadSettings":false,"loggingFile":null,"loggingLevel":"WARN","namespace_id":null,"registrations":[],"rootMarkers":null,"roots":{},"selectionUI":"LocationList","selectionUI_autoOpen":true,"serverCommands":{},"serverStderr":null,"settingsPath":".vim/settings.json","sign_next_id":75000,"signs":{},"stashed_codeAction_actions":[],"text_documents":{},"text_documents_metadata":{},"trace":null,"use_virtual_text":"All","user_handlers":{},"wait_output_timeout":{"nanos":0,"secs":10},"windowLogMessageLevel":2}
10:01:02 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"eval","params":["[!!get(g:, 'LanguageClient_autoStart', 1), s:GetVar('LanguageClient_serverCommands', {}), get(g:, 'LanguageClient_selectionUI', v:null), get(g:, 'LanguageClient_trace', v:null), expand(get(g:, 'LanguageClient_settingsPath', '.vim/settings.json')), !!get(g:, 'LanguageClient_loadSettings', 1), get(g:, 'LanguageClient_rootMarkers', v:null), get(g:, 'LanguageClient_changeThrottle', v:null), get(g:, 'LanguageClient_waitOutputTimeout', v:null), !!get(g:, 'LanguageClient_diagnosticsEnable', 1), get(g:, 'LanguageClient_diagnosticsList', 'Quickfix'), get(g:, 'LanguageClient_diagnosticsDisplay', {}), get(g:, 'LanguageClient_windowLogMessageLevel', 'Warning'), get(g:, 'LanguageClient_hoverPreview', 'Auto'), get(g:, 'LanguageClient_completionPreferTextEdit', 0), has('nvim')]"],"id":3}
10:01:02 INFO reader-None src/rpcclient.rs:169 <= None {"id": 3, "jsonrpc": "2.0", "result": [1, {"typescript": ["typescript-language-server", "--stdio"], "c": ["clangd", "-header-insertion-decorators=false"], "tex": ["/home/kwon-young/prog/texlab/target/release/texlab", "-vvv"], "cpp": ["clangd", "-header-insertion-decorators=false"], "python": ["pyls"]}, null, "verbose", ".vim/settings.json", 1, null, null, null, 1, "Location", {}, "Log", "Auto", 0, 1]}
10:01:02 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"eval","params":["[get(g:, 'LanguageClient_diagnosticsSignsMax', v:null), get(g:, 'LanguageClient_diagnosticsMaxSeverity', 'Hint'), get(g:, 'LanguageClient_documentHighlightDisplay', {}), !!s:GetVar('LanguageClient_selectionUI_autoOpen', 1), s:useVirtualText(), !!s:GetVar('LanguageClient_echoProjectRoot', 1)]"],"id":4}
10:01:02 INFO reader-None src/rpcclient.rs:169 <= None {"id": 4, "jsonrpc": "2.0", "result": [null, "Hint", {}, 1, "All", 1]}
10:01:02 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"eval","params":["get(g:, 'loaded_fzf')"],"id":5}
10:01:02 INFO reader-None src/rpcclient.rs:169 <= None {"id": 5, "jsonrpc": "2.0", "result": 1}
10:01:02 DEBUG unnamed src/language_client.rs:65 state.serverStderr: null ==> "/tmp/LanguageServer.log"
10:01:02 DEBUG unnamed src/language_client.rs:65 state.loggingFile: null ==> "/tmp/LanguageClient.log"
10:01:02 DEBUG unnamed src/language_client.rs:65 state.diagnosticsList: "Quickfix" ==> "Location"
10:01:02 DEBUG unnamed src/language_client.rs:65 state.is_nvim: false ==> true
10:01:02 DEBUG unnamed src/language_client.rs:65 state.serverCommands.c: null ==> ["clangd","-header-insertion-decorators=false"]
10:01:02 DEBUG unnamed src/language_client.rs:65 state.serverCommands.cpp: null ==> ["clangd","-header-insertion-decorators=false"]
10:01:02 DEBUG unnamed src/language_client.rs:65 state.loggingLevel: "WARN" ==> "DEBUG"
10:01:02 DEBUG unnamed src/language_client.rs:65 state.windowLogMessageLevel: 2 ==> 4
10:01:02 DEBUG unnamed src/language_client.rs:65 state.serverCommands.python: null ==> ["pyls"]
10:01:02 DEBUG unnamed src/language_client.rs:65 state.trace: null ==> "verbose"
10:01:02 DEBUG unnamed src/language_client.rs:65 state.selectionUI: "LocationList" ==> "FZF"
10:01:02 DEBUG unnamed src/language_client.rs:65 state.loadSettings: false ==> true
10:01:02 DEBUG unnamed src/language_client.rs:65 state.serverCommands.typescript: null ==> ["typescript-language-server","--stdio"]
10:01:02 DEBUG unnamed src/language_client.rs:65 state.serverCommands.tex: null ==> ["/home/kwon-young/prog/texlab/target/release/texlab","-vvv"]
10:01:02 INFO unnamed src/language_server_protocol.rs:238 End sync settings
10:01:02 INFO unnamed src/language_server_protocol.rs:3082 settings synced
10:01:02 INFO unnamed src/language_server_protocol.rs:3108 Project root: /home/kwon-young/prog/thesis
10:01:02 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"s:EchomsgEllipsis","params":["Project root: /home/kwon-young/prog/thesis"]}
10:01:02 DEBUG unnamed src/language_client.rs:65 state.roots.tex: null ==> "/home/kwon-young/prog/thesis"
10:01:02 INFO unnamed src/language_server_protocol.rs:3185 End languageClient/startServer
10:01:02 INFO unnamed src/language_server_protocol.rs:257 Defining signs
10:01:02 INFO unnamed src/language_server_protocol.rs:963 Begin initialize
10:01:02 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"s:command","params":["sign define LanguageClientError text=✖ texthl=ALEErrorSign","sign define LanguageClientWarning text=⚠ texthl=ALEWarningSign","sign define LanguageClientInformation text=ℹ texthl=ALEInfoSign","sign define LanguageClientHint text=➤ texthl=ALEInfoSign"]}
10:01:02 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"eval","params":["s:hasSnippetSupport()"],"id":6}
10:01:02 INFO reader-None src/rpcclient.rs:169 <= None {"id": 6, "jsonrpc": "2.0", "result": 0}
10:01:02 INFO writer-Some("tex") src/rpcclient.rs:215 => Some("tex") {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"textDocument":{"codeLens":{"dynamicRegistration":true},"colorProvider":null,"completion":{"completionItem":{"snippetSupport":false}},"declaration":{"linkSupport":true},"definition":{"linkSupport":true},"implementation":{"linkSupport":true},"publishDiagnostics":{"relatedInformation":true},"signatureHelp":{"signatureInformation":{"parameterInformation":{"labelOffsetSupport":true}}},"typeDefinition":{"linkSupport":true}},"workspace":{"applyEdit":true,"didChangeWatchedFiles":{"dynamicRegistration":true}}},"processId":27502,"rootPath":"/home/kwon-young/prog/thesis","rootUri":"file:///home/kwon-young/prog/thesis","trace":"verbose"},"id":1}
10:01:03 INFO reader-Some("tex") src/rpcclient.rs:169 <= Some("tex") {"jsonrpc":"2.0","result":{"capabilities":{"completionProvider":{"resolveProvider":true,"triggerCharacters":["\\","{","}","@","/"," "]},"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentLinkProvider":{"resolveProvider":false},"documentSymbolProvider":true,"foldingRangeProvider":true,"hoverProvider":true,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"textDocumentSync":{"change":1,"openClose":true,"save":{"includeText":false}},"workspaceSymbolProvider":true}},"id":1}
10:01:03 DEBUG unnamed src/language_client.rs:65 state.capabilities.tex: null ==> {"capabilities":{"completionProvider":{"resolveProvider":true,"triggerCharacters":["\\","{","}","@","/"," "]},"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentLinkProvider":{"resolveProvider":false},"documentSymbolProvider":true,"foldingRangeProvider":true,"hoverProvider":true,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"textDocumentSync":{"change":1,"openClose":true,"save":{"includeText":false}},"workspaceSymbolProvider":true}}
10:01:03 INFO unnamed src/language_server_protocol.rs:1058 End initialize
10:01:03 INFO unnamed src/language_server_protocol.rs:740 Begin register NCM source
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"eval","params":["exists('g:cm_matcher')"],"id":7}
10:01:03 INFO reader-None src/rpcclient.rs:169 <= None {"id": 7, "jsonrpc": "2.0", "result": 0}
10:01:03 INFO unnamed src/language_server_protocol.rs:781 Begin register NCM2 source
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"eval","params":["exists('g:ncm2_loaded')"],"id":8}
10:01:03 INFO reader-None src/rpcclient.rs:169 <= None {"id": 8, "jsonrpc": "2.0", "result": 0}
10:01:03 INFO unnamed src/language_server_protocol.rs:1075 Begin initialized
10:01:03 INFO unnamed src/language_server_protocol.rs:1080 End initialized
10:01:03 INFO writer-Some("tex") src/rpcclient.rs:215 => Some("tex") {"jsonrpc":"2.0","method":"initialized","params":{}}
10:01:03 INFO unnamed src/language_server_protocol.rs:1779 Begin workspace/didChangeConfiguration
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"eval","params":["LSP#filename()"],"id":9}
10:01:03 INFO reader-None src/rpcclient.rs:169 <= None {"id": 9, "jsonrpc": "2.0", "result": "/home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex"}
10:01:03 INFO unnamed src/language_server_protocol.rs:1791 End workspace/didChangeConfiguration
10:01:03 INFO unnamed src/language_server_protocol.rs:1870 Begin textDocument/didOpen
10:01:03 INFO writer-Some("tex") src/rpcclient.rs:215 => Some("tex") {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"latex":{"forwardSearch":{"args":"%p","executable":"okular"}}}}}
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"LSP#text","params":["/home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex"],"id":10}
10:01:03 INFO reader-None src/rpcclient.rs:169 <= None {"id": 10, "jsonrpc": "2.0", "result": [...]}
10:01:03 DEBUG unnamed src/language_client.rs:65 state.text_documents./home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex: null ==> {"languageId":"tex","text":"...","uri":"file:///home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex","version":0}
10:01:03 INFO unnamed src/language_server_protocol.rs:1832 Begin textDocument/codeLens
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"s:command","params":["setlocal omnifunc=LanguageClient#complete"]}
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"setbufvar","params":["/home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex","LanguageClient_projectRoot","/home/kwon-young/prog/thesis"]}
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"s:ExecuteAutocmd","params":["LanguageClientTextDocumentDidOpenPost"]}
10:01:03 INFO writer-Some("tex") src/rpcclient.rs:215 => Some("tex") {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"tex","text":"...","uri":"file:///home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex","version":0}}}
10:01:03 INFO writer-Some("tex") src/rpcclient.rs:215 => Some("tex") {"jsonrpc":"2.0","method":"textDocument/codeLens","params":{"textDocument":{"uri":"file:///home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex"}},"id":2}
10:01:03 INFO reader-Some("tex") src/rpcclient.rs:169 <= Some("tex") {"jsonrpc":"2.0","error":{"code":-32601,"message":"Method not found"},"id":2}
10:01:03 WARN unnamed src/language_server_protocol.rs:2389 Failed to start language server automatically. Error: Failure { jsonrpc: Some(V2), error: Error { code: MethodNotFound, message: "Method not found", data: None }, id: Num(2) }
10:01:03 INFO unnamed src/language_server_protocol.rs:2394 End languageClient/handleFileType
10:01:03 INFO reader-Some("tex") src/rpcclient.rs:169 <= Some("tex") {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex"}}
10:01:03 INFO reader-Some("tex") src/rpcclient.rs:169 <= Some("tex") {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///home/kwon-young/prog/thesis/these-ubl.cls"}}
10:01:03 INFO reader-Some("tex") src/rpcclient.rs:169 <= Some("tex") {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///home/kwon-young/prog/thesis/stopcover.tex"}}
10:01:03 INFO unnamed src/language_server_protocol.rs:2011 Begin textDocument/publishDiagnostics
10:01:03 INFO reader-Some("tex") src/rpcclient.rs:169 <= Some("tex") {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///home/kwon-young/prog/thesis/main.tex"}}
10:01:03 INFO unnamed src/language_server_protocol.rs:2011 Begin textDocument/publishDiagnostics
10:01:03 INFO unnamed src/language_server_protocol.rs:2011 Begin textDocument/publishDiagnostics
10:01:03 DEBUG unnamed src/language_client.rs:65 state.diagnostics./home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex: null ==> []
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"setloclist","params":[0,[],"r"]}
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"setloclist","params":[0,[],"a",{"title":"[LC]: diagnostics"}]}
10:01:03 DEBUG unnamed src/language_client.rs:65 state.diagnostics./home/kwon-young/prog/thesis/these-ubl.cls: null ==> []
10:01:03 INFO unnamed src/language_server_protocol.rs:2011 Begin textDocument/publishDiagnostics
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"eval","params":["LSP#filename()"],"id":11}
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"setloclist","params":[0,[],"r"]}
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"setloclist","params":[0,[],"a",{"title":"[LC]: diagnostics"}]}
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"eval","params":["LSP#filename()"],"id":12}
10:01:03 DEBUG unnamed src/language_client.rs:65 state.diagnostics./home/kwon-young/prog/thesis/stopcover.tex: null ==> []
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"setloclist","params":[0,[],"r"]}
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"setloclist","params":[0,[],"a",{"title":"[LC]: diagnostics"}]}
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"eval","params":["LSP#filename()"],"id":13}
10:01:03 INFO reader-None src/rpcclient.rs:169 <= None {"id": 11, "jsonrpc": "2.0", "result": "/home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex"}
10:01:03 INFO reader-None src/rpcclient.rs:169 <= None {"id": 12, "jsonrpc": "2.0", "result": "/home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex"}
10:01:03 DEBUG unnamed src/language_client.rs:65 state.diagnostics./home/kwon-young/prog/thesis/main.tex: null ==> []
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"setloclist","params":[0,[],"r"]}
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"setloclist","params":[0,[],"a",{"title":"[LC]: diagnostics"}]}
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"eval","params":["LSP#filename()"],"id":14}
10:01:03 INFO reader-None src/rpcclient.rs:169 <= None {"id": 13, "jsonrpc": "2.0", "result": "/home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex"}
10:01:03 INFO reader-None src/rpcclient.rs:169 <= None {"id": 14, "jsonrpc": "2.0", "result": "/home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex"}
10:01:03 DEBUG unnamed src/language_client.rs:65 state.highlights./home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex: null ==> []
10:01:03 INFO unnamed src/language_server_protocol.rs:2454 Begin languageClient/handleCursorMoved
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"eval","params":["LSP#filename()"],"id":15}
10:01:03 INFO reader-None src/rpcclient.rs:169 <= None {"id": 15, "jsonrpc": "2.0", "result": "/home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex"}
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"getbufvar","params":["/home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex","&filetype"],"id":16}
10:01:03 INFO reader-None src/rpcclient.rs:169 <= None {"id": 16, "jsonrpc": "2.0", "result": "tex"}
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"eval","params":["LSP#position()"],"id":17}
10:01:03 INFO reader-None src/rpcclient.rs:169 <= None {"id": 17, "jsonrpc": "2.0", "result": {"character": 0, "line": 0}}
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"eval","params":["bufnr('/home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex')"],"id":18}
10:01:03 INFO reader-None src/rpcclient.rs:169 <= None {"id": 18, "jsonrpc": "2.0", "result": 1}
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"eval","params":["LSP#viewport()"],"id":19}
10:01:03 INFO reader-None src/rpcclient.rs:169 <= None {"id": 19, "jsonrpc": "2.0", "result": {"end": 45, "start": 0}}
10:01:03 DEBUG unnamed src/language_client.rs:65 state.signs./home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex: null ==> {}
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"s:set_signs","params":["/home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex",[],[]],"id":20}
10:01:03 INFO reader-None src/rpcclient.rs:169 <= None {"id": 20, "jsonrpc": "2.0", "result": 0}
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"nvim_buf_add_highlight","params":[0,0,"Error",1,1,1],"id":21}
10:01:03 INFO reader-None src/rpcclient.rs:169 <= None {"id": 21, "jsonrpc": "2.0", "result": 1}
10:01:03 DEBUG unnamed src/language_client.rs:65 state.highlight_source: null ==> 1
10:01:03 DEBUG unnamed src/language_client.rs:65 state.highlights_placed./home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex: null ==> []
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"nvim_buf_clear_highlight","params":[0,1,0,45]}
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"s:AddHighlights","params":[1,[]]}
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"eval","params":["LSP#filename()"],"id":22}
10:01:03 INFO reader-None src/rpcclient.rs:169 <= None {"id": 22, "jsonrpc": "2.0", "result": "/home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex"}
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"nvim_create_namespace","params":["LanguageClient"],"id":23}
10:01:03 INFO reader-None src/rpcclient.rs:169 <= None {"id": 23, "jsonrpc": "2.0", "result": 2}
10:01:03 DEBUG unnamed src/language_client.rs:65 state.namespace_id: null ==> 2
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"s:set_virtual_texts","params":[1,2,0,45,[]],"id":24}
10:01:03 INFO reader-None src/rpcclient.rs:169 <= None {"id": 24, "jsonrpc": "2.0", "result": 0}
10:01:03 INFO unnamed src/language_server_protocol.rs:2669 End languageClient/handleCursorMoved
10:01:03 INFO unnamed src/language_server_protocol.rs:2067 End textDocument/publishDiagnostics
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"s:ExecuteAutocmd","params":["LanguageClientDiagnosticsChanged"]}
10:01:05 INFO reader-None src/rpcclient.rs:169 <= None {"id": 1, "jsonrpc": "2.0", "method": "textDocument/forwardSearch", "params": {"bufnr": 1, "languageId": "tex", "textDocument": {"uri": "file:///home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex"}, "position": {"character": 1, "line": 1}}}
10:01:05 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"eval","params":["LSP#filename()"],"id":25}
10:01:05 INFO reader-None src/rpcclient.rs:169 <= None {"id": 25, "jsonrpc": "2.0", "result": "/home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex"}
10:01:05 INFO unnamed src/rpchandler.rs:118 Proxy message directly to language server: MethodCall { jsonrpc: Some(V2), method: "textDocument/forwardSearch", params: Map({"bufnr": Number(1), "languageId": String("tex"), "position": Object({"character": Number(1), "line": Number(1)}), "textDocument": Object({"uri": String("file:///home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex")})}), id: Num(1) }
10:01:05 INFO writer-Some("tex") src/rpcclient.rs:215 => Some("tex") {"jsonrpc":"2.0","method":"textDocument/forwardSearch","params":{"bufnr":1,"languageId":"tex","position":{"character":1,"line":1},"textDocument":{"uri":"file:///home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex"}},"id":3}
10:01:05 INFO reader-Some("tex") src/rpcclient.rs:169 <= Some("tex") {"jsonrpc":"2.0","result":{"status":3},"id":3}
10:01:05 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","result":{"status":3},"id":1}
10:01:07 INFO reader-None src/rpcclient.rs:169 <= None {"method": "exit", "jsonrpc": "2.0", "params": {"bufnr": 1, "languageId": "tex"}}
10:01:07 INFO unnamed src/language_server_protocol.rs:2210 Begin exit
10:01:07 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"eval","params":["LSP#filename()"],"id":26}
10:01:07 INFO reader-None src/rpcclient.rs:169 <= None {"id": 26, "jsonrpc": "2.0", "result": "/home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex"}
10:01:07 INFO reader-None src/rpcclient.rs:202 reader-None terminated

And here is what I could gather from the stderr of texlab:

INFO - Detected TeX distribution: Texlive
ERROR - Error { code: MethodNotFound, message: "Method not found", data: Null }

So I spotted these lines in the above client log:

10:01:03 INFO unnamed src/language_server_protocol.rs:1779 Begin workspace/didChangeConfiguration
10:01:03 INFO writer-None src/rpcclient.rs:215 => None {"jsonrpc":"2.0","method":"eval","params":["LSP#filename()"],"id":9}
10:01:03 INFO reader-None src/rpcclient.rs:169 <= None {"id": 9, "jsonrpc": "2.0", "result": "/home/kwon-young/prog/thesis/Chapitre4/chapitre4.tex"}
10:01:03 INFO unnamed src/language_server_protocol.rs:1791 End workspace/didChangeConfiguration
10:01:03 INFO unnamed src/language_server_protocol.rs:1870 Begin textDocument/didOpen
10:01:03 INFO writer-Some("tex") src/rpcclient.rs:215 => Some("tex") {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"latex":{"forwardSearch":{"args":"%p","executable":"okular"}}}}}

So it seems that LanguageClient-Neovim is actually sending the configuration. However, it seems weird that it does a workspace/didChangeConfiguration call after logging and End workspace/didChangeConfiguration. Do you think that it is LanguageClient-Neovim that have a bug here? Or maybe my configuration in .vim/settings is wrong? Maybe you could add some logging to the texlab server so we can trace the calls on the server sides?

Thanks again for working on this!

pfoerster commented 4 years ago

Thank you for the very detailed report. The issue seems to be that the LSP client does not advertise its capabilities which causes TexLab to assume that the client does not support configuration at all. Nevertheless, I patched TexLab with 62b9ea0e2071354e7d25566362ca87fe9d952395 so that it should work with LanguageClient-Neovim. To get more logging information out of TexLab, you can call TexLab with texlab -vvvv (trace verbosity). Can you try the latest commit on the master branch, please? Don't mind the CI failure, it seems to be related to Rust nightly and should compile on Rust stable.

kwon-young commented 4 years ago

Thank you for the very detailed report.

You're welcome!

The issue seems to be that the LSP client does not advertise its capabilities which causes TexLab to assume that the client does not support configuration at all.

Do you consider this to be a faulty protocol implementation? Maybe I should open an issue on LanguageClient-Neovim side to let them know about this?

Nevertheless, I patched TexLab with 62b9ea0 so that it should work with LanguageClient-Neovim. To get more logging information out of TexLab, you can call TexLab with texlab -vvvv (trace verbosity). Can you try the latest commit on the master branch, please? Don't mind the CI failure, it seems to be related to Rust nightly and should compile on Rust stable.

Well, I manage to understand where my error was using more verbosity, and it was a configuration error in my settings.json where args should have been a list of strings instead of a string. So now, it is opening okular. However, okular fails to open the pdf because of the uri naming:

Could not open file:///home/kwon-young/prog/thesis/Chapitre4/chapitre4.pdf

I'm not sure any pdf viewer is able to parse this kind of path, so maybe you should trim the file:// at the beginning of the path?

pfoerster commented 4 years ago

I'm not sure any pdf viewer is able to parse this kind of path, so maybe you should trim the file:// at the beginning of the path?

That's odd. After converting a URI to a PathBuf, it should not contain the file:// prefix anymore. I cannot reproduce this issue with another viewer. Does the file that Okular tries to open exist? I think that is the reason of the problem. Maybe there is problem in determining the root document. If the file does indeed exist, I can remove the file:// prefix at the beginning at the path.

pfoerster commented 4 years ago

Do you consider this to be a faulty protocol implementation? Maybe I should open an issue on LanguageClient-Neovim side to let them know about this?

Technically, it is not faulty and most LSP clients seem to ignore both the client and server capabilities anyway (e. g. LanguageClient-Neovim sends code lens requests to TexLab although we do not advertise that capabiltity).

kwon-young commented 4 years ago

Hi, I'm sorry to only respond now. I've identified the issue. I'm getting this error from okular file:///home/kwon-young/prog/thesis/Chapitre4/chapitre4.pdf because this file effectively does not exist. texlab is not correctly identifying the main tex file which should be file:///home/kwon-young/prog/thesis/main.tex and therefore the corresponding pdf file which should be file:///home/kwon-young/prog/thesis/main.pdf. So, when I try to open okular when editing main.tex it works perfectly but not when editing chapitre4.tex. It seems to be a similar problem to my previous issue https://github.com/latex-lsp/texlab/issues/122 where texlab had trouble identifying the main tex file.

In your documentation, you mention that %p is The path of the current PDF file.. This seems ambiguous if you have a multi-file project where it is unclear what pdf file texlab should open.

pfoerster commented 4 years ago

texlab is not correctly identifying the main tex file which should be file:///home/kwon-young/prog/thesis/main.tex and therefore the corresponding pdf file which should be file:///home/kwon-young/prog/thesis/main.pdf.

How are you including the file chapitre4.tex? I am assuming you are using something like \include{Chapitre4/chapitre4} in the file main.tex. What is the current working directory (e. g. are you using nvim Chapitre4/chapitre4.tex or nvim chapitre4.tex? Have you tried setting the new property latex.rootDirectory to "/home/kwon-young/prog/thesis" for the current workspace configuration using the latest master branch of TexLab? Do you get completion inside chapitre4.tex with the packages you included in the main file?

In your documentation, you mention that %p is The path of the current PDF file.. This seems ambiguous if you have a multi-file project where it is unclear what pdf file texlab should open.

This could indeed be worded a bit better. %p refers the to path of the PDF file of the main document and %f to the TeX file you are calling the forward search from.

kwon-young commented 4 years ago

How are you including the file chapitre4.tex? I am assuming you are using something like \include{Chapitre4/chapitre4} in the file main.tex.

I use \input{Chapitre4/chapitre4.tex}

What is the current working directory (e. g. are you using nvim Chapitre4/chapitre4.tex or nvim chapitre4.tex?

I usually do:

cd ~/prog/thesis
nvim
:e Chapitre4/chapitre4.tex

:pwd in neovim gives me: ~/prog/thesis.

Have you tried setting the new property latex.rootDirectory to "/home/kwon-young/prog/thesis" for the current workspace configuration using the latest master branch of TexLab?

Yes, it still gives the same error.

Do you get completion inside chapitre4.tex with the packages you included in the main file?

Yes

One workaround I tested is to replace %p in settings.json with main.pdf which works like a charm. Since you can have a settings.json per project, you can customize it for every project.

pfoerster commented 3 years ago

The latest version of texlab should be a lot smarter in figuring out where the PDF is located so I think this workaround should no longer be necessary. Closing this issue for now.