sublimelsp / LSP

Client implementation of the Language Server Protocol for Sublime Text

Home Page:https://lsp.sublimetext.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

aashish108 opened this issue · comments

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

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.

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

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.

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)

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

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.

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.

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.