diff --git a/.config/nvim/lua/null/plug.lua b/.config/nvim/lua/null/plug.lua index bb746e7..f42a005 100644 --- a/.config/nvim/lua/null/plug.lua +++ b/.config/nvim/lua/null/plug.lua @@ -1,19 +1,6 @@ --- << Getting lazy.nvim for the first time -local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not (vim.uv or vim.loop).fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - lazypath, - }) -end -vim.opt.rtp:prepend(lazypath) --- >> +local util = require("null.util") -require("lazy").setup({ +util.getch_lazy_nvim().setup({ { "stevearc/oil.nvim", opts = {}, diff --git a/.config/nvim/lua/null/remap.lua b/.config/nvim/lua/null/remap.lua index 027c659..9244c31 100644 --- a/.config/nvim/lua/null/remap.lua +++ b/.config/nvim/lua/null/remap.lua @@ -1,16 +1,5 @@ -- Loaded by `null.config` -local map = function(modes, key, target, opts) - local mt = {} - - for mode in modes:gmatch"." do - table.insert(mt, mode) - end - - vim.keymap.set(mt, key, target, opts or { - noremap = true, - silent = true, - }) -end +local map = require("null.util").map -- Map Ctrl+U as U so it can be used as redo map("n", "", "U") diff --git a/.config/nvim/lua/null/util.lua b/.config/nvim/lua/null/util.lua new file mode 100644 index 0000000..17a8018 --- /dev/null +++ b/.config/nvim/lua/null/util.lua @@ -0,0 +1,33 @@ +local RT = {} + +function RT.getch_lazy_nvim() -- Get or Fetch lazy.nvim + local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" + if not (vim.uv or vim.loop).fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) + end + vim.opt.rtp:prepend(lazypath) + + return require("lazy") +end + +function RT.map(modes, key, target, opts) + local mt = {} + + for mode in modes:gmatch"." do + table.insert(mt, mode) + end + + vim.keymap.set(mt, key, target, opts or { + noremap = true, + silent = true, + }) +end + +return RT