diff --git a/integration-tests/package.json b/integration-tests/package.json index 1dbe350..a9e9e7e 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -17,7 +17,7 @@ "zod": "3.23.8" }, "devDependencies": { - "@tui-sandbox/library": "7.2.0", + "@tui-sandbox/library": "7.2.1", "@types/node": "22.8.7", "@types/tinycolor2": "1.4.6", "@typescript-eslint/eslint-plugin": "8.12.2", diff --git a/integration-tests/test-environment/.config/nvim/init.lua b/integration-tests/test-environment/.config/nvim/init.lua index 0b691de..6a49368 100644 --- a/integration-tests/test-environment/.config/nvim/init.lua +++ b/integration-tests/test-environment/.config/nvim/init.lua @@ -37,6 +37,9 @@ local plugins = { event = "VeryLazy", -- use a release tag to download pre-built binaries version = "v0.*", + + -- to (locally) track nightly builds, use the following: + -- dir = "/Users/mikavilpas/git/blink.cmp/", ---@module 'blink.cmp' ---@type blink.cmp.Config opts = { @@ -58,6 +61,7 @@ local plugins = { }, }, }, + -- configuration for the stable version of blink windows = { autocomplete = { max_height = 25, @@ -69,6 +73,27 @@ local plugins = { max_width = 200, }, }, + + -- 2024-11-28 configuration for the nightly version of blink. mikavilpas + -- uses this for local development, but currently ci uses the stable + -- version + -- + ---@diagnostic disable-next-line: missing-fields + completion = { + ---@diagnostic disable-next-line: missing-fields + documentation = { + ---@diagnostic disable-next-line: missing-fields + window = { + desired_min_height = 30, + }, + auto_show = true, + auto_show_delay_ms = 0, + }, + ---@diagnostic disable-next-line: missing-fields + menu = { + max_height = 25, + }, + }, }, }, { diff --git a/lua/blink-ripgrep/init.lua b/lua/blink-ripgrep/init.lua index 53e1d08..287bafd 100644 --- a/lua/blink-ripgrep/init.lua +++ b/lua/blink-ripgrep/init.lua @@ -14,26 +14,33 @@ ---@field get_completions? fun(self: blink.cmp.Source, context: blink.cmp.Context, callback: fun(response: blink.cmp.CompletionResponse | nil)): nil local RgSource = {} -local starting_word_character = vim.lpeg.R("az", "AZ", "09", "\128\255") -local word_character = starting_word_character - + vim.lpeg.P("_") - + vim.lpeg.P("-") -local non_middle_word_character = vim.lpeg.P(1) - word_character -local non_starting_word_character = vim.lpeg.P(1) - starting_word_character - -local collect_pattern = vim.lpeg.Ct( - ( - non_starting_word_character ^ 0 - * vim.lpeg.C(word_character ^ 1) - * non_middle_word_character ^ 0 - ) ^ 0 -) +local word_pattern +do + -- match an ascii character as well as unicode continuation bytes. + -- Technically, unicode continuation bytes need to be applied in order to + -- construct valid utf-8 characters, but right now we trust that the user + -- only types valid utf-8 in their project. + local char = vim.lpeg.R("az", "AZ", "09", "\128\255") + + local non_starting_word_character = vim.lpeg.P(1) - char + local word_character = char + vim.lpeg.P("_") + vim.lpeg.P("-") + local non_middle_word_character = vim.lpeg.P(1) - word_character + + word_pattern = vim.lpeg.Ct( + ( + non_starting_word_character ^ 0 + * vim.lpeg.C(word_character ^ 1) + * non_middle_word_character ^ 0 + ) ^ 0 + ) +end ---@param text_before_cursor string "The text of the entire line before the cursor" ---@return string function RgSource.match_prefix(text_before_cursor) - local matches = vim.lpeg.match(collect_pattern, text_before_cursor) - return matches and matches[#matches] or "" + local matches = vim.lpeg.match(word_pattern, text_before_cursor) + local last_match = matches and matches[#matches] + return last_match or "" end ---@param context blink.cmp.Context diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ab84e89..0738e1a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -37,8 +37,8 @@ importers: version: 3.23.8 devDependencies: '@tui-sandbox/library': - specifier: 7.2.0 - version: 7.2.0(cypress@13.15.1)(prettier@3.3.3)(type-fest@4.26.1)(typescript@5.6.3) + specifier: 7.2.1 + version: 7.2.1(cypress@13.15.1)(prettier@3.3.3)(type-fest@4.26.1)(typescript@5.6.3) '@types/node': specifier: 22.8.7 version: 22.8.7 @@ -358,19 +358,19 @@ packages: '@tootallnate/quickjs-emscripten@0.23.0': resolution: {integrity: sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==} - '@trpc/client@11.0.0-rc.643': - resolution: {integrity: sha512-Y7coaGHPxnzW9nZrigXInjSw3QoQ2IOIBnBaalC4m5B0Tt72j3UTc4gnELKDWxD/u3tRV7EoSnf8MvFhNsuDHA==} + '@trpc/client@11.0.0-rc.648': + resolution: {integrity: sha512-k4FfLKvJwbosUH8KYyZkC50RJHYtIyJECi5WhRXsvaf9a6lgrTlcA+osq815zYcAHo7wEgR9E9UdSTrpLdAQFQ==} peerDependencies: - '@trpc/server': 11.0.0-rc.643+0914e43c5 + '@trpc/server': 11.0.0-rc.648+77b4d8920 typescript: '>=5.6.2' - '@trpc/server@11.0.0-rc.643': - resolution: {integrity: sha512-w8qPtnbvKF441erzLjDX55AcgrC+5wXT3VCyBp8HMCUKJS4Q7LSEmig02Kva+gJ3E6cYTahsQFTDWaVnr26YZA==} + '@trpc/server@11.0.0-rc.648': + resolution: {integrity: sha512-nKW7FNM+QZrY/CVGlX3hFNIdUvbw6pwSJ+HzEF8GIeSJDKLHK7Ke1QJGI2mRW6oF9dCKMBXfuLaYY2dXfjfn7Q==} peerDependencies: typescript: '>=5.6.2' - '@tui-sandbox/library@7.2.0': - resolution: {integrity: sha512-4YLARWba3luoOkTdz9ZURIUT+gplYFubAwwtG1PKMuBjn1uModrFq5Q+amymht+qC721W4UTOiFYQqzqpxPiPw==} + '@tui-sandbox/library@7.2.1': + resolution: {integrity: sha512-Oot33wsISonReNH0vcsN1u6kJSqpTG8ogzl3fLol6qRulGXRWlvfnrUxOW5HQFXla8oypObsel/aNP0X2EpBhg==} hasBin: true peerDependencies: cypress: ^13 @@ -2643,20 +2643,20 @@ snapshots: '@tootallnate/quickjs-emscripten@0.23.0': {} - '@trpc/client@11.0.0-rc.643(@trpc/server@11.0.0-rc.643(typescript@5.6.3))(typescript@5.6.3)': + '@trpc/client@11.0.0-rc.648(@trpc/server@11.0.0-rc.648(typescript@5.6.3))(typescript@5.6.3)': dependencies: - '@trpc/server': 11.0.0-rc.643(typescript@5.6.3) + '@trpc/server': 11.0.0-rc.648(typescript@5.6.3) typescript: 5.6.3 - '@trpc/server@11.0.0-rc.643(typescript@5.6.3)': + '@trpc/server@11.0.0-rc.648(typescript@5.6.3)': dependencies: typescript: 5.6.3 - '@tui-sandbox/library@7.2.0(cypress@13.15.1)(prettier@3.3.3)(type-fest@4.26.1)(typescript@5.6.3)': + '@tui-sandbox/library@7.2.1(cypress@13.15.1)(prettier@3.3.3)(type-fest@4.26.1)(typescript@5.6.3)': dependencies: '@catppuccin/palette': 1.7.1 - '@trpc/client': 11.0.0-rc.643(@trpc/server@11.0.0-rc.643(typescript@5.6.3))(typescript@5.6.3) - '@trpc/server': 11.0.0-rc.643(typescript@5.6.3) + '@trpc/client': 11.0.0-rc.648(@trpc/server@11.0.0-rc.648(typescript@5.6.3))(typescript@5.6.3) + '@trpc/server': 11.0.0-rc.648(typescript@5.6.3) '@xterm/addon-attach': 0.11.0(@xterm/xterm@5.5.0) '@xterm/addon-fit': 0.10.0(@xterm/xterm@5.5.0) '@xterm/xterm': 5.5.0