I need to enable .tpl files to be formatted like HTML by Prettier.
I've found on GitHub this block of code who should do it :
overrides: [
{
files: '*.html.tpl',
options: { parser: 'html' },
},
],
How should I implement it?
Go to File -> Preferences -> Settings.
In the search for box, search for "Associations" and then click on "Edit on settings.json".
Add the following to the JSON file:
"files.associations": {
"*.html.tpl": "html"
}
You have multiple options as of the syntax you want to use.
Here is an exemple in JSON:
//.prettierrc.json
{
"semi": false,
"overrides": [
{
"files": "*.html.tpl",
"options": { "parser": "html" },
},
],
}
You have more exemples on the documentation.
Related
I believe this is a general question about JSON and how VS-code handles settings, but I will give a specific example below that regards the LaTeXWorkshop extension.
I am used to overwriting settings in settings.json by adding lines such as "option": value".
But what if "option" expects a list, and I just want to append a new element to the defaults, without removing the defaults. How do I do that?
Specific Example using LaTeXWorkshop
The default for the latex-workshop-latex-recipe option is given by this (see here):
[
{
"name": "latexmk 🔃",
"tools": [
"latexmk"
]
},
{
"name": "pdflatex ➞ bibtex ➞ pdflatex`×2",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
}
]
I want to add the following item to this list without removing the two defaults:
{
"names": ".Rnw: knitr -> latexmk",
"tools": [
"knitr",
"latexmk"
]
}
If I add this to my settings, the default recipes seem to be deleted:
"latex-workshop.latex.recipes" : [{
"names": ".Rnw: knitr -> latexmk",
"tools": [
"knitr",
"latexmk"
]
}],
How do I append instead of replacing?
This is the bowerrc file. I want to search in 2 urls for the polymer components. Is it possible to do that? Neither of the url is local.
{
"registry": {
"search": [
"url1",
"url2"
]
},
"strict-ssl" : false,
"resolvers" : [
"bower-art-resolver"
],
}
In Angular 5 and earlier versions, to stop generating the spec files while generationg a component we had to add the following in .angular-cli.json file:
{
...
"defaults": {
"spec": {
"class": false,
"component": false,
"directive": false,
"module": false,
"pipe": false,
"service": false
}
}
}
in Angular 6+, following this link we have to add the next in the new angular.json file, under the schematics section:
....
"schematics": {
"#schematics/angular:component": {
....
"properties": {
....
"spec": {
"type": "boolean",
"description": "Specifies if a spec file is generated.",
"default": false
}
}
}
},
But when generating a new component a new spec file is still created, even after IDE restart, what is missing ?
You can set it in the angular-cli.json as
{
"defaults": {
"component": {
"spec": false
}
}
}
This will disable generating all spec files. If you want to disable on a specific component,
ng g c component-name --spec false
Thanks to the link provided here by G. Ross, the solution despite it doesn't match the official documentation of Angular 6 but it worked for me.
added the next in the "angular.json" file, under the schematics section:
....
"schematics": {
"#schematics/angular:component": {
....
"spec": false,
....
}
},
You can simply use to generate a component without its spec files ng g c NewComponent --spec=false
How do I hide certain hidden folders that are nested 3 folders deep from my sublime project.
{
"folders":
[
{
"path": "/C/Users/me/Desktop/files/siteFiles/happy site/trunk"
},
{
"folder_exclude_patterns": ["myHiddenFolder",".svn", "._d", ".metadata", ".settings"]
}
]
}
You need to edit your .sublime-project file like so:
{
"folders":
[
{
"path": "/C/Users/me/Desktop/files/siteFiles/happy site/trunk",
"folder_exclude_patterns": ["myHiddenFolder",".svn", "._d", ".metadata", ".settings"]
}
]
}
Save the file, and you should be all set. For more info on project settings, check out the docs.
My sublime project looks like this:
{
"folders":
[
{
"folder_exclude_patterns":
[
".bzr",
"build",
"webapps",
"work",
".settings"
],
"path": "/home/charles/project/Editor/trunk"
}
],
"settings":
{
"build_on_save": true,
"filename_filter": "\\.(java)$",
"tab_size": 4,
"translate_tabs_to_spaces": false
},
"build_systems":
[
{
"name": "compile",
"cmd": ["ant", "-f", "dev.xml", "compile"]
}
]
}
When I save a file the console says:
Buildfile: dev.xml does not exist!
Build failed
[Finished in 0.2s with exit code 1]
I know that I need to put something before dev.xml but I don't know what.
I found some possibilities here: http://sublimetext.info/docs/en/reference/build_systems.html#variables
But What I need is the folder path "/home/charles/project/Editor/trunk" in my case...
Any idea how I can achieve this?
You are missing "working_dir" in your "build_systems" setup. The example below will use the directory that holds the sublime project file as the build starting directory.
"build_systems":
[
{
"name": "compile",
"working_dir": "${project_path}",
"cmd": ["ant", "-f", "dev.xml", "compile"]
}
]
More information can be found at: http://www.sublimetext.com/docs/2/projects.html