Garethp / ScreepsAutocomplete

Autocomplete for Screeps
478 stars 105 forks source link

[Feature Request] Visual Studio Code Support #44

Open ghost opened 8 years ago

ghost commented 8 years ago

First great project like it !

But it would be awesome if you support VS Code, for the ScreepsAutocomplete project.

Hope you have a great day !

Garethp commented 8 years ago

Hi @Venom-Code If you look through the Readme, there should be instructions on how to make this work with VisualStudio. Does this not work for you?

ghost commented 8 years ago

I meen Visual Studio Code not Visual Studio :)

Garethp commented 8 years ago

Ah, gotcha. Is there a fair difference? Does the same process not work? What part of the process stops being the same for VSC? I'll look in to it, but if you can answer those upfront it may be quicker

ghost commented 8 years ago

VS Code is quite similar to Atom both are build on electron (an Javascript framework). I think extension in Atom are written in Coffescript right ? In VS Code you write extesions in Javascript. Here is an link for extension developing.. and so on https://code.visualstudio.com/docs/extensions/overview I hope, i could help you. I love this editor so much :) Hope you can get it !

Garethp commented 8 years ago

I'll look in to seeing if I can make some installation instructions for it

Eitz commented 7 years ago

Any progress on this?

zhengying commented 7 years ago

any update?

greenfrogs commented 7 years ago

Has there been any progress on this?

MrFaul commented 7 years ago

Add the line at the beginning: /// <reference path="where/ever/ScreepsAutocomplete/is" /> and you are done -_- took me 3 days to find that... Result is that I have now a entire tool chain working that I never wanted ... <- which worked before i got autocomplete to do something.

Code is awesome but wired in some ways I blame MS ;-P

AVATAR-Phoenix commented 7 years ago

Nice ty @MrFaul , would i have to add this to each file though or just the first?

MrFaul commented 7 years ago

This is for some reason very buggy so I recommend putting it in every file, if you still have issues I recommend to switch to a typescript definition like screeps.d.ts sometimes it works without reference link sometimes not. I still have no clue what's going on so I just tell you what "somehow" worked for me ^^

quonic commented 7 years ago

Just in case someone happens upon this problem . Add _references.js to the ScreepsAutocomplete folder and VScode's intelisense works.

Also add jsconfig.json with the following to the root folder if your project: { "compilerOptions": { "target": "ES6" }, "exclude": [ "node_modules" ] }

GWJYonder commented 6 years ago

For future googlers, I was just able to get this working with a combination of MrFaul and quonic's advice. I added the _references.js file to the ScreepsAutocomplete folder as quonic suggested, and then added

/// <reference path="..\..\ScreepsAutocomplete\_references.js" />

to the tops of the file, not just a reference to the folder of the project. This worked without me needing to add a jsconfig file, at least I haven't yet.

Jason-Terry commented 6 years ago

This needs to be documented elsewhere. For more visibility.

resb53 commented 6 years ago

Building on GWJYonder's findings, I played around with the various permutations of the above a bit.

Seems like the /// <reference path=....... line needed to only be in one file. But that file needed to be open in VScode for it to work. So you could put it in every file to be safe... or in one, e.g. main.js and ensure it's always open.

I ran the same tests without using this line at all, but including quonic's jsconfig.json file in the root project folder, and it seems to have the same effect, working even with no other windows open.

These weren't fully comprehenesive, just checking how many options I was presented with for a creep object, but seems like quonic's advice gets it all working.

Lujia-Cheng commented 5 years ago

Found a way, although this might not relate to this project whatsoever. Just type in below in terminal/cmd

npm install @types/screeps
npm install @types/lodash

Credit to: Remoh(ID: UJL4HDL9Z) on Screeps Slack

QAutoBotOP commented 4 years ago

I got it working here summary:

  1. Add ScreepsAutocomplete-master to screeps/scripts/screeps.com/default

  2. Added ScreepsAutocomplete to main Screeps folder (in .../steamapps/common for me)

  3. Added _references.js to ScreepsAutocomplete folder

  4. Added jsconfig.json to ScreepsAutocomplete folder this is the file with in it: { "compilerOptions": { "target": "ES6" }, "exclude": [ "node_modules" ] }

  5. Opened a terminal from VSCode and did these two: npm install @types/screeps npm install @types/lodash

  6. Restarted VSCode and it works.

Some of these steps are not needed but it works. Just the summary, thanks to the guys above!! I've been trying to get this to work for quite some time now. Have fun gaming fellas.

C0rn3j commented 3 years ago

I just installed the NPM types, but if someone wants to generate up to date _references.js and not the one from 2017, I made a small snippet for Linux. Didn't get to test it however.

cd ScreepsAutocomplete
rm -f _references.js
for i in $(find ./ -iname \*.js | cut -c3-); do echo "/// <reference path=\"${i}\" />"; done > _references.js
ethanxxxl commented 1 year ago

I was able to get autocompletion working using @QAutoBotOP's method in emacs!

I am using doom, rjsx-mode with lsp integration enabled. this might be off topic, but for anyone who stumbles on this I made a hook which automatically copies the ScreepsAutocomplete directory (with modifications) into the current project directory, if it is a screeps project:

(add-hook 'rjsx-mode-hook
          (lambda ()
            "sets up auto-complete for screeps projects.

Checks if rjsx-mode is being run in a screeps project. If so,
then copy over the autocomplete files to the current directory.

there is a potential problem, where, if there are multiple
subdirectories, the autocomplete files will be copied over
multiple times. this may or may not be an issue."

            ; check if we are in a screeps project
            (if (and (string-match "Screeps/scripts"
                                   (file-name-directory (buffer-file-name)))
                     (not (file-exists-p "ScreepsAutocomplete/")))
                ;; we are in a screeps directory without the autocomplete files
                (copy-directory
                 "Absolute/path/to/Screeps/scripts/ScreepsAutocomplete/"
                 (file-name-directory (buffer-file-name))))))