sublimelsp / LSP-typescript

TypeScript, JavaScript support for Sublime LSP plugin
MIT License
134 stars 11 forks source link

"Go to definition" only works on open files #218

Closed lapega closed 1 year ago

lapega commented 1 year ago

The "Go to definition" command only find definitions on open files (files showed in sublime tabs). If the file is closed, the message showed is "No results found".

Same thing happens with the find "References" command, only show references in open files.

This behavior doesn't happens on another LSP servers, like PHP, only happens on .js files.

I've tried reinstalling the LSP-typescript server, and also deleting user preferences, but the bug still happens.

rchl commented 1 year ago

Should work. Provide a project that reproduces or at least provide the output of LSP: Troubleshoot Server command.

lapega commented 1 year ago

(didn't know how to provide a project)

Troubleshooting: LSP-typescript

Version

## Server Configuration
 - command
```json
[
  "${node_bin}", 
  "${server_path}", 
  "--stdio"
]

Active view

Project / Workspace

LSP configuration

{
  "diagnostics_delay_ms": 3000, 
  "diagnostics_gutter_marker": "sign", 
  "log_debug": true, 
  "show_diagnostics_panel_on_save": 0
}

System PATH

rchl commented 1 year ago

If your code is not written as Common JS or ES modules then Typescript doesn't really have a way to figure out references. It seems like the vista/html/_js/funciones.js file might be just a old-school web code that references some global stuff defined in other files. This wouldn't be very TS-friendly. You'd need to either use ES modules (which would only work in modern browsers) or use ES modules and add bundler to your project to compile the code to plain JS.

lapega commented 1 year ago

Indeed, in all my projects I have a bunch of js files that are called individually. I thought that TLS-ts will look at any js file in the project.

Thanks anyway!