Strange suggestions sublime text editor

174 Views Asked by At

when I write code I like the computer to give me suggestions. But with sublime text editor I get very weird unwanted suggestions like this:

weird suggestions

even when I want to use a function or class it doesn't tell me which parameters are required.

no function parameters

does anyone know how I can solve this problem?

class student:
    def __init__(self,name,age,grade):
        self.name = name
        self.age = age
        self.grade = grade

    def get_grade(self):
        return self.grade

s1 = student()
1

There are 1 best solutions below

0
On

Sublime's internal autocompletion system suggests symbols/words from the files that are available in your project (that is, the files that are available from the side bar). As such, the answer to your first question is that you're seeing those symbols because they appear in other files.

You can turn that off with this setting (shown here with the default value):

    // Auto complete will used indexed data to provide completions from other
    // files when this is enabled
    "auto_complete_use_index": true,

For your second question, it's probably worth mentioning first that you might also notice that not only does Sublime not offer you help with parameters, it will also not show you methods on the classes you're using. For example using your code, if you tried to autocomplete s1. you might expect to see the method of that class only, but you'll see all completions.

If you want that kind of IDE-like completion, you need to install the LSP package along with a support package for your language (in your case one for Python).

The LSP server does deep introspection of the contents of your code to provide (among other services) an autocompletion experience closer to what you're looking for.