Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Excluded environments for snippets #248

Open
BobVarioa opened this issue Jan 25, 2024 · 7 comments
Open

[FEATURE] Excluded environments for snippets #248

BobVarioa opened this issue Jan 25, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@BobVarioa
Copy link

Description of the Problem

Its annoying when in environments where the syntax is different (e.g. ce, pu) the default snippets still run.

Description of the Solution

Either something like the current auto-fraction options to disable all snippets from running in certain environments or a new parameter for each snippet that lets you exclude (/ whitelist) certain environments.

@BobVarioa BobVarioa added the enhancement New feature or request label Jan 25, 2024
@Comprehensive-Jason
Copy link
Contributor

I agree, this would be a great feature. For example, using mhchem's arrows is very annoying since the plugin keeps autocompleting math inside \ce{}. I have to type everything with spaces to stop the autocomplete.

Recording.2024-02-25.081846.mp4

@Comprehensive-Jason
Copy link
Contributor

Comprehensive-Jason commented Mar 4, 2024

@BobVarioa I'm thinking of writing a PR for this by either extending the auto-fraction options or building a system of entries.

1

I will add a blacklist under Advanced Snippet Settings. Any environment written in the blacklist will have all snippets disabled unless the snippet has an e option added.

The limitation with this approach is that you can't select specific snippets for specific environments. For instance, if you have certain snippets that you want to run in \ce{ } but not in \physics{ } and vice versa, there is no way to specifically select for each.

2

I add a dialog for the user to enter individual environments to blacklist. Each environment will have an associated dialog box where the user could add a custom option character to enable snippets in that environment.

Example: I blacklist \ce{ } and add the option character h to enable snippets in it.


Which one do you think is the better approach?

@BobVarioa
Copy link
Author

I think 2 is probably the better approach, as it's more gradual, i.e. people would only add things that annoy them, etc.

@artisticat1
Copy link
Owner

Excluded environments are actually already implemented in code (see here), though currently the list of exclusions is fixed - there is no way for users to define custom exclusions for their snippets.

What do you think about exposing this functionality to the user through an interface like this (as opposed to a dialog box)?

{trigger: "->", replacement: "\\to", options: "mA", excluding: [["\ce{", "}"]]}

@Comprehensive-Jason
Copy link
Contributor

@artisticat1 This would be perfect! That puts all the customization in one place, which is way simpler.

@sylph520
Copy link

@artisticat1 I encountered recently that the i want to enter inline code mkdir folder_A, but the mk is automatically fracted to $$ after I input mk, I found a setting Excluded Environment (seems related), but no detailed notes, so I tried to add a line ["", ""] or ["\'", "\'"], but still no luck, it still auto-fracted. Would you tell me how to set this configuration. Thanks.

@Comprehensive-Jason
Copy link
Contributor

@sylph520 I don't think this feature has been implemented yet, though the bones are already there as artisticat said. We're waiting on them to add the feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants