From 5653be90419af3aa234f6eeb902abf45a13a9b1a Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Thu, 31 Aug 2023 21:57:42 -0500 Subject: [PATCH] feat(nvim): add user cmd to strip trailing whitespace --- dots/.config/nvim/lua/core/autocmds.lua | 2 +- dots/.config/nvim/lua/core/cmds.lua | 6 ++++++ dots/.config/nvim/lua/core/init.lua | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 dots/.config/nvim/lua/core/cmds.lua diff --git a/dots/.config/nvim/lua/core/autocmds.lua b/dots/.config/nvim/lua/core/autocmds.lua index 02d5ae85..54d9a959 100644 --- a/dots/.config/nvim/lua/core/autocmds.lua +++ b/dots/.config/nvim/lua/core/autocmds.lua @@ -13,7 +13,7 @@ M.setup = function() -- NOTE: Remove trailing whitespace on save vim.api.nvim_create_autocmd("BufWritePre", { group = augroup, - command = "%s/\\s\\+$//e", + command = "StripTrailSpace", }) diff --git a/dots/.config/nvim/lua/core/cmds.lua b/dots/.config/nvim/lua/core/cmds.lua new file mode 100644 index 00000000..fb4e62f7 --- /dev/null +++ b/dots/.config/nvim/lua/core/cmds.lua @@ -0,0 +1,6 @@ +local M = {} +M.setup = function() + vim.api.nvim_create_user_command("StripTrailSpace", "%s/\\s\\+$//e", {}) +end + +return M diff --git a/dots/.config/nvim/lua/core/init.lua b/dots/.config/nvim/lua/core/init.lua index 30567709..ef4d6f96 100755 --- a/dots/.config/nvim/lua/core/init.lua +++ b/dots/.config/nvim/lua/core/init.lua @@ -2,6 +2,7 @@ require("core.disabled").setup() require("core.options").setup() require("core.mappings").setup() require("core.globals").setup() +require("core.cmds").setup() require("core.autocmds").setup() require("core.filetypes").setup() require("core.lsp").setup()