nyngwang/NeoRoot.lua

github github
project
star 17
stars
alert-circle 0
open issues
users 1
subscribers
git-branch 1
forks
CREATED

2021-12-29

UPDATED

34 minutes ago


NeoRoot.lua

DEMO

TODO: update

New Intro.

With NeoRoot.lua, you will be able to:

  • Run nvim MyProj to open neovim with Project Root at ../somewhere/MyProj/
  • During development, you can use toggle to temporarily change between cwd to your current buffer, and ../somewhere/MyProj/ .
  • During development, you can temporarily re-define your project root to, for example: ~/.config. (shorthand ~, ../s are available :))
    • if you want to change back to ../somewhere/MyProj/, just leave the prompt blank. Simple
  • That's it!

Old Promo.

Now you won't have a hard time :cd to the right place to see more files before executing commands that takes your current working directory into account (i.e. you need to go up some levels to make tools like rg/fd to "see" more files). You can also change your project root in the runtime, without typing any command, anymore!

Features

  • No dependencies
  • No requirements
  • free
  • Light-weight, ~100 lines

Compatibility

Setup

Packer.nvim

local NOREF_NOERR_TRUNC = { noremap = true, silent = true, nowait = true }
use {
  'nyngwang/NeoRoot.lua'
}
vim.cmd'au BufEnter * NeoRoot'
vim.keymap.set('n', '<Leader>p', function() vim.cmd('NeoRootSwitchMode') end, NOREF_NOERR_TRUNC)
vim.keymap.set('n', '<Leader>pre', function() vim.cmd('NeoRootChange') end, NOREF_NOERR_TRUNC)

Hint

To see your current working directory, simply call NeoRootSwitchMode twice.

TODO list

  • Add installation guide in README.md
    • packer.nvim
  • Customizable
    • keymappings
    • ignore list