From 8186744af8241bad7cf13d921ca43f74bdd30d41 Mon Sep 17 00:00:00 2001 From: Proctor Date: Tue, 29 Apr 2025 09:49:04 -0500 Subject: [PATCH] nvim - start of moving modules to pure fennel --- nvim/.config/nvim/fnl/dotfiles/conceal.fnl | 95 ++++++++++------------ nvim/.config/nvim/fnl/dotfiles/util.fnl | 39 +++++---- 2 files changed, 68 insertions(+), 66 deletions(-) diff --git a/nvim/.config/nvim/fnl/dotfiles/conceal.fnl b/nvim/.config/nvim/fnl/dotfiles/conceal.fnl index 7a00a4c..8e04427 100644 --- a/nvim/.config/nvim/fnl/dotfiles/conceal.fnl +++ b/nvim/.config/nvim/fnl/dotfiles/conceal.fnl @@ -1,65 +1,58 @@ -(module dotfiles.conceal - {autoload {nvim aniseed.nvim - nu aniseed.nvim.util - u dotfiles.util}}) +(local u (require :dotfiles.util)) +(local conceals {:defn "𝑓" + ;; :defn- : + :fn "λ" + :lambda "λ" + :and "∧" + :&& "∧" + :or "∨" + :|| "∨" + :not "¬" + :! "¬" + :for "∀" + :in "∈" + ; "\\ \\" :∉ + :true "⊤" + :false "⊥" + ;; and + ;; or + ;; if-not + ;; when-not + ;; (not + ;; None | ∅ + ;; true, false | ⊤, ⊥ (top and bottom from logic) + ;; + ;; for | ∀ + ;; in | ∈ + ;; not in | ∉ + }) -(def conceals {:defn :𝑓 - ;; :defn- : - :fn :λ - :lambda :λ - :and :∧ - :&& :∧ - :or :∨ - :|| :∨ - :not :¬ - :! :¬ - :for :∀ - :in :∈ - ; "\\ \\" :∉ - :true :⊤ - :false :⊥ -;; and -;; or -;; if-not -;; when-not -;; (not -;; None | ∅ -;; true, false | ⊤, ⊥ (top and bottom from logic) -;; -;; for | ∀ -;; in | ∈ -;; not in | ∉ - }) - - -(defn setup-conceals [] - (nvim.fn.clearmatches) +(fn setup-conceals [] + (vim.fn.clearmatches) (each [the-match replacement (pairs conceals)] - (let [the-match (.. "\\<" the-match "\\>" )] - (nvim.fn.matchadd :Conceal the-match 0 -1 {:conceal replacement}))) + (let [the-match (.. "\\<" the-match "\\>")] + (vim.fn.matchadd :Conceal the-match 0 -1 {:conceal replacement}))) + (set vim.wo.conceallevel 2) + (set vim.wo.concealcursor :nvc)) - (set nvim.wo.conceallevel 2) - (set nvim.wo.concealcursor :nvc)) - - -(defn toggle-conceal [] - ( if (= 0 nvim.wo.conceallevel) - (set nvim.wo.conceallevel 2) - (set nvim.wo.conceallevel 0))) +(fn toggle-conceal [] + (if (= 0 vim.wo.conceallevel) + (set vim.wo.conceallevel 2) + (set vim.wo.conceallevel 0))) ;(setup-conceals) ;(toggle-conceal) ;(if true true false) - -(nu.fn-bridge :ToggleConceal :dotfiles.conceal :toggle-conceal {:return false}) -(nu.fn-bridge :SetupConceals :dotfiles.conceal :setup-conceals {:return false}) +(vim.api.nvim_create_user_command :ToggleConceal toggle-conceal {}) +(vim.api.nvim_create_user_command :SetupConceals setup-conceals {}) (u.nnoremap :ts "call ToggleConceal()") -(def pretty-filetypes [:fennel - :clojure]) +(local pretty-filetypes [:fennel :clojure]) (each [_ ftype (pairs pretty-filetypes)] - (nvim.ex.autocmd :FileType ftype :call "SetupConceals()")) + (vim.api.nvim_create_autocmd [:FileType] + {:pattern ftype :callback setup-conceals})) +{} diff --git a/nvim/.config/nvim/fnl/dotfiles/util.fnl b/nvim/.config/nvim/fnl/dotfiles/util.fnl index f85b7e5..aeb7c9b 100644 --- a/nvim/.config/nvim/fnl/dotfiles/util.fnl +++ b/nvim/.config/nvim/fnl/dotfiles/util.fnl @@ -1,23 +1,32 @@ -(module dotfiles.util {autoload {a aniseed.core} require {nvim aniseed.nvim}}) +(local a (require :aniseed.core)) -(defn noremap [mode from to opts] - (let [map-opts {:noremap true :silent true} - to (.. ":" to :) - buff-num (a.get opts :buff-num)] - (if (or (a.get opts :local?) buff-num) - (nvim.buf_set_keymap (or buff-num 0) mode from to map-opts) - (nvim.set_keymap mode from to map-opts)))) +(fn noremap [mode from to opts] + (let [map-opts {:noremap true :silent true} + to (.. ":" to :) + buff-num (a.get opts :buff-num)] + (if (or (a.get opts :local?) buff-num) + (vim.api.nvim_buf_set_keymap (or buff-num 0) mode from to map-opts) + (vim.api.nvim_set_keymap mode from to map-opts)))) -(defn nnoremap [from to opts] (noremap :n from to opts)) +(fn nnoremap [from to opts] (noremap :n from to opts)) -(defn tnoremap [from to opts] (noremap :t from to opts)) +(fn tnoremap [from to opts] (noremap :t from to opts)) -(defn inoremap [from to opts] (noremap :i from to opts)) +(fn inoremap [from to opts] (noremap :i from to opts)) -(defn vnoremap [from to opts] (noremap :v from to opts)) +(fn vnoremap [from to opts] (noremap :v from to opts)) -(defn lnnoremap [from to] (nnoremap (.. : from) to)) +(fn lnnoremap [from to] (nnoremap (.. : from) to)) -(defn ltnoremap [from to opts] (noremap :v (.. : from) to opts)) +(fn ltnoremap [from to opts] (noremap :v (.. : from) to opts)) -(defn lvnoremap [from to opts] (noremap :t (.. : from) to opts)) +(fn lvnoremap [from to opts] (noremap :t (.. : from) to opts)) + +{: noremap + : nnoremap + : tnoremap + : inoremap + : vnoremap + : lnnoremap + : ltnoremap + : lvnoremap}