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

fix: add coq_nvim completion integration #1597

Merged
merged 1 commit into from
Oct 31, 2024
Merged
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
30 changes: 26 additions & 4 deletions lua/neorg/modules/core/integrations/coq_nvim/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,39 @@ module.public = {
return callback()
end

local completion_cache = module.public.invoke_completion_engine(args)
local row, col = unpack(args.pos)
local line = args.line
local before_char = line:sub(#line, #line)
-- Neorg requires a nvim-compe like context nvim-compe defines
-- the following fields. Not all of them are used by Neorg, but
-- they are left here for future reference
local context = {
start_offset = nil,
benlubas marked this conversation as resolved.
Show resolved Hide resolved
char = col + 1,
before_char = before_char,
line = line,
column = nil,
buffer = nil,
line_number = row + 1,
previous_context = nil,
full_line = line,
}
local completion_cache = module.public.invoke_completion_engine(context)
local prev = line:match("({.*)$")

if completion_cache.options.pre then
completion_cache.options.pre(args)
completion_cache.options.pre(context)
end

local completions = vim.deepcopy(completion_cache.items)

for index, element in ipairs(completions) do
local word = element
local label = element
-- coq_nvim requries at least 2 exact prefix characters by
-- default. Users could chagnge this setting, but instead
-- we are providing the start of the match (for links) so
-- coq_nvim doesnt' filter our results
local word = (prev or "") .. element
local label = (prev or "") .. element
if type(element) == "table" then
word = element[1]
label = element.label
Expand Down
Loading