mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 22:59:15 +00:00
ref(nvim): made everything a tiny module
This commit is contained in:
parent
f0fd9699cc
commit
7a5e1537e8
4 changed files with 1 additions and 1 deletions
75
.config/nvim/fnl/autocmds/init.fnl
Normal file
75
.config/nvim/fnl/autocmds/init.fnl
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
(import-macros {: map! : set! : setlocal! : set+ : exec!} :hibiscus.vim)
|
||||
|
||||
(local autocmd vim.api.nvim_create_autocmd)
|
||||
(local usercmd vim.api.nvim_create_user_command)
|
||||
|
||||
(vim.filetype.add {:extension {:typ :typst}})
|
||||
(vim.filetype.add {:extension {:skel :skel :sk :skel}})
|
||||
(vim.filetype.add {:extension {:mlw :why3}})
|
||||
|
||||
(autocmd :TextYankPost {:callback #(vim.highlight.on_yank)})
|
||||
|
||||
(autocmd :FileType {:pattern [:markdown :tex :typst]
|
||||
:callback (fn []
|
||||
(setlocal! :shiftwidth 2)
|
||||
(setlocal! :tabstop 2)
|
||||
(setlocal! :textwidth 80))})
|
||||
|
||||
(autocmd :FileType {:pattern :skel
|
||||
:callback (fn []
|
||||
(setlocal! :commentstring "(* %s *)")
|
||||
(map! [:n :buffer] :<leader>f
|
||||
#(exec! [w]
|
||||
[silent
|
||||
exec
|
||||
"!necroprint % -o %"]
|
||||
[e])))})
|
||||
|
||||
(autocmd :FileType {:pattern :fennel
|
||||
:callback (fn []
|
||||
(setlocal! :list false)
|
||||
(map! [:n :buffer] :<leader>f
|
||||
#(exec! [w]
|
||||
[silent exec "!fnlfmt --fix %"]
|
||||
[e])))})
|
||||
|
||||
(autocmd :FileType
|
||||
{:pattern :why3
|
||||
:callback (fn []
|
||||
(setlocal! :commentstring "(* %s *)")
|
||||
(setlocal! :shiftwidth 2)
|
||||
(setlocal! :tabstop 2)
|
||||
(setlocal! :expandtab true))})
|
||||
|
||||
; Using `sudoedit` would create gibberish extension names,
|
||||
; detection using extension would hence not work.
|
||||
(autocmd :BufEnter
|
||||
{:pattern :*Caddyfile
|
||||
:callback (fn []
|
||||
(setlocal! :filetype :Caddy)
|
||||
(setlocal! :commentstring "# %s"))})
|
||||
|
||||
(autocmd :OptionSet
|
||||
{:pattern :shiftwidth
|
||||
:callback (fn []
|
||||
(when vim.o.expandtab
|
||||
(var c "")
|
||||
(for [_ (c:len) (+ vim.o.shiftwidth 1)]
|
||||
(set c (.. c " ")))
|
||||
(set+ lcs (.. "leadmultispace:" c))))})
|
||||
|
||||
(usercmd :Retab
|
||||
(fn [opts]
|
||||
(if (= (length opts.fargs) 2)
|
||||
(let [src (tonumber (. opts.fargs 1))
|
||||
dst (tonumber (. opts.fargs 2))]
|
||||
(set! :shiftwidth src)
|
||||
(set! :tabstop src)
|
||||
(set! :expandtab false)
|
||||
(exec! [%retab!])
|
||||
(set! :shiftwidth dst)
|
||||
(set! :tabstop dst)
|
||||
(set! :expandtab true)
|
||||
(exec! [%retab!]))
|
||||
(print "should have exactly two argument: [src] and [dst]")))
|
||||
{:nargs "+"})
|
||||
Loading…
Add table
Add a link
Reference in a new issue