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

WIP: Scala 3 #170

Draft
wants to merge 45 commits into
base: master
Choose a base branch
from
Draft

WIP: Scala 3 #170

wants to merge 45 commits into from

Conversation

Kazark
Copy link
Contributor

@Kazark Kazark commented Apr 2, 2021

Putting this here in case anyone wants to follow my progress and comment or critique.

@Kazark Kazark mentioned this pull request Apr 2, 2021
@cchantep
Copy link

cchantep commented Apr 6, 2021

Would be nice

@Kazark
Copy link
Contributor Author

Kazark commented Apr 6, 2021

@cchantep yep, I'm working on it as I get time. Good news is if you use mostly the old syntax for now, the mode is up to date enough to be reasonable to use with Scala 3. It's going to be a while before there is a lot of code on newly converted codebases that is thoroughly embracing Scala 3 idioms. Hopefully by then I will have this done. My team is going to adopt quickly, so I will have incentive.

Keith Pinson added 2 commits April 13, 2021 13:40
I haven't been able to find exactly when it was dropped but it seems to have
actually been during Scala 2.
@Kazark
Copy link
Contributor Author

Kazark commented Apr 15, 2021

I've turned off Metals, and now I notice that I get these warnings without Metals:

image

Is this arising from this package? Or is there something going on here with Flycheck or something? (Emacs n00b questions, I know.)

@Kazark
Copy link
Contributor Author

Kazark commented Apr 15, 2021

Ah yes, I discovered that it is a Flycheck acting as a minor mode. The question is, where is Flycheck getting its syntactic knowledge?

@Kazark
Copy link
Contributor Author

Kazark commented Apr 15, 2021

Ah, it is getting it from scalac, so I just have to set that to a new path. But the annoying new scalac always uses ANSI color, without trying to detect whether it's in a terminal, and confuses Flycheck. 🤦‍♂️

@smarter
Copy link

smarter commented Apr 23, 2021

