ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Folder​2​Project

by divinites ST3

A sublime text plug-in that open the folder that contains current open file.

Details

Installs

  • Total 2K
  • Win 1K
  • OS X 422
  • Linux 407
Oct 22 Oct 21 Oct 20 Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8 Sep 7
Windows 1 1 0 2 3 1 2 2 0 0 0 1 0 1 2 1 0 1 1 1 0 0 1 0 1 0 0 1 0 2 0 0 1 0 1 1 0 0 1 1 1 2 0 0 1 0
OS X 0 0 0 0 0 1 0 2 0 2 0 0 0 1 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 1 0 2 0 1 0 2 0 0 0 1 0 0 0 0 0 0 1 0 0 2 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 1 0 1

Readme

Source
raw.​githubusercontent.​com

Open Folder From File As a Project

Introduction

Sublime Text has a bunch of useful API, However, given an opened file, there is no explicit way to open the folder that contains this file as a project, especially when a *.sublime-project inside that folder. That's why I develop this small plug-in. Basically, this plug-in does two things:

  • Open the folder that contains the openned file as a project. If there is a sublime-project file in this folder, load it (This may change the interpreter, syntax theme, etc.)
  • provide an API for futher developement:

window.run_command(“open_folder_as_project”, {“folder”: folder})

It is a bit tricky to implement this API. First, Sublime only has three project-related API:

- sublime.window.project_file_name()

- sublime.window.project_data()

- sublime.window.set_project_data()

Admittedly, if you have already opened a project file, the methods API are enough to retrive the project settings, but no method can directly open a sublime-project file, nor open a folder as a project.

Therefore, I designed a workaround: 1. Search the folder for *.sublime-project file 2. If exist, load this file. Otherwise create a temporary project configuration. 3. put folder's path in project settings, temporarily change all relative paths to absolute paths to correctly show relevant folders in side bar. 4. update project data.

Usage

  • “open_current_folder_as_project”: Add the folder that contains current file to the sidebar.

  • “remove_folder_from_project”: Remove the folder that contains current file from sidebar.

  • You can define your own keymaps, the default keymap is:

[
   { "keys": ["ctrl+shift+h"], "command": "open_current_folder_as_project"},
   { "keys": ["ctrl+shift+l"], "command": "remove_folder_from_project"}
]