neoclide / coc-tsserver

Tsserver extension for coc.nvim that provide rich features like VSCode for javascript & typescript
MIT License
1.06k stars 68 forks source link

How do I avoid `jumpImplementation` from jumping to type file #289

Open davidsu opened 3 years ago

davidsu commented 3 years ago

I have a custom handler to fallback to regex search function implementation when I can't find one with ts-server. It happens quite often on the monorepos I work that I can easily find the function declared on another subproject but using CocAction('jumpImplementtion') jumps to .d.ts files. Is there some way to tell ts-server to filter out .d.ts files from possible jumpLocations for jumpImplemention?

chemzqm commented 3 years ago

Don't know, you need ask typescript team.

chemzqm commented 3 years ago

Or maybe create plugin of tsserver could help

davidsu commented 3 years ago

I should have started by saying that I love your work. I really do. What im doing is to map gd to a custom function that tries to jumpimplementation and fallsback to regex search if typescript don't have implementation location. I endedup using feedkeys(<c-o>.... if i endup in a d.ts file and then fallingback to regex, works well enough for me. Thanks

JamesApple commented 3 years ago

This is already supported with project references and declarationMap: true. I've used this in yarn workspace monorepos as well as lerna/npm monorepos to jump between subprojects.

davidsu commented 3 years ago

@JamesApple looks like create-react-app doesn't play well with project references. There are clever solutions to the problems of CRA, it's a bit of an overkill for me at this time. I'm happy enough with my hacks for now. It was fun to learn about it, thank u for that.