From b31ae70a7d953d95b580280f501766758e46b3ef Mon Sep 17 00:00:00 2001 From: Steven Proctor Date: Sat, 31 Dec 2022 13:08:18 -0600 Subject: [PATCH] Neovim - Trim trailing whitespace mapping --- nvim/.config/nvim/fnl/dotfiles/mapping.fnl | 10 ++++++++++ nvim/.config/nvim/fnl/dotfiles/util.fnl | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/nvim/.config/nvim/fnl/dotfiles/mapping.fnl b/nvim/.config/nvim/fnl/dotfiles/mapping.fnl index 2d948e5..da201c6 100644 --- a/nvim/.config/nvim/fnl/dotfiles/mapping.fnl +++ b/nvim/.config/nvim/fnl/dotfiles/mapping.fnl @@ -68,3 +68,13 @@ (nvim.ex.autocmd :FileType :sql :nmap :s :vapS) (noremap :n :Q ":.!bash ") + +; Ruby old hash syntax to new hash syntax +;(util/lvnoremap :uhs "s/\\([a-z][^ \\t]*\\) =>/\\1:/ge" ) +;(util/lnnoremap :uhs "s/\\([a-z][^ \\t]*\\) =>/\\1:/ge" ) + +; Trim trailing Whitespace in visual selection +(util.lvnoremap :tw "s/\\s\\+$//ge:nohlsearch/") + +; Trim trailing Whitespace in current line +(util.lnnoremap :tw ".s/\\s\\+$//ge:nohlsearch/") diff --git a/nvim/.config/nvim/fnl/dotfiles/util.fnl b/nvim/.config/nvim/fnl/dotfiles/util.fnl index 54fb013..8d3074c 100644 --- a/nvim/.config/nvim/fnl/dotfiles/util.fnl +++ b/nvim/.config/nvim/fnl/dotfiles/util.fnl @@ -9,7 +9,6 @@ (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)))) @@ -19,3 +18,6 @@ (defn lnnoremap [from to] (nnoremap (.. "" from) to)) + +(defn lvnoremap [from to opts] + (noremap :v (.. "" from) to opts))