Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep track of current project #30

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

Gazareth
Copy link

@Gazareth Gazareth commented Feb 5, 2023

As requested in #27

This brings in some changes which make switcher more responsible and keep track of the projects its opened. Some functionality is moved away from session into switcher.

I know you want to keep projections.nvim very tiny which I appreciate, however I hope you will consider that this paves the way for potential future functionalities like:

  • Being able to store multiple sessions per project and select between them (via .e.g. telescope) when opening a project

The implementation in this PR already allows some cool functionality, e.g. I am showing in my statusline that I'm inside a project:

image

Or not

image

And now a session is not overwritten when browsing a file within a workspace project that you didn't use projections.switcher to open!

Let me know if you want anything tidying up, I was treating this as a proof of concept for the majority of the time so some things might be loosely named etc.

@Gazareth Gazareth marked this pull request as draft February 5, 2023 02:11
…stance

- Convert switcher:switch() into being a wrapper function around switcher:switch_project() which constructs a Project instance internally
- Fix 'workspace' not being created properly in Project:new_from_dir
- Update switcher:set_current()to be safer
- Reorder logic of switcher:switch() to improve safety and terseness
@GnikDroy
Copy link
Owner

GnikDroy commented Feb 5, 2023

Sounds promising. Thank you for the PR. I will take a look at integrating this in a few days (am busy for a few days) 😄

One thing I noticed is - doc/projections.txt. This file doesn't need to be updated, since it is generated from README automatically.

…f the Project class

- Remove Project.new_from_dir()
- Extract 'find workspace' logic into Workspace.find()
- Add explicit function for detecting if we are in a project: Switcher:in_project()
- Expand paths in Switcher:switch_project() so that comparisons provide consistent results
It is generated automatically from the README so doesn't need to be updated
@Gazareth
Copy link
Author

Gazareth commented Feb 5, 2023

Sounds promising. Thank you for the PR. I will take a look at integrating this in a few days (am busy for a few days) 😄

One thing I noticed is - doc/projections.txt. This file doesn't need to be updated, since it is generated from README automatically.

Cheers for looking. I converted it to draft because I was having some trouble with some autocmds, turns out it was due to directory paths being inconsistent (darn Windows and its "\" separator).

Also added a check within the switcher to make sure the project is a valid one by reusing the workspace logic found in Session.

@Gazareth Gazareth marked this pull request as ready for review February 5, 2023 21:31
@GnikDroy
Copy link
Owner

Apologies for being a bit late. But I will take a look at this today. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants