Sublime Forum

Too many autocomplete suggestions

#1

Whenever I access the properties of any object, Sublime Text suggests pretty much every single word that’s in the document. See the simplified example below, the only valid suggestion is path, but it lists every word that’s in the document, including “png”, “common”, and “const”.

autocomplete

This happens both with JavaScript and TypeScript. Is there a setting to tell Sublime Text not to read everything in the file and throw it back at me?

This answer says that ST makes suggestions by “words contained in your document”. Is there a way to disable this?

0 Likes

#2

You can disable the auto complete entirely, or rely on a plugin to provide it instead.

0 Likes

#3

Thanks for the suggestion! I disabled autocomplete in the settings with: "auto_complete": false, then triggered it manually when needed with the Ctrl + SPACE shortcut, but the excessive suggestions still showed up.

I already use the TypeScript plugin, which recognizes .path as the only available property of assets.char, but SublimeText fills the rest of the suggestions with every word in the file. Is there a setting that tells Sublime not to do this?

0 Likes

#4

Thanks for the suggestion! I disabled autocomplete in the settings with: "auto_complete": false, then triggered it with the Ctrl + SPACE shortcut, but the excessive suggestions still showed up.

The suggestions are the auto-complete. If you manually trigger auto-complete they will of course show. Overriding the default auto-complete is up to the plugin afaik.

0 Likes

#5

Below is the plugin I use. I could not find the original author to give him/her the credit, though.

import sublime
import sublime_plugin

class DisableCompletionWordsInBufferCommand(sublime_plugin.EventListener):
	def on_query_completions(self, view, prefix, locations):
		return ([], sublime.INHIBIT_WORD_COMPLETIONS)
2 Likes

#6

Thank you so much, @rcopat! This worked like a charm! Now when I type al.char. the only suggestion available is path, without adding all the words in the document.

noSuggestions

To anyone looking for this solution in the future:

  1. Go to Tools > Developer > New Plugin...
  2. A template plugin will appear. Replace this with the plugin above.
  3. Save as .py file in Packages directory (on my Windows machine it’s C:\Users\[MyUserName]\AppData\Roaming\Sublime Text 3\Packages\User\)
  4. Sublime no longer suggests every word in the file!
1 Like

#7

I’ve upgraded to SublimeText4, and it seems like the problem returns in a different way. I no longer get every word on the file (thanks to @rcopat’s plugin), but it seems I am now being recommended every keyword that exists in every package in my project’s node_modules folder.

See the example below, I type scr in my .ts file, and it gives me 500 options of things I’m not even remotely using:

I’m using LSP-Typescript to enable TypeScript functionality. Could this be the culprit? I’m not importing any of these libraries into my files, they’re just needed as dependents of dependents for my dev environment, so I’m not sure why it’s recommending them. How can I turn this excessive number of suggestions off?

0 Likes

#8

Solution It does look like it is an LSP-Typescript functionality. I found in their Github issues that this can be disabled by setting "includeCompletionsForModuleExports": false in the LSP-typescript settings file.

I’m back to only getting suggestions available within the current context :slight_smile:!

0 Likes