1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

nvim-lspのDiagnosticをquickfixで表示する

Last updated at Posted at 2020-06-24

neovimのissueで見つけた設定が動かなくなってたので、修正したものをとりいそぎ。

lspから返ってくるresult.diagnosticsをerrorformatに変換してquickfixに渡します。
この設定ではquickfixにもlocationlistにも入れています(欲張りなので)。

lua << EOF
do
  local method = "textDocument/publishDiagnostics"
  local default_callback = vim.lsp.callbacks[method]
  vim.lsp.callbacks[method] = function(err, method, result, client_id)
    default_callback(err, method, result, client_id)
    if result and result.diagnostics then
      for _, v in ipairs(result.diagnostics) do
        v.uri = v.uri or result.uri
        v.bufnr = vim.uri_to_bufnr(v.uri)
        v.lnum = v.range.start.line + 1
        v.col = v.range.start.character + 1
        v.text = v.message
      end
      vim.lsp.util.set_qflist(result.diagnostics)
      vim.lsp.util.set_loclist(result.diagnostics)
    end
  end
end
EOF

nvimのbuiltin lsp、なんか異様に速い気がするのでよいですね。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?