area / language-latex

Syntax highlighting for LaTeX for Atom.
Other
79 stars 47 forks source link

Some snippets doesn't work #120

Open wtrtony opened 7 years ago

wtrtony commented 7 years ago

Some snippets doesn't work. Like "frac","it",ect. image image

It's a .tex file in latex.

Aerijo commented 7 years ago

No math snippets work because mathmode is a string environment with this package, and strings don't get considered for snippets by the autocomplete-snippet package. See atom/autocomplete-snippets#55 and https://github.com/atom/autocomplete-snippets/commit/28a0af0935baf4e26ca95d4e606dbb5dc53a6bbc.

In fact, these snippets shouldn't have been working for a couple of years now.

Aerijo commented 7 years ago

A workaround is to run the command apm develop autocomplete-snippets and edit the new local version of the package it installs in the following way:

Go to the new package it made (try ~/github/<package>), open lib/snippets-provider.coffee, and change line 4 to disableForSelector: '.comment'.

Now go to your .atom folder, into dev/packages. You should see a linked folder to autocomplete-snippets. Move this link to the normal packages folder (.atom/packages).

Having done this, the next time you load Atom it will use the local version of the autocomplete-snippets package you made, as opposed to the normal version. This should allow snippets to be used in mathmode. If this still doesn't work, go to .atom/packages/language-latex/snippets/language-latex.cson and change line 71 to '.text.tex.latex, .string.other.math': (I inserted a comma; this fixed an issue I was having. It may also be needed on line 114).

If you (or someone else reading this) get stuck, let me know where. For updates on when the snippets package itself will implement this, subscribe to https://github.com/atom/autocomplete-snippets/pull/77.

Antzy21 commented 7 years ago

@Aerijo Hey! This math mode snippets thing is really annoying. I've been following your interest in the matter and you're definitely the guy who knows what they're doing. Thank you for trying to fix this for us! It looks like the overarching snippet problem isn't going to get fixed, the user trying to sort it has given up, as you found. I'm wondering if you've had anything new pop up since you last posted in August?

Cheers for the hard work on the topic!

Aerijo commented 6 years ago

@Antzy21 I think the math scope will eventually be changed to markup in version2 (see #137), which should be allowed by autocomplete-snippets.

The real issue with autocomplete-snippets is that they want changes to the disabled scopes to be in effect immediately, but it seems autocomplete-plus will only make the changes after restarting atom. Therefore, the issue seems to be in how autocomplete-plus handles the disableForSelector key (provider documentation here)

As a workaround / side project I've been making an autocomplete-latex package which would do (more or less) the same thing as the snippets. There is already a latex-autocomplete package, but it doesn't offer the completions and snippets I would expect. Note it's not published yet, as I'm still working on some parts.

Aerijo commented 6 years ago

It's available now, for anyone interested. Feel free to make a PR with more default commands that everybody could appreciate.