Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code block syntax for editor plugin #6

Open
mathiasbredholt opened this issue Feb 6, 2025 · 5 comments
Open

Code block syntax for editor plugin #6

mathiasbredholt opened this issue Feb 6, 2025 · 5 comments

Comments

@mathiasbredholt
Copy link

mathiasbredholt commented Feb 6, 2025

I started working on a sapf plugin for neovim, that works in a similar manner as scnvim.

The plugin spawns sapf in the background and allows evaluating the current selection in a vim buffer.

I came across a question which is, what defines the start and end of a code block that should be evaluated? In SC we have the (). But is there an equivalent in sapf?

Should such a plugin evaluate the innermost function only or perhaps search outwards until we find a line that doesn't begin with \[ or ]?

My initial implementation uses the indentation to detect blocks but it would be better to use the language syntax.

@salkin-mada
Copy link

I am using _- and -_ for now in my plugin. Have also been using ( and ) which actually worked fine for "block" evaluation. And been thru <` >` and other variants :-)

@mathiasbredholt
Copy link
Author

mathiasbredholt commented Feb 7, 2025

I am using _- and -_ for now in my plugin. Have also been using ( and ) which actually worked fine for "block" evaluation. And been thru <` >` and other variants :-)

Cool, are they part of the sapf syntax or are you just ignoring those symbols before passing to sapf?

Would be nice to agree on something that also works for the examples.

@lfnoise
Copy link
Owner

lfnoise commented Feb 7, 2025

The REPL evaluates line by line unless you are inside of a string, parentheses, a lambda, an array, or a form.
I would use parens for a selectable code group, but the examples file does not put parens around the examples. That could be done though.

@mathiasbredholt
Copy link
Author

The REPL evaluates line by line unless you are inside of a string, parentheses, a lambda, an array, or a form.
I would use parens for a selectable code group, but the examples file does not put parens around the examples. That could be done though.

Parentheses then! Would be nice if the examples used parentheses IMHO.

@mathiasbredholt
Copy link
Author

The REPL evaluates line by line unless you are inside of a string, parentheses, a lambda, an array, or a form.
I would use parens for a selectable code group, but the examples file does not put parens around the examples. That could be done though.

Parentheses then! Would be nice if the examples used parentheses IMHO.

Or I could just accept both parentheses and functions (with no indentation) as blocks in my plugin. Parentheses around functions doesn't really help readability IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants