Skip to content

use_git_branch = true does not work when cwd is not git root directory #149

Answered by mrloop
mrloop asked this question in Q&A
Discussion options

You must be logged in to vote

My lazy config for future searchers wondering how to use in mono repos

{
    "olimorris/persisted.nvim",
    lazy = false, -- make sure the plugin is always loaded at startup
    opts = {
      autoload = true,
      autosave = true,
      use_git_branch = true,
    },
    config = function(_, opts)
      local persisted = require("persisted");
      -- use_git_branch not working from sub directory of git project https://github.com/olimorris/persisted.nvim/discussions/149
      persisted.branch = function()
        local branch = vim.fn.systemlist("git branch --show-current")[1]
        return vim.v.shell_error == 0 and branch or nil
      end
      persisted.setup(opts);
    end,
    init =

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@olimorris
Comment options

@guoliang
Comment options

Answer selected by mrloop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants