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

Scheme: improve alignment for some snippets and add one UltiSnips snippet #1499

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Aster89
Copy link
Contributor

@Aster89 Aster89 commented Sep 12, 2023

No description provided.

Copy link
Contributor

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will now be mixing tabs and spaces, is that desirable? Until this commit we've used tabs always as this means the user can configure indentation to whatever is their preference.

@Aster89
Copy link
Contributor Author

Aster89 commented Sep 13, 2023

That's intendeed.

In scheme functions' and special forms' applications look syntactically the same, i.e. (func-or-macro arg1 arg2 ...), so there's no reason to not align arg1, arg2 and the rest under the same vertical.¹

Try to write the following, say, on rextester (or even on Vim itself; I haven't customised anything, so that should be the default), and press enter right before entering the marked character

(cond (#f "ciao") (#t "uffa"))
;     ^           ^

(cond (#f "ciao") (#t "uffa"))
;                 ^

and you'll get these:

(cond (#f "ciao")
      (#t "uffa"))

(cond
 (#f "ciao")
 (#t "uffa"))

The latter can all be handled by tabs, but the former can't, it must use spaces because the indentation must exactly be the same width as (cond .

I'm obviously assuming claiming that having the various "arguments" of functions/special forms be aligned vertically is the right thing to do.


(¹) One could claim that the 1st of the 3 arguments to if in (if condition consequence alternative) has a different "meaning" than the other two, and so that it would be ok for it to be aligned differently. I would disagree based on the fact that actual functions look the same, and for functins all the arguments are "created equal". Furthermore, cond is a special form too, but all the "arguments" are also "equal".

@lpil
Copy link
Contributor

lpil commented Sep 13, 2023

I understand the intention, what I mean is that with this if the programmer says they wish to indent using tabs we will no longer respect that wish. This is not what we do with any other snippets, including all the other Lisp favours.

@Aster89
Copy link
Contributor Author

Aster89 commented Sep 13, 2023

In this case, a solution would be to always LineBreak after the function name, as in

(cond
  (#f "ciao")
  (#t "uffa"))

(if
  a
  b
  c)

(define
  (fun-name args)
  def)

(+
  x
  y
  z)

@Aster89
Copy link
Contributor Author

Aster89 commented Mar 3, 2024

@lpil , what if I try using !v &expandtab to decide whether to use tabs (so expanding to the original snippets) or spaces (thus using my proposed indentation)?

@lpil
Copy link
Contributor

lpil commented Mar 6, 2024

Sorry, we use tabs in this project.

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

Successfully merging this pull request may close these issues.

2 participants