Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation not showing #151

Closed
idelice opened this issue Oct 20, 2024 · 18 comments
Closed

Documentation not showing #151

idelice opened this issue Oct 20, 2024 · 18 comments
Labels
bug Something isn't working LSP Related to a specific LSP

Comments

@idelice
Copy link

idelice commented Oct 20, 2024

Pressing <C-space (default keymap) wont show the documentation.

I tried setting: auto_show = true, but that didn't do the trick either.

My config:

return {
  "saghen/blink.cmp",
  lazy = false, -- lazy loading handled internally
  -- optional: provides snippets for the snippet source
  dependencies = "rafamadriz/friendly-snippets",

  -- use a release tag to download pre-built binaries
  version = "v0.*",

  opts = {

    keymap = {
      show = "<C-space>",
      hide = "<C-e>",
      accept = "<Tab>",
      select_prev = { "<Up>", "<C-k>" },
      select_next = { "<Down>", "<C-j>" },

      show_documentation = "<C-space>",
      hide_documentation = "<C-space>",
      scroll_documentation_up = "<C-b>",
      scroll_documentation_down = "<C-f>",

      snippet_forward = "<Tab>",
      snippet_backward = "<S-Tab>",
    },

    accept = {
      create_undo_point = true,
      auto_brackets = {
        enabled = true,
        default_brackets = { "(", ")" },
        override_brackets_for_filetypes = {},
        -- Overrides the default blocked filetypes
        force_allow_filetypes = {},
        blocked_filetypes = {},
        -- Synchronously use the kind of the item to determine if brackets should be added
        kind_resolution = {
          enabled = true,
          blocked_filetypes = { "typescriptreact", "javascriptreact", "vue" },
        },
        -- Asynchronously use semantic token to determine if brackets should be added
        semantic_token_resolution = {
          enabled = true,
          blocked_filetypes = {},
          -- How long to wait for semantic tokens to return before assuming no brackets should be added
          timeout_ms = 400,
        },
      },
    },

    trigger = {
      completion = {
        -- 'prefix' will fuzzy match on the text before the cursor
        -- 'full' will fuzzy match on the text before *and* after the cursor
        -- example: 'foo_|_bar' will match 'foo_' for 'prefix' and 'foo__bar' for 'full'
        keyword_range = "prefix",
        -- regex used to get the text when fuzzy matching
        -- changing this may break some sources, so please report if you run into issues
        -- todo: shouldnt this also affect the accept command? should this also be per language?
        keyword_regex = "[%w_\\-]",
        -- after matching with keyword_regex, any characters matching this regex at the prefix will be excluded
        exclude_from_prefix_regex = "[\\-]",
        -- LSPs can indicate when to show the completion window via trigger characters
        -- however, some LSPs (*cough* tsserver *cough*) return characters that would essentially
        -- always show the window. We block these by default
        blocked_trigger_characters = { " ", "\n", "\t" },
        -- when true, will show the completion window when the cursor comes after a trigger character when entering insert mode
        show_on_insert_on_trigger_character = true,
        -- list of additional trigger characters that won't trigger the completion window when the cursor comes after a trigger character when entering insert mode
        show_on_insert_blocked_trigger_characters = { "'", '"' },
        -- when false, will not show the completion window when in a snippet
        show_in_snippet = false,
      },

      signature_help = {
        enabled = true,
        -- blocked_trigger_characters = {},
        -- blocked_retrigger_characters = {},
        -- when true, will show the signature help window when the cursor comes after a trigger character when entering insert mode
        show_on_insert_on_trigger_character = true,
      },
    },

    fuzzy = {
      -- frencency tracks the most recently/frequently used items and boosts the score of the item
      use_frecency = true,
      -- proximity bonus boosts the score of items with a value in the buffer
      use_proximity = true,
      max_items = 200,
      -- controls which sorts to use and in which order, these three are currently the only allowed options
      sorts = { "label", "kind", "score" },

      prebuiltBinaries = {
        -- Whether or not to automatically download a prebuilt binary from github. If this is set to `false`
        -- you will need to manually build the fuzzy binary dependencies by running `cargo build --release`
        download = true,
        -- When downloading a prebuilt binary force the downloader to resolve this version. If this is uset
        -- then the downloader will attempt to infer the version from the checked out git tag (if any).
        --
        -- Beware that if the FFI ABI changes while tracking main then this may result in blink breaking.
        forceVersion = nil,
      },
    },

    sources = {
      -- similar to nvim-cmp's sources, but we point directly to the source's lua module
      -- multiple groups can be provided, where it'll fallback to the next group if the previous
      -- returns no completion items
      -- WARN: This API will have breaking changes during the beta
      providers = {
        { "blink.cmp.sources.lsp", name = "LSP" },
        { "blink.cmp.sources.path", name = "Path", score_offset = 3 },
        { "blink.cmp.sources.snippets", name = "Snippets", score_offset = -3 },
        { "blink.cmp.sources.buffer", name = "Buffer", fallback_for = { "LSP" } },
      },
      -- WARN: **For reference only** to see what options are available. **See above for the default config**
      providers = {
        -- all of these properties work on every source
        {
          "blink.cmp.sources.lsp",
          name = "LSP",
          keyword_length = 0,
          score_offset = 0,
          trigger_characters = { "f", "o", "o" },
        },
        -- the following two sources have additional options
        {
          "blink.cmp.sources.path",
          name = "Path",
          score_offset = 3,
          opts = {
            trailing_slash = false,
            label_trailing_slash = true,
            get_cwd = function(context)
              return vim.fn.expand(("#%d:p:h"):format(context.bufnr))
            end,
            show_hidden_files_by_default = true,
          },
        },
        {
          "blink.cmp.sources.snippets",
          name = "Snippets",
          score_offset = -3,
          -- similar to https://github.com/garymjr/nvim-snippets
          opts = {
            friendly_snippets = true,
            search_paths = { vim.fn.stdpath("config") .. "/snippets" },
            global_snippets = { "all" },
            extended_filetypes = {},
            ignored_filetypes = {},
          },
        },
        {
          "blink.cmp.sources.buffer",
          name = "Buffer",
          fallback_for = { "LSP" },
        },
      },
    },

    windows = {
      autocomplete = {
        min_width = 60,
        max_height = 20,
        border = "none",
        winhighlight = "Normal:BlinkCmpMenu,FloatBorder:BlinkCmpMenuBorder,CursorLine:BlinkCmpMenuSelection,Search:None",
        -- keep the cursor X lines away from the top/bottom of the window
        scrolloff = 2,
        -- which directions to show the window,
        -- falling back to the next direction when there's not enough space
        direction_priority = { "s", "n" },
        -- Controls whether the completion window will automatically show when typing
        auto_show = true,
        -- Controls how the completion items are selected
        -- 'preselect' will automatically select the first item in the completion list
        -- 'manual' will not select any item by default
        -- 'auto_insert' will not select any item by default, and insert the completion items automatically when selecting them
        selection = "preselect",
        -- Controls how the completion items are rendered on the popup window
        -- 'simple' will render the item's kind icon the left alongside the label
        -- 'reversed' will render the label on the left and the kind icon + name on the right
        -- 'minimal' will render the label on the left and the kind name on the right
        -- 'function(blink.cmp.CompletionRenderContext): blink.cmp.Component[]' for custom rendering
        draw = "reversed",
        -- Controls the cycling behavior when reaching the beginning or end of the completion list.
        cycle = {
          -- When `true`, calling `select_next` at the *bottom* of the completion list will select the *first* completion item.
          from_bottom = true,
          -- When `true`, calling `select_prev` at the *top* of the completion list will select the *last* completion item.
          from_top = true,
        },
      },
      documentation = {
        min_width = 10,
        max_width = 70,
        max_height = 20,
        border = "padded",
        winhighlight = "Normal:BlinkCmpDoc,FloatBorder:BlinkCmpDocBorder,CursorLine:BlinkCmpDocCursorLine,Search:None",
        -- which directions to show the documentation window,
        -- for each of the possible autocomplete window directions,
        -- falling back to the next direction when there's not enough space
        direction_priority = {
          autocomplete_north = { "e", "w", "n", "s" },
          autocomplete_south = { "e", "w", "s", "n" },
        },
        -- Controls whether the documentation window will automatically show when selecting a completion item
        auto_show = true,
        auto_show_delay_ms = 500,
        update_delay_ms = 50,
      },
      signature_help = {
        min_width = 1,
        max_width = 100,
        max_height = 10,
        border = "padded",
        winhighlight = "Normal:BlinkCmpSignatureHelp,FloatBorder:BlinkCmpSignatureHelpBorder",
      },
    },

    highlight = {
      ns = vim.api.nvim_create_namespace("blink_cmp"),
      -- sets the fallback highlight groups to nvim-cmp's highlight groups
      -- useful for when your theme doesn't support blink.cmp
      -- will be removed in a future release, assuming themes add support
      use_nvim_cmp_as_default = true,
    },

    -- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
    -- adjusts spacing to ensure icons are aligned
    nerd_font_variant = "normal",

    -- don't show completions or signature help for these filetypes. Keymaps are also disabled.
    blocked_filetypes = {},

    kind_icons = {
      Text = "󰉿",
      Method = "󰊕",
      Function = "󰊕",
      Constructor = "󰒓",

      Field = "󰜢",
      Variable = "󰆦",
      Property = "󰖷",

      Class = "󱡠",
      Interface = "󱡠",
      Struct = "󱡠",
      Module = "󰅩",

      Unit = "󰪚",
      Value = "󰦨",
      Enum = "󰦨",
      EnumMember = "󰦨",

      Keyword = "󰻾",
      Constant = "󰏿",

      Snippet = "󱄽",
      Color = "󰏘",
      File = "󰈔",
      Reference = "󰬲",
      Folder = "󰉋",
      Event = "󱐋",
      Operator = "󰪚",
      TypeParameter = "󰬛",
    },
  },
}
@idelice idelice changed the title Documentatio not showing Documentation not showing Oct 20, 2024
@Saghen
Copy link
Owner

