Skip to content

Commit

Permalink
fix: do not autostart the plugin if nvim is passed args
Browse files Browse the repository at this point in the history
  • Loading branch information
olimorris committed Oct 17, 2024
1 parent 3006e64 commit e65093d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lua/persisted/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ local utils = require("persisted.utils")
local M = {}

local config
local start_args = vim.fn.argc() > 0 or vim.g.started_with_stdin

local e = vim.fn.fnameescape
local uv = vim.uv or vim.loop

Expand Down Expand Up @@ -35,7 +37,7 @@ end
function M.autoload(opts)
opts = opts or {}

if not opts.force and (vim.fn.argc() > 0 or vim.g.started_with_stdin) then
if not opts.force and start_args then
return
end

Expand Down Expand Up @@ -72,7 +74,7 @@ function M.load(opts)
config.on_autoload_no_session()
end

if config.autostart and M.allowed_dir() then
if config.autostart and M.allowed_dir() and not start_args then
M.start()
end
end
Expand Down Expand Up @@ -223,7 +225,7 @@ function M.setup(opts)

vim.fn.mkdir(config.save_dir, "p")

if config.autostart and M.allowed_dir() and vim.g.persisting == nil then
if config.autostart and M.allowed_dir() and vim.g.persisting == nil and not start_args then
M.start()
end
end
Expand Down

0 comments on commit e65093d

Please sign in to comment.