Search code examples
vue.jssublimetext3sublimetextvue-loader

Sublime Text 3 cannot parse symbols from vuejs


In Sublime Text, I'm used to accessing function names through the @ symbol list. However, when using a project established from vue-templates, all the function names and data attributes in .vue files do not appear in this list.

This makes navigating .vue files tedious. I have installed all vue-related Sublime packages but none of them seem to fix this.

How can I get symbol indexing working properly with Vue files? Or, do you have any experience with other text editors that do this properly?


Solution

  • The symbol list in Sublime (visible via Goto > Goto Symbol... or Goto > Goto Symbol in Project...) is controlled primarily by the syntax definition for the language in question and secondarily by configuration metadata that tells Sublime what parts of the syntax are actually symbols that should be displayed in the symbol list.

    In general:

    • Sublime runs an indexer over all of the files that are currently in your project
    • The indexer uses the rules in the syntax definition to break up the text into various scopes that describe the purpose of each bit of text (e.g. "This is a string", "this is a method call", etc)
    • A preferences file contains rules that indicate what scopes are considered symbols, both for the current file as well as project wide

    The two parts of this need to work hand in hand in order for the symbol lists to populate correctly (as Sublime can't guess on its own), and both parts should be provided by the package or packages that are providing Vue support to Sublime.

    The best course of action would be to raise an issue with the developers for the Vue package that's providing the Syntax definition. It's possible that the simple inclusion of an appropriate Symbol List.tmPreferences file by the syntax author would be enough to fix the issue.

    It's also possible that the symbol list is not fully populated because sublime is still indexing all of the files in the project and so the data is not available yet.

    You can check the status of the indexer in recent builds of sublime by selecting Help > Indexing Status... from the menu to see if that's the issue. However unless you have an extremely large set of files this is likely not the issue.