refactor: move commands to vim file

main
olimorris 2023-02-21 16:01:27 +00:00
parent 452c36a3f9
commit f99ad40198
2 changed files with 11 additions and 15 deletions

View File

@ -6,20 +6,6 @@ local M = {}
local e = vim.fn.fnameescape
local default_branch = "main"
---Setup the plugin's commands
---@return nil
local function setup_commands()
vim.cmd([[
command! SessionStart :lua require("persisted").start()
command! SessionStop :lua require("persisted").stop()
command! SessionSave :lua require("persisted").save()
command! SessionLoad :lua require("persisted").load()
command! SessionLoadLast :lua require("persisted").load({ last = true })
command! SessionDelete :lua require("persisted").delete()
command! SessionToggle :lua require("persisted").toggle()
]])
end
---Does the current working directory allow for the auto-saving and loading?
---@return boolean
local function allow_dir()
@ -80,7 +66,6 @@ end
---@return nil
function M.setup(opts)
config.setup(opts)
setup_commands()
if config.options.autoload and (allow_dir() and not ignore_dir()) and vim.fn.argc() == 0 then
M.load()

11
plugin/persisted.vim Normal file
View File

@ -0,0 +1,11 @@
if exists('g:loaded_persisted') | finish | endif
command! SessionStart :lua require("persisted").start()
command! SessionStop :lua require("persisted").stop()
command! SessionSave :lua require("persisted").save()
command! SessionLoad :lua require("persisted").load()
command! SessionLoadLast :lua require("persisted").load({ last = true })
command! SessionDelete :lua require("persisted").delete()
command! SessionToggle :lua require("persisted").toggle()
let g:loaded_persisted = 1