Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find references not working across the project but only on opened files #2396

Closed
aashish108 opened this issue Jan 20, 2024 · 8 comments
Closed

Comments

@aashish108
Copy link

Describe the bug
Find references (panel that appears on hover over, say, an exported function, only finds references on open files rather than searching in the whole project

To Reproduce
Steps to reproduce the behavior:

  1. Just find for references of an exported function that is used elsewhere but that file is not open (tested on a React project using LSP/LSP-eslint)
  2. It will not find references for files that are closed but if you open a file that does use the reference then it will show relevant references

Expected behavior
Previously, it used to search the whole project and was very useful. Not sure when it started but might have been a few weeks/ or even months as I was wondering why references are not being found across the project.

Environment (please complete the following information):

  • OS: macOS 14.2.1
  • Sublime Text version: 4169
  • LSP version: 1.27.0
  • Language servers used: bash/css/dockerfile/eslint/graphql/html/intelephesense/jdtls/json/stylelint/tailwindcss/terraform/typescript/yaml

Additional context
See attached config files:
LSP-eslint config.txt

@rchl
Copy link
Member

rchl commented Jan 20, 2024

LSP-eslint is a linter. It doesn't provide any references.

If you meant to say LSP-typescript then provide a log from LSP: Toggle Log Panel command.

@predragnikolic
Copy link
Member

If you are talking about the Sublime Text show_definitions popup:

2024-01-20-133108_604x130_scrot

This popup has nothing to do with LSP, it is a Sublime Text feature that can be turned of with "show_definitions: false in Sublime Text preferences.

LSP find references look like this:
https://user-images.githubusercontent.com/6579999/128551752-b37fe407-148c-41cf-b1e4-6fe96ed0f77c.gif

Feel free to explore the docs for LPS https://lsp.sublimetext.io/features/#find-references

@aashish108
Copy link
Author

Thanks for that clarification! I should have known :/

Though it appears, the same issue happens when I find references via the LSP right-click menu as well as the Sublime Text hover references option. References are only checked if the file is open.

Sounds like a Sublime error, might ask in the forums.

@predragnikolic
Copy link
Member

This is the perfect place to ask questions about LSP :⁠-⁠)

I do not quite know what exactly you are seeing,
Can you post a screenshot of what you are seeing?

Also, do you have LSP-typescript installed?

If yes, please see the message above
#2396 (comment)

@aashish108
Copy link
Author

Cool! Here is what I mean, and this is with using the right-click > lsp > find references option. I have also attached the LSP-typescript config log.

Searching without file open
Screenshot 2024-01-20 at 14 36 31

Searching with file open
Screenshot 2024-01-20 at 14 37 00

Cheers.

LSP-typescript.config.txt

@rchl
Copy link
Member

rchl commented Jan 20, 2024

It all depends on the tsconfig.json configuration in your project. If typescript is not told where to look for your files then it will only be able to handle open files.

You should check for tsconfig.json is parent directories up to the workspace root.

@aashish108
Copy link
Author

The thing is we are not using Typescript thus there is no tsconfig.json. Its a React project but just using js/jsx. Where would I configure the files' location in this case?

Also, it's a big monorepo, if that matters.

@aashish108
Copy link
Author

You were right! Got it working with the below jsconfig.json :)

{
  "include": ["shells/direct-shell/src/**/*"],
  "exclude": ["node_modules", "**/node_modules/*"],
}

Thanks for pointing me in the right direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants