artisticat1 / obsidian-latex-suite

Make typesetting LaTeX as fast as handwriting through snippets, text expansion, and editor enhancements
MIT License
1.3k stars 52 forks source link

[DOCS] how to format a file containing file snippets #168

Open userrand opened 1 year ago

userrand commented 1 year ago

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)

wenlzhang commented 1 year ago

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:

userrand commented 1 year ago

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 .js files and add own snippets
  • Add the path to the folder where the .js files 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 ?

wenlzhang commented 1 year ago

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:

image
userrand commented 1 year ago

@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

image

wenlzhang commented 1 year ago

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.

mayurankv commented 1 year ago

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.

userrand commented 1 year ago

@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.