Skip to content

p5.js library Autocomplete and/or link to specific parts of reference #99

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

Closed
shiffman opened this issue Sep 16, 2016 · 11 comments · Fixed by #1873 or #2236
Closed

p5.js library Autocomplete and/or link to specific parts of reference #99

shiffman opened this issue Sep 16, 2016 · 11 comments · Fixed by #1873 or #2236
Labels
Feature Request Proposal for adding a new functionality Good Medium Issue A moderately complex issue for contributors with some experience Help Wanted Would love additional input or contributions!

Comments

@shiffman
Copy link
Member

Students requested a link to the p5.js reference in the editor. Ideally we would also eventually have an option where you could highlight a function name like fill, right-click, and have a "find in reference" option.

@shiffman shiffman added the Feature Request Proposal for adding a new functionality label Sep 16, 2016
@catarak
Copy link
Member

catarak commented Sep 16, 2016

We could also consider features like autocomplete, definitions in the editor, and so on, using Tern.js. I found an example of using it with CodeMirror as well..

@zhuoxi
Copy link
Contributor

zhuoxi commented Sep 17, 2016

In the mean time, maybe we could just put a link to the reference https://p5js.org/reference/ somewhere in the editor menu bar?

@catarak catarak changed the title Link to Reference p5.js library Autocomplete and/or link to specific parts of reference Oct 11, 2016
@ducklin5
Copy link

ducklin5 commented Jan 5, 2017

Ive tried compiling a tern definitions json file for p5 with tern's "condense" tool but it failed to work. Ive even tried it with other libraries like Three.js and jquery, and it worked. So condense works fine; I think the problem is the script. This was the command and the output :
****@**** MINGW64 ~/AppData/Roaming/Brackets/extensions/user/ternific/node_modules/tern/bin $ ./condense --name p /c/wamp/www/libraries/p5.js { "!name": "p" }

@catarak
Copy link
Member

catarak commented Jan 6, 2017

@ducklin5 I've never used tern before so I'm not sure how to help... want to give me more details as to what you've done so far and maybe we can attack it together?

@ducklin5
Copy link

ducklin5 commented Jan 7, 2017

Yes! Im using tern on brackets and on sublime text. Ive got no experience with it either and Im just trying to follow the manual and guides that Ive found googling. From what I gather we can use the "condense" tool that comes with it to compile a json file of definition and autocomplete terms for p5. Another option is the configure the yuidoc to format the output in the same format as that of tern.

@catarak catarak added the Priority:Medium Moderately important, should be completed in a fair timeframe label Feb 23, 2017
@catarak
Copy link
Member

catarak commented May 24, 2017

@ducklin5
Copy link

@catarak, is this json file a tern plugin or auto completion specifically for the p5 web editor?

@kaganjd
Copy link
Collaborator

kaganjd commented Jun 23, 2017

@ducklin5 it's the output of running grunt on the p5 source. it's basically all the p5 documentation in JSON form. i'm working on getting it to a format that works with tern. here's a gist of that process so far: https://gist.github.com/kaganjd/32c87c49fda5f61b78aa2b88993daca4

@catarak catarak added Good First Issue A beginner-friendly issue, great for first-time contributors Help Wanted Would love additional input or contributions! Priority:High Should be addressed soon but not critical and removed Priority:Medium Moderately important, should be completed in a fair timeframe labels Apr 18, 2019
@catarak catarak added Good Medium Issue A moderately complex issue for contributors with some experience and removed Good First Issue A beginner-friendly issue, great for first-time contributors Priority:High Should be addressed soon but not critical labels Feb 12, 2020
@catarak catarak mentioned this issue Apr 6, 2020
11 tasks
@ash97531
Copy link

@catarak if this issue still not done.. I will be happy to work on this.

@jonnytest1
Copy link

jonnytest1 commented Jul 16, 2022

y not just add typescript integration ?
(i'd recommend switching to the monaco editor for this )

@lindapaiste
Copy link
Collaborator

The autocompletion is actually very easy to do using @codemirror/autocomplete once we upgrade to CodeMirror v6.

image

import { completeFromList, autocompletion } from '@codemirror/autocomplete';

import {
  p5FunctionKeywords,
  p5VariableKeywords
} from '../../../utils/p5-keywords';

const p5AutocompleteSource = completeFromList(
  Object.keys(p5FunctionKeywords)
    .map((keyword) => ({
      label: keyword,
      type: 'function',
      boost: 99 // TODO: detail
    }))
    .concat(
      Object.keys(p5VariableKeywords).map((keyword) => ({
        label: keyword,
        type: 'constant',
        boost: 50 // TODO: detail
      }))
    )
);

const p5AutocompleteExt = autocompletion({
  override: [p5AutocompleteSource] // TODO: include native JS
});

And then you include that p5AutocompleteExt object in the extensions array when creating the EditorView.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Proposal for adding a new functionality Good Medium Issue A moderately complex issue for contributors with some experience Help Wanted Would love additional input or contributions!
Projects
None yet
8 participants