Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Dec 29, 2024
1 parent 66933cd commit 3d56d5a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
14 changes: 2 additions & 12 deletions example/cmd/_test/cmd-clink.lua
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
local function example_completion(word, word_index, line_state, match_builder)
args = { "example", "_carapace", "fish", "\"\"" }
for i = 2,word_index-1,1 do
table.insert(args, string.format("%q" ,line_state:getword(i)))
end

-- table.insert(args, string.format("%q", word))
local exploded = string.explode(line_state:getline() .. "a")
word = string.gsub(exploded[#exploded], 'a$', "")
table.insert(args, string.format("%q", word))
local compline = string.sub(line_state:getline(), 1, line_state:getcursor())

output = io.popen(table.concat(args, " ")):read("*a")
local output = io.popen("env CARAPACE_COMPLINE=" .. string.format("%q", compline) .. " example _carapace cmd-clink ''"):read("*a")
for line in string.gmatch(output, '[^\r\n]+') do
-- match_builder:addmatch(line)
match_builder:addmatch(string.gsub(line, '\t.*', ""))
end

return true
end

Expand Down
14 changes: 2 additions & 12 deletions internal/shell/cmd_clink/snippet.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,12 @@ import (

func Snippet(cmd *cobra.Command) string {
result := fmt.Sprintf(`local function %v_completion(word, word_index, line_state, match_builder)
args = { %#v, "_carapace", "fish", "\"\"" }
for i = 2,word_index-1,1 do
table.insert(args, string.format("%%q" ,line_state:getword(i)))
end
-- table.insert(args, string.format("%%q", word))
local exploded = string.explode(line_state:getline() .. "a")
word = string.gsub(exploded[#exploded], 'a$', "")
table.insert(args, string.format("%%q", word))
local compline = string.sub(line_state:getline(), 1, line_state:getcursor())
output = io.popen(table.concat(args, " ")):read("*a")
local output = io.popen("env CARAPACE_COMPLINE=" .. string.format("%%q", compline) .. " %v _carapace cmd-clink ''"):read("*a")
for line in string.gmatch(output, '[^\r\n]+') do
-- match_builder:addmatch(line)
match_builder:addmatch(string.gsub(line, '\t.*', ""))
end
return true
end
Expand Down

0 comments on commit 3d56d5a

Please sign in to comment.