0

I'm trying to setup Neogit to open in my workspace directory instead of cwd. The problem is that I use multi root workspaces, so I usually set my cwd to be workspace1/... My initial try was to use something like this (I use NvChad):

M.neovim = {
  n = {
    ["<leader>gg"] = {
      function()
          local neovim = require("neogit");
          neovim.open({ cwd = vim.lsp.buf.list_workspace_folders()[0] })
      end,
      "Open Neogit in lsp cwd",
    },
  }
}

But that doesn't seem to do anything and Neogit uses workspace1/.. anyway :/

Any ideas?

1 Answer 1

0

This is assuming I don't change the workspace after launching vim.

M.neovim = {
  n = {
    ["<leader>gg"] = {
      function()
          local neovim = require("neogit");
          neovim.open({ cwd = vim.lsp.buf.list_workspace_folders()[1] })
      end,
      "Open Neogit in lsp cwd",
    },
  }
}
1
  • Please don't post answers in the body of a question; post them down here as an answer instead. (Welcome to Vi and Vim! The help center has more information on our Q&A model.)
    – D. Ben Knoble
    Jul 14, 2023 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.