project.nvim icon indicating copy to clipboard operation
project.nvim copied to clipboard

[Feature] just before changing/opening project execute direnv

Open dhruvinsh opened this issue 2 years ago • 3 comments

I have feature request for this plugin. Not sure if fesible or not, or even should be part of this or not, but it would be great that when one of the project get activated, if any direnv (.envrc) file exisits then allow to excute that.

My lot of project relies on activating the .envrc, which intern enable some extra binaries for the project or dependencies and then LSP or formatter might work. With that this plugin becomes little un-useful. For non-env projects this plugin has been helping me out a lot. Kudos to dev!

I can think of work flow something like below,

  • open neovim in home directory
  • open project picker and selct project
  • if envrc directed and if its allow then load the envrc first. All the path will be reloaded as well (I guess this is the hardest part)
  • update the cwd for nvim-tree
  • since path is updated, LSP will load happily
  • null-ls will find the needed binary tucked inside the envrc paths
  • when switching the project, clenup the envrc and start from third step.

dhruvinsh avatar Sep 16 '22 22:09 dhruvinsh

@ahmedkhalf While thinking further, I feel that this feature requests is out of the scope of the project.

But It would be great if we have some sort of hook (unless I am missing existing of one), to run certain command, before it trigger some sort of environment changes for telescope or nvim-tree etc.

dhruvinsh avatar Oct 07 '22 00:10 dhruvinsh

Yes, something more general, i would like the ability to run a function before and/or after the project opening

a pre-hook and a post-hook

hacktivateit avatar Oct 10 '22 16:10 hacktivateit

There is a plugin called direnv.vim provided by the direnv team that does this. Work nicely with project.nvim.

vohoanglong0107 avatar Dec 26 '22 15:12 vohoanglong0107