I am working with Sublime and also running some q/kdb scripts from Sublime.
I have a "q Build" set up and works fine when I manually change the build.
But I tend to switch between q and other languages quiet often and each time I need to manually change the build type.
How can I setup all *.q files to be run automatically with the q build setup I already have only by doing the usual Command + B?
{
"cmd": ["[full q path]", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.q",
}
When you have the Build System set to Automatic (e.g. Tools > Build System > Automatic from the menu), Sublime should select the correct build system for the currently focused file as long as the build file is set up correctly.
Based on the build system you have outlined above, as long as you have some package installed that is providing a custom syntax for this package (e.g. the q KBD package) that assigns the scope source.q as a base scope, this should work fine in this case.
To verify, while a q file has the input focus, select Tools > Developer > Show Scope Name from the menu (or press the associated key) and make sure that the scope begins with source.q (the package above does this). The scope that you see may be longer than this depending on where you are in the file, but as long as it starts with this, you should be OK.
If that's not the scope that you see, then the reason the build as you've outlined it is not automatically selected is because the package you're using uses a different scope, or you don't have a q package installed (this is the case if the scope you see is text.plain, for example).
The solution in that case would be to either update the scope based on the package you're using or install the above package (if you don't have anything related to this already installed).
In lieu of installing a support package that provides a syntax, you could also modify the build to be as follows, which should tell it it to use the build for all *.q files regardless of their scope. Arguably the package install method is superior since it would give you syntax highlighting for your files as well.
{
"cmd": ["[full q path]", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"file_patterns": ["*.q"]
}
I believe you need to add a language syntax definition file, in order to create a new "scope" for automatically enabling the build system.
You can see the answer here for an example: https://stackoverflow.com/a/14263821/8694303
Related
I'm trying to set up Chrome as a build system in Sublime Text on MacOs.
Tried using the New build menu option and plugged in:
{
"/Applications/Google Chrome.app": "Chrome"
}
It appears in list after I restart as build option but doesn't work. Any ideas?
For reference, the build system documentation has lots of examples if you want to add more functionality. However, for now, we'll just make a simple build system with one command - open the current file in Chrome.
Each build system needs to have a "cmd" key - the command you want to run - and optionally a "selector" key - a rule for selecting which types of files you want to run. For now, we'll just assume you only want to run HTML files. Select Tools → Build System → New Build System… and replace the contens with this:
{
"cmd": ["/Applications/Google Chrome.app", "$file"],
"selector": "text.html"
}
Next, hit Save and save the file in the suggested folder with a name like Chrome.sublime-build. You don't need to restart for it to be visible in the Build System menu.
Now, when you want to view an HTML file in Chrome, you'll first select Tools → Build System → Chrome, then hit ⌘B to actually run the build. Chrome will stay selected as the current build system, so if you want to build again all you have to do is hit ⌘B.
If you do any work on Windows or Linux, the build command shortcut is CtrlB.
I'm trying to create a build system for OCaml in sublime text 3 on Windows 8.1. I installed OCaml via opam in Cygwin and typed the following into the OCaml.sublime-build file:
{
"cmd": ["C:/OCaml64/home/LENOVO/.opam/4.05.0+mingw64c/bin/ocaml.exe", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.ml"
}
I'm trying the build system out with a test.ml that contains print_endline "hello world";;. I can run the command directly from the terminal with the ocaml interactive command line or using ocaml test.ml. But when I open the file in Sublime Text 3 and run Ctrl-B, I get the following error:
File "command line", line 1:
Error: Unbound module Pervasives
I searched for this error online but could not find much that applies to my situation. Any help is much appreciated!
I've had the same problem with OcaIDE under Eclipse, if you installed Ocaml following this tutorial
then this solution should work for you too, simply from Cygwin terminal type:
ocaml-env-win -- "<insert the path to sublime text>".
This should launch Sublime Text with the proper environment settings.
Source : https://fdopen.github.io/opam-repository-mingw/ocaml-env/#program-startup.
This error means, that the compiler cannot find the interface file (the pervasives.cmi file) for the Pervasives module. By default, the compiler searches in the current folder first, then in the standard library directory. You can add more directories using the -I option, however in your case, Pervasives should be in the standard library.
The path to the standard library is compiled in the compiler and is specified during the configuration of the compiler, use ocamlc -where to print the path.
In your case, this path either doesn't exist (e.g., you removed it, assuming that it is a non-necessary build artifact, or just moved in a different place), not accessible (some permission problems), or doesn't contain the library code (i.e., cmi, cmo, cmx, and other files). In any case, it is a problem with your installation.
Environment: windows 10, VS2013.
I have a C++ app, using Poco framework (Poco 1.7.6) and I need to launch some batch files. It works without problem, but for a particular script, and I can't figure out the reason.
This particular script is as follows (let's call it buildMySolution.bat):
set BUILD_DIR=%~dp0
call "C:\Program Files(x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"
msbuild /p:Platform=%~1 /p:Configuration=%~2 %BUILD_DIR%\Mysolution.sln
As you can see the batch file simply compiles a VS2013 solution. Needless to say that this simple batch works perfectly well if launched from command line.
The problem is that this batch is in drive D: (in D:\DevRoot\build\MySolution) and when launched from my app (in D:\ drive as well), I get a "cannot find the path" on the second line.
I tried several modifications in the batch: like forcing C: or cd /D C: ... it can go to C: but not further, it refuses to cd to the directory containing vcvarsall.bat (again, I know the path is correct as the very same script executes fine from command line). It has however no problem coming back to initial directory through a cd /D %BUILD_DIR%.
To launch the script from my C++ app, I use this:
Poco::ProcessHandle handleBuild = Poco::Process::launch(path_to_script, argsBuild);
handleBuild.wait();
The Poco launch is just a thin wrapper around CreateProcessA(), I don't see anything special in their code (Poco Process.cpp).
I tried as well to specify the working directory to be the directory containing vcvarsall.bat, but then CreateProcess fails.
I just found a solution: I changed the line (in the batch buildMySolution.bat):
call "C:\Program Files(x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"
to:
call C:\PROGRA~2\micros~1.0\vc\vcvarsall.bat
Believe it or not: using DOS names and removing quotes makes it work!!!
Bug or feature, I'm not sure...
So I have started to use Sublime Text 3 recently with my Ubuntu OS. I wanted to test it out so wrote a simple piece of c++ code. But when I try to build it does nothing, I have checked online and still nothing I even installed a build system (https://github.com/shikharkunal99/Sublime-Build-System) and still whenever I go to build it just opens open a black section at the bottom (see picture)
Install g++ to run c++ code
apt-get install g++
Then I will tell you a personal trick that I used. it is:
find | grep "part of your filename"
Replace "part of your filename" section with the name of the file or a part of the name of the file.
Suppose, the file name is Here.c. I type "Here" in place of part of your filename.
Then the final step, type
./a.out
Output is ready in front of you.
This post will help you in setting up Sublime Text 3 in a way that leads to a good workflow specifically for C++ programming environment (Ubuntu, GNU C++ Compiler) :
Note: Only the following step is essential for running c++ programs.
1. Create a Build System in Sublime Editor :
Sublime Text provides build systems to allow users to run external programs.
Go to Tools -> Build System -> New Build System.
Paste the following code in the file
{
"cmd": ["g++ -Wall -Wextra -O2 -pthread -H -std=c++17 \"${file}\" -o runfile && ./runfile <input.in> output.out"],
//above line works fine if input.in and output.out files are present in same directory in which .cpp file is present else add complete address of these files for using them as common input output files in your system.
"shell":true,
"working_dir":"$file_path",
"selector":"source.c,source.c++,source.cpp",
"variants": [
{
"name": "Variant Run",
"cmd" : ["gnome-terminal -- bash -c \"g++ $file_name ;echo ------------Output-------------; ./a.out;echo;echo; echo Press ENTER to continue; read line;exit; exec bash\""
],
}
]
}
Save the file (By default the file is placed in "~/.config/sublime-text-3/Packages/User" dir) something like "C++17.sublime-build" to differentiate it from the other build system files.
Create input.in and output.out text files in your working directory. This can be used for piping input from the input.in file, and output to the output.out file.
Note in the first line it uses the -std=c++17 flag to enable the latest features of C++17. If you don't want this or want to use C++14, replace this with the -std=c++14 flag.
Refer to https://linux.die.net/man/1/g++ for different compiler flags.
See Also https://discuss.codechef.com/t/are-any-compiler-flags-set-on-the-online-judge/1866
2. Setup window layout :
Create three new c++ file, file.cpp. Select View > Layout > Columns : 3. This will create three columns in the workspace. Select View > Groups > Max Columns : 2.
Write a hello world program & save inputs if any in the input.in file, and test its working. Use Shift+Ctrl+B and Select C++17 to build and execute the file (If selected C++17 - Variant Run it will execute the program in a separate terminal window like a normal program would).
The windows will look like this when you are done.
Layout Preview
3. Precompile headers :
Generally useful in competitive programming, we can speed up compilation time by precompiling all the header files as mentioned here, i.e. by precompiling the bits/stdc++.h header file.
For this, first, navigate to the stdc++.h file. This will be located at a directory similar to ~/usr/include/x86_64-linux-gnu/c++/9/bits Open terminal window here.
Run the command sudo g++ -std=c++17 stdc++.h, to compile the header. Take care to use the same flags you used in your build system. Check to make sure that the stdc++.h.gch file was created in that directory.
4. Sublime Text features :
Snippets & Completion
Read up on the documentation of snippets and completions at the official guide.
5. Other Features :
Read https://scotch.io/bar-talk/best-of-sublime-text-3-features-plugins-and-settings
This program works perfectly fine for me using Build 3120, and I expect it will work fine with previous builds. First, you need to select Tools → Build System → C++ Single File (Tools → Build System → Automatic should also work, but I prefer to be explicit). Then, either hit CtrlShiftB or select Tools → Build With… and select C++ Single File - Run. This will compile your .cpp file to an executable in the same directory as the source file, then run it.
Well I also got various issues with this thing finally I got an amazing thing in the package control pallet.Follow the instructions:
1.Open up the Package control Pallet
2.Search for C++ Builder
3.You will see C++ Builder-Mingyang Yang
4.click it and then wait for a couple of seconds
5.finally go to tools->build system->select C++ Builder-Mingyang Yang
6.finally tap the Shift+Ctrl+B and then select C++ Builder-Mingyang Yang Build and Run
7.finally here you go you can not only build this but also use the console for input
Note:This will execute only when there is gcc compiler included in the terminal otherwise at first install gcc by the command apt-get install gcc then you can use c++
I m a ROS user. With that framework you usually define a working directory:
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/src
// Here create your c++ packages
and then let the system to compile your packages by typing the following:
$ cd ~/catkin_ws/
$ catkin_make
But this means that you should keep at least one more console open, to call the command:
$ catkin_make
which compiles at once all the packages you ve written in that working directory.
Since I m using Sublime Text 3 to write my software I want to be able to call that function from Sublime
I went through this tutorial so many times, but I still don't understand how I can create my building system.
I tried already with the following:
{
"path": "~/workspace_ros",
"cmd": ["catkin_make"]
}
but I get the following error message:
[Errno 2] No such file or directory: 'catkin_make'
[cmd: ['catkin_make']]
[dir: /home/will/workspace_ros/src/flight_system/src/include]
[path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games]
[Finished]
I tried even with the following options:
path
shell_cmd
but still it doesn't recognize catkin as command for compiling
What's wrong?
PS: in the workspace I have already a CMakeLists.txt file. Calling catkin in the shell compiles everything fine.
I am not sure if this is the best way to accomplish it, but this is what I did. Keep in mind that I did this for a winros project, so for regular ROS projects, you just need to tweak it a bit.
First, I created a build system for the project as follows (so append this to your project file):
"build_systems":
[
{
"name" : "ROS",
"cmd" : ["$project_path/build.bat"],
"working_dir" : "$project_path",
"variants" : [
{
"name" : "Run",
"cmd" : ["$project_path/run.bat"]
}
]
}
]
I then created the build.bat and run.bat scripts referenced in there in the project's root directory (in your case ~/workspace_ros). I created these scripts because there is more to building/running the nodes than just calling catkin_make. You also need to call the setup scripts first.
Here's build.bat
#ECHO OFF
REM Basically, change the cwd to the project's root dir
SET ws_path=%~dp0
cd /D "%ws_path%"
call setup.bat
winros_make -i
You might want to change this to a bash script for your linux system, and tweak the script itself. The idea is to change your cwd to the project's path and call the setup file and build afterwards.
Here's run.bat
#ECHO OFF
REM Call the setup script and launch the node
call "C:\opt\ros\hydro\x86\setup.bat"
roslaunch eyetracker_talker talker.launch
Again, you might need to change this to a bash script. In my case, I use roslaunch to run the node.
Finally, this gives you two build options (Build and Build: Run). The output of both should be shown in the build output window.
Hope this helps.
I realize this is a bit of an old question, but it is still top on google for using catkin with Sublime, so heres my shameless self plug.
I recently wrote a Sublime 3 Package, Catkin Builder that bulids ROS packages inside Sublime. It uses catkin build as opposed to catkin_make but it might help you out.