refactor: move commands to vim file
parent
452c36a3f9
commit
f99ad40198
|
|
@ -6,20 +6,6 @@ local M = {}
|
||||||
local e = vim.fn.fnameescape
|
local e = vim.fn.fnameescape
|
||||||
local default_branch = "main"
|
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?
|
---Does the current working directory allow for the auto-saving and loading?
|
||||||
---@return boolean
|
---@return boolean
|
||||||
local function allow_dir()
|
local function allow_dir()
|
||||||
|
|
@ -80,7 +66,6 @@ end
|
||||||
---@return nil
|
---@return nil
|
||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
config.setup(opts)
|
config.setup(opts)
|
||||||
setup_commands()
|
|
||||||
|
|
||||||
if config.options.autoload and (allow_dir() and not ignore_dir()) and vim.fn.argc() == 0 then
|
if config.options.autoload and (allow_dir() and not ignore_dir()) and vim.fn.argc() == 0 then
|
||||||
M.load()
|
M.load()
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
Loading…
Reference in New Issue