mirror of
https://github.com/stevenproctor/dotfiles.git
synced 2026-01-28 08:39:56 -06:00
nvim - start of moving modules to pure fennel
This commit is contained in:
@@ -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 "∈"
|
||||
; "\\<not\\> \\<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 :∈
|
||||
; "\\<not\\> \\<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 :<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}))
|
||||
|
||||
{}
|
||||
|
||||
@@ -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 :<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))))
|
||||
(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)
|
||||
(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}
|
||||
|
||||
Reference in New Issue
Block a user