jedhy
jedhy copied to clipboard
Support more complex completions
This is a really great library, currently trying to integrate with vscode but was wondering about some more complex use-cases:
- Would it be possible to support completions on variables?
(setv some-var [])
(some-var. ) ;; should print all array methods?
- Can completion on things like this work:
(.r subprocess "...") ;; where the .r should show a list of completions for subprocess.r
- Would it be possible to support completions on variables?
I think the issue is that the Hy shell does not know yet of the some-var variable. If you evaluate (setv some-var []) first, it should give completions via (dir some-var).
(dir some-var)
["__add__" "__class__" "__class_getitem__" "__contains__" "__delattr__" "__delitem__" "__dir__" "__doc__" "__eq__" "__format__" "__ge__" "__getattribute__" "__getitem__" "__getstate__" "__gt__" "__hash__" "__iadd__" "__imul__" "__init__" "__init_subclass__" "__iter__" "__le__" "__len__" "__lt__" "__mul__" "__ne__" "__new__" "__reduce__" "__reduce_ex__" "__repr__" "__reversed__" "__rmul__" "__setattr__" "__setitem__" "__sizeof__" "__str__" "__subclasshook__" "append" "clear" "copy" "count" "extend" "index" "insert" "pop" "remove" "reverse" "sort"]
(.r subprocess "...")
If you rewrite it to (subprocess.run "pwd"), it's a lot clearer and gives completions via (dir subprocess):
(dir subprocess)
["CalledProcessError" "CompletedProcess" "DEVNULL" "PIPE" "Popen" "STDOUT" "SubprocessError" "TimeoutExpired" "_PIPE_BUF" "_PopenSelector" "_USE_POSIX_SPAWN" "_USE_VFORK" "_WIFSTOPPED" "_WNOHANG" "_WSTOPSIG" "__all__" "__builtins__" "__cached__" "__doc__" "__file__" "__loader__" "__name__" "__package__" "__spec__" "_active" "_args_from_interpreter_flags" "_can_fork_exec" "_cleanup" "_fork_exec" "_mswindows" "_optim_args_from_interpreter_flags" "_text_encoding" "_time" "_use_posix_spawn" "_waitpid" "_waitstatus_to_exitcode" "builtins" "call" "check_call" "check_output" "contextlib" "errno" "fcntl" "getoutput" "getstatusoutput" "io" "list2cmdline" "locale" "os" "run" "select" "selectors" "signal" "sys" "threading" "time" "types" "warnings"]
But note that I am not using this package since it doesn't work with the latest Hy version. I have my own completions based on (dir) and (locals) (and soon the inspect Python package).