Native code snippets for Visual Studio Code. Similar to what I’ve made in the past for Notepad++
I know some version similar to this already exists here, but that hasn’t been updated for quite some time and does not provide a description with detailed information about return value, namespace, CFX apiset and the actual native description.
So here’s my version:
Code snippets (all native functions) for visual studio code
Download the json file (just right click > save as)
Either
copy/paste everything into your user snippets (in visual studio go to File > Preferences > User Snippets and open the Lua one), or;
place the lua.json file inside {your visual studio code installation folder}\resources\app\extensions\lua\snippets\lua.json (make the snippets folder if it doesn’t exist), next follow step 3.
(skip if you chose the first option in step 2): go up one folder level from the previous step, so you end up in \lua\, and open the package.json file, add this code below the “grammars” section.
Restart visual studio code and edit any .lua file to test it out.
Profit
issues
Only known issue currently is that there’s no snippets for Citizen.CreateThread and similar non-native functions. Neither does it have actual basic Lua functions like table.unpack for example. For the non-native functions, I suggest you just add those manually for now (until I add them at some later point) or use the ones from the other release mentioned at the top of this thread.
The download will be updated whenever major changes are made to the native reference, so just download the file from the same url as mentioned above whenever a new version is released.
Can’t seem to get this to work, I tried both methods (adding with VSCode and putting the file in the snippets folder) but it keeps saying “No Suggestions”. I tried the old snippets you linked in your post and they work fine. When I copy/paste into lua.json it says: Incorrect type. Expected “object”
I’ll look into this, it worked fine for me, maybe I’ve confused the two output files of my script when uploading this latest version. Will let you guys know tomorrow.
Edit: looks like I indeed mixed up the output file with another. My bad, I’ll fix this tomorrow.