hylang / hy-mode

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

How to get hy-mode to work? #108

Open tkaryadis opened 1 year ago

tkaryadis commented 1 year ago

Can you add instructions how to install it to get auto-complete? I never used Emacs in the past.

I think its very important people to be able to start with hylang in easy way, i am stuck days now. I added MELPA i found hy-mode i press install but nothing happened.

I use ubuntu 22.04, with hy 0.25 , thank you.

kovan commented 1 year ago

I think that for now you have to use hy 0.20 because hy-mode is not yet adapted to hy 0.25.

tkaryadis commented 1 year ago

ok thank you i can do that, but can someone explain what i should do, like step by step, because i am not Emacs user, it can help other people to get started with hy

kovan commented 1 year ago

I would install Doom Emacs and uncomment the line that adds hy support in the init.el file.

About the Python hy package, in your virtualenv do pip install hy=0.20.0

tkaryadis commented 1 year ago

Its ok for now i will not try that auto-complete, if someone sometime makes a guide that works, i will re-try it. Because i am new to hy and to python(haven't used it years) and to Emacs, so its many new things.

Thank you for trying to help me, doom emacs looks cool.

i got this after installing doom

Also with pip install hy=0.20.0 i got this

white@death:~/myVirtual$ pip install hy==0.20.0
Defaulting to user installation because normal site-packages is not writeable
Collecting hy==0.20.0
  Using cached hy-0.20.0-py2.py3-none-any.whl (83 kB)
Requirement already satisfied: colorama in /usr/lib/python3/dist-packages (from hy==0.20.0) (0.4.4)
Requirement already satisfied: rply>=0.7.7 in /home/white/.local/lib/python3.10/site-packages (from hy==0.20.0) (0.7.8)
Requirement already satisfied: funcparserlib>=0.3.6 in /home/white/.local/lib/python3.10/site-packages (from hy==0.20.0) (1.0.1)
Requirement already satisfied: astor>=0.8 in /home/white/.local/lib/python3.10/site-packages (from hy==0.20.0) (0.8.1)
Requirement already satisfied: appdirs in /home/white/.local/lib/python3.10/site-packages (from rply>=0.7.7->hy==0.20.0) (1.4.4)
Installing collected packages: hy
Successfully installed hy-0.20.0
white@death:~/myVirtual$ hy
Traceback (most recent call last):
  File "/home/white/.local/lib/python3.10/site-packages/hy/compiler.py", line 1692, in compile_eval_and_compile
    hy_eval(new_expr + body,
  File "/home/white/.local/lib/python3.10/site-packages/hy/compiler.py", line 2082, in hy_eval
    eval(ast_compile(_ast, filename, "exec"),
  File "/home/white/.local/lib/python3.10/site-packages/hy/compiler.py", line 64, in ast_compile
    return compile(a, filename, mode, hy_ast_compile_flags)
TypeError: required field "lineno" missing from alias

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/white/.local/bin/hy", line 8, in <module>
    sys.exit(hy_main())
  File "/home/white/.local/lib/python3.10/site-packages/hy/cmdline.py", line 662, in hy_main
    sys.exit(cmdline_handler("hy", sys.argv))
  File "/home/white/.local/lib/python3.10/site-packages/hy/cmdline.py", line 653, in cmdline_handler
    return run_repl(
  File "/home/white/.local/lib/python3.10/site-packages/hy/cmdline.py", line 442, in run_repl
    hr = HyREPL(**kwargs)
  File "/home/white/.local/lib/python3.10/site-packages/hy/cmdline.py", line 249, in __init__
    self.hy_compiler = HyASTCompiler(self.module)
  File "/home/white/.local/lib/python3.10/site-packages/hy/compiler.py", line 396, in __init__
    load_macros(self.module)
  File "/home/white/.local/lib/python3.10/site-packages/hy/macros.py", line 230, in load_macros
    builtin_mod = importlib.import_module(builtin_mod_name)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 879, in exec_module
  File "<frozen importlib._bootstrap_external>", line 1017, in get_code
  File "/home/white/.local/lib/python3.10/site-packages/hy/importer.py", line 128, in _hy_source_to_code
    data = hy_compile(hy_tree, module)
  File "/home/white/.local/lib/python3.10/site-packages/hy/compiler.py", line 2168, in hy_compile
    result = compiler.compile(tree)
  File "/home/white/.local/lib/python3.10/site-packages/hy/compiler.py", line 445, in compile
    reraise(type(e), e, sys.exc_info()[2])
  File "/home/white/.local/lib/python3.10/site-packages/hy/_compat.py", line 13, in reraise
    raise value.with_traceback(traceback)
  File "/home/white/.local/lib/python3.10/site-packages/hy/compiler.py", line 435, in compile
    ret = self.compile_atom(tree)
  File "/home/white/.local/lib/python3.10/site-packages/hy/compiler.py", line 429, in compile_atom
    return Result() + _model_compilers[type(atom)](self, atom)
  File "/home/white/.local/lib/python3.10/site-packages/hy/compiler.py", line 1778, in compile_expression
    return Result() + build_method(
  File "/home/white/.local/lib/python3.10/site-packages/hy/compiler.py", line 640, in compile_do
    return self._compile_branch(body)
  File "/home/white/.local/lib/python3.10/site-packages/hy/compiler.py", line 512, in _compile_branch
    for x in map(self.compile, exprs[:-1]):
  File "/home/white/.local/lib/python3.10/site-packages/hy/compiler.py", line 445, in compile
    reraise(type(e), e, sys.exc_info()[2])
  File "/home/white/.local/lib/python3.10/site-packages/hy/_compat.py", line 13, in reraise
    raise value.with_traceback(traceback)
  File "/home/white/.local/lib/python3.10/site-packages/hy/compiler.py", line 435, in compile
    ret = self.compile_atom(tree)
  File "/home/white/.local/lib/python3.10/site-packages/hy/compiler.py", line 429, in compile_atom
    return Result() + _model_compilers[type(atom)](self, atom)
  File "/home/white/.local/lib/python3.10/site-packages/hy/compiler.py", line 1778, in compile_expression
    return Result() + build_method(
  File "/home/white/.local/lib/python3.10/site-packages/hy/compiler.py", line 1708, in compile_eval_and_compile
    reraise(HyEvalError,
  File "/home/white/.local/lib/python3.10/site-packages/hy/_compat.py", line 13, in reraise
    raise value.with_traceback(traceback)
  File "/home/white/.local/lib/python3.10/site-packages/hy/compiler.py", line 1692, in compile_eval_and_compile
    hy_eval(new_expr + body,
  File "/home/white/.local/lib/python3.10/site-packages/hy/compiler.py", line 2082, in hy_eval
    eval(ast_compile(_ast, filename, "exec"),
  File "/home/white/.local/lib/python3.10/site-packages/hy/compiler.py", line 64, in ast_compile
    return compile(a, filename, mode, hy_ast_compile_flags)
hy.errors.HyEvalError: 
  File "[HyExpression([
  HySymbol('import'),
  HySymbol('hy')]), HyExpression([
  HyExpression([
    HySymbol('hy.macros.macro'),
    HyString('defmacro')]),
  HyExpression([
    HySymbol('fn'),
    HyList([
      HySymbol('&name'),
      HySymbol('macro-name'),
      HySymbol('lambda-list'),
      HySymbol('&rest'),
      HySymbol('body')]),
    HyString('the defmacro macro'),
    HyExpression([
      HySymbol('if*'),
      HyExpression([
        HySymbol('not'),
        HyExpression([
          HySymbol('isinstance'),
          HySymbol('macro-name'),
          HySymbol('hy.models.HySymbol')])]),
      HyExpression([
        HySymbol('raise'),
        HyExpression([
          HySymbol('hy.errors.HyTypeError'),
          HyExpression([
            HySymbol('%'),
            HyString("received a `%s' instead of a symbol for macro name"),
            HyExpression([
              HySymbol('.'),
              HyExpression([
                HySymbol('type'),
                HySymbol('name')]),
              HySymbol('__name__')])]),
          HySymbol('None'),
          HySymbol('--file--'),
          HySymbol('None')])])]),
    HyExpression([
      HySymbol('for'),
      HyList([
        HySymbol('kw'),
        HyExpression([
          HySymbol('quote'),
          HyList([
            HySymbol('&kwonly'),
            HySymbol('&kwargs')])])]),
      HyExpression([
        HySymbol('if*'),
        HyExpression([
          HySymbol('in'),
          HySymbol('kw'),
          HySymbol('lambda-list')]),
        HyExpression([
          HySymbol('raise'),
          HyExpression([
            HySymbol('hy.errors.HyTypeError'),
            HyExpression([
              HySymbol('%'),
              HyString('macros cannot use %s'),
              HySymbol('kw')]),
            HySymbol('macro-name'),
            HySymbol('--file--'),
            HySymbol('None')])])])]),
    HyExpression([
      HySymbol('quasiquote'),
      HyExpression([
        HySymbol('eval-and-compile'),
        HyExpression([
          HySymbol('import'),
          HySymbol('hy')]),
        HyExpression([
          HyExpression([
            HySymbol('hy.macros.macro'),
            HyExpression([
              HySymbol('unquote'),
              HyExpression([
                HySymbol('str'),
                HySymbol('macro-name')])])]),
          HyExpression([
            HySymbol('fn'),
            HyExpression([
              HySymbol('unquote'),
              HyExpression([
                HySymbol('+'),
                HyExpression([
                  HySymbol('quasiquote'),
                  HyList([
                    HySymbol('&name')])]),
                HySymbol('lambda-list')])]),
            HyExpression([
              HySymbol('unquote-splice'),
              HySymbol('body')])])])])])])])]", line 1
    ;;; Hy bootstrap macros
    ^---------------------^
required field "lineno" missing from alias
kovan commented 1 year ago

Did you activate the virtualenv and run pip inside it? In Emacs you also have to activate it, with M-x pyvenv-activate. That's all tha comes to my mind now.