Saghen commented Oct 20, 2024

What LSPs have you tested with? Also, you should drop the large sources.providers config that's purely for reference

@idelice
Copy link
Author

idelice commented Oct 21, 2024

What LSPs have you tested with? Also, you should drop the large sources.providers config that's purely for reference

using JDTLS (java)

@idelice
Copy link
Author

idelice commented Oct 21, 2024

I can confirm that the documentation window is showing up on typescript-react (vtsls) files, but not on java (jdtls) files.

Haven't tested other lsp's

@Saghen
Copy link
Owner

Saghen commented Oct 21, 2024

Please try again with ffc4282

@allengueco
Copy link

Please try again with ffc4282

I faced the same issue as above and I tested with this commit. It works, the documentation window appears but only the signature is shown.

image

@idelice
Copy link
Author

idelice commented Oct 22, 2024

Please try again with ffc4282

I faced the same issue as above and I tested with this commit. It works, the documentation window appears but only the signature is shown.

image

I can confirm same behaviour from my side.

@Saghen Saghen added bug Something isn't working LSP Related to a specific LSP labels Oct 24, 2024
@idelice
Copy link
Author

idelice commented Oct 25, 2024

I did some debugging to see why no documentation where showing, and why it does show in nvim-cmp.

This is the entry table available before attaching documentation to the view, and what I noticed is the item.documentation field available whereas that field is non-existent in blink.cmp.

