Can I exclude files like I do folders in the config for sublime? - json

Is it possible for sublime not to display files such as package-lock.json the same way you can tell it not to display folder such as node_modules using:
"folder_exclude_patterns":
[
"node_modules",
".git"
],
I'm referring to the sidebar display of files and folders.

Yes, you use the file_exclude_patterns setting for that. The default uses wildcards:
"file_exclude_patterns": ["*.pyc", "*.pyo", "*.exe", "*.dll", "*.obj","*.o", "*.a", "*.lib", "*.so", "*.dylib", "*.ncb", "*.sdf", "*.suo", "*.pdb", "*.idb", ".DS_Store", "*.class", "*.psd", "*.db", "*.sublime-workspace"],
However you can include direct filenames in there to exclude specific files if you want to. Remember that if you want to modify the setting you should copy the entire value from the defaults into your user settings and modify it there; otherwise the default settings will be lost and you'll end up with more files in your sidebar and not less.
Both file_exclude_patterns and folder_exclude_patterns can be used in your sublime-project file if you want certain files and folders to only be excluded for a particular project.

Related

How can I handle html files in Luminus which aren't in "resources"?

I have this:
(defn about-page []
(layout/render "about.html" {:title "About"}))
But since I have moved the directory "templates" from "resources" to the root directory and on a server I might put it yet in another place, it doesn't work. I did it because I don't want the html templates to be embedded in the output jar.
So how can I make the code work, how can I get access to my html files in "templates" then?
And the same question for static images, css, js: I put them in the root directory for now, so they aren't in "resources". They're in "public" folder. However, when I refer to them as "public/css/css1.css", they aren't getting found, that is, the path localhost:3000/public/css/css1.css doesn't exist.
How can I tell Luminus where my statics are located now?
Templates location
Selmer's documentation describes how to change the location of the templates:
By default the templates are located relative to the ClassLoader URL.
If you'd like to set a custom location for the templates, you can use
selmer.parser/set-resource-path! to do that:
(selmer.parser/set-resource-path! "/var/html/templates/")
It's also
possible to set the root template path in a location relative to the
resource path of the application:
(set-resource-path! (clojure.java.io/resource "META-INF/foo/templates"))
This allows the templates to be refrerenced
using include and extends tags without having to specify the full
path.
To reset the resource path back to the default simply pass it a nil:
(selmer.parser/set-resource-path! nil)
The application will then look
for templates at this location. This can be useful if you're deploying
the application as a jar and would like to be able to modify the HTML
without having to redeploy it.
As you want your templates to be reload when you change them you should also remember that Selmer caches them:
When rendering files Selmer will cache the compiled template. A
recompile will be triggered if the last modified timestamp of the file
changes. Note that changes in files referenced by the template will
not trigger a recompile. This means that if your template extends or
includes other templates you must touch the file that's being rendered
for changes to take effect.
Alternatively you can turn caching on and off using
(selmer.parser/cache-on!) and (selmer.parser/cache-off!) respectively.
Assets location
Handling of static resources is configured using site-defaults in your <app>.middleware namespace. You need to configure its' :static entry to use :files instead:
(-> site-defaults
(assoc :static {:files "/var/www/html"}))
and you need to copy files from resources/public directory to that location.

Different user settings for synced sublime

I've synced my User folder with sublime settings.
But what if I want to use different settings for different machines? For example, in settings of terminal package I define path to Git Bash, and it's
"terminal": "C:/Program Files (x86)/Git/bin/sh.exe"
on one machine, and
"terminal": "C:/Program Files/Git/bin/sh.exe"
on another.
I've tried to use default settings, but they refresh all the time.
Maybe look into this package: https://packagecontrol.io/packages/PackageSync
I've never used it, but according to the README,
PackageSync provides the following user configurable settings:
...
ignore_files [array]
The list of files to ignore when backing up.
So you would want to create a PackageSync.sublime_settings file that has this in it:
{
"ignore_files": "Terminal.sublime_settings"
}
This isn't ideal since it prevents the enitre file from syncing, not just that one entry (the "terminal": "C:/Program Files (x86)/Git/bin/sh.exe" entry), but it should work. (Disclaimer: I have not tried this myself)
Alternative: Possible workaround:
You could also just use the line "terminal" : "~/my_custom_terminal_shortcut" in your settings and then create a ~/my_custom_terminal_shortcut file on each computer that links to the appropriate location

How can I exclude a folder from indexing in Sublime Text, while still showing it in the sidebar?

For a large project with many dependencies e.g. in the node_modules/ folder, I noticed frequent CPU spikes because of Sublime indexing all the files in the folder.
I know I can hide files and folders using the folder_exclude_patterns setting, but I still want the folder to be visible in the sidebar.
How can I keep e.g. node_modules/ in the sidebar, but exclude it from indexing?
To exclude files from the index but keep them in the sidebar, use the binary_file_patterns setting in your User Settings, for example:
"binary_file_patterns": [
"*.jpg", "*.jpeg", "*.png", "*.gif", "*.ttf", "*.tga", "*.dds",
"*.ico", "*.eot", "*.pdf", "*.swf", "*.jar", "*.zip",
"node_modules/**",
"bower_components/**"
]
Make sure to copy the values from your Settings - Default preferences (here shown as "*.jpg" etc.), or you will start indexing binary files.
You can change your personal settings, in Preferences -> Settings - User, add:
{
"folder_exclude_patterns":
[
".svn", ".git", ".hg", "CVS",
"node_modules",
],
}
Sublime Text 3 now provides a way to exclude files and folders from indexing while keeping them in the sidebar:
"index_exclude_patterns": [
"*.log",
"node_modules/*"
]
On my project I observed the following improvement in the indexing status menu after applying changes:
Before:
index "MyApp" collated in 0.70s from 73934 files
index "MyApp" is using 15167488 bytes for 54234 symbols across 1357673 locations
After:
index "MyApp" collated in 0.00s from 137 files
index "MyApp" is using 61440 bytes for 730 symbols across 4763 locations
Doesn't work in ST3 (Build 3126).
You can show node modules folders in sidebar and hide files inside this way :
"file_exclude_patterns":
[
...,
"node_modules/**"
]
If you want to hide subfolders from each node module :
"folder_exclude_patterns":
[
"node_modules/*/**"
]
All files inside node_modules will be removed from search, but each node_module subfolder will be still visible in sidebar.
I thought binary_file_patterns wasn't working, because I am in the habit of right-clicking my top level folder and choosing "Find in folder". folder_exclude_patterns works with this but binary_file_patterns still searches everything - because the "Where" field overrides the setting.
So you can either use the menu option Find > Find in files OR right click-your top level folder, choose "Find in folder" and then delete the text in the "Where" field so it shows the placeholder text "Open files and folders".
Obviously you still have to add this to Preferences/Settings:
"binary_file_patterns": [
"node_modules/",
],

Sublime Text 2: Cannot override the global file_exclude_pattern?

Is it possible to include a file in per-project settings that's been excluded by Sublime Text's global settings?
For example, the global settings have mandated that "*.obj" files (intending files output by a build process) be excluded. Without changing those global settings, I cannot seem to include .obj files (these being 3d model files) in my project. Putting file_exclude_patterns in the "settings" section doesn't override, and adding a file_include_patterns key to the paths section simply filters every other file type out, and yet the .obj files still aren't included! (Apparently exclusion filters are applied after inclusion filters.)
So do I have to change global settings for this then??
I just came across exactly the same problem for exactly the same files.
The only solution seems to be to override the setting in your user settings, minus the "*.obj" wildcard. If you need to exclude those files in other projects or folders within projects, you'll have to specify the setting in your project settings.

How do you configure JSHint options globally in Sublime Text 2?

I'd like to turn off particular warnings globally when using Sublime Text 2's JSHint plugin. For instance, "laxcomma".
I tried editing the .jshintrc file in JSHint's Sublime Packages folder, but this did not work.
{
"laxcomma": true
}
Adding a project specific .jshintrc file with the same options solves the issue for that particular project, but I would like these options to be global.
Any suggestions?
From the JSHint docs page:
http://www.jshint.com/docs/
JSHint will look for this file in the current working directory and, if not found, will move one level up the directory tree all the way up to the filesystem root.
So, technically you could put a .jshintrc file at the root level of your filesystem (/.jshintrc) and every new project would default to those options. Individual projects could override them as needed.
If anyone's having trouble creating a .jshintrc in Windows, you could go to AppData\Roaming\Sublime Text 3\Packages\SublimeLinter, copy .editorconfig for example, rename and edit it then place it in your root directory like #philip-walton suggested.
If you edit the file here, you may need to Run your text editor as administrator.
If you try to rename the file here, you may need to right-click the file, go to Security, Advanced, change the Owner object name to yourself (PC-Name\User-Name), then also Add yourself to the list of Permissions by selecting the Principal.