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

Won't find file for some project typs, like Nuxt. #19

Open
mikeslattery opened this issue Jun 15, 2022 · 3 comments
Open

Won't find file for some project typs, like Nuxt. #19

mikeslattery opened this issue Jun 15, 2022 · 3 comments
Assignees

Comments

@mikeslattery
Copy link

mikeslattery commented Jun 15, 2022

Nuxt projects don't have a /src directory. This plugin won't jump to files in my projects. I believe this will cause other projects to fail to find files, such as maybe next.js.

The issue is that src is hard-coded for file search. I believe the solution would be to use tsconfig.js settings for baseUrl, paths, include, and exclude.


Additional information. This is just me poking around at ways to deal with it.

Here's a way to reliably and easily resolve a module (e.g. @/services/user) within a node project with a tsconfig.js file.

node -e "
    paths = require('tsconfig-paths');
    config = paths.loadConfig();
    paths.register(config);
    console.log(
        paths.createMatchPath(config.baseUrl, config.paths)(process.argv[1])
    )" -- "@/services/user"

Unfortunately, tsconfig-path removes the file extension, so you have to check for .js or .ts. Also, it doesn't work with node_modules.

I think there might be a better way than above. I poked around at the source of tsc, but gave up after a while due to complexity. Maybe I'll tacklet it again later.

Workarounds I'm using:

  • Coc and Neovim's LSP have a "goto-definition" command that can be used instead
  • Relative paths work with regular Vim. import user from '../services/user'

Also btw, json_decode(string) was added to Vim 8.

@hotoo
Copy link
Owner

hotoo commented Jun 17, 2022

src is not hard coded, but you're right, I'll use tsconfig file to find path alias.

Thank you for this issue.

@hotoo hotoo self-assigned this Jun 17, 2022
@mikeslattery
Copy link
Author

mikeslattery commented Jun 17, 2022

src is not hard coded,

Hmm, I saw this and assumed it was: https://github.com/hotoo/jsgf.vim/blob/master/plugin/jsgf.vim#L25

Thanks for the quick reply! I'm glad you're going to fix it.

@hotoo
Copy link
Owner

hotoo commented Jun 17, 2022

Hmm, I saw this and assumed it was: https://github.com/hotoo/jsgf.vim/blob/master/plugin/jsgf.vim#L25

It's just external find path, see https://github.com/hotoo/jsgf.vim/blob/master/plugin/jsgf.vim#L30

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

No branches or pull requests

2 participants