From a4d82f2fc56a7b0c3dc84dc61cd074f94dfce62f Mon Sep 17 00:00:00 2001 From: Mike Vink Date: Wed, 11 Oct 2023 16:40:00 +0000 Subject: move impure stuff --- mut/neovim/fnl/conf/init.fnl | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) (limited to 'mut') diff --git a/mut/neovim/fnl/conf/init.fnl b/mut/neovim/fnl/conf/init.fnl index 151f829..3b29f40 100644 --- a/mut/neovim/fnl/conf/init.fnl +++ b/mut/neovim/fnl/conf/init.fnl @@ -20,14 +20,26 @@ (tel.setup {:defaults (vim.tbl_extend :force (themes.get_ivy) {})}) +(local cope #(vim.cmd (.. ":copen " (math.floor (/ vim.o.lines 2.6))))) + (let [map vim.keymap.set] - (map :n :qf ":copen") + (map :v :y "OSCYankVisual|gvy") + (map :n :qf cope) (map :n :q ":cclose") (map :n :ll ":lopen") (map :n :l ":lclose") (map :n : ":cprev") + (map :n : ":cprev") (map :n : ":cnext") - (map :n : ":Compile") + (map :n : #(do + (vim.fn.setreg "/" "Compile") + (vim.api.nvim_feedkeys + (vim.api.nvim_replace_termcodes + ":Compile" true false true) + :n false) + (vim.schedule #(do + (map :n :/ "/Compile.* " {:buffer true}) + (map :n :? "?Compile.* " {:buffer true}))))) (map :n : ":Recompile") (map :n "[q" ":cprevious") (map :n "]q" ":cnext") @@ -66,14 +78,15 @@ (.. l word)))) (local lines (icollect [_ l (ipairs lines)] - (if l + (if (not= l "") (prettify l)))) - (vim.fn.setqflist [] :a {: id : title : lines})))) + (vim.fn.setqflist [] :a {: id : title : lines}) + (vim.cmd ":cbottom")))) (var last_job nil) (local job (fn [cmd] - (local title (table.concat cmd " ")) + (local title cmd) (vim.fn.setqflist [] " " {: title}) (local add2qf (qf (vim.fn.getqflist {:id 0 :title 1}))) (local id @@ -86,24 +99,28 @@ (if data (add2qf data))) :on_exit (fn [id rc] - (if (= rc 0) - (vim.cmd ":cope")))})) + (set last_job.finished true) + (if (= rc 0) + (cope)))})) (set last_job {: cmd - : id}))) + : id + :finished false}))) (vim.api.nvim_create_user_command :Compile (fn [cmd] - (job cmd.fargs)) + (job cmd.args)) {:nargs :* :bang true :complete :shellcmd}) (vim.api.nvim_create_user_command :Recompile (fn [] - (if (not= nil last_job) - (job last_job) - (vim.notify "nothing to recompile"))) + (if (= nil last_job) + (vim.notify "nothing to recompile") + (if (not last_job.finished) + (vim.notify "Last job not finished") + (job last_job.cmd)))) {:bang true}) (vim.api.nvim_create_user_command :Abort -- cgit v1.2.3