From 0aca7170ae1761a054c5dced0ab62dfdea6f0691 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 19 Apr 2026 08:30:57 +0800 Subject: [PATCH 1/4] feat(term): add fish shell completion support and improve task command --- lua/kide/term.lua | 48 ++++++++++++++++++++++++++++++++++++++++++----- lua/mappings.lua | 19 ++++++++++++------- 2 files changed, 55 insertions(+), 12 deletions(-) diff --git a/lua/kide/term.lua b/lua/kide/term.lua index aff6783..aca04ff 100644 --- a/lua/kide/term.lua +++ b/lua/kide/term.lua @@ -12,6 +12,40 @@ local repls = { } local sid +local function is_fish_shell() + local shell = vim.o.shell or vim.env.SHELL or "" + return vim.endswith(shell, "fish") +end + +local function fish_complete(arglead, cmdline, cursorpos) + if not is_fish_shell() then + return vim.fn.getcompletion(arglead, "shellcmd") + end + + local line = cmdline or arglead or "" + if cursorpos and cursorpos > 0 then + line = line:sub(1, cursorpos) + end + + local ok, output = pcall(vim.fn.systemlist, { + vim.o.shell, + "-c", + "complete -C " .. vim.fn.shellescape(line), + }) + if not ok or vim.v.shell_error ~= 0 then + return {} + end + + local items = {} + for _, item in ipairs(output) do + local text = vim.split(item, "\t", { plain = true })[1] + if text and text ~= "" then + table.insert(items, text) + end + end + return items +end + local function launch_term(cmd, opts) opts = opts or {} @@ -99,11 +133,15 @@ function M.send_line(line) end M.last_input = nil -function M.input_run(last) - if last then - return M.toggle(M.last_input) - end - local ok, cmd = pcall(vim.fn.input, "CMD: ") +M.complete = fish_complete +_G.kide_term_run_complete = fish_complete + +function M.input_run() + local ok, cmd = pcall(vim.fn.input, { + prompt = "CMD: ", + default = M.last_input or "", + completion = "customlist,v:lua.kide_term_run_complete", + }) if ok then if cmd == "" then M.toggle() diff --git a/lua/mappings.lua b/lua/mappings.lua index 7a987bb..b41dc04 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -156,13 +156,18 @@ end, { desc = "files", silent = true, noremap = true }) map("n", "o", "Outline", { desc = "Symbols Outline" }) -- task -command("TaskRun", function() - require("kide.term").input_run(false) -end, { desc = "Task Run" }) - -command("TaskRunLast", function() - require("kide.term").input_run(true) -end, { desc = "Restart Last Task" }) +command("Run", function(opt) + if opt.args ~= "" then + require("kide.term").last_input = opt.args + require("kide.term").toggle(opt.args) + return + end + require("kide.term").input_run() +end, { + desc = "Run Task", + nargs = "*", + complete = "customlist,v:lua.kide_term_run_complete", +}) map("n", "", function() require("conform").format({ lsp_fallback = true }) From b9f1b5f5cc04cb39b8fad4a42d759f3e1f29f509 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 19 Apr 2026 09:12:23 +0800 Subject: [PATCH 2/4] feat(term): add open file under cursor functionality and bind to Enter key --- lua/kide/term.lua | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/lua/kide/term.lua b/lua/kide/term.lua index aca04ff..35259f3 100644 --- a/lua/kide/term.lua +++ b/lua/kide/term.lua @@ -46,6 +46,45 @@ local function fish_complete(arglead, cmdline, cursorpos) return items end +local function open_file_under_cursor() + local mode = vim.api.nvim_get_mode().mode + if mode == "t" then + vim.cmd("stopinsert") + end + + local file = vim.fn.expand("") + if file == nil or file == "" then + return + end + + local current_win = vim.api.nvim_get_current_win() + local fallback_win = nil + local file_path = vim.fn.fnamemodify(file, ":p") + + for _, win in ipairs(vim.api.nvim_tabpage_list_wins(0)) do + if win ~= current_win and vim.api.nvim_win_is_valid(win) then + local win_buf = vim.api.nvim_win_get_buf(win) + if vim.api.nvim_buf_is_valid(win_buf) and vim.api.nvim_buf_get_name(win_buf) == file_path then + vim.api.nvim_set_current_win(win) + return + end + + local cfg = vim.api.nvim_win_get_config(win) + if fallback_win == nil and cfg.relative == "" and vim.bo[win_buf].buftype == "" then + fallback_win = win + end + end + end + + if fallback_win ~= nil then + vim.api.nvim_set_current_win(fallback_win) + vim.cmd("edit " .. vim.fn.fnameescape(file)) + return + end + + vim.cmd("split " .. vim.fn.fnameescape(file)) +end + local function launch_term(cmd, opts) opts = opts or {} @@ -54,7 +93,10 @@ local function launch_term(cmd, opts) vim.cmd("belowright new") termwin = api.nvim_get_current_win() - require("kide").term_stl(vim.api.nvim_get_current_buf(), cmd) + local bufnr = vim.api.nvim_get_current_buf() + -- vim.wo.winfixbuf = true + require("kide").term_stl(bufnr, cmd) + vim.keymap.set({ "t", "n" }, "", open_file_under_cursor, { silent = true, buffer = bufnr }) vim.bo.path = path vim.bo.buftype = "nofile" vim.bo.bufhidden = "wipe" From fbff5dc68b12cf4b3f806d1923f3b53f5cf57795 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 19 Apr 2026 11:07:16 +0800 Subject: [PATCH 3/4] feat(lsp): add make to copilot language support list --- lsp/copilot.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lsp/copilot.lua b/lsp/copilot.lua index a3eda87..31f8986 100644 --- a/lsp/copilot.lua +++ b/lsp/copilot.lua @@ -87,6 +87,8 @@ return { "swift", "kotlin", "zig", + + "make", }, root_markers = { ".git" }, init_options = { From ca36da6e43e85e7cef3a366b5befa4c2d0a28173 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 19 Apr 2026 11:18:48 +0800 Subject: [PATCH 4/4] feat(term): remove terminal mode mapping for `` and improve empty command handling --- lua/kide/term.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/kide/term.lua b/lua/kide/term.lua index 35259f3..a4c4d20 100644 --- a/lua/kide/term.lua +++ b/lua/kide/term.lua @@ -96,7 +96,7 @@ local function launch_term(cmd, opts) local bufnr = vim.api.nvim_get_current_buf() -- vim.wo.winfixbuf = true require("kide").term_stl(bufnr, cmd) - vim.keymap.set({ "t", "n" }, "", open_file_under_cursor, { silent = true, buffer = bufnr }) + vim.keymap.set({ "n" }, "", open_file_under_cursor, { silent = true, buffer = bufnr }) vim.bo.path = path vim.bo.buftype = "nofile" vim.bo.bufhidden = "wipe" @@ -186,7 +186,7 @@ function M.input_run() }) if ok then if cmd == "" then - M.toggle() + vim.notify("No command entered", vim.log.levels.WARN) else M.last_input = cmd M.toggle(cmd)