item = table: 0x0109a59a58
    insertTextFormat = 2
    kind = 7additionalTextEdits = table: 0x0106cd1160
    sortText = 999999148
    insertText = StringUtilstextEdit = table: 0x0106f12d20
    filterText = StringUtilscommand = table: 0x0106cd13d0data = table: 0x0109a59c60
    insertTextMode = 2
    detail = ext.plantuml.com.google.zxing.common.StringUtilslabelDetails = table: 0x0106b788f8documentation = table: 0x0106f12c68
     kind = markdown
     value = Common string-related functions.
           
            *  **Author:**
               
                *  Sean Owen
    textEditText = StringUtils
    label = StringUtils

I'm not sure the author of nvim-cmp is doing some customization in order to populate item table with documentation but i doubt it.

I've used the exact same (java) file for testing purposes.

I hope this you can give a better explanation on this matter @Saghen than me.

@allengueco
Copy link

Maybe this snippet from nvim-cmp is relevant?

Thoughts? @Saghen

@Saghen
Copy link
Owner

Saghen commented Nov 9, 2024

Are you folks still running into this issue? Unfortunately I'm unable to setup jdtls on my end so I'm unable to continue without some more info from your end. You might want to try looking at the .resolve call made in windows/documentation.lua

@windowsrefund

This comment was marked as off-topic.

@allengueco
Copy link

allengueco commented Nov 9, 2024

Are you folks still running into this issue? Unfortunately I'm unable to setup jdtls on my end so I'm unable to continue without some more info from your end. You might want to try looking at the .resolve call made in windows/documentation.lua

I unfortunately am still running into this issue. I am new to configuring Neovim/its plugins, so I cannot help with this - but I can point you to a guide from lsp-zero that can help you set up jdtls (the guide itself doesn't even use lsp-zero).

@windowsrefund

This comment was marked as off-topic.

@Saghen
Copy link
Owner

Saghen commented Nov 11, 2024

@windowsrefund Fixed on main, you're talking about something different so minimized the comments

@Saghen Saghen closed this as completed in fb9f374 Nov 11, 2024
@oysandvik94
Copy link
Contributor

@Saghen I am still seeing the issue. I might try and debug it later by building from source.
Blink:
image

Cmp:
image

@Saghen
Copy link
Owner

Saghen commented Nov 11, 2024

It looks like the capabilities must be passed to jdtls to get it to return the documentation. Is this also the case for nvim-cmp?

require('jdtls').start_or_attach({
  capabilities = require('blink.cmp').get_lsp_capabilities(),
  ...
})

@oysandvik94
Copy link
Contributor

oysandvik94 commented Nov 11, 2024

@Saghen That was it! I had this cryptic code in my jdtls config so I missed that:

		local ok_cmp, cmp_lsp = pcall(require, "cmp_nvim_lsp")
		cache_vars.capabilities = ok_cmp and cmp_lsp.default_capabilities()

So it works on master now. Thanks!

@idelice
Copy link
Author

idelice commented Nov 11, 2024

It looks like the capabilities must be passed to jdtls to get it to return the documentation. Is this also the case for nvim-cmp?

require('jdtls').start_or_attach({
  capabilities = require('blink.cmp').get_lsp_capabilities(),
  ...
})

I'm already doing that but i still get no documentation

    jdtls = function(opts)
      opts.capabilities = require("blink.cmp").get_lsp_capabilities()
      return opts
    end,

@Saghen That was it! I had this cryptic code in my jdtls config so I missed that:

		local ok_cmp, cmp_lsp = pcall(require, "cmp_nvim_lsp")
		cache_vars.capabilities = ok_cmp and cmp_lsp.default_capabilities()

So it works on master now. Thanks!

How exactly did you get it to work?

@allengueco
Copy link

It looks like the capabilities must be passed to jdtls to get it to return the documentation. Is this also the case for nvim-cmp?

require('jdtls').start_or_attach({
  capabilities = require('blink.cmp').get_lsp_capabilities(),
  ...
})

I'm already doing that but i still get no documentation

    jdtls = function(opts)
      opts.capabilities = require("blink.cmp").get_lsp_capabilities()
      return opts
    end,

@Saghen That was it! I had this cryptic code in my jdtls config so I missed that:

		local ok_cmp, cmp_lsp = pcall(require, "cmp_nvim_lsp")
		cache_vars.capabilities = ok_cmp and cmp_lsp.default_capabilities()

So it works on master now. Thanks!

How exactly did you get it to work?

Not sure if you have already done so, but I had to use the main branch in my lazy config instead of version = "v0.*"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working LSP Related to a specific LSP
Projects
None yet
Development

No branches or pull requests

5 participants