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

Indentation after importing operators #12

Open
yuyichao opened this issue Apr 1, 2016 · 8 comments
Open

Indentation after importing operators #12

yuyichao opened this issue Apr 1, 2016 · 8 comments

Comments

@yuyichao
Copy link
Contributor

yuyichao commented Apr 1, 2016

End of line operators doesn't always require indentation on the next line

module A
import Base: *
    a = 1
b = *
    c = 2
end

I guess this was introduced in JuliaLang/julia#15156. Not sure this can be fixed without a full parser though...

@tpapp
Copy link
Collaborator

tpapp commented Mar 13, 2017

I have a fix for this, which I will submit once #37 is merged.

@non-Jedi
Copy link
Contributor

@tpapp did you ever submit this fix?

@tpapp
Copy link
Collaborator

tpapp commented Nov 15, 2019

No. I have a branch which is severely outdated and provides a partial fix, if no one wants to take it up I will do it if #87 is merged.

@ronisbr
Copy link
Contributor

ronisbr commented May 29, 2020

Sorry about the dup.

To solve this, can’t we just check if the line stars with import here:

(defun julia-indent-hanging ()

@yuyichao
Copy link
Contributor Author

Note that the title is not completely accurate. It also applies to the b = * case, as shown in the example. Basically any time when an operator is used not as an operator.

@ronisbr
Copy link
Contributor

ronisbr commented May 29, 2020

Hum, I see. However, since the case:

import Base: *

should be way more common than the other, can we implement this temporary fix until we have a full parser?

EDIT: By the way, am I missing something, or the second case will always happen if an operator appears after a =? Is there any other case that an operator can hang at the end of line without being an operation that did not end?

If I am right, then we can add two checks to that function: if the line started with import or if the operator is preceded by =, then the operator is not hanging.

@ronisbr
Copy link
Contributor

ronisbr commented May 31, 2020

I gave a try to solve it, but now I understand why we need a full parser. The indentation of lines after an import is treated here:

(defun julia-indent-import-export-using ()

instead of the previous function I marked. However, it does not seem easy to separate the code that mark a code line “unfinished” with that code that search for continuation in import. At least in my elisp level.

@ronisbr
Copy link
Contributor

ronisbr commented Jan 11, 2023

This issue is not present in tree-sitter implementation:

module A
import Base: *
a = 1
b = *
c = 2
end

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

No branches or pull requests

4 participants