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

Compat #43

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
25 changes: 25 additions & 0 deletions integration-tests/test-environment/.config/nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -58,6 +61,7 @@ local plugins = {
},
},
},
-- configuration for the stable version of blink
windows = {
autocomplete = {
max_height = 25,
Expand All @@ -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,
},
},
},
},
{
Expand Down
39 changes: 23 additions & 16 deletions lua/blink-ripgrep/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 15 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading