autozimu / LanguageClient-neovim

Language Server Protocol (LSP) support for vim and neovim.
MIT License
3.55k stars 273 forks source link

Unhandled method when formatting HTML #498

Closed MartenBE closed 6 years ago

MartenBE commented 6 years ago

If you are reporting a bug, please read following FAQ first. If you are requesting other types of issue, please ignore.

If you are still experiencing an issue, please create ticket with

Summary

When formatting an HTML file, neovim returns an Unhandled method error. However, https://github.com/vscode-langservers/vscode-html-languageserver-bin/blob/master/README.md describes that formatting is enabled.

Reproduction

Features: +acl +iconv +jemalloc +tui See ":help feature-compile"

system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

- This plugin version (`git rev-parse --short HEAD`): `96079a7`
- This plugin's binary version (`bin/languageclient --version`): `languageclient 0.1.94 `
- Minimal vimrc content (A minimal vimrc is the smallest vimrc that could
  reproduce the issue. Refer to an example [here][min-init.vim]):

set hidden set signcolumn=yes

let g:LanguageClient_loggingFile = '/tmp/LanguageClient.log' let g:LanguageClient_loggingLevel = 'INFO' let g:LanguageClient_serverStderr = '/tmp/LanguageServer.log' let g:LanguageClient_autoStart = 1 let g:LanguageClient_serverCommands = {}

if executable('html-languageserver') let g:LanguageClient_serverCommands.html = ['html-languageserver', '--stdio'] " npm install -g vscode-html-languageserver-bin autocmd FileType html nnoremap f :call LanguageClient_textDocument_formatting() else echo "LSP: html-languageserver not installed!\n" endif


- Language server link and version:
- Steps to reproduce the issue from clean state
    1. **Open HTML file**
    2. **`:call LanguageClient_textDocument_formatting()`**
- Logs (Paste or attach log file content):

