Sublime Forum

Enable Package for Single Language



I’d like to use the “IndentToAllBrackets” plugin for .hs files only. I can see that I can specify syntax-specific settings, but I wasn’t able to find a way to do syntax-specific packages.

I tried placing the package in the “ignored packages” list in my main settings file and then overriding that in the haskell specific settings, but it seemed to stay disabled in .hs files. Any suggestions?



It’s not possible to enable packages in a granular way; packages are either loaded globally or not loaded at all. Settings that can be placed in syntax specific settings (and project specific settings) are Editor settings, which are the class of settings that modify how the editor behaves. Things like the overall application theme or the list of ignored packages control the application as a whole.

That said, for a properly created package there’s no real speed hit or having a package enabled even if the file you’re editing doesn’t need it. Generally speaking, the appropriate thing here is for packages to either self-constrain themselves to specific file type(s) or have a setting that enables or disables them that you CAN put in the syntax specific settings if you want to opt out.



Gotcha, guess I would need to fork the package to make it work. Although it looks like maybe I should be modifying the “add line in braces” snippet. I’ll have to do some finangling and see…

Edit: It seems that the “add line in braces” snippet already has different behavior by filetype, but I can’t figure out what controls it. In a JSON file, it keeps each brace in the same column but separates them by a blank line, whereas with other filetypes it removes indentation from the closing bracket. I’m trying to use the JSON behavior for other filetypes, and apply that to parens and square brackets, similarly to how VS code works by default.