When working with multiple projects (managed by git), how could I easily switch between them and still do file and search related tasks within the context of the current project only.
For example, I have a clojure project being developed in ~/project/gameboard directory and a tutorial project in ~/project/practicalli/tutorial
If I have service.clj open in a buffer from the gameboard project, opening a file in telescope should only see the files from gameboard. Switching to the tutorial project and opening telescope should show only tutorial related files and buffers
Ideally i’d like to have a key binding to switch to the tutorial project or even toggle between the two projects (or select from a list projects available). added bonus if i can create a new project by typing its name.
I guess one way is just to have a terminal window with neovim open for each project and use the window manager (or terminal tabs) to switch. any other options?
You can use :cd to change the root directory in vim
Your could use vim-rooter to set the cwd argument of Telescope to change to the “root” of a given file
You could open vim from ~/projects to make that cwd and have access to both projects
You could use mksession or a plug-in wrapping it to switch between “sessions”, which are bundles of tabs and buffers (i use https://github.com/Shatur/neovim-session-manager)
I use guis so I’m very used to alt-tabbing or alt-tildeing between windows that act as project groups
i got a bit confused when using (and forgetting to use) :cd or lcd so something a bit more specific to projects seems to be needed for me.
I’ll take a look at the session manager.
I found a telescope project extension that gives me a simple (more foolproof for me) approach
https://github.com/nvim-telescope/telescope-project.nvim
I found project_nvim but that seemed to be more manual config.
I use tmux, which makes it easy to manage multiple terminal sessions. Switching projects entails opening a new terminal window (inside tmux) and starting Neovim in the directory for that project. tmux makes it really easy to switch back and forth between the windows, so I've never found it necessary to use vim project/context management plugins.
^Not a one-size-fits-all solution, but it's worked well for me, as a tmux-oriented person.
When I was using Spacemacs, there was an option of pressing <space>pp (space-project-projects) which show all the project you have. I wanted the same with vim.
My current config is nvim+telescope based.
Basically this plugin does all the work https://github.com/nvim-telescope/telescope-project.nvim
Another plugin I used is the https://github.com/airblade/vim-rooter which sets the correct path automatically.
When I want to open another project, I press <space>pp, search for a project, select a file, and press t to open it in a new tab.
@dave yes, tmux is neat. I've used byobu for similar effect before switching to Kitty terminal. I have to use a Mac for my current employer and kitty seemed the best terminal for my needs. I liked kitty so much I now also use it on Linux - https://sw.kovidgoyal.net/kitty/ The only caveat to this approach is ensuring I don't open the same file in two different neovim instances, but that seems unlikely so long as I do relative files
@arturdumchev thanks. I use layouts in Spacemacs (SPC l) to organise projects and Telescope-project extension seems to be what fits my existing workflow. Nice tip about using t to open project in another tab, that's useful. The telescope project extension has the snyc_with_nvim_tree option and so I simply set that to true and nvim-tree keeps in sync.
Thanks for all the ideas,much appreciated
I've been using https://github.com/m00qek/nvim-contabs for the exact same use case. I'm certain there might some fancier solution out there but this one has been working fine for me
Since I wanted to move away from fzf I tried nvim-telescope-project but I couldn’t get it to work the way I intended. Particulary, I don’t see any option to open a project in a new tab. @arturdumchev @jr0cket how do you get around that? Since I also wanted to play around with lua/fennel and the newer neovim APis, I went ahead and created https://github.com/fuadsaud/rhizome.nvim. It’s a WIP and I’m not sure if it even makes sense since it’s a bit more limited than telescope-project.
:h telescope.actions.select_tab()
Alternatively, you could try https://github.com/akinsho/bufferline.nvim.
to emulate the behavior of tabs used by other editors such as VSCode or Idea. I recently switched to it and commented out my tab mapping:
> Since I also wanted to play around with lua/fennel I can give you one piece of advice that could save you several lifetimes. Just use the https://fennel-lang.org/seefennel translator> to get configs and code snippets from lua translated immediately