Sublime Forum

LaTeX Sublime completions problem after update

#1

Hey guys,

It’s my first time posting here; I just created the account because I’m having some trouble and not finding a working solution on the web. I will appreciate your patience, as I am very unexperienced with the issues I’m going to expose here.

I updated Sublime Text today, I am unsure about what version I had before, this one tells me it’s build 4107 if that makes sense. Before the update, my LaTeX completions were working perfectly fine. However, I immediately noticed two problems after the update, which are the following:

  1. What I type after an underscore does not trigger the autocomplete options to appear. I can in principle leave a blank space and then use the feature, but it makes the math much more difficult to read, and is just overall very annoying. How can I make completion suggestions appear for the text typed after an underscore? That used to be the case before the update.

  2. Most importantly, the autocompletion completely ignores my preferences. For instance, “a” used to turn into “\alpha” when pressing tab. Now, even though “a” appears as an autocompleting option tied to “\alpha” (so it seems as though my completion files are nicely recognized, but more on this below), I have to scroll down through all the options every single time, with every completion. Needless to say, this is extremely aggravating. How can I force Sublime to preferentially suggest my custom completions?

In the file LATEX math.sublime-completions I have before the completions:
“scope”: “text.tex.latex string.other.math, text.tex.latex meta.environment.math”

In the file LATEX.sublime-completions I have before the completions:
“scope”: “text.tex.latex - (string.other.math, meta.environment.math)”

I used to have both in this second form, but after the update the completion files are ONLY recognized if I have them in this particular way for the respective files. The file preferences.sublime-settings is as follows:

{
"auto_complete": true,
"auto_complete_commit_on_tab": true,
"auto_complete_selector":
[
	"latex - comment",
	"meta.tag - punctuation.definition.tag.begin, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc"
],
"auto_complete_triggers":
[
	{
		"characters": "<",
		"selector": "text.html",
	},
	{
		"characters": "\\",
		"selector": "text.tex.latex",
	}
],
"auto_complete_with_fields": true,
"color_scheme": "Packages/New Moon Color Scheme/New Moon.tmTheme",
"font_size": 11,
"ignored_packages":
[
	"Vintage",
],
"theme": "Adaptive.sublime-theme",

}

I would appreciate if someone could clarify what the problems are and how to solve them. I don’t know if I should have created more than one thread since these seem like unrelated issues; my apologies if this would’ve been more appropriate. Also, I have no experience whatsoever with these types of issues, so I again ask for your patience; I had trouble setting up the completions back in the day but finally got it working, and it is frustrating to have it broken.

Thanks a lot in advance!

0 Likes

#2

The “auto_complete_selector” setting should be a single string - and no array. Also, some of the default settings were slightly updated. Can you try if the following settings help:

{
    "auto_complete_selector": "text.tex.latex - comment, meta.tag, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc",
    "auto_complete_triggers":
    [
        {"selector": "text.html, text.xml", "characters": "<",},
        {"selector": "punctuation.accessor", "rhs_empty": true,},
        {"selector": "text.tex.latex", "characters": "\\",}
    ],
}

Or probably it would be better to restrict the completions only to math environments:

"auto_complete_selector": "text.tex.latex meta.environment.math, meta.tag, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc",

For the autocompletion order, I would suggest to try the different options for the “auto_complete_preserve_order” setting to see if you can restore the former behavior.

2 Likes

#3

First of all, thanks a lot! Setting “auto_complete_preserve_order” to “none” fixed my issue with the autocompletion order, that is back to usual. I also updated the settings as you suggested in order to have the correct syntax. However it doesn’t fix the problem with my underscore (I don’t know if it was supposed to, though). Looking around the web a bit more I have found that it is apparently related to the syntax-specific setting “word_separators”, which is by default set to “./\()”’-:,.;<>~!@#$%^&*|+=[]{}`~?". I updated it to add the underscore, since it is not present by default, but for some reason it is not detecting the change. Also hyphens should be regarded as a word separator by default, but the completion suggestions do not show up after a hyphen. Any suggestions for this? Again, your answer was already a huge help, so thank you very much for that!

0 Likes

#4

Hello fellow Sublime/LaTeX user! I was on the same boat as you for the longest time (regarding the autocomplete for greek letters no longer doing what I wanted in ST4). These above fixes have resolved my issue perfectly. Thank you for that!

I’ve never run into the problem you have for the underscore, because I wrap all sub/superscripts in brackets, which, granted, makes things a little more difficult to read, but in any case is good practice if you ever need multiple symbols. I have this keybinding which has become second nature to me.

{ "keys": ["option+minus"], "command": "insert_snippet", "args": {"contents": "_{$0}"},
"context":
  [
    {"key": "selector", "operator": "equal", "operand": "text.tex.latex, text.html.markdown.rmarkdown"},
    { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
    { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }
  ]
},
{ "keys": ["option+equals"], "command": "insert_snippet", "args": {"contents": "^{$0}"},
"context":
  [
    {"key": "selector", "operator": "equal", "operand": "text.tex.latex, text.html.markdown.rmarkdown"},
    { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
    { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }
  ]
}
2 Likes

#5

Hi, first of all thanks a lot, this solution would actually be perfect as well. But for some reason my key bindings aren’t working. I pasted your code into Preferences > Key Bindings, but unfortunately nothing is happening. I looked around and found the following post: Keybinds not working , in which the OP ended up just reinstalling everything to solve the issue. I can go without solving the underscore problem, but I feel like if I ever need to change something more important I won’t be able to. This seems somehow related to the fact that I was not able to get the underscore working as a word separator in the syntax-specific settings. The file has the name “Default (Windows).sublime-keymap” and is located in the User folder. Any ideas? I can provide any additional info, but since this seems mysterious I don’t know what is relevant.

0 Likes

#6

Apologies! It’s because I’m on Mac, and I’m using specific keys. It depends on what shortcut you want. For instance, you might change “option+minus” to “control+minus”, which means it gets triggered when you press ctrl,- (I use this because it’s like typing in the underscore, but instead of shift, you use ctrl). Same for “option+equals”.

1 Like

#7

Thanks! On Windows it’s actually shift+minus, for some reason it’s not working when I update the key bindings. However, control+minus does work. I don’t know why it’s refusing to recognize the shift key, but in any case this basically solves my problem! I’ll flag this as solved, thank you again :smiley:

0 Likes