Skip to content

Possible faster way to find top level expressions for completion context #391

@SevereOverfl0w

Description

@SevereOverfl0w

I was talking to @PEZ about my PR (#390) and he mentioned how zmacs solved this problem

A Lisp file contains a sequence of expressions that we call top-level expressions, to distinguish them from their own sUbexpressions. Zmacs assumes that top-level expressions begin with an open parenthesis against the left margin. It does not parse top-level expressions by balancing parentheses, since parentheses do not always balance while programs are being written. The indentation represents the programmer’s conception of program structure, and provides a better guide. So by top-level expression, we mean a section of text delimited by open parentheses at the beginning of two lines.

This would be substantially faster than searchpairpos, and would work in plain vim too. Most users are working with vim-sexp or parinfer.vim so will have their parens balanced 99% of the time.

Not sure if you'd be interested in a PR to this effect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions