Sublime Forum

Can I add syntax (and if possible other settings, maybe even plugins) to my project?

#1

I am trying to use SublimeText as IDE of sorts for my project made in C.

I realized, that maybe I can “abuse” SublimeText to make for example it parse custom files and whatnot (for example what if I want to make a custom configuration file for my program).

But I wouldn’t want to change its behaviour outside the proejct, even because when I said “abuse” I wasn’t kidding, one of my ideas is to see if I can figure how to make SublimeText edit some files that are hybrids of UTF-8 and binary… this for example would require disabling the “automatic hex” thing.

But I don’t want my custom build systems, syntax, possible plugins, colour schemes, whatever, that is only appropriate to this project affecting stuff elsewhere.

Also it would be cool if I could copy-paste the project folder in other machine, install SublimeText there, and have my custom things there too.

So, is it possible?

0 Likes

#2

The only thing that can be specific to a project are settings, stored in a settings key inside of your sublime-project file.

However, if you’re using Windows you can use the portable version of Sublime; that version stores all configuration and user files directly inside of the installation folder instead of in your home directory, which makes it distinct from everything else.

The same is possible under Linux by creating a Data directory inside of the extracted package, although this is not documented and so possibly not officially supported.

In either case it’s a bit heavy weight,but it does mean that you could carry your project to another machine and have it work there because you would be bringing your entire install along with you.

1 Like

#3

I use OSX, Linux and Windows (yes, all 3)

So that is not really an option.

0 Likes

#4

I use all three platforms as well. Theoretically the same thing would work under OSX, but I’ve never actually tried it so I’m not sure.

The only other option available would be to put all of your customized changes into a specific package, and then disable and enable that package on a per-project basis. If I recall correctly, the ignored_packages setting is not allowed to be set per-project.

1 Like

#5

Complementing, on the folder Packges/User you can create the files:

  1. Preferences (Windows).sublime-settings
  2. Preferences (Linux).sublime-settings
  3. Preferences (OSX).sublime-settings

And inside each one of them to add an ignored_packages array as:

{
	"ignored_packages":
	[
		"Anaconda",
		"ApplySyntax",
		"ColorHelper",
        ]
}

I think this array could be also created on your project file, so on that project those packages would be ignored. But I am not sure without testing it first, because I do not know how multiple definitions of ignored_packages array will be handled by Sublime Text or whether you may specify settings on the project file.

0 Likes

#6

No, ignored_packages is a global setting.

@Speeder, you could use https://packagecontrol.io/packages/Package%20Bundler to only have a package (set) active for certain projects, but it will not bundle the package with the project itself. You’ll need to have the package installed on every machine.

1 Like

#7

The main reason you can’t disable packages on a project-specific basis is because there is only one plugin_host that is run for all Sublime Text windows. That is to say, the plugin architecture is application-level.

Since packages can define Python code that starts threads and in the background, there isn’t really a way to “unload” it when a specific Window is focused since it could easy break background processes for other windows.

Due to the Python API, it is certainly possible to mass-enable and disable packages. It seems as though the Package Bundler package that @FichteFoll linked to is one such solution. Just be aware that most plugins aren’t really tested in such a way that they are regularly enabled and disabled. You may run into subtle bugs in such situations, such as regions not being removed, syntaxes disappearing that are still applied to a view, etc.

3 Likes