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

[Feature Request] Visual Studio Code Support #44

Open
ghost opened this issue Sep 6, 2016 · 19 comments
Open

[Feature Request] Visual Studio Code Support #44

ghost opened this issue Sep 6, 2016 · 19 comments

Comments

@ghost
Copy link

ghost commented Sep 6, 2016

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
Copy link
Owner

Garethp commented Sep 6, 2016

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
Copy link
Author

ghost commented Sep 6, 2016

I meen Visual Studio Code not Visual Studio :)

@Garethp
Copy link
Owner

Garethp commented Sep 7, 2016

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
Copy link
Author

ghost commented Sep 7, 2016

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
Copy link
Owner

Garethp commented Sep 7, 2016

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

@Eitz
Copy link

Eitz commented Nov 21, 2016

Any progress on this?

@zhengying
Copy link

any update?

@greenfrogs
Copy link
Contributor

Has there been any progress on this?

@MrFaul
Copy link

MrFaul commented Mar 30, 2017

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
Copy link

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

@MrFaul
Copy link

MrFaul commented Mar 30, 2017

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
Copy link

quonic commented Aug 5, 2017

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
Copy link

GWJYonder commented Dec 8, 2017

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
Copy link

This needs to be documented elsewhere. For more visibility.

@resb53
Copy link

resb53 commented Jun 13, 2018

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
Copy link

Lujia-Cheng commented May 24, 2019

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
Copy link

QAutoBotOP commented Jan 23, 2020

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
Copy link

C0rn3j commented Apr 16, 2021

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
Copy link

ethanxxxl commented May 2, 2023

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))))))

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