nvim - start of moving modules to pure fennel

This commit is contained in:
2025-04-29 09:49:04 -05:00
parent acdba51080
commit 8186744af8
2 changed files with 68 additions and 66 deletions

View File

@@ -1,24 +1,20 @@
(module dotfiles.conceal
{autoload {nvim aniseed.nvim
nu aniseed.nvim.util
u dotfiles.util}})
(local u (require :dotfiles.util))
(def conceals {:defn :𝑓
(local conceals {:defn "𝑓"
;; :defn- :
:fn
:lambda
:and :∧
:&& :∧
:or :
:|| :
:not
:!
:for :∀
:in :∈
:fn "λ"
:lambda "λ"
:and "∧"
:&& "∧"
:or ""
:|| ""
:not "¬"
:! "¬"
:for "∀"
:in "∈"
; "\\<not\\> \\<in\\>" :∉
:true :
:false :⊥
:true ""
:false "⊥"
;; and
;; or
;; if-not
@@ -32,34 +28,31 @@
;; 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})))
(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 :<leader>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}))
{}

View File

@@ -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]
(fn noremap [mode from to opts]
(let [map-opts {:noremap true :silent true}
to (.. ":" to :<cr>)
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))))
(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 (.. :<leader> from) to))
(fn lnnoremap [from to] (nnoremap (.. :<leader> from) to))
(defn ltnoremap [from to opts] (noremap :v (.. :<leader> from) to opts))
(fn ltnoremap [from to opts] (noremap :v (.. :<leader> from) to opts))
(defn lvnoremap [from to opts] (noremap :t (.. :<leader> from) to opts))
(fn lvnoremap [from to opts] (noremap :t (.. :<leader> from) to opts))
{: noremap
: nnoremap
: tnoremap
: inoremap
: vnoremap
: lnnoremap
: ltnoremap
: lvnoremap}