zongben/proot.nvim

github github
project
stars 4
issues 0
subscribers 1
forks 0
CREATED

2025-01-16

UPDATED

12 days ago


proot.nvim

Lightweight project navigator with telescope

圖片

Features

  • Autodetect by using lsp and files to save project root dir
  • Use telescope to search and change root dir
  • Allow freely renaming projects for easier management

Installation

With lazy.nvim

{
  "zongben/proot.nvim",
  dependencies = {
    "nvim-telescope/telescope.nvim",
    "nvim-lua/plenary.nvim"
  },
  opts = {}
}

Configuration

The default configuration is as follows

{
  detector = {
    enable_file_detect = true,
    enable_lsp_detect = true,
  },
  files = { ".git" },
  ignore = {
    lsp = nil, -- ignore lsp clients by name e.g. { "pyright", "tsserver" }
  },
  events = {
    -- called when you change the directory
    entered = function(path)
    end
  },
}

Usage

Open proot picker by calling :Proot
In proot picker you can use d to delete project dir and use r to rename project name virtually

Tips

I like to close all buffers and restart LSP servers after I switched repositories

events = {
  entered = function (path)
    vim.cmd("bufdo bd")

    local clients = vim.lsp.get_clients()
    for _, client in pairs(clients) do
      vim.cmd("LspRestart " .. client.name)
    end
  end
}

For users who use toggleterm and lazygit, you can set the directory of lazygit each time you launch it.
This way, each time proot switches to a new directory, lazygit can also switch to the new path accordingly.

local Terminal = require("toggleterm.terminal").Terminal
local lazygit = Terminal:new({
  cmd = "lazygit",
  hidden = true,
  direction = "float",
  float_opts = {
    border = "curved",
  },
})
function Lazygit_toggle()
  lazygit.dir = vim.fn.getcwd()
  lazygit:toggle()
end

NOTE

If you encounter any issues, please check the changelog first.

Similar Plugin

ahmedkhalf/project.nvim - The superior project management solution for neovim.