obsidian-latex-suite
obsidian-latex-suite copied to clipboard
[DOCS] how to format a file containing file snippets
Description
It is unclear to me how one should format a file containing snippets. What file extension should the file have?
Should there be more than just the snippets in the file ? For example javascript commands or a json structure ?
Another user mentioned their confusion regarding this here: https://github.com/artisticat1/obsidian-latex-suite/discussions/148
Importance
Importance level: 4/10 (I can manage without it)
I also had the same question. After searing for the keyword "file", I found the following remark that answered my doubt: https://github.com/artisticat1/obsidian-latex-suite/pull/75#issuecomment-1297370748
In short, one can following the following steps to achieve this:
- Copy and paste everything in the settings
- Put them in
.jsfiles and add own snippets - Add the path to the folder where the
.jsfiles are stored to the settings
I also had the same question. After searing for the keyword "file", I found the following remark that answered my doubt: #75 (comment)
In short, one can following the following steps to achieve this:
- Copy and paste everything in the settings
- Put them in
.jsfiles and add own snippets- Add the path to the folder where the
.jsfiles are stored to the settings
Hello thanks, I tried following this but then none of the snippets worked and I got linting issues when i saved the file as a js file. Did you add anything else to the file ?
What kind of linting issues do you have? I did not add anything special, except for defining some snippets for my use case.
My .js file looks something like the following:
@wenlzhang
Using the solarlint vscode extension (which I am not very familiar with) i am getting the error below whereas the snippets work if i copy paste them to the settings text area
Using the solarlint vscode extension (which I am not very familiar with) i am getting the error below
I also saw such errors when installing the extension. However, I did not do anything about them, and the plugin works in Obsidian.
Hi, this is just because sonarlint sees a single javascript file and thinks you are running a standalone script. In a standalone script, defining an array like this makes no sense, you would instead do something like
const array = [
...
]
However, in this scenario, the plugin is using this file, sonarlint just can't see that. Basically you can ignore the sonarlint errors in this file. (Try //NOSONAR) on the line with the error if you aesthetically want to make it disappear - this shouldn't interfere with the plugin.
@wenlzhang @mayurankv
Thank you both for your help regarding the error. I was unable to get the snippets to run from a file but i can manage with the snippets in the settings.
Latex suite imports the default export so an example for an file would be
export default [
{trigger: "mk", replacement: "$$0$", options: "mA"},
// insert your other snippets here
];
You could also do
const greek_snippets = [
// greek snippets here
];
const symbol_snippets = [
// symbol snippets here
];
export default [...greek_snippets, ...symbol_snippets];
A few examples in the docs probably wouldn't hurt.