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

Mishandling semicolon inside vertical bar literal #115

Open
ylixir opened this issue Nov 29, 2021 · 1 comment
Open

Mishandling semicolon inside vertical bar literal #115

ylixir opened this issue Nov 29, 2021 · 1 comment

Comments

@ylixir
Copy link

ylixir commented Nov 29, 2021

Parinfer thinks that semicolons between vertical bars is a comment (it's not). At least in common lisp, racket, and lumen this is wrong

(define |;| 5)
(print |;|)

is changed to

(define |);| 5)
(print |);|)

which is wrong.

reproductions:
https://onecompiler.com/racket/3xjvghuay
https://onecompiler.com/commonlisp/3xjvgwzbj

this is burning me when | is being used to quote literal code in a transpiler:
https://github.com/sctb/lumen/blob/master/test.l#L202

@jul1u5
Copy link

jul1u5 commented Apr 6, 2022

Seems related to #77 — enabling lisp_vline_symbols option fixes the issue.

However, #78 only implements this for (neo)vim plugin, so currently, there's no support for this in Emacs:

lisp_vline_symbols: false,

(I haven't checked, but I think kakoune plugin doesn't implement this either)

Potential Fix for Emacs

  1. Add lisp_vline_symbols parameter for new_options (and make_option) in parinfer-rust:

    fn new_options(
    cursor_x: Option<i64>,
    cursor_line: Option<i64>,
    selection_start_line: Option<i64>,
    old_options: &Options,
    changes: &Vec<Change>,
    ) -> Result<Options> {

  2. Pass additional argument for lisp_vline_symbols in parinfer-rust-mode:
    https://github.com/justinbarclay/parinfer-rust-mode/blob/c2c1bbec6cc7dad4f546868aa07609b8d58a78f8/parinfer-rust-mode.el#L346-L351

But this will be a breaking change: the new version of parinfer-rust will not be compatible with the current parinfer-rust-mode and vice versa.

Vim plugin doesn't have this problem since it communicates with parinfer-rust via JSON and sends options as a dictionary:

\ "options": { "commentChar": b:parinfer_comment_char,
\ "stringDelimiters": b:parinfer_string_delimiters,
\ "cursorX": l:cursor[2],
\ "cursorLine": l:cursor[1],
\ "forceBalance": g:parinfer_force_balance ? v:true : v:false,
\ "lispVlineSymbols": b:parinfer_lisp_vline_symbols ? v:true : v:false,
\ "lispBlockComments": b:parinfer_lisp_block_comments ? v:true : v:false,
\ "guileBlockComments": b:parinfer_guile_block_comments ? v:true : v:false,
\ "schemeSexpComments": b:parinfer_scheme_sexp_comments ? v:true : v:false,
\ "janetLongStrings": b:parinfer_janet_long_strings ? v:true : v:false,
\ "prevCursorX": w:parinfer_previous_cursor[2],
\ "prevCursorLine": w:parinfer_previous_cursor[1],
\ "prevText": b:parinfer_previous_text } }

So it doesn't need to pass all the options.

Perhaps JSON communication could be used for Emacs mode too? Or is there a way to pass a dictionary/map from Elisp to Rust directly?

@eraserhd @justinbarclay, what do you think?

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

2 participants