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

New feat #107

Closed
wants to merge 16 commits into from
1 change: 1 addition & 0 deletions lua/wf/builtin/which_key.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ local function _get_gmap(mode)
for _, val in ipairs(keys) do
if not string.match(val.lhs, "^<Plug>") then
local lhs = string.gsub(val.lhs, " ", "<Space>")
lhs = string.gsub(lhs, "\t", "<Tab>")
choices[lhs] = val.desc or val.rhs
end
end
Expand Down
1 change: 1 addition & 0 deletions lua/wf/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ local function gen_obj(row_offset, opts, cursor, buftype, title)
vim.api.nvim_buf_set_option(buf, "bufhidden", "wipe")
vim.api.nvim_buf_set_option(buf, "swapfile", false)
vim.api.nvim_buf_set_option(buf, "buflisted", false)
vim.api.nvim_buf_set_option(buf, "expandtab", false)
return buf, win
end

Expand Down
3 changes: 2 additions & 1 deletion lua/wf/fuzzy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local au = require("wf.util").au
local function input_obj_gen(opts, cursor)
local _row_offset = row_offset() + opts.style.input_win_row_offset
local buf, win = gen_obj(_row_offset, opts, cursor, "nofile", opts.style.borderchars.bottom[2])
vim.api.nvim_buf_set_name(buf, "wffuzzy")

au(_g, "BufEnter", function()
local _, _ = pcall(function()
Expand All @@ -16,7 +17,7 @@ local function input_obj_gen(opts, cursor)
end, { buffer = buf })

-- vim.fn.prompt_setprompt(buf, opts.style.icons.fuzzy_prompt)
local wcnf = vim.api.nvim_win_get_config(win)
-- local wcnf = vim.api.nvim_win_get_config(win)
-- vim.api.nvim_win_set_config(
-- win,
-- vim.fn.extend(wcnf, { title = opts.style.borderchars.bottom[2] })
Expand Down
4 changes: 4 additions & 0 deletions lua/wf/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,9 @@ local function which_setup(
-- end
-- end
-- end, "match")
bmap(which_obj.buf, { "i" }, "<Tab>", function()
return "<Tab>"
end, "<Tab>", { expr = true })
bmap(which_obj.buf, { "i" }, "<C-H>", function()
local pos = vim.api.nvim_win_get_cursor(which_obj.win)
local line = vim.api.nvim_buf_get_lines(which_obj.buf, pos[1] - 1, pos[1], true)[1]
Expand Down Expand Up @@ -638,6 +641,7 @@ local function setup_objs(choices_obj, callback, opts_)
local which_obj = which.input_obj_gen(opts, opts.selector == "which")
local fuzzy_obj = fuzzy.input_obj_gen(opts, opts.selector == "fuzzy")
vim.api.nvim_buf_set_lines(which_obj.buf, -2, -1, true, { opts.text_insert_in_advance })
print("fuzzy buf name: ", vim.api.nvim_buf_get_name(fuzzy_obj.buf))

vim.schedule(function()
vim.cmd("startinsert!")
Expand Down
2 changes: 1 addition & 1 deletion lua/wf/input.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local function async(callback)
local handle
handle = vim.loop.new_async(vim.schedule_wrap(function()
local ret = callback()
print(vim.g[full_name .. "#text_insert_in_advance"])
-- print(vim.g[full_name .. "#text_insert_in_advance"])
local text_insert_in_advance = vim.g[full_name .. "#text_insert_in_advance"]
local which_obj_buf = vim.g[full_name .. "#which_obj_buf"]
if text_insert_in_advance ~= nil and which_obj_buf ~= nil then
Expand Down
Loading