nvimdev / lspsaga.nvim

improve neovim lsp experience
MIT License
3.47k stars 288 forks source link

`indented-code-blocks` no syntax highlighting #1322

Closed scottming closed 1 year ago

scottming commented 1 year ago

Describe the bug

I noticed that the hover module has some logic to handle in_codeblock, but it seems not to handle the case of indented-code-blocks.

This results in many code blocks not being displayed properly.

Steps to reproduce

I think you do not need the minimal config(if needed, pls let me know)

This is the hover response:

[DEBUG][2023-10-15 10:20:50] .../vim/lsp/rpc.lua:387    "rpc.receive"   {
  id = 6,
  jsonrpc = "2.0",
  result = {
    contents = {
      kind = "markdown",
      value = '```elixir\nEnum\n```\n\nFunctions for working with collections (known as enumerables).\n\nIn Elixir, an enumerable is any data type that implements the\n`Enumerable` protocol. `List`s (`[1, 2, 3]`), `Map`s (`%{foo: 1, bar: 2}`)\nand `Range`s (`1..3`) are common data types used as enumerables:\n\n    iex> Enum.map([1, 2, 3], fn x -> x * 2 end)\n    [2, 4, 6]\n\n    iex> Enum.sum([1, 2, 3])\n    6\n\n    iex> Enum.map(1..3, fn x -> x * 2 end)\n    [2, 4, 6]\n\n    iex> Enum.sum(1..3)\n    6\n\n    iex> map = %{"a" => 1, "b" => 2}\n    iex> Enum.map(map, fn {k, v} -> {k, v * 2} end)\n    [{"a", 2}, {"b", 4}]\n\nHowever, many other enumerables exist in the language, such as `MapSet`s\nand the data type returned by `File.stream!/3` which allows a file to be\ntraversed as if it was an enumerable.\n\nThe functions in this module work in linear time. This means that, the\ntime it takes to perform an operation grows at the same rate as the length\nof the enumerable. This is expected on operations such as `Enum.map/2`.\nAfter all, if we want to traverse every element on a list, the longer the\nlist, the more elements we need to traverse, and the longer it will take.\n\nThis linear behaviour should also be expected on operations like `count/1`,\n`member?/2`, `at/2` and similar. While Elixir does allow data types to\nprovide performant variants for such operations, you should not expect it\nto always be available, since the `Enum` module is meant to work with a\nlarge variety of data types and not all data types can provide optimized\nbehaviour.\n\nFinally, note the functions in the `Enum` module are eager: they will\ntraverse the enumerable as soon as they are invoked. This is particularly\ndangerous when working with infinite enumerables. In such cases, you should\nuse the `Stream` module, which allows you to lazily express computations,\nwithout traversing collections, and work with possibly infinite collections.\nSee the `Stream` module for examples and documentation.\n'
    },
    range = {
      ["end"] = {
        character = 10,
        line = 47
      },
      start = {
        character = 6,
        line = 47
      }
    }
  }
}
CleanShot 2023-10-15 at 10 20 57@2x

Expected behavior

Like zed or VScode:

CleanShot 2023-10-15 at 10 21 40@2x

Zed

Neovim version (nvim -v)

0.9.2

lspsaga commit

798c1b650d541bb14492fb54d533673162fb848f

Terminal name/version

alacritty

glepnir commented 1 year ago

I guess :lua vim.lsp.buf.hover also doesn't render it correct right ?

scottming commented 1 year ago

I guess :lua vim.lsp.buf.hover also doesn't render it correct right ?

Yes, it doesn't.

glepnir commented 1 year ago

limit of tui :) .. could you try builtin-hover by using neovim-nightly . it has a big improve that render hover by treesitter too. but i guess it also not work. treesitter cant not parse it correct i think T.T

scottming commented 1 year ago

I can't use neovim-nightly, it broke many of my plugins, and the treesitter.

glepnir commented 1 year ago

just use a min config is enough

vim.opt.rtp:append('path/to/lspcongig')
---start your server

then nvim --clean -u min.lua

glepnir commented 1 year ago

I think this is not a bug. in tui something not work

scottming commented 1 year ago
CleanShot 2023-10-15 at 15 06 18@2x

yeah, it also has this problem.

glepnir commented 1 year ago

okay. that's the tui works way. if want render it correctly there may need some special works on doc format ...

scottming commented 1 year ago

@glepnir Sorry, I just submitted a screenshot of lspsaga hover, and the screenshot of vim.lsp.buf.hover() looks like this:

CleanShot 2023-10-15 at 15 14 20@2x

It looks like it's already recognized as code blocks, but no specific language is set. So it looks grayed out

glepnir commented 1 year ago

yep it do lots of work on markdown render . saga just simply enable markdown parser. when 0.10 release i will remove hover from saga .