ScreepsAutocomplete icon indicating copy to clipboard operation
ScreepsAutocomplete copied to clipboard

[Feature Request] Visual Studio Code Support

Open ghost opened this issue 8 years ago • 19 comments

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 !

ghost avatar Sep 06 '16 12:09 ghost

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?

Garethp avatar Sep 06 '16 15:09 Garethp

I meen Visual Studio Code not Visual Studio :)

ghost avatar Sep 06 '16 17:09 ghost

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

Garethp avatar Sep 07 '16 08:09 Garethp

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 !

ghost avatar Sep 07 '16 09:09 ghost

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

Garethp avatar Sep 07 '16 10:09 Garethp

Any progress on this?

Eitz avatar Nov 21 '16 14:11 Eitz

any update?

zhengying avatar Nov 29 '16 12:11 zhengying

Has there been any progress on this?

greenfrogs avatar Dec 29 '16 17:12 greenfrogs

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

MrFaul avatar Mar 30 '17 12:03 MrFaul

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

AVATAR-Phoenix avatar Mar 30 '17 13:03 AVATAR-Phoenix

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

MrFaul avatar Mar 30 '17 13:03 MrFaul

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" ] }

quonic avatar Aug 05 '17 15:08 quonic

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.

GWJYonder avatar Dec 08 '17 02:12 GWJYonder

This needs to be documented elsewhere. For more visibility.

Jason-Terry avatar Jan 12 '18 18:01 Jason-Terry

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.

resb53 avatar Jun 13 '18 11:06 resb53

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

Lujia-Cheng avatar May 24 '19 18:05 Lujia-Cheng

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.

QAutoBotOP avatar Jan 23 '20 01:01 QAutoBotOP

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

C0rn3j avatar Apr 16 '21 17:04 C0rn3j

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

ethanxxxl avatar May 02 '23 10:05 ethanxxxl