Assign syntax to a file without an extension in Sublime Text 2 - sublimetext2

I have a file Guardfile in my rails project, but appears just in plain text, so each time is opened it must be assigned the ruby syntax to display it correctly.
I cannot use Open all with current extension as... because it doesn't have an extension, but I suppose I could assign a specific syntax to a file without an extension because files like Gemfile, Capfile or Rakefile are displaying correctly.
How can I achieve this?

Menu: Preferences -> Browser Packages
Then open the file Ruby\Ruby.tmLanguage
Look up for this block:
<array>
<string>rb</string>
<string>rbx</string>
<string>rjs</string>
<string>Rakefile</string>
<string>rake</string>
<string>cgi</string>
<string>fcgi</string>
<string>gemspec</string>
<string>irbrc</string>
<string>capfile</string>
<string>Gemfile</string>
</array>
Add the new entry:
<string>Guardfile</string>

Install facelessuser / ApplySyntax. It has a built in rule for Guardfiles. It is also good for other random files that should be set as a certain syntax. For example, here is one I set up for a random file that should have Bash syntax.
"syntaxes": [
{
"name": "ShellScript/Shell-Unix-Generic",
"rules": [
{"file_name": ".*random$"}
]
}
]
The name value is the path to the tmLanguage file from Packages. ShellScript is the name of the Packages folder that the tmLanguage file is in. Shell-Unix-Generic is the tmLanguage file name.

For Sublime 3:
Commmand + Shift + p: set syntax ruby
Preference -> Settings - Syntax Specific
Add syntax like following:
{
"extensions": [
"Gemfile",
"Gemfile.lock",
"Podfile",
"Podfile.lock",
"Manifest.lock",
"Fastfile_helper",
"Fastfile",
"Appfile"
]
}
What really bad is that the syntax does not support fuzzy match, regex thing. This means you must list all the files.

Related

Cannot connect to MySQL with Weka

I am trying to connect a database to Weka 3.6.13 in Linux Elementary OS.
First, I had a problem with JDBC connection, solved by this answer changing the /usr/bin/weka file.
Now, when I load the database, this error comes:
Unknown data type: INT. Add entry in weka/experiment/DatabaseUtils.props.
However, I am trying to use explorer only, this file doesn't even exists in my installation.
I installed via sudo apt install weka.
What should I do?
Look inside the directory where your weka.jar file resides, and check if there exists a file called DatabaseUtils.props.
The Weka wiki says:
Weka only looks for the DatabaseUtils.props file. If you take one of
the example files listed above, you need to rename it first.
My file is different I think the actual name does not really matter, it's the filename extension that matters.
In my version of this file there is a section that looks like this:
... (snip...
# mysql-conversion / type-mappings
CHAR=0
TEXT=0
VARCHAR=0
STRING=0
LONGVARCHAR=9
BINARY=0
VARBINARY=0
LONGVARBINARY=9
BIT=1
BOOL=1
NUMERIC=2
DECIMAL=2
FLOAT=2
DOUBLE=2
TINYINT=3
SMALLINT=4
#SHORT=4
SHORT=5
INTEGER=5
INT=5
BIGINT=6
LONG=6
REAL=7
DATE=8
TIME=10
TIMESTAMP=11
#mappings for table creation
CREATE_STRING=TEXT
CREATE_INT=INT
CREATE_DOUBLE=DOUBLE
CREATE_DATE=DATETIME
DateFormat=yyyy-MM-dd HH:mm:ss
#database flags
checkUpperCaseNames=false
checkLowerCaseNames=false
checkForTable=true
setAutoCommit=true
createIndex=false
# All the reserved keywords for this database
Keywords=\
AND,\
ASC,\
BY,\
DESC,\
FROM,\
GROUP,\
INSERT,\
ORDER,\
SELECT,\
UPDATE,\
WHERE
# The character to append to attribute names to avoid exceptions due to
# clashes between keywords and attribute names
KeywordsMaskChar=_
#flags for loading and saving instances using DatabaseLoader/Saver
nominalToStringLimit=50
idColumn=auto_generated_id
If you do a google search for this file, another guy has posted his on github. The weka Wiki or SVN/Git-Repo might also list an offfical version somewhere (cannot find it right now), or you can open your weka.jar file as a zip file and extract the .props file (/src/main/java/weka/experiment/DatabaseUtils.props.mysql).
In any case, Mysql exists in many different versions, and I think you can even switch the query engine inside mysql. So I cannot express any guarantees that any of these 2 .props files shown here really work for you. You should experiment a bit.

Setting Jenkins build name from package.json version value

I want to include the value of the "version" parameter in package.json as part of the Jenkins build name.
I'm using the Jenkins Build Name Setter plugin - https://wiki.jenkins-ci.org/display/JENKINS/Build+Name+Setter+Plugin
So far I've tried to use PROPFILE syntax in the "Build name macro template" step:
${PROPFILE,file="./mainline/projectDirectory/package.json",property="\"version\""}
This successfully creates a build, but includes the quotes and comma surrounding the value of the version property in package.json, for example:
"0.0.1",
I want just the value inside returned, so it reads
0.0.1
How can I do this? Is there a different plugin that would work better for parsing package.json and getting it into the template, or should I resort to some sort of regex for removing the characters I don't want?
UPDATE:
I tried using token transforms based on reading the Token Macro Plugin documentation, but it's not working:
${PROPFILE%\"\,#\",file="./mainline/projectDirectory/package.json",property="\"version\""}
still just returns
However, using only one escaped character and only one of # or % works. No other combinations I tried work.
${PROPFILE%\,,file="./mainline/projectDirectory/package.json",property="\"version\""}
which returns "0.0.1" (comma removed)
${PROPFILE#\"%\"\,,file="./mainline/projectDirectory/package.json",property="\"version\""}
which returns "0.0.1", (no characters removed)
UPDATE:
Tried to use the new Jenkins Token Macro plugin's JSON macro with no luck.
Jenkins Build Name Setter set to update the build name with Macro:
${JSON,file="./mainline/pathToFiles/package.json",path="version"}-${P4_CHANGELIST}
Jenkins build logs for this job show:
10:57:55 Evaluated macro: 'Error processing tokens: Error while parsing action 'Text/ZeroOrMore/FirstOf/Token/DelimitedToken/DelimitedToken_Action3' at input position (line 1, pos 74):
10:57:55 ${JSON,file="./mainline/pathToFiles/package.json",path="version"}-334319
10:57:55 ^
10:57:55
10:57:55 java.io.IOException: Unable to serialize org.jenkinsci.plugins.tokenmacro.impl.JsonFileMacro$ReadJSON#2707de37'
I implemented a new macro JSON, which takes a file and a path (which is the key hierarchy in the JSON for the value you want) in token-macro-2.1. You can only use a single transform per macro usage.
Try the token transformations # and % (see Token-Makro-Plugin):
${PROPFILE#"%",file="./mainline/projectDirectory/package.json",property="\"version\""}
(This will only help if you are using pipelines. But for what it's worth,..)
What works for me is a combination of readJSON from the Pipeline Utility Steps plugin and directly setting currentBuild.displayName, thusly:
script {
// readJSON from "Pipeline Utility Steps"
def packageJson = readJSON file: 'package.json'
def version = packageJson.version
echo "Setting build version: ${packageJson.version}"
currentBuild.displayName = env.BUILD_NUMBER + " - " + packageJson.version
// currentBuild.description = "other cool stuff"
}
Omitting error handling etc obvs.

Sublime ignores syntax specific tab size for new files

I am using the latest Sublime Text 3, and have this in a syntax specific config for JavaScript
{
"translateTabsToSpaces": true,
"tabSize": 2
}
But every time I create a new file, it defaults to 4 spaces. I have tried adding "detect_indentation": true but then ALL files started to be 4 spaces for tabs, ignoring the syntax specific config even further.
Am I missing something?
Your settings names are incorrect. Sublime uses snake_case variables, not camelCase. Your JavaScript.sublime-settings file should look like this:
{
"translate_tabs_to_spaces": true,
"tab_size": 2
}
To see all of the available settings, select Preferences → Settings—Default.

Using several languages in Sublime Text 3 spell check

I have two dictionaries: ru_RU and en_US. How can I use it together in Sublime Text 3 spell check? Is it possible?
This is currently not possible. It has been mentioned in the official issues list for ST3 - see this issue for details.
I have this working for me using this steps.
Download your dictionary (e.g. from GitHub or following the README.md recipe in this respository).
Create a folder in your Sublime Text 3 config (e.g. "Language - Spanish"), this will be the name shown in the ST menu, and move the dictionary inside this folder.
~/.config/sublime-text-3/Packages/Language - Spanish
Be sure that spell checking is active and the dictionaries as well in your preference settings:
"spell_check": true,
"dictionary": [
"Packages/Language - English/en_US.dic",
"Packages/Language - Spanish/Spanish.dic"
],
Now you can switch the current spell checking:
View > Dictionary > Language - Spanish > Spanish
For me was solved following this instructions:
https://www.sublimetext.com/docs/3/spell_checking.html
I've downloaded the dict files from:
https://github.com/SublimeText/Dictionaries
Then I simply copy the UTF-8 encoded dictionary files (in my case Spanish) into Packages/Language - Spanish/ (You can access it from Preferences/Browse Packages).
Then activate by adding this line to user setting's
"spell_check": true,
Or by View/Spell Check menu.
You can select the dictionary from the View/Dictionary menu.
It would not be an easy task to create the affix for a "merged" language, like 2 dicts working at once. In my case I'd love some Spanglish dict... have to work on it.

Build system for typescript using different flags

I want to use different flags (sourcemap, out, target) that the typescript compiler provides. I am trying to define a build system in sublime 2 but unable to do so.
Have already read this question.
basically i want to do something like the following
tsc src/main/ts/myModule.ts --out src/main/js/myModule.js --sourcemap --target ES5
Just add them to the cmd array
{
"cmd": ["tsc","$file", "--out", "src/main/js/myModule.js"],
"file_regex": "(.*\\.ts?)\\s\\(([0-9]+)\\,([0-9]+)\\)\\:\\s(...*?)$",
"selector": "source.ts",
"osx": {
"path": "/usr/local/bin:/opt/local/bin"
}
}
First of all let me say that I'm using Sublime Text 3 on Windows and Typescript 1.0.
I don't think that SublimeText2 is so much different, though...
If you're on similar conditions, take a look at my current configuration file:
{
"cmd": ["tsc", "$file"],
"file_regex": "(.*\\.ts?)\\s*\\(([0-9]+)\\,([0-9]+)\\)\\:\\s(.+?)$",
"selector": "source.ts",
"windows": {
"cmd": ["tsc.cmd", "$file", "--target", "ES5"]
}
}
Please notice that I tweaked the regex so that it matches the TSC error format (and brings you to the line containing the error when you double click it from the error log...)
Besides of that, I think that the real command-line which gets run is the lower one: as a matter of fact I had it working only placing the options down there... (in this specific case I'm asking an ES5 compilation type, your parameters will differ).
This suppose you have a tsc.cmd avaliable on path; if not, put the full path of tsc.cmd or tsc.exe instead of "tsc.cmd" and be sure to escape backslashes \ as \\...
This works in my situation, maybe in other contexts they should also be placed on the first line...
Hope this helps :)