I've been doing a lot of MaxScript lately and have mashed together (from an attempt here) a ST2 plugin for evaluating scripts from ST.
I've got the syntax highlighting working as well as evaluating the whole file and the current selection, but what I need (due partly to my bad memory and also the gigantic number of MaxScript built-in functions, not to mention those exposed by other plugins I'm using) is for the autocomplete list to be populated initially by a separate text file containing the built-in function names (generated by these instructions) and then the file's own names.
The text file is of the following format:
...
<function name>
polyOps.createShapeFromEdges
polyOps.startCutEdge
polyOps.selectByID
polyOps.attachList
polyOps.startExtrudeEdge
...
Can anyone give me any pointers?
The completions docs have all the information you'll need. Briefly, .sublime-completions files are JSON-formatted resources that can contain either simple completions or snippets. For example, a simple completions list using your given terms would look like this:
{
"scope": "source.maxscript",
"completions": [
"polyOps.createShapeFromEdges",
"polyOps.startCutEdge",
"polyOps.selectByID",
"polyOps.attachList",
"polyOps.startExtrudeEdge"
]
}
If you would like to use snippet syntax for more complex auto-completion (for example, to fill in default values for a function), it would look something like this:
{
"scope": "source.maxscript",
"completions": [
{ "trigger": "myfunc", "contents": "my_function(${1:param}=${2:value})$0" },
"polyOps.createShapeFromEdges",
"polyOps.startCutEdge",
"polyOps.selectByID",
"polyOps.attachList",
"polyOps.startExtrudeEdge"
]
}
Once you have your completions set up, save the file as Packages/User/LanguageName.sublime-completions where LanguageName is the name of your .tmLanguage file, and you should be all set. Good luck!
Related
I use VS code for lots of things, from actual programming to just taking notes or conspecting. A few features I would really love would be
ability to insert images in between the text
live, cell based auto formatting for text that forms a small table
Both of these can be done in rich text editors like ms word by inserting just images or an excel table.
Now I realize that VS code is rather file format agnostic and it wouldn't make a whole lot of sense to somehow have an excel table in the middle of a .js file but I think there is a way.
For example, JSDoc is a kind of add-on format that lives entirely within js comments. Same could be done with tables and/or images. Of course there wouldn't be a universal way to encode this but just like JSDoc it could be adapted to different language environments, be it a php file or c file or plain text.
For example, in raw text format, an auto formatted table of data could look something like this within a javascript file:
const my_data = [
/*!!! auto_format_csv(Title, Description, Weight) !!!*/
"Apple", "A nice fruit", 1,
"Car", "A motorized vehicle", 2000
/*!!! auto_format_end !!!*/
];
and while editing the file in vs code, it could look something like this:
So to the question part: are there perhaps any extensions that already do this sort of thing? If not, is it possible to create such an extension with the liberties given to extensions as of right now?
I know that vs code is based on electron and open source so in theory, everything is possible but I want to have these features as easily as possible so having framework support for this would likely help a lot.
I'm trying to develop an vs code extension by using its javascript apis.
i have a .hocon file (https://github.com/lightbend/config/blob/master/HOCON.md) the file is fairly complex and i would like to create an autocomplete feature.
My problem:
1] I have a dictionary file, its a simple text file for sake of example lets assume its toml/csv something easy to parse
[ips]
x.x.x.x
y.y.y.y
some.ipv6
[actions]
someString1
someString2
2] the hocon file contains two arrays
Ips: [
]
Actions: [
]
When a user places a cursor inside the Ips array, i want to show standard code-completion pop up window which will contain list of ips from the dictionary file, but won't contain a single record from the actions block.
My question is: I looked at the vs code documentation and I feel like this cannot be solved by a simple vscode extension, but I should use some language server? Am I correct?
In Vistual Studio Code, I can create file-associations relating file extensions to a specific language syntax.
However, I have a particular case where files inside a subdirectory may or may not have extensions... In fact, files can have all sorts of extensions, but they all use a sepcific language syntax.
Is it possible to create a more flexible file-association rule that scans certains subdirectories of my project to apply a language syntax?
Working around this, I created a broad file-association that matches any file, similar to this:
"files.associations": {
"*": "nginx"
},
Except, this rule applies to the entire project. I would like to restrict this to a particular subdirectory.
In the Django extension I found an example of more complex file association
"files.associations": {
"**/templates/*.html": "django-html",
"**/templates/*": "django-txt",
"**/requirements{/**,*}.{txt,in}": "pip-requirements"
},
You can find a bit more info about glob patterns.
You can have these patterns defined on a folder/workspace level if needed.
I have an .rmd file that I want to put on GitHub. In order for the results to be visible along with the code I converted my .rmd file to .md via RStudio.
After conversion, however, the (r-)code is not highlighted anymore, when I view the .md file on GitHub. I noticed that a code block in the .md file is identified by indending 4 times instead of three backticks + language definition. So obviously the language definition from the .rmd file gets lost.
How can I fix this?
Note: To reproduce you can just open a new .rmd file in RStudio and change the YAML header to:
---
title: "TestRun"
output:
md_document:
variant: markdown_github
---
Help is much appreciated!
Indentation is important in YAML.
Here's an example from the R Markdown documentation:
---
output:
md_document:
variant: markdown_github
---
This YAML document has a mapping with the key output, whose value is a mapping with one key, md_document, whose value is a mapping with one key, variant, whose value is the scalar markdown_github.
The equivalent in JSON (for example) would be:
{ "output": {
"md_document": {
"variant": "markdown_github"
}
}
}
Here's your document (disregarding the title key for clarity):
---
output:
md_document:
variant: markdown_github
---
Your document has a mapping with the key output, whose value is a mapping with two keys, md_document (with an empty or null value) and variant (with the scalar value markdown_github). The JSON equivalent would be:
{ "output": {
"md_document": null,
"variant": "markdown_github"
}
}
See the difference?
Fenced code blocks (backticks + language definition) is a non-standard (although increasingly common) way of marking up code blocks. Therefore, it is not understood by all Markdown implementations. In fact, standard Markdown offers no way to identify the language of a code block. That being the case, when converting to standard Markdown, that info is appropriately lost. If you would like to retain that info, then I would suggest converting to something other that standard Markdown. Although, according to another answer, if you fix your YAML config, then you would be using the non-standard GitHub Flavored Markdown, which does support fenced code blocks.
If you really need standard Markdown, then you may find that a JavaScript highlighting engine will serve you fine. Some of the better JavaScript highlighting engines have pretty good language detection, so you usually don't need to label the language of the code blocks.
I would need to find all the places in my code (several M files in a folder) where I used a particular function (unique in this case).
Do you know if it is possible?
In Matlab, there is the command "Find Files" - in the "Edit" menu, or on the "Home" and "Editor" ribbon - that allows you to find files containing specific text, either in a folder or on the entire Matlab path:
Use the "find in files" function in Notepad++
If you want to check what functions you're using, depfun allows you to do so, although it might be overkill if you only want to check for a single known function.
For example (checking functions called directly by a function only):
[list builtins] = depfun(fun, '-toponly');
"which" seems to do it.
Take a look at this: http://www.mathworks.co.uk/help/matlab/ref/which.html (1st example)
Otherwise, notepad++ allows you to search (and replace) multiple files for a text string, here's a simple tutorial:
http://www.makeuseof.com/tag/how-to-find-and-replace-words-in-multiple-files/