gerardroche / sublime-sesame

Open projects and folders commands.
https://www.gerardroche.com
GNU General Public License v3.0
21 stars 3 forks source link

sesame_open does nothing #12

Open joelmellon opened 3 years ago

joelmellon commented 3 years ago

Preface: I've configured my Menu > Preferences > Settings correctly with "sesame.path": "~/projects" confirming the path is correct.

When I select Sesame: Open from the command palette, I get this message ("Sesame: No projects found") in the status bar at the bottom of Sublime. (The same thing happens when executing the keyboarding binding I've set up for sesame_open.)

Screen Shot 2021-03-04 at 1 47 33 PM Screen Shot 2021-03-04 at 1 47 35 PM

I'm not sure if I understand its functionality correctly, but I'm trying to open a new window with the current project like Project > New Workspace for Project does.

Screen Shot 2021-03-04 at 1 51 34 PM

Regardless, I presume something should be happening. Am I missing something?

gerardroche commented 3 years ago

Hmm.

Are you projects located at ~/projects?

With:

|-- ~/projects
           |-- project/name
           |-- project/name2
           |-- project-b/name
           |-- project-b/name2

This should display a select list with the four projects above.

gerardroche commented 2 years ago

I think there is confusion between Sesame projects and Sublime projects. They are different things and nothing to do with one another.

Sesame only provides an easy way to access folders or "projects" on your system.

For example, let's say you organise your projects folders like so:

~/projects/project-1/project-a
~/projects/project-1/project-b
~/projects/project-2/project-a
~/projects/project-3/project-a

With that folder structure for your projects you can set:

sesame.path": "~/projects"

And then when you run Sesame: Open it will prompt you with a list of your projects (folders) to open:

project-1/project-a
project-1/project-b
project-2/project-a
project-3/project-a

If you prefer to organise your project folders at a single level you can set the depth to 1, so with the following folder structure:

~/projects/project-1-project-a
~/projects/project-1-project-b
~/projects/project-2-project-a
~/projects/project-3-project-a

And setting the depth to 1:

"sesame.depth": 1

Now running Sesame: Open will prompt you with a list at a single depth:

project-1-project-a
project-1-project-b
project-2-project-a
project-3-project-a

I hope that helps.

joelmellon commented 2 years ago

Sorry, I missed your reply a year and a half ago. Thanks for revisiting this issue.

The functionality you describe is exactly what I'm trying to achieve, and I think I'm using the plugin as intended. ‾\(ツ)/‾

I've got the following file structure:

~/Code/projects % ls
test.sublime-project    test.sublime-workspace

...and two different configuration attempts in my Sublime.prefrences:

    "sesame.path": "~/Code/projects/",
    "sesame.depth": 1,
    "sesame": {
        "path": "~/Code/projects/",
        "depth": 1,
    },

No combination of these work individually either, FYI. I just listed everything I've tried. With and without depth, different depth values, nested JSON, etc.

And when I Sesame: Open I still get "Sesame: No projects found" in the status bar.

As an alternative, I started using an Alfred file filter workflow to search my "~/Code/projects" directory for "*.sublime-project" files in order to achieve this functionality, so this isn't super important to me now. 😬 I have a knack for finding edges cases, so if no one else is seeing this, I'd probably just close the issue.

Thanks again.

gerardroche commented 2 years ago

Ah yes, move both test.sublime-project and test.sublime-workspace into a folder:

~/Code/projects/test/test.sublime-project
~/Code/projects/test/test.sublime-workspace

Sesame looks for folders, it won't pickup sublime-project files by themselves.

With the test project above and a depth of 1, Sesame will prompt with one project:

test

If you have the following with a depth of 2:

~/Code/projects/test/test/test.sublime-project
~/Code/projects/test/test/test.sublime-workspace
~/Code/projects/one/a/test.sublime-project
~/Code/projects/one/a/test.sublime-workspace
~/Code/projects/one/b/
~/Code/projects/one/c/
~/Code/projects/fizz/buzz/

Sesame will prompt:

test/test
one/a
one/b
one/c
fizz/buzz

If the folder contains a sublime-project Sesame use it to open the folder, otherwise it just opens the folder.

joelmellon commented 2 years ago

I tried that just now. I can't get it to work. I might need to restart Sublime or something, but it's not happening for me. Sorry to be a pain. I'm sure it's user error.

gerardroche commented 1 year ago

@joelmellon Did you ever get it working? I wrote a blog post which may help: https://blog.gerardroche.com/2023/05/19/sesame-a-sublime-text-plugin/

mike2hex commented 1 year ago

I just ran into a similar issue. I am on windows and set my sesame.path to ~/projects. In the _find_folders function, the folder gets constructed like C:\Users\me/projects and I got the same "No project found" message. Not sure that is the original poster issue though, their screenshots look like they are on a Mac.

If I change sesame.path to ~\\projects then it works as advertised. This will cause me problems switching between windows and linux. Couple of thoughts, ordered by my guess at least amount of work to most work.

  1. Move the PROJECTS_PATH environment variable up so it overrides what is in sesame.path
  2. do some path munging so ~/project is turned into ~\project on windows

Just getting started with Sublime Text. Looking at https://www.sublimetext.com/docs/settings.html#settings-files I don't see anything like a Packages/Users/Preferences Windows.sublime-settings. If something like exists, I could use that instead.

I guess technically I could omit the sesame.path in all configs, but I am trying to version control my configs in one git repo with submodules for the packages. Does anyone else do that? I saw you https://github.com/gerardroche/sublimefiles repo, thanks for that.

Appreciate your time.

mike2hex commented 1 year ago

You can ignore this entire comment. After working on linux all day today with sesame.path set to ~/projects and the syncing back to windows it is working correctly. Maybe I had the depth misconfigured. Sorry for the noise.

gerardroche commented 1 year ago

@mike2hex no worries. Glad you got it working, and for the information.

1) The PROJECTS_PATH is intentionally loaded before the sublime setting to allow overriding it directly in sublime. Loading it after the setting would need to be configurable, and default to how it works now.

You could leave the setting in sublime blank and set the PROJECTS_PATH environment variable on each system.

Example: For Windows users:

You can set environment variables for each user separately through the System Properties dialog box. The steps to do that:

  1. Type Windows Key + R to open the "Run" dialog box.
  2. Enter "sysdm.cpl" and press the "OK" button. The "System Properties" dialog box will open.
  3. Select the "Advanced" tab and press the "Environment Variables..." button. The "Environment Variables" dialog box will open.
  4. Select an existing variable in the "User variables" list and press the "Edit..." button to edit it. Or press the "New..." button to add a new variable.
  5. After you finished editing variables, press the "OK" button to save the changes.

Please keep in mind that to activate these changes, you will be required to restart Sublime Text and, in some cases, reboot your system.

2) The plugin should be able to handle the ~/project case for linux and windows, I will need to look into it and if the path separator can be resolved os.

OS specific settings

We could maybe provide some way of configuring sesame for different operating systems too because I can see how this could be difficult. I don't personally switch between linux and windows systems so haven't been faced with this problem.

But I don't think this is an issue unique to sesame. I think you will have similar issues with other plugins.

For instance, I've faced the issue where I want different ui_scale settings for my desktop and laptop. What I've done, for the want of a better solution, is create a settings file unique on my laptop and on my desktop:

Packages/UserLaptop/Preferences.sublime-settings
Packages/UserDesktop/Preferences.sublime-settings

And then have git ignore those files: https://github.com/gerardroche/sublimefiles/blob/master/.gitignore#L33

I then set two different ui scales in those.

The downside is they are not version controlled, but once I had the ui_scale set, I haven't changed them since.

Note that you don't actually need different setting files, you could just as easily use one, e.g. Packages/UserUIScale/Preferences.sublime-settings. I used two so that I could name them for their intended purpose i.e. settings unique to that environment.

You can use os specific settings files in packages, so you could create one package with three different os specific settings, with a default fallback:

Packages/UserSettings/Preferences (Linux).sublime-settings
Packages/UserSettings/Preferences (Windows).sublime-settings
Packages/UserSettings/Preferences (OSX).sublime-settings
Packages/UserSettings/Preferences.sublime-settings

Here are the docs on sublime settings: See https://www.sublimetext.com/docs/settings.html

I would recommend prefixing any custom packages that use with "User" to avoid clashing with any package names in package control.