uniquifier 沒有 TagMatch
在組filters 時常常被 uniquifier 屏蔽 不想屏蔽的候選 另外可否在 TagMatch 加上 exclude_tags:機制
把uniquifier放最後
uniquifier 在打字時重覆字過濾很重要, 在用 lua_xxxx 時候 ,有些場景 cand.text = "" 只是commit "" 觸發 commit_notifier 不要上屏 比如 設定 lua_translator@option -- 設定option
commit 時 切換 option , commit 空字串 因爲 uniquilfier 被過濾掉了 ,如果可以設定 tags 可以排除 特定 tag
local options= {"ascii_mode" , ...)
function M.init(env)
local context = env.engine.context
env.notifier= context.commit_notifier:connect(
function(ctx)
local cand = ctx:get_selected_candidate()
if cand.type == "set_option" then
-- toggle option
ctx:set_option( cand.comment ,not ctx:get_option(cand.comment))
end)
end
function M.fini(env)
env.notifier:disconnect()
end
--
function M.func(input,seg,env)
local ctx = env.engine.context
if not seg:has_tag("set_option") then return end
local opt = input:sub(2)
-- 候選 options
for i, opt_name in ipairs(options) do
if opt_name:match(opt) then
-- 將 opt_name 放在 comment
yield( Candidate( "set_option" , seg.start,seg._end, "", opt_name) )
end
end
end
return M
pattern set_option: "^O[a-z_]+"
uniquifier 在打字時重覆字過濾很重要, 在用 lua_xxxx 時候 ,有些場景 cand.text = "" 只是commit "" 觸發 commit_notifier 不要上屏 比如 設定 lua_translator@option -- 設定option
commit 時 切換 option , commit 空字串 因爲 uniquilfier 被過濾掉了 ,如果可以設定 tags 可以排除 特定 tag
local options= {"ascii_mode" , ...) function M.init(env) local context = env.engine.context env.notifier= context.commit_notifier:connect( function(ctx) local cand = ctx:get_selected_candidate() if cand.type == "set_option" then -- toggle option ctx:set_option( cand.comment ,not ctx:get_option(cand.comment)) end) end function M.fini(env) env.notifier:disconnect() end -- function M.func(input,seg,env) local ctx = env.engine.context if not seg:has_tag("set_option") then return end local opt = input:sub(2) -- 候選 options for i, opt_name in ipairs(options) do if opt_name:match(opt) then -- 將 opt_name 放在 comment yield( Candidate( "set_option" , seg.start,seg._end, "", opt_name) ) end end end return Mpattern set_option: "^O[a-z_]+"
只需要set_option(_session, "dumb", true)