diff options
| author | Mike Vink <ivi@vinkies.net> | 2024-01-08 18:52:11 +0100 |
|---|---|---|
| committer | Mike Vink <ivi@vinkies.net> | 2024-01-08 18:52:11 +0100 |
| commit | 9afed39b20971a296b1350c96ed632bb975279b2 (patch) | |
| tree | 657887c8ea3375ccc4d272769dfde24e6327a80f | |
| parent | 76507c3a085f4b443b9bc604d6dfe92c227ef7c1 (diff) | |
fix oil bug
| -rw-r--r-- | mut/neovim/fnl/conf/init.fnl | 30 | ||||
| -rw-r--r-- | mut/neovim/fnl/conf/pkgs/oil.fnl | 14 |
2 files changed, 28 insertions, 16 deletions
diff --git a/mut/neovim/fnl/conf/init.fnl b/mut/neovim/fnl/conf/init.fnl index 195bfcf..6fd0967 100644 --- a/mut/neovim/fnl/conf/init.fnl +++ b/mut/neovim/fnl/conf/init.fnl @@ -99,14 +99,15 @@ (and is-at-last-line is-qf)) (vim.cmd ":cbottom"))))))) -(var last_job nil) +(var last_job_state nil) +(var last_job_thunk nil) (local qfjob (fn [cmd stdin] (local title (table.concat cmd " ")) (vim.fn.setqflist [] " " {: title}) (local add2qf (qf (vim.fn.getqflist {:id 0 :title 1}))) (set - last_job + last_job_state (vim.system cmd {: stdin @@ -133,34 +134,39 @@ (vim.api.nvim_create_user_command :Compile (fn [cmd] - (qfjob cmd.fargs nil)) + (local thunk #(qfjob cmd.fargs nil)) + (set last_job_thunk thunk) + (thunk)) {:nargs :* :bang true :complete :shellcmd}) (vim.api.nvim_create_user_command :Sh (fn [cmd] - (qfjob [:sh :-c cmd.args] nil)) + (local thunk #(qfjob [:sh :-c cmd.args] nil)) + (set last_job_thunk thunk) + (thunk)) {:nargs :* :bang true :complete :shellcmd}) (vim.api.nvim_create_user_command :Recompile (fn [] - (if (= nil last_job) + (if (= nil last_job_state) (vim.notify "nothing to recompile") - (if (not (last_job:is_closing)) + (if (not (last_job_state:is_closing)) (vim.notify "Last job not finished") - (qfjob last_job._state.cmd)))) + (last_job_thunk)))) {:bang true}) (vim.api.nvim_create_user_command :Stop (fn [] - (if (not= nil last_job) - (last_job:kill)) + (if (not= nil last_job_state) + (last_job_state:kill)) (vim.notify "stopped job")) {:bang true}) (vim.api.nvim_create_user_command :Args (fn [obj] (if (not= 0 (length obj.fargs)) - (qfjob - [:sh :-c obj.args] - (vim.fn.argv)))) + (do + (local thunk #(qfjob [:sh :-c obj.args] (vim.fn.argv))) + (set last_job_thunk thunk) + (thunk)))) {:nargs :* :bang true :complete :shellcmd}) diff --git a/mut/neovim/fnl/conf/pkgs/oil.fnl b/mut/neovim/fnl/conf/pkgs/oil.fnl index 2365872..7845b79 100644 --- a/mut/neovim/fnl/conf/pkgs/oil.fnl +++ b/mut/neovim/fnl/conf/pkgs/oil.fnl @@ -28,12 +28,18 @@ "." "actions.open_cmdline" "gx" {:callback (fn [] (local file (oil.get_cursor_entry)) - (vim.cmd (.. :argadd " " file.name)) - (vim.cmd :args))} + (local dir (oil.get_current_dir)) + (if (and dir file) + (do + (vim.cmd (.. :argadd " " dir file.name) + (vim.cmd :args)))))} "gX" {:callback (fn [] (local file (oil.get_cursor_entry)) - (vim.cmd (.. :argdel " " file.name)) - (vim.cmd :args))} + (local dir (oil.get_current_dir)) + (if (and dir file) + (do + (vim.cmd (.. :argdel " " dir file.name) + (vim.cmd :args)))))} "gc" {:callback (fn [] (vim.cmd "argdel *") (vim.cmd "args"))} |
