diff options
| author | kylo252 <[email protected]> | 2022-05-21 16:48:47 +0200 | 
|---|---|---|
| committer | GitHub <[email protected]> | 2022-05-21 16:48:47 +0200 | 
| commit | 23df368b00bda0ed4a01fac92f7ad80998c1d34a (patch) | |
| tree | 2362ff18ac68eab313380e814238fa15c1237934 /lua/lvim/core/commands.lua | |
| parent | a2454310b6c0b5b530521a77b9b8eb290274e040 (diff) | |
refactor: load the default options once (#2592)
BREAKING CHANGE: modifying the default options for keymaps and autocmds
is now done by overwriting them, since they won't be loaded into the
global `lvim` table anymore
* refactor: use the lua-commands api
* refactor!: use the lua-autocmds api
* fix(settings): let neovim handle spellfile
* feat: add log:set_log_level()
* chore: update examples
* chore: add deprecation notice for custom_groups
Diffstat (limited to 'lua/lvim/core/commands.lua')
| -rw-r--r-- | lua/lvim/core/commands.lua | 78 | 
1 files changed, 63 insertions, 15 deletions
| diff --git a/lua/lvim/core/commands.lua b/lua/lvim/core/commands.lua index 4ddbfcf0..80c5bb03 100644 --- a/lua/lvim/core/commands.lua +++ b/lua/lvim/core/commands.lua @@ -1,7 +1,6 @@  local M = {} -M.defaults = { -  [[ +vim.cmd [[    function! QuickFixToggle()      if empty(filter(getwininfo(), 'v:val.quickfix'))        copen @@ -9,21 +8,70 @@ M.defaults = {        cclose      endif    endfunction -  ]], -  [[ command! BufferKill lua require('lvim.core.bufferline').buf_kill('bd') ]], -  -- :LvimInfo -  [[ command! LvimInfo lua require('lvim.core.info').toggle_popup(vim.bo.filetype) ]], -  [[ command! LvimCacheReset lua require('lvim.utils.hooks').reset_cache() ]], -  [[ command! LvimUpdate lua require('lvim.bootstrap').update() ]], -  [[ command! LvimSyncCorePlugins lua require('lvim.plugin-loader'):sync_core_plugins() ]], -  [[ command! LvimReload lua require('lvim.config'):reload() ]], -  [[ command! LvimToggleFormatOnSave lua require('lvim.core.autocmds').toggle_format_on_save() ]], -  [[ command! LvimVersion lua require('lvim.core.telescope.custom-finders').view_lunarvim_changelog() ]], +]] + +M.defaults = { +  { +    name = "BufferKill", +    fn = function() +      require("lvim.core.bufferline").buf_kill "bd" +    end, +  }, +  { +    name = "LvimToggleFormatOnSave", +    fn = function() +      require("lvim.core.autocmds").toggle_format_on_save() +    end, +  }, +  { +    name = "LvimInfo", +    fn = function() +      require("lvim.core.info").toggle_popup(vim.bo.filetype) +    end, +  }, +  { +    name = "LvimCacheReset", +    fn = function() +      require("lvim.utils.hooks").reset_cache() +    end, +  }, +  { +    name = "LvimReload", +    fn = function() +      require("lvim.config"):reload() +    end, +  }, +  { +    name = "LvimUpdate", +    fn = function() +      require("lvim.bootstrap"):update() +    end, +  }, +  { +    name = "LvimSyncCorePlugins", +    fn = function() +      require("lvim.plugin-loader").sync_core_plugins() +    end, +  }, +  { +    name = "LvimChangelog", +    fn = function() +      require("lvim.core.telescope.custom-finders").view_lunarvim_changelog() +    end, +  }, +  { +    name = "LvimVersion", +    fn = function() +      print(require("lvim.utils.git").get_lvim_version()) +    end, +  },  } -M.load = function(commands) -  for _, command in ipairs(commands) do -    vim.cmd(command) +function M.load(collection) +  local common_opts = { force = true } +  for _, cmd in pairs(collection) do +    local opts = vim.tbl_deep_extend("force", common_opts, cmd.opts or {}) +    vim.api.nvim_create_user_command(cmd.name, cmd.fn, opts)    end  end | 
