hylang / hy-mode

Hy mode for Emacs
GNU General Public License v3.0
191 stars 47 forks source link

Eldoc Support #58

Closed ekaschalk closed 6 years ago

ekaschalk commented 6 years ago

eldoc-mode is now supported. It formats the docs/args similarly to python-mode.

~Python style formatting is clearly not the best format for a lisp - I will investigate changing the syntax of the eldoc strings to be lispy, once everything is completing as it should.~ Lispy formatting (and kwargs/rest/optional...) all supported now.

The following improvements are ideal:

  1. ~Attribute accessor methods opening a form (eg. (.format str ...) ) aren't supported yet (but (str.format ...) is supported).~
  2. ~Macros aren't supported - some combination of work on Hy internals and some custom introspection utilities are required.~
  3. ~Highlight the form-at-point in the returned string if the string allows for it (emacs-lisp makes great use of this).~ - later
  4. ~Within threading macros, for forms not wrapped in parenthesis, get the eldoc for the unwrapped symbol rather than the threading macro.~ decided against for now.

Bugs:

  1. ~Sometimes the bottom messages a comint error, only seen on forms without docs. Haven't determined how to reliably reproduce yet.~ Error with incomplete dot form, might be fixed.

Eldoc works and all bugs are fixed. But formatting/inspection can be improved. This issue will remain open as I work to improve its messages for more data structures. Also compile table constructs still don't have Eldoc support and won't until Hy's compiler table is refactored.

ekaschalk commented 6 years ago

Attribute methods are now supported, even in case of string/dict/list literals. So both (.format str ...) and (.format "some-str" ...) are supported.

ekaschalk commented 6 years ago

hy.core.macros are now supported by Eldoc. Completing all namespaced macros is simple. To support hy.compiler macros defined with @builds is actually easier than standard macros, however I will need to PR Hy with some docstrings for such functions.

ekaschalk commented 6 years ago

Eldoc is now solid! It formats all introspections lispy-like and puts &rest, &optional, ... all within the argstring.

Next I will highlight the eldoc string emacs-side similarly to how emacs-lisp does it.

ekaschalk commented 6 years ago

Eldoc now fontifies text.

todos

  1. Distinguish the form at point in the argstring (might be hard/not possible due to not all python objs can be introspected)
  2. Collect macros besides macros just in hy.core.macros.
  3. PR hy with docstrings and add support for @builds compiler functions.
ekaschalk commented 6 years ago

As an update - we now have a pretty awesome, works in all cases, formats python builtins too, eldoc mode.

It will be released once the new-shell2 branch is finished up and how to handle the now-large hy setup code.