Any way in SublimeText 4 to include a path for a file type?

203 Views Asked by At

I want to include a global file path, specifically "C:\dev-tools\node_modules@types\jquery\index.d.ts" every time a JS file is being edited. Any way to do this?

I can see in this question/answer that a custom plugin can be coded to automatically insert snippets based on file type, can something similar be done but just include a path?

Is there a way in Sublime text 3 to auto add the format for language after selecting it from syntax?

Trying to get autocomplete for jQuery for files that are not part of a project.

Thanks in advance.

I have tried adding the file by reference like so:

/// <reference path="C:\dev-tools\node_modules\@types\jquery\index.d.ts" />

And this works (I have LSP and LSP-typescript installed) and autocomplete works flawlessly. I also have jquery types globally installed so adding this to the beginning of the file works too:

require(jQuery);

I am trying to achieve/expecting to achieve

...being able to get autocomplete without extra code in the beginning of the file which I'd have to remove later on.

1

There are 1 best solutions below

0
MattDMo On

You can include the path to jQuery as part of your .sublime-project file. Just select Project → Add Folder to Project… and select C:\dev-tools\node_modules\@types\jquery, and it will be indexed for autocomplete along with all the other folders.