How to ignore a folder in definition index for Sublime Text 3? - sublimetext3

Sublime Text added a new feature to show function definition.
Do you know how to disable "dist" folder from the index?

There is a setting called index_exclude_patterns which can be used to exclude specific file patterns from the index. The default value of this is:
// index_exclude_patterns indicate which files won't be indexed.
"index_exclude_patterns": ["*.log"],
However it seems this can only specify file patterns, not directory patterns. So things like "dist", "dist*", "dist/" or "dist/*" do not work.
In this case a workaround is to amend the binary_file_patterns setting. The default for this is:
// These files will still show up in the side bar, but won't be included in
// Goto Anything or Find in Files
"binary_file_patterns": ["*.jpg", "*.jpeg", "*.png", "*.gif", "*.ttf", "*.tga", "*.dds", "*.ico", "*.eot", "*.pdf", "*.swf", "*.jar", "*.zip"],
Files that are binary are not indexed and so won't show up in the definition list.
Adding "dist/*" to the list of patterns should fix the problem up for you. Note that if you don't already have a custom setting for this you should probably copy the default first, otherwise things like images won't be considered binary any longer.

Changing the setting "folder_exclude_patterns" works for this, although the doc says its function is to control which folders are shown in the sidebar.

Related

Modify or extend default settings for a project

In a sublimetext3 project, is there a way to modify or extend, not replace, default settings?
To be specific, in a project I specify the paths of the folders to include in the project. Each folder has files and directories unique to that folder that I want to exclude using either folder_exclude_patterns or file_exclude_patterns; see documentation for Projects.
But as I understand this, these project settings replace not extend the default settings. What I would like, however, is to have a project setting that appends to the default pattern rather than replacing it. Is this possible?
Pseudo code that expresses what I would like to do:
"folders":
[
{
"path": "c:\\dir1",
"folder_exclude_patterns": default_folder_exclude_patterns + ["junk"]
},
{
"path": "C:\\dir2"
"folder_exclude_patterns": default_folder_exclude_patterns + ["old"]
},
]
If this is not possible, then I believe the only thing I can easily do is copy the default settings and replicate them for each folder item. Since I have multiple projects/folders and need to do this for file exclude, folder exclude and binary file settings, this will get tedious and be hard to maintain. Of course, this seems like it is ripe for a plugin, but that is not in the scope of what I am looking to do. (Of course if someone else has a plugin that does something like this, I would be happy to try it out! :-))
Unfortunately, due to the way Sublime is set up, higher-precedence settings replace lower-precedence ones, not supplement them. This is a good thing because many settings are either/or - what would you do if your user settings had "highlight_line": false while a project had "highlight_line": true, for example?
A plugin should be able to do the trick. sublime.Window contains the project_data() and set_project_data() methods, which allow you to retrieve and write project settings, respectively. You could add a "more_folder_exclude_patterns" key to each folder in your project with the additional patterns you would like to add to the defaults set in your Preferences.sublime-settings file. The plugin could then check if the "more" key exists, read both arrays, concatenate them, and write the result back to the .sublime-project file, erasing the "more" key at the same time. Finally, you could set up an event listener to run the plugin whenever you wanted - on save, upon loading a new file, etc.
EDIT
Here's a working example:
import sublime
import sublime_plugin
from copy import deepcopy
class ModifyExcludedFoldersCommand(sublime_plugin.WindowCommand):
def run(self):
proj_data = self.window.project_data() # dict
orig_proj_data = deepcopy(proj_data) # for comparison later
settings = sublime.load_settings("Preferences.sublime-settings")
fep = settings.get("folder_exclude_patterns") # list
for folder in proj_data["folders"]:
try:
if folder["folder_exclude_patterns"]:
break # if f_e_p is already present, our work is done
except KeyError:
pass # if it doesn't exist, move on to mfep
try:
mfep = folder["more_folder_exclude_patterns"]
new_fep = sorted(list(set(fep + mfep))) # combine f_e_p from
# Preferences and project,
# excluding duplicates using
# a set.
folder["folder_exclude_patterns"] = new_fep
del folder["more_folder_exclude_patterns"]
except KeyError:
pass # if mfep doesn't exist, just move on to the next folder
if proj_data != orig_proj_data:
self.window.set_project_data(proj_data)
class UpdateProjectData(sublime_plugin.EventListener):
def on_activated(self, view):
window = view.window()
window.run_command("modify_excluded_folders")
Save the file as Packages/User/modify_excluded_folders.py (where Packages is the folder opened when selecting Preferences -> Browse Packages...) and it should go into effect immediately. It will run each time a view is activated. It checks for the presence of a "folder_exclude_patterns" array in each folder defined in the current .sublime-project file, and if found it assumes everything is OK and passes on to the next folder. If that array is not found, it then checks for the presence of a "more_folder_exclude_patterns" array. If found, it does its magic and merges the contents with the existing "folder_exclude_patterns" array from your preferences (Default or User). It then writes a new "folder_exclude_patterns" array into the folder and deletes the "more_folder_exclude_patterns" array. Finally, it checks to see if any changes were made, and if so it writes the new data back to the .sublime-project file.

Change .eclipse folder in Linux

How can I change the .eclipse folder in Linux? I tried adding this line:
-Dosgi.configuration.area=/directory/directory1/eclipse/.eclipse
at the top of eclipse.ini but it doesn't work. I've also tried adding it to various other places in the eclipse.ini but still no luck.
Edit
I have added this line:
-Dosgi.configuration.area=file:/directory/directory1/eclipse/.eclipse
immediately below -vmargs. When Eclipse starts, it now reads from the correct .eclipse location and if .eclipse does not exist there, it creates it. Unfortunately, after Eclipse has loaded, another .eclipse folder is created in my home folder and Eclipse then continues to read from that folder. I suspect that my eclipse.ini file is now correct but there is another file I need to change.
The simplest thing to do is probably pass java a different user.home so that all the other myriad of places that derive a location base it off of user.home. So instead of what you have, use this in .ini file:
-Duser.home=/directory/other/here
In addition to .eclipse, you will probably find other directories created in your overridden user.home, such as .p2, .oracle_jre_usage, etc.
Other notes:
-Dosgi.configuration.area is the changes the configuration area for Eclipse, it does not effect user area. You also probably don't want to change that setting away from the default unless you really want multiple configurations (read more below).
Additionally, the normal thing to do would be to use -configuration as an argument to eclipse{.exe} and let eclipse convert it to the appropriate VM argument.
You probably want -user though to override the user area. Have a look at locations in the Eclipse help for more info (quoted below).
However, there are still things that have individual control over their location, such as secure storage, which is controlled by the -eclipse.keyring command line argument.
Locations
The Eclipse runtime defines a number of locations which give
plug-in developers context for reading/storing data and Eclipse users
a control over the scope of data sharing and visibility. Eclipse
defines the following notions of location:
User (-user) {osgi.user.area} [#none, #noDefault, #user.home,
#user.dir, filepath, url]
User locations are specific to, go figure,
users. Typically the user location is based on the value of the Java
user.home system property but this can be overridden. Information such
as user scoped preferences and login information may be found in the
user location.
Install (-install) {osgi.install.area} [#user.home,
#user.dir, filepath, url]
An install location is where Eclipse itself
is installed. In practice this location is the directory (typically
"eclipse") which is the parent of the eclipse.exe being run or the
plugins directory containing the org.eclipse.equinox.launcher bundle.
This location should be considered read-only to normal users as an
install may be shared by many users. It is possible to set the install
location and decouple eclipse.exe from the rest of Eclipse.
Configuration (-configuration) {osgi.configuration.area} [#none,
#noDefault, #user.home, #user.dir, filepath, url]
Configuration
locations contain files which identify and manage the (sub)set of an
install to run. As such, there may be many configurations per install.
Installs may come with a default configuration area but typical
startup scenarios involve the runtime attempting to find a more
writable configuration location.
Instance (-data) {osgi.instance.area}
[#none, #noDefault, #user.home, #user.dir, filepath, url]
Instance
locations contain user-defined data artifacts. For example, the
Resources plug-in uses the instance area as the workspace location and
thus the default home for projects. Other plugins are free to write
whatever files they like in this location.
While users can set any of
these locations, Eclipse will compute reasonable defaults if values
are not given. The most common usecase for setting location is the
instance area or, in the IDE context, the workspace. To run the
default Eclipse configuration on a specific data set you can specify:
eclipse -data c:\mydata
You must put property definitions like this at the end of the eclipse.ini after the -vmargs line. If there is no -vmargs line you must add one.
So:
.... other lines ....
-vmargs
... other arguments
-Dosgi.configuration.area=/directory/directory1/eclipse.eclipse

SublimeText 3 using 100% CPU, "stuck while processing file"

I've been using Sublime Text 3 for some time now, and over the past few weeks I've run into an issue where Sublime will spawn numerous processes, eating up 100% of my CPU.
Below is the output of wmic process where "name='sublime_text.exe'"
CommandLine ProcessId
"C:\Program Files\Sublime Text 3\sublime_text.exe" 10980
"/C/Program Files/Sublime Text 3/sublime_text.exe" "--crawl" "10980:crawl:1" 12152
"/C/Program Files/Sublime Text 3/sublime_text.exe" "--crawl" "10980:crawl:1" 8420
"/C/Program Files/Sublime Text 3/sublime_text.exe" "--crawl" "10980:crawl:3" 6016
"/C/Program Files/Sublime Text 3/sublime_text.exe" "--crawl" "10980:crawl:3" 12008
When I open Sublimes console, I see the following lines
worker 8420 appears stuck while processing file /D/dev/project/ext/index.html, killing process
worker 8420 appears stuck while processing file /D/dev/project/ext/build/index.html, killing process
I've since removed the entire /D/dev/project/ext folder from the index, and then I removed it from the project entirey, but that didn't seem to help.
Has anyone seen this before? I'd really rather not do a full re-install of Sublime.
You can try this:
shift + super + p:
{
"color_scheme": "Packages/User/SublimeLinter/Monokai Bright (SL).tmTheme",
"font_size": 13,
"folder_exclude_patterns": [".svn", ".git", ".hg", "CVS", "node_modules/*"],
"binary_file_patterns": ["*.jpg", "*.jpeg", "*.png", "*.gif", "*.ttf", "*.tga", "*.dds", "*.ico", "*.eot", "*.pdf", "*.swf", "*.jar", "*.zip"],
}
references:
Limit File Search Scope in Sublime Text 2
It may be the case that you have opened a project which contains 3rd party libraries.
In my particular case I have this kind of problem if I do not exclude from Project Index node_modules directory of some bigger node.js application.
Sublime Text tries to refresh index files on each run.
Add exclude pattern in your Project:
"folder_exclude_patterns":
[
"DIR_NAME"
]
I have had this question come up several times so I'd like to give a more complete answer.
What are they and how do I stop them?
The processes you see are the indexing workers which are parsing all of the files included in the side bar of your project(s) (yes, every single file) and building an index for Goto Anything. See Sublime Text 3 File Indexing.
Disabling All Indexing
This can be completely disabled by adding "index_files": false, to your Preferences.sublime-settings (Prefereces > Settings). To disable this system-wide, you add it to your Default settings file, or you can add it to your User setting file. Either will work.
Limiting the Scope of Indexing
However, if you would rather not disable indexing entirely, you can simply modify the scope of the files that are excluded from indexing:
(this is a good starting list, but feel free to edit to better fit your needs)
"index_exclude_patterns": [
"data/*",
"log/*",
"logs/*",
"node_modules/*",
"vendor/*",
"*.log"
]
Additionally, you might also want to expand what is considered a "binary" file (binaries are also excluded from indexing):
"binary_file_patterns": [
"*.bz2",
"*.cache",
"*.dds",
"*.eot",
"*.gif",
"*.gz",
"*.ico",
"*.jar",
"*.jpeg",
"*.jpg",
"*.pdf",
"*.png",
"*.swf",
"*.tar",
"*.tga",
"*.ttf",
"*.zip"
]
I have seen people suggest adding folders to the folder_exclude_patterns array, but that is the list of folders to hide from display in the side bar. While folders not displayed in the side bar will not be indexed, there might be files or folders that you do want displayed but don't want indexed; in such cases index_exclude_patterns should be used.
Limiting Indexing Per Project
Indexing exclusions can also be defined per project in the *.sublime-project file:
{
"folders":
[
{
"path": "src",
"folder_exclude_patterns": ["vendor"]
},
{
"path": "doc",
"index_exclude_patterns": ["*.md"]
}
]
}
Limiting the Number of Indexing Worker Processes
It is also worth noting that you can limit the number of indexing worker processes with "index_workers": 1, where 1 is the number of worker processes. By default that number is 0 which instructs Sublime to guess and the optimal number of workers based on the number of CPU cores available.
Removing the folder containing those two problem files did do the trick afterall, but only after I also removed the Javatar plugin. I've since added the Javatar plugin back, and I haven't add issues since, so if I were to guess is that when I removed the files project and restarted Sublime, the Javatar plugin still knew about them and was telling Sublime to index them. Once I uninstalled and reinstalled the Javatar plugin, after the files had been removed, everything seemed to work fine.

Adding files to sourcecontrol on linux using cleartool

I have a file that i want to add to sourcecontrol on linux using cleartool .
I've followed the IBM documentation for this, i've tried this:
cleartool mkelem testScript.sh
I got an error: Can't modify directory "." because it is not checked out.
I also would like to know how can i checkout/checkin files or directories and setting activities.
You need to checkout the parent folder first.
cd /path/to/file/
cleartool mkact newfile
cleartool checkout -c "add file" .
cleartool mkelem testScript.sh
cleartool checkin -nc
The cleartool mkact would work if you are in an UCM view.
It will create and set a new activity, which will record the files and folder you will modify.
Here, the new activity newFile will record the new version of the parent folder, as well as the version 0 and 1 of the file.
You should create separate questions for .. separate questions...
Going back to the original - the reason why it isn't working is, as VonC has pointed out, you haven't checked out the parent of the file. Remember, when you run "cleartool mkelem", you are about to modify the contents of the parent directory (. in this case) by adding a new "pointer" to the element you're now creating. As with everything else in clearcase, when you want to modify the contents of an element, you have to check it out first.
One of ClearCase's greatest strength (and hardest to wrap one's head around) is the concept of an "element", IMO. "Everything" behaves similarly with an element. Making any change to an "element" (file or directory) means you have to check it out first to make that change.
In the case of a file, that's easy to grasp - you're just editing lines in a file. For a directory, it's almost as easy - you can think of a directory as just a list of pointers to data blobs. We make the name of the blob something convenient we can remember (like foo.java or myapplication.cc or README.md). But we can also change the name of the pointer (even though it points to the same data blob) by renaming a file. We can remove the pointer to the blob without impacting the blob itself by using "rmname". That's essentially what "rmname" does.
In ClearCases' case, the mkelem command is a little bit special - it creates the initial datablob, and adds a pointer to that datablob in the current directory (kind of does 2 things at once).

How do I configure Textmate2 to turn off Soft Wrap by default for all files?

I put a .tm_properties file in my home folder and also at the top of my source tree with the following in it, none of the versions had any effect.
softWrap = false
softWrap = :false
softWrap=false
Also with no effect, I put the line below section headers such as:
[ source ]
[ text ]
[ "*.*" ]
Would love to know what I'm missing here.
I have the following entry below and it work just fine. Try removing other file type specific configuration to ensure its not being overridden.
softWrap = false
Also do check the "global" defaults under
TextMate.app/Contents/Resources/Default.tmProperties
If you haven't already seen https://gist.github.com/1478685, do check it out. The tm_properties in your most immediate folder should take priority. So try and remove other setting and just test it with this one.
Alternatively, remove all other tm_properties and just leave the "global" one and test it out.
Finally do check out this discussion and the version of TM2 you are using. There have been certain fixes to softwarp, and it could just be a bug that you are facing.
EDIT
Also just FYI, I found this item in the latest release notes of TM2.(2012-02-18)
Cached .tm_properties files are now observed via kevent so changes invalidate the cache immediately (previously it could take up to 30 seconds before the updated file was read). On file systems without kevent support you need to relaunch TextMate to flush the cache.

Resources