aboutsummaryrefslogtreecommitdiff
path: root/fnl/nvrc/events.fnl
diff options
context:
space:
mode:
authorsefidel <contact@sefidel.net>2022-02-10 00:24:03 +0900
committersefidel <contact@sefidel.net>2022-02-10 00:24:03 +0900
commit72d448e384249103748ee83b587c45924e4bc44d (patch)
tree2aa05a6aaf8c7aa37a8c278fd2fede6e62ff2218 /fnl/nvrc/events.fnl
downloadnvimrc-72d448e384249103748ee83b587c45924e4bc44d.zip
Initial commit
Diffstat (limited to 'fnl/nvrc/events.fnl')
-rw-r--r--fnl/nvrc/events.fnl47
1 files changed, 47 insertions, 0 deletions
diff --git a/fnl/nvrc/events.fnl b/fnl/nvrc/events.fnl
new file mode 100644
index 0000000..a798fcf
--- /dev/null
+++ b/fnl/nvrc/events.fnl
@@ -0,0 +1,47 @@
+(import-macros {: au!
+ : ac!} :nvrc.macro.event)
+(import-macros {: set!
+ : setl!} :nvrc.macro.set)
+(local {: echo!} (require :nvrc.lib.io))
+
+(local {: line
+ : mode} vim.fn)
+(fn cmd! [...] (vim.cmd ...))
+(fn bufexists? [...] (= (vim.fn.bufexists ...) 1))
+
+; Restore cursor style to beam on exit
+(au! restore-cursor
+ (ac! VimLeave * #(set! guicursor ["a:ver75-blinkon0"])))
+
+; Restore the last cursor line
+(au! restore-last-cursor-line
+ (ac! BufReadPost * #(if (and (> (line "'\"") 1)
+ (<= (line "'\"") (line "$")))
+ (cmd! "normal! g'\""))))
+
+; Resize splits on window resize
+(au! resize-splits-on-resize
+ (ac! VimResized * "wincmd ="))
+
+;; Read file when it changes on disk
+(au! read-file-on-disk-change
+ (ac! [FocusGained BufEnter CursorHold CursorHoldI] *
+ #(if (and (not= :c (mode))
+ (not (bufexists? "[Command Line]")))
+ (cmd! "checktime")))
+ (ac! FileChangedShellPost *
+ #(echo! "File changed on disk. Buffer reloaded.")))
+
+(au! terminal-options
+ ;; Enter Terminal-mode (insert) automatically
+ (ac! TermOpen * "startinsert")
+ ;; Disables line number on terminal buffers
+ (ac! TermOpen * #(do
+ (setl! nonumber)
+ (setl! norelativenumber)))
+ ;; Disables spell on terminal buffers
+ (ac! TermOpen * #(setl! nospell))
+ ;; Disables sign column on terminal buffers
+ (ac! TermOpen * #(setl! signcolumn :no))
+ ;; Disables colorcolumn on terminal buffers
+ (ac! TermOpen * #(setl! colorcolumn [])))