You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for this amazing plugin. Autocompletion was never this hackable and easy.
I'm writing a custom resource, which I'm filter using fzf. Though, I can see (from logs) that fzf is giving me some results, I don't see them in the autocomplete menu.
So can we avoid further filtering from Coq, for some custom resources, may be based on a flag or something?
The custom source,
localfzf=require('lib/fzf_helpers')
locallog=require('lib/log')
localcoq_3p_utils=require('coq_3p/utils')
log.outfile="/tmp/coq_nvim_lua.log"log.level="trace"-- `COQsources` is a global registry of sourcesCOQsources=COQsourcesor {}
COQsources["dd10e3499-7dde-4781-ab52-a7e894da7f7e"] = {
name="TagsFileUsingFzf", -- this is displayed to the clientfn=function(args, callback)
local_row, col=unpack(args.pos)
localline=args.linelocalcurrent_word=coq_3p_utils.cword(line, col)
localitems= {}
log.info("TagsFileUsingFzf: Received word: " ..current_word)
-- label :: display label-- insertText :: string | null, default to `label` if null-- kind :: int ∈ `vim.lsp.protocol.CompletionItemKind`-- detail :: doc popuplocalfile_path="tags"localfile=io.open(file_path, "r")
-- Make sure the file existsiffilethenfile:close()
result=fzf.filter_from_file({file_path=file_path, query=current_word})
log.info("TagsFileUsingFzf: Matches: " ..table.concat(result, "\n"))
log.info("\n\n\n\n\n")
fori, lineinipairs(result) dolocaltag_name, file_path, short_def, tag_type, parent_classforfirst_part, path, definition, type_info, class_infoinstring.gmatch(line, "(%S+)%s+(%S+)%s+(%S+)%s+(%S+)%s+(%S+)") dotag_name=first_partfile_path=pathshort_def=definition:gsub("/^ ", ""):gsub("$/","")
tag_type=type_info:gsub(";", "")
parent_class=class_info:gsub("class:", "")
end-- Capture the required parts using gmatch-- print(tag_name) -- prints: <<-- print(file_path) -- prints: app/migration/utils/logger.rb-- print(short_def) -- prints: def <<(msg)-- print(tag_type) -- prints: f-- print(parent_class) -- prints: Utils.Logger-- Get the first word and the remaining wordslocaldetail=tag_name.." [" ..tag_type.."] " .."\n" ..file_path.."\n" ..short_def.."\n" ..parent_classlocalitem= {
label=tag_name.."" .." [" ..tag_type.."] " .."" ..parent_class,
insertText=tag_name, -- defaults to label if nullkind=vim.lsp.protocol.CompletionItemKind.Text,
detail=detail
}
table.insert(items, item)
endendcallback {
isIncomplete=true,
items=items
}
end,
resolve=function()
end,
exec=function(...)
end
}
fzf_helpers.lua
localfzf= {}
-- Accepts a table-- { command = <command whose output will be piped to fzf>,-- query = <used in the --filter flag of fzf> }functionfzf.filter(args)
localcommand=args.commandor"find . -type f"localquery=args.querylocalhandle=io.popen(command.." | fzf --filter='" ..query.."'")
localresults= {}
forlineinhandle:lines() dotable.insert(results, line)
endhandle:close()
returnresultsend-- Accepts a table-- { file_path = <file whose content will be piped to fzf>,-- query = <used in the --filter flag of fzf> }functionfzf.filter_from_file(args)
localfile_path=args.file_pathlocalquery=args.querylocalhandle=io.popen("fzf --filter='" ..query.."' < " ..file_path)
localresults= {}
forlineinhandle:lines() dotable.insert(results, line)
endhandle:close()
returnresultsendreturnfzf
log.lua
---- log.lua---- Copyright (c) 2016 rxi---- This library is free software; you can redistribute it and/or modify it-- under the terms of the MIT license. See LICENSE for details.--locallog= { _version="0.1.0" }
log.usecolor=truelog.outfile=nillog.level="trace"localmodes= {
{ name="trace", color="\27[34m", },
{ name="debug", color="\27[36m", },
{ name="info", color="\27[32m", },
{ name="warn", color="\27[33m", },
{ name="error", color="\27[31m", },
{ name="fatal", color="\27[35m", },
}
locallevels= {}
fori, vinipairs(modes) dolevels[v.name] =iendlocalround=function(x, increment)
increment=incrementor1x=x/incrementreturn (x>0andmath.floor(x+.5) ormath.ceil(x-.5)) *incrementendlocal_tostring=tostringlocaltostring=function(...)
localt= {}
fori=1, select('#', ...) dolocalx=select(i, ...)
iftype(x) =="number" thenx=round(x, .01)
endt[#t+1] =_tostring(x)
endreturntable.concat(t, "")
endfori, xinipairs(modes) dolocalnameupper=x.name:upper()
log[x.name] =function(...)
-- Return early if we're below the log levelifi<levels[log.level] thenreturnendlocalmsg=tostring(...)
localinfo=debug.getinfo(2, "Sl")
locallineinfo=info.short_src..":" ..info.currentline-- Output to log fileiflog.outfilethenlocalfp=io.open(log.outfile, "a")
localstr=string.format("[%-6s%s] %s: %s\n",
nameupper, os.date(), lineinfo, msg)
fp:write(str)
fp:close()
else-- Output to consoleprint(string.format("%s[%-6s%s]%s %s: %s",
log.usecolorandx.coloror"",
nameupper,
os.date("%H:%M:%S"),
log.usecolorand"\27[0m" or"",
lineinfo,
msg))
endendendreturnlog
The text was updated successfully, but these errors were encountered:
Thanks for this amazing plugin. Autocompletion was never this hackable and easy.
I'm writing a custom resource, which I'm filter using fzf. Though, I can see (from logs) that fzf is giving me some results, I don't see them in the autocomplete menu.
So can we avoid further filtering from Coq, for some custom resources, may be based on a flag or something?
The custom source,
fzf_helpers.lua
log.lua
The text was updated successfully, but these errors were encountered: