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

Scalapy completion dev #2

Open
wants to merge 18 commits into
base: scalapy-completion
Choose a base branch
from

Conversation

kiendang
Copy link
Owner

@kiendang kiendang commented Aug 4, 2021

This PR adds completion support for ScalaPy in ammonite. It is not to be merged into ammonite as is but ideally waits till ammonite has support for completion extension

How to try this out

build an executable from this branch

./mill "amm[2.13.6].assembly"

run ammonite

java -jar out/amm/2.13.6/assembly/dest/out.jar

inside the repl, set up ScalaPy

import $ivy.`ai.kien::python-native-libs:0.2.1`
import $ivy.`me.shadaj::scalapy-core:0.5.0+8-7c7a6042`

import ai.kien.python.Python

Python().scalapyProperties.fold(
  ex => println(s"Error while getting ScalaPy properties: $ex"),
  props => props.foreach { case(k, v) => System.setProperty(k, v) }
)

import me.shadaj.scalapy.py
import me.shadaj.scalapy.py.PyQuote
import me.shadaj.scalapy.interpreter.CPythonInterpreter

Features

Basic completion is provided by the standard library rlcompleter, more advanced completion is available if jedi is installed.

Basic completion

This provides completion for attributes only

@ py.Dynamic.global.li|
license( list(

@ val v = py"'string'"
@ v.up|
upper(

@ Object Obj { val v = py"'string'" }
@ Obj.v.up|
upper(

@ CPythonInterpreter.execManyLines("class Cls(): x = 'string'")
@ py.Dynamic.global.Cls.x.up|
upper(

Things like py.Dynamic.global.range(10).cou| won't work

Jedi completion

This has support for more advanced completion thanks to jedi static analysis

@ py.Dynamic.global.range(10).cou|
count|

@kiendang kiendang force-pushed the scalapy-completion-dev branch 2 times, most recently from f5fc081 to f862e11 Compare August 11, 2021 20:41
@kiendang kiendang force-pushed the scalapy-completion-dev branch 3 times, most recently from 93a15dd to 982fe51 Compare August 18, 2021 20:51
@kiendang kiendang force-pushed the scalapy-completion-dev branch 4 times, most recently from fc591dc to d15b958 Compare August 23, 2021 13:40
@kiendang kiendang force-pushed the scalapy-completion-dev branch 2 times, most recently from 4399b90 to ea91986 Compare August 27, 2021 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant