microsoft / TypeScript-Sublime-Plugin

IO wrapper around TypeScript language services, allowing for easy consumption by editor plugins
Apache License 2.0
1.72k stars 235 forks source link

GoTo Definition shows all function calling in file #604

Open vosecek opened 7 years ago

vosecek commented 7 years ago

GoTo Definition by cmd+r on Mac shows all function calling in open file of project. The tool is useless now, if there are multiple calling of one method in current file.

screenshot 2017-05-03 11 18 14

billti commented 7 years ago

Is this only for the Sublime "GoTo definition"? Does the TypeScript one (F12) work as expected for you?

it6 commented 7 years ago

This actually happens in 'Go To Symbol' which navigates across symbols in a given file, (F12) 'Go To Definition' works as expected

saskoh commented 7 years ago

Here's a workaround to display only method names in the symbol list by setting up a configuration file for SublimeText that excludes bindables, method calls, etc.:

1) Open the SublimeText Packages Folder and navigate to the "TypeScript" folder 2) Inside the "TypeScript" folder create a new file called "Symbol List.tmPreferences" 3) Edit this file and copy the following lines into it:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>name</key>
  <string>Symbol List</string>
  <key>scope</key>
  <string>meta.decorator.ts, meta.var.expr.ts, meta.block.ts, meta.field.declaration.ts</string>
  <key>settings</key>
  <dict>
    <key>showInSymbolList</key>
    <integer>0</integer>
  </dict>
</dict>
</plist>

4) Save the file

The next time you press "ctrl-r" in a TypeScript file, you'll only get the method names displayed.

vosecek commented 7 years ago

@Saskoh Thanks, works great.

stweedie commented 6 years ago

Why has this not made it to the actual package?

binarynate commented 6 years ago

@stweedie , I think it's just that nobody had created a PR yet. So, I just put up #653 for it.

kylebebak commented 5 years ago

For anyone that stumbles on this, you can create a .tmPreferences file in any directory from which .tmPreferences files are loaded, included the User directory.

It can also have any name you want.

I have TypeScript - Symbol List.tmPreferences in Packages/User, which is nice, because it won't get overwritten every time there's a new release of the TypeScript plugin.

Also, there are a few other scopes that should be ignored aside from the ones @Saskoh listed. This is what I'm working with right now:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>name</key>
  <string>Symbol List</string>
  <key>scope</key>
  <string>meta.function-call.ts, meta.parameters.ts, meta.decorator.ts, meta.var.expr.ts, meta.block.ts, meta.field.declaration.ts</string>
  <key>settings</key>
  <dict>
    <key>showInSymbolList</key>
    <integer>0</integer>
    <key>showInIndexedSymbolList</key>
    <integer>0</integer>
  </dict>
</dict>
</plist>
ntr-808 commented 3 years ago

The above XML snippets didn't give me very many symbols to navigate to.

I copied the following from the #727 PR:

~/.config/sublime-text-3/Packages/User/ts-symbols-exclude.tmPreferences

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>name</key>
  <string>Symbol List</string>
  <key>scope</key>
  <string>meta.import.ts,meta.parameters.ts,meta.function-call.ts,meta.return.type.ts,meta.type.parameters.ts,meta.type.annotation.ts,meta.var.expr.ts,entity.name.type.module.ts,entity.name.type.ts</string>
  <key>settings</key>
  <dict>
    <key>showInSymbolList</key>
    <integer>0</integer>
  </dict>
</dict>
</plist>

~/.config/sublime-text-3/Packages/User/ts-symbols-include.tmPreferences

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>name</key>
  <string>Symbol List</string>
  <key>scope</key>
  <string>entity.name.type.class.ts, meta.definition.property.ts</string>
  <key>settings</key>
  <dict>
    <key>showInSymbolList</key>
    <integer>1</integer>
  </dict>
</dict>
</plist>