12:16:49 INFO main src/vim.rs:90 => None {"jsonrpc":"2.0","method":"eval","params":["[!!get(g:, 'LanguageClient_autoStart', 1), get(g:, 'LanguageClient_serverCommands', {}), get(g:, 'LanguageClient_selectionUI', v:null), get(g:, 'LanguageClient_trace', v:null), 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":4} 12:16:49 INFO reader-main src/vim.rs:386 <= None {"id": 4, "jsonrpc": "2.0", "result": [1, {"c": ["clangd"], "json": ["json-languageserver", "--stdio"], "javascript": ["javascript-typescript-stdio"], "html": ["html-languageserver", "--stdio"], "cpp": ["clangd"], "css": ["css-languageserver", "--stdio"], "python": ["docker-langserver", "--stdio"]}, null, null, ".vim/settings.json", 1, null, null, null, 1, "Quickfix", {}, "Warning", "Auto", 0, 1]} 12:16:49 INFO main src/vim.rs:90 => None {"jsonrpc":"2.0","method":"eval","params":["[get(g:, 'LanguageClient_diagnosticsSignsMax', v:null)]"],"id":5} 12:16:49 INFO reader-main src/vim.rs:386 <= None {"id": 5, "jsonrpc": "2.0", "result": [null]} 12:16:49 INFO main src/vim.rs:90 => None {"jsonrpc":"2.0","method":"eval","params":["get(g:, 'loaded_fzf')"],"id":6} 12:16:49 INFO reader-main src/vim.rs:386 <= None {"id": 6, "jsonrpc": "2.0", "result": 1} 12:16:49 INFO main src/languageclient.rs:2538 End languageClient/startServer 12:16:49 INFO main src/languageclient.rs:219 Define signs 12:16:49 INFO main src/vim.rs:90 => None {"jsonrpc":"2.0","method":"execute","params":["echo | execute 'sign define LanguageClientHint text=➤ texthl=ALEInfoSign' | execute 'sign define LanguageClientWarning text=⚠ texthl=ALEWarningSign' | execute 'sign define LanguageClientError text=✖ texthl=ALEErrorSign' | execute 'sign define LanguageClientInformation text=ℹ texthl=ALEInfoSign'"],"id":7} 12:16:49 INFO reader-main src/vim.rs:386 <= None {"id": 7, "jsonrpc": "2.0", "result": 0} 12:16:49 INFO main src/languageclient.rs:233 Define signs 12:16:49 INFO main src/languageclient.rs:654 Begin initialize 12:16:49 INFO main src/languageclient.rs:46 gather_args: [LanguageId, Filename] = [String("html"), String("/home/martijn/Desktop/test.html")] 12:16:49 INFO main src/languageclient.rs:29 Some arguments are not available. Requesting from vim. Keys: ["rootPath", "hasSnippetSupport"]. Exps: ["v:null", "s:hasSnippetSupport()"] 12:16:49 INFO main src/vim.rs:90 => None {"jsonrpc":"2.0","method":"eval","params":["[v:null, s:hasSnippetSupport()]"],"id":8} 12:16:49 INFO reader-main src/vim.rs:386 <= None {"id": 8, "jsonrpc": "2.0", "result": [null, 0]} 12:16:49 INFO main src/languageclient.rs:46 gather_args: [("rootPath", "v:null"), ("hasSnippetSupport", "s:hasSnippetSupport()")] = [Null, Number(0)] 12:16:49 INFO main src/vim.rs:90 => None {"jsonrpc":"2.0","method":"s:Echomsg","params":["LanguageClient project root: /home/martijn"],"id":9} 12:16:49 INFO reader-main src/vim.rs:386 <= None {"id": 9, "jsonrpc": "2.0", "result": 0} 12:16:49 INFO main src/languageclient.rs:674 Project root: /home/martijn 12:16:49 WARN main src/languageclient.rs:681 Failed to get initializationOptions: No such file or directory (os error 2) 12:16:49 INFO main src/vim.rs:90 => Some("html") {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"textDocument":{"completion":{"completionItem":{"snippetSupport":false}}},"workspace":{"applyEdit":true,"didChangeWatchedFiles":{"dynamicRegistration":true}}},"processId":32266,"rootPath":"/home/martijn","rootUri":"file:///home/martijn","trace":"off"},"id":10} 12:16:50 INFO reader-html src/vim.rs:386 <= Some("html") {"jsonrpc":"2.0","id":10,"result":{"capabilities":{"textDocumentSync":1,"hoverProvider":true,"documentHighlightProvider":true,"documentRangeFormattingProvider":false,"documentLinkProvider":{"resolveProvider":false},"documentSymbolProvider":true,"definitionProvider":true,"signatureHelpProvider":{"triggerCharacters":["("]},"referencesProvider":true,"colorProvider":{},"foldingRangeProvider":true}}} 12:16:50 INFO main src/languageclient.rs:733 End initialize 12:16:50 INFO main src/languageclient.rs:511 Begin register NCM source 12:16:50 INFO main src/vim.rs:90 => None {"jsonrpc":"2.0","method":"eval","params":["exists('g:cm_matcher')"],"id":11} 12:16:50 INFO reader-main src/vim.rs:386 <= None {"id": 11, "jsonrpc": "2.0", "result": 0} 12:16:50 INFO main src/languageclient.rs:744 Begin initialized 12:16:50 INFO main src/languageclient.rs:46 gather_args: [LanguageId] = [String("html")] 12:16:50 INFO main src/vim.rs:90 => Some("html") {"jsonrpc":"2.0","method":"initialized","params":{}} 12:16:50 INFO main src/languageclient.rs:751 End initialized 12:16:50 WARN main src/languageclient.rs:2554 Failed to get workspace settings: No such file or directory (os error 2) 12:16:50 INFO main src/languageclient.rs:1516 Begin textDocument/didOpen 12:16:50 INFO main src/languageclient.rs:29 Some arguments are not available. Requesting from vim. Keys: ["text"]. Exps: ["LSP#text()"] 12:16:50 INFO main src/vim.rs:90 => None {"jsonrpc":"2.0","method":"eval","params":["[LSP#text()]"],"id":12} 12:16:50 INFO reader-main src/vim.rs:386 <= None {"id": 12, "jsonrpc": "2.0", "result": [["<!DOCTYPE html>", "", "", "<meta charset=\"UTF-8\">", "Title of the document", "", "", "", "Content of the document......", "", "", "", ""]]} 12:16:50 INFO main src/languageclient.rs:46 gather_args: [Buftype, LanguageId, Filename, Text] = [String(""), String("html"), String("/home/martijn/Desktop/test.html"), Array([String("<!DOCTYPE html>"), String(""), String(""), String("<meta charset=\"UTF-8\">"), String("Title of the document"), String(""), String(""), String(""), String("Content of the document......"), String(""), String(""), String(""), String("")])] 12:16:50 INFO main src/vim.rs:90 => Some("html") {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"html","text":"<!DOCTYPE html>\n\n\n<meta charset=\"UTF-8\">\nTitle of the document\n\n\n\nContent of the document......\n\n\n\n","uri":"file:///home/martijn/Desktop/test.html","version":0}}} 12:16:50 INFO main src/vim.rs:90 => None {"jsonrpc":"2.0","method":"execute","params":["setlocal omnifunc=LanguageClient#complete"],"id":13} 12:16:50 INFO reader-main src/vim.rs:386 <= None {"id": 13, "jsonrpc": "2.0", "result": 0} 12:16:50 INFO main src/vim.rs:90 => None {"jsonrpc":"2.0","method":"s:ExecuteAutocmd","params":["LanguageClientBufReadPost"],"id":14} 12:16:50 INFO reader-main src/vim.rs:386 <= None {"id": 14, "jsonrpc": "2.0", "result": 0} 12:16:50 INFO main src/languageclient.rs:1555 End textDocument/didOpen 12:16:50 INFO main src/languageclient.rs:1560 Begin textDocument/didChange 12:16:50 INFO main src/languageclient.rs:46 gather_args: [Buftype, LanguageId, Filename] = [String(""), String("html"), String("/home/martijn/Desktop/test.html")] 12:16:50 INFO main src/languageclient.rs:29 Some arguments are not available. Requesting from vim. Keys: ["text"]. Exps: ["LSP#text()"] 12:16:50 INFO main src/vim.rs:90 => None {"jsonrpc":"2.0","method":"eval","params":["[LSP#text()]"],"id":15} 12:16:50 INFO reader-main src/vim.rs:386 <= None {"id": 15, "jsonrpc": "2.0", "result": [["<!DOCTYPE html>", "", "", "<meta charset=\"UTF-8\">", "Title of the document", "", "", "", "Content of the document......", "", "", "", ""]]} 12:16:50 INFO main src/languageclient.rs:46 gather_args: [Text] = [Array([String("<!DOCTYPE html>"), String(""), String(""), String("<meta charset=\"UTF-8\">"), String("Title of the document"), String(""), String(""), String(""), String("Content of the document......"), String(""), String(""), String(""), String("")])] 12:16:50 INFO main src/languageclient.rs:1584 Texts equal. Skipping didChange. 12:16:50 INFO main src/vim.rs:90 => None {"jsonrpc":"2.0","method":"s:ExecuteAutocmd","params":["LanguageClientStarted"],"id":16} 12:16:50 INFO reader-main src/vim.rs:386 <= None {"id": 16, "jsonrpc": "2.0", "result": 0} 12:16:50 INFO main src/languageclient.rs:1975 End languageClient/handleBufReadPost 12:16:50 INFO main src/languageclient.rs:2032 Begin languageClient/handleCursorMoved 12:16:50 INFO main src/languageclient.rs:46 gather_args: [Buftype, Filename, Line] = [String(""), String("/home/martijn/Desktop/test.html"), Number(0)] 12:16:50 INFO main src/languageclient.rs:1980 Begin languageClient/handleTextChanged 12:16:50 INFO main src/languageclient.rs:46 gather_args: [Buftype, Filename] = [String(""), String("/home/martijn/Desktop/test.html")] 12:16:50 INFO main src/languageclient.rs:1560 Begin textDocument/didChange 12:16:50 INFO main src/languageclient.rs:46 gather_args: [Buftype, LanguageId, Filename] = [String(""), String("html"), String("/home/martijn/Desktop/test.html")] 12:16:50 INFO main src/languageclient.rs:29 Some arguments are not available. Requesting from vim. Keys: ["text"]. Exps: ["LSP#text()"] 12:16:50 INFO main src/vim.rs:90 => None {"jsonrpc":"2.0","method":"eval","params":["[LSP#text()]"],"id":17} 12:16:50 INFO reader-main src/vim.rs:386 <= None {"id": 17, "jsonrpc": "2.0", "result": [["<!DOCTYPE html>", "", "", "<meta charset=\"UTF-8\">", "Title of the document", "", "", "", "Content of the document......", "", "", "", ""]]} 12:16:50 INFO main src/languageclient.rs:46 gather_args: [Text] = [Array([String("<!DOCTYPE html>"), String(""), String(""), String("<meta charset=\"UTF-8\">"), String("Title of the document"), String(""), String(""), String(""), String("Content of the document......"), String(""), String(""), String(""), String("")])] 12:16:50 INFO main src/languageclient.rs:1584 Texts equal. Skipping didChange. 12:16:50 INFO main src/languageclient.rs:2005 End languageClient/handleTextChanged 12:16:50 INFO reader-html src/vim.rs:386 <= Some("html") {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/martijn/Desktop/test.html","diagnostics":[]}} 12:16:50 INFO main src/languageclient.rs:1674 Begin textDocument/publishDiagnostics 12:16:50 INFO main src/vim.rs:90 => None {"jsonrpc":"2.0","method":"setqflist","params":[[],"r"],"id":18} 12:16:50 INFO reader-main src/vim.rs:386 <= None {"id": 18, "jsonrpc": "2.0", "result": 0} 12:16:50 INFO main src/vim.rs:90 => None {"jsonrpc":"2.0","method":"eval","params":["LSP#filename()"],"id":19} 12:16:50 INFO reader-main src/vim.rs:386 <= None {"id": 19, "jsonrpc": "2.0", "result": "/home/martijn/Desktop/test.html"} 12:16:50 INFO main src/languageclient.rs:394 Command to update signs: echo 12:16:50 INFO main src/vim.rs:90 => None {"jsonrpc":"2.0","method":"execute","params":["echo"],"id":20} 12:16:50 INFO reader-main src/vim.rs:386 <= None {"id": 20, "jsonrpc": "2.0", "result": 0} 12:16:50 INFO main src/vim.rs:90 => None {"jsonrpc":"2.0","method":"nvim_buf_add_highlight","params":[0,0,"Error",1,1,1],"id":21} 12:16:50 INFO reader-main src/vim.rs:386 <= None {"id": 21, "jsonrpc": "2.0", "result": 1} 12:16:50 INFO main src/vim.rs:90 => None {"jsonrpc":"2.0","method":"nvim_buf_clear_highlight","params":[0,1,1,-1],"id":22} 12:16:50 INFO reader-main src/vim.rs:386 <= None {"id": 22, "jsonrpc": "2.0", "result": null} 12:16:50 INFO main src/vim.rs:90 => None {"jsonrpc":"2.0","method":"s:ExecuteAutocmd","params":["LanguageClientDiagnosticsChanged"],"id":23} 12:16:50 INFO reader-main src/vim.rs:386 <= None {"id": 23, "jsonrpc": "2.0", "result": 0} 12:16:50 INFO main src/languageclient.rs:1708 End textDocument/publishDiagnostics 12:16:52 INFO reader-main src/vim.rs:386 <= None {"id": 1, "jsonrpc": "2.0", "method": "textDocument/formatting", "params": {"character": 0, "handle": true, "languageId": "html", "line": 0, "buftype": "", "text": ["<!DOCTYPE html>", "", "", "<meta charset=\"UTF-8\">", "Title of the document", "", "", "", "Content of the document......", "", "", "", ""], "filename": "/home/martijn/Desktop/test.html"}} 12:16:52 INFO main src/languageclient.rs:1560 Begin textDocument/didChange 12:16:52 INFO main src/languageclient.rs:46 gather_args: [Buftype, LanguageId, Filename] = [String(""), String("html"), String("/home/martijn/Desktop/test.html")] 12:16:52 INFO main src/languageclient.rs:46 gather_args: [Text] = [Array([String("<!DOCTYPE html>"), String(""), String(""), String("<meta charset=\"UTF-8\">"), String("Title of the document"), String(""), String(""), String(""), String("Content of the document......"), String(""), String(""), String(""), String("")])] 12:16:52 INFO main src/languageclient.rs:1584 Texts equal. Skipping didChange. 12:16:52 INFO main src/languageclient.rs:1264 Begin textDocument/formatting 12:16:52 INFO main src/languageclient.rs:46 gather_args: [Buftype, LanguageId, Filename, Handle] = [String(""), String("html"), String("/home/martijn/Desktop/test.html"), Bool(true)] 12:16:52 INFO main src/vim.rs:90 => None {"jsonrpc":"2.0","method":"eval","params":["[shiftwidth(), &expandtab]"],"id":24} 12:16:52 INFO reader-main src/vim.rs:386 <= None {"id": 24, "jsonrpc": "2.0", "result": [4, 1]} 12:16:52 INFO main src/vim.rs:90 => Some("html") {"jsonrpc":"2.0","method":"textDocument/formatting","params":{"options":{"insertSpaces":true,"tabSize":4},"textDocument":{"uri":"file:///home/martijn/Desktop/test.html"}},"id":25} 12:16:52 INFO reader-html src/vim.rs:386 <= Some("html") {"jsonrpc":"2.0","id":25,"error":{"code":-32601,"message":"Unhandled method textDocument/formatting"}} 12:16:52 ERROR main src/vim.rs:57 Error handling message: Unhandled method textDocument/formatting

Message: {"jsonrpc":"2.0","method":"textDocument/formatting","params":{"buftype":"","character":0,"filename":"/home/martijn/Desktop/test.html","handle":true,"languageId":"html","line":0,"text":["<!DOCTYPE html>","","","<meta charset=\"UTF-8\">","Title of the document","","","","Content of the document......","","","",""]},"id":1}

Error: ErrorMessage { msg: "Unhandled method textDocument/formatting" } 12:16:52 INFO main src/vim.rs:90 => None {"jsonrpc":"2.0","error":{"code":-32603,"message":"Unhandled method textDocument/formatting"},"id":1}



## Current Behavior
Formatting in HTML mode returns the following error: `Unhandled method textDocument/formatting `

## Expected Behavior
Formatting in HTML mode formats the HTML in the buffer

> Please understand the more detailed information provided, the sooner a issue
could be resolved. Low quality bug reports might be closed directly.)

[troubleshooting]: https://github.com/autozimu/LanguageClient-neovim/blob/next/INSTALL.md#6-troubleshooting
[min-init.vim]: https://github.com/autozimu/LanguageClient-neovim/blob/next/min-init.vim
DeltaEvo commented 6 years ago

vscode-html-languageserver-bin only handle Range Formatting and not textDocument/formatting, however you can send a Range Formatting request with the full file as Range

autozimu commented 6 years ago

Language server issue. Closing.

MartenBE commented 6 years ago

Aha I see, I will do that. @DeltaEvo, is this also the case for the css and json vscode languageservers?