Esempio n. 1
0
def get_column_indent(buffer):
    from hy.macros import _hy_macros
    from hy.compiler import _compile_table

    tokens = get_tokens_in_current_sexp(buffer.document)
    if len(tokens) == 0:
        return buffer.document.cursor_position_col
    elif len(tokens) == 1 or tokens[0].name == "LPAREN":
        return tokens[0].source_pos.colno - 1
    else:
        for module, namespace in _hy_macros.items():
            if module is None:
                for macro in namespace.keys():
                    if macro == tokens[0].value:
                        return tokens[0].source_pos.colno
        for name in _compile_table.keys():
            if str(name) == tokens[0].value and len(str(name)) > 1:
                return tokens[0].source_pos.colno
        return tokens[1].source_pos.colno - 1
Esempio n. 2
0
def get_column_indent(buffer):
    from hy.macros import _hy_macros
    from hy.compiler import _compile_table

    tokens = get_tokens_in_current_sexp(buffer.document)
    if len(tokens) == 0:
        return buffer.document.cursor_position_col
    elif len(tokens) == 1 or tokens[0].name == "LPAREN":
        return tokens[0].source_pos.colno - 1
    else:
        for module, namespace in _hy_macros.items():
            if module is None:
                for macro in namespace.keys():
                    if macro == tokens[0].value:
                        return tokens[0].source_pos.colno
        for name in _compile_table.keys():
            if str(name) == tokens[0].value and len(str(name)) > 1:
                return tokens[0].source_pos.colno
        return tokens[1].source_pos.colno - 1
Esempio n. 3
0
    def _find_hy_completions(self, partial_name):
        from hy.macros import _hy_macros
        from hy.compiler import load_stdlib, _stdlib, _compile_table
        from itertools import chain
        from keyword import iskeyword

        # Without this, built in macros will not load until after
        # the first sexp is evalutaed
        load_stdlib()

        matches = []

        # Add macros
        for namespace in _hy_macros.values():
            for name in namespace.keys():
                if name.startswith(partial_name):
                    matches.append(name)

        # Add builtins
        for name in chain(_stdlib.keys(), _compile_table.keys()):
            if str(name).startswith(partial_name) and not iskeyword(str(name)):
                matches.append(name)
        return matches
Esempio n. 4
0
    def _find_hy_completions(self, partial_name):
        from hy.macros import _hy_macros
        from hy.compiler import load_stdlib, _stdlib, _compile_table
        from itertools import chain
        from keyword import iskeyword

        # Without this, built in macros will not load until after
        # the first sexp is evalutaed
        load_stdlib()

        matches = []

        # Add macros
        for namespace in _hy_macros.values():
            for name in namespace.keys():
                if name.startswith(partial_name):
                    matches.append(name)

        # Add builtins
        for name in chain(_stdlib.keys(), _compile_table.keys()):
            if str(name).startswith(partial_name) and not iskeyword(str(name)):
                matches.append(name)
        return matches