You can run the compiler with -color:never, but the compiler output is not guaranteed to be stable (and neither is the scala 2 compiler output for that matter). (And we do run terminal detection but I guess it's not working in your case for some reason.)

@Kazark
Copy link
Contributor Author

Kazark commented Apr 23, 2021

@smarter ah, thank you. BTW enjoyed hearing from you at the release party just now.

@Kazark
Copy link
Contributor Author

Kazark commented Apr 23, 2021

@smarter for further context, I have hit this problem not just with Flycheck but also with using Scala 3 in Org Babel. I looked for a color option, but couldn't find it. Maybe it isn't documented? Maybe I'm bad at finding things. It wouldn't be the first time.

Keith Pinson added 9 commits May 5, 2021 12:05
I have to tear down first, before I can rebuild. 20% of the algorithm gets us
80% of the way there for braces. This totally breaks whitespace again, but it
wasn't _really_ working with what I had before, and it will be much easier to
get it working once we get a bunch of stuff out of the way. So many concepts of
have shifted, and it's just too hard to read Emacs-style code which is not
declarative. More tearing down may come after this.
@cayhorstmann
Copy link

I don't know if this is the right place for this comment, but here goes: Indentation with quiet syntax is currently unusable.

  1. Enter. Try typing
def fun = 
  println("Hello") 
  println("World") // Hitting Enter here does the wrong thing

Hitting Enter where indicated results in

def fun = 
  println("Hello") 
println("World") // Hitting Enter here does the wrong thing

Sure, that's correctly formatted, but not the user's intent. The first rule ought to be "do no harm". If a user indented a line and then hits Enter, don't mess with the preceding line. The next line should have the same indent or one more (after def, if, class, etc.)

  1. Tab.
def fun = 
  println("Hello") 
  println("World") // Hitting Tab here does the wrong thing

The Tab key should cycle through the valid indentations, like the Python mode does. It should be easy enough to find the number of valid indentations--either the same as the preceding line, or one more.

@hvesalai
Copy link
Owner

@cayhorstmann is this comment in relation to the WIP scala3 changes or also applicable to the scala2 mode?

@cayhorstmann
Copy link

In Scala 2, both Enter and Tab work as expected. I just checked with a Scala 2 project. The issue is the quiet (brace-free) syntax, which changes how Tab must work.

@Kazark
Copy link
Contributor Author

Kazark commented Aug 26, 2021

@cayhorstmann yeah, this work is severely incomplete, and was interrupted for some time while I did not have access to a second monitor. I hope to pick it up again soon, but no promises on when I can get it finished; I have found it challenging, and we are not moving to 3 as rapidly as I had expected at work, so the push isn't as hard as I expected.

@Kazark
Copy link
Contributor Author

Kazark commented Oct 4, 2021

I don't know. This is rather overwhelming.

@Kazark
Copy link
Contributor Author

Kazark commented Oct 4, 2021

How far back, in general, should I look in order to correct indentation? If I have object Foo: at the very top of the file, and then one thousand lines that are not indented, and I try to fix the indentation of the thousandth line, do I look back one thousand lines?

@jackcviers
Copy link

jackcviers commented May 18, 2022 via email

Incorrect order of arguments causes wrong type argument error in
scala-indent:indent-line. Swapping argument order fixes the error reported by
@jj1uzh [here](#1 (comment)).
@jackcviers
Copy link

@Kazark CLA signed, sealed and delivered. And you have a pr to your branch that fixes <TAB> and the @jj1uzh error discovered here.

Fixes incorrect argument order in call-interactively
@jackcviers
Copy link

They are all the same committed. I'll see if I can find the commit without an email address....

@jackcviers
Copy link

CLA assistant check Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.2 out of 3 committers have signed the CLA.✅ Kazark✅ jackcviers❌ Jack Viers
Jack Viers seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

PR fixing missing email address in commit: Kazark#3

@VitalyAnkh
Copy link

Oh why is this still blocked...

@Kazark
Copy link
Contributor Author

Kazark commented Aug 15, 2022

@VitalyAnkh All the codebases I worked on (except breakable toys) are stuck on Scala 2 until, at a minimum, this gets fixed. As such, my motivation to work on this has stalled. If any wants to contribute, I'm happy to rebase the branch to get rid of the committer problem above, and open the branch for others to edit. You can also use what I've got so far (which is okay, but imperfect) but just downloading this branch and manually loading this version of the package.

@maemre
Copy link

maemre commented Dec 8, 2022

I'd be happy to pick up the remaining work on this. I used Emacs Lisp only for my personal configuration before, but I have some free time to spend on this during the next few weeks.

@Kazark
Copy link
Contributor Author

Kazark commented Dec 8, 2022

@maemre would you want to have a video call to hand stuff off? I don't know whether you will find my approach intelligible or not just reading the code.

@maemre
Copy link

maemre commented Dec 8, 2022

@Kazark That'd be great! I can go through the code over the weekend and we can have a quick chat next week, if that sounds good. For scheduling the chat, my email address is maemre2 at gmail dot com

@maemre
Copy link

maemre commented Dec 8, 2022

I edited my last comment because my email address wasn't formatted properly.

@Kazark
Copy link
Contributor Author

Kazark commented Dec 12, 2022

Noted. I have an exceedingly busy week ahead---I'll hope to drop you a line next week.

@VitalyAnkh
Copy link

Hi! Just a kind reminder: how are things going now?

@maemre
Copy link

maemre commented Mar 14, 2023

@VitalyAnkh thanks for the reminder, this completely fell through the cracks because I haven't been using Scala for the past few months. @Kazark would you be free sometime this week or next week to meet up? I am looking at the code base again, and some functions like scala-indent:analyze-syntax-stack are took a while to wrap my head around. The rest of scala-mode-indent.el makes sense though.

Also, from what I understand pretty much everything is implemented behind the custom variable scala-indent:use-cycle-indent already. And, the main issue with merging this upstream is the commit email addresses and the CLA for one specific commit. Is that correct?

I can try some git cherry-picking and re-implement the cycling feature that commit describes, then I think this should be good for a merge. @Kazark how does that sound?

@Kazark
Copy link
Contributor Author

Kazark commented Mar 14, 2023

the main issue with merging this upstream is the commit email addresses and the CLA for one specific commit. Is that correct?

No, that part should be relatively easy to fix, I think. The main issue with merging is that this is still in a highly experimental state. I have been steadily using this branch locally for as long as it has existed, but I haven't written any Scala 3 beyond toys.

@Kazark
Copy link
Contributor Author

Kazark commented Mar 14, 2023

The last time I had my head really into this, there were definitely some cases that didn't work right. Ultimately it is up to @hvesalai ; we could just plunge in & patch; but from my point of view, this is not stable yet.

@Kazark
Copy link
Contributor Author

Kazark commented Mar 14, 2023

Also @rossabaker was wondering whether we might be able to replace some of this haphazardness with Treesitter.

@Kazark
Copy link
Contributor Author

Kazark commented Mar 14, 2023

would you be free sometime this week or next week to meet up?

@maemre I might be able to do something on Friday; otherwise my week is pretty full. Did you get my email of few months back, or did it perhaps go to your spam folder? Just asking so we can coordinate further over email.

@jackcviers
Copy link

jackcviers commented Mar 14, 2023 via email

@maemre
Copy link

maemre commented Mar 14, 2023

I see. I'd be interested in debugging it then. I'll set it up locally and see if I hit any bugs myself. @Kazark I found your email, and replied to it for scheduling.

maemre and others added 8 commits June 4, 2023 19:41
In Scala 3, `do-while` is dropped, and `do` is used only for separating the body of a `while` or `for` from the guard/comprehension. So, `do` would need to be indented like `then` or `else`. See: https://docs.scala-lang.org/scala3/reference/dropped-features/do-while.html#
This allows differentiating between indenting a blank line and re-indenting the
line before it.  This situation occurs fairly often: it happens every time the
user hits re turn to create a new line, which calls indentation function on the
previous line and the newly created line separately.  Before this fix, these two
calls would incorrectly calculate the same indentation level, e.g. when the
previous line just created a block.
Various indentation fixes: typos, differentiating new lines, support for `do` and `extension`
@jake-miles
Copy link

Hello. I was hoping to use scala-mode and metals for scala 3 work using python-style identation. Is there any update on this PR? Or some other way people get that working?

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.