diff --git a/integration-tests/cypress/e2e/cmp-rg/basic_spec.cy.ts b/integration-tests/cypress/e2e/cmp-rg/basic_spec.cy.ts index 71bfb34..7b1ccd3 100644 --- a/integration-tests/cypress/e2e/cmp-rg/basic_spec.cy.ts +++ b/integration-tests/cypress/e2e/cmp-rg/basic_spec.cy.ts @@ -15,6 +15,9 @@ describe("the basics", () => { cy.typeIntoTerminal("hip") cy.contains("Hippopotamus123 (rg)") + + // should show documentation with more details about the match + cy.contains("Hippopotamus123 is my password") }) }) }) diff --git a/integration-tests/test-environment/other-file.txt b/integration-tests/test-environment/other-file.txt index b612bbd..20a6c71 100644 --- a/integration-tests/test-environment/other-file.txt +++ b/integration-tests/test-environment/other-file.txt @@ -1,2 +1,3 @@ This file contains some text that can be matched in integration-tests. -Hippopotamus123 +Hippopotamus123 is my password. +Hippopotamus234 was my previous password. diff --git a/integration-tests/test-environment/test-setup.lua b/integration-tests/test-environment/test-setup.lua index 1e3c3e7..4460982 100644 --- a/integration-tests/test-environment/test-setup.lua +++ b/integration-tests/test-environment/test-setup.lua @@ -71,6 +71,10 @@ local plugins = { autocomplete = { max_height = 25, }, + documentation = { + auto_show = true, + auto_show_delay_ms = 0, + }, }, }, }, diff --git a/lua/blink-cmp-rg/init.lua b/lua/blink-cmp-rg/init.lua index ac90af1..b788639 100644 --- a/lua/blink-cmp-rg/init.lua +++ b/lua/blink-cmp-rg/init.lua @@ -79,9 +79,16 @@ function RgSource:get_completions(context, resolve) item = ok and item or {} if item.type == "match" then + assert( + item.data.lines.text, + "ripgrep output missing item.data.lines.text for item " + .. vim.inspect(item) + ) + local documentation = item.data.lines.text or "" for _, submatch in ipairs(item.data.submatches) do ---@diagnostic disable-next-line: missing-fields items[submatch.match.text] = { + documentation = documentation, source_id = "blink-cmp-rg", label = submatch.match.text .. " (rg)", insertText = submatch.match.text,