nim-lang / nim-mode

An emacs major mode for the Nim programming language
138 stars 46 forks source link

Wrong indent in multil-line var definition with types #199

Open ogdenwebb opened 6 years ago

ogdenwebb commented 6 years ago

Conforming Bugs

Please tell us below:

Expected behavior:

var
  x, y: string
  a, b: float

Actual behavior:

# after calling 'electric-and-indent' or 'indent-region'
var
  x, y: string
a, b: float

But with a value it works well:

var
  x, y: string = "test string"
  a, b: float
krux02 commented 6 years ago

put (electric-indent-mode 0) from your nim-mode-hook. Electric indent has more severe problems thas this. Sometimes it blocks emacs for several seconds and then automatically screws up the entire file. It's not worth the trouble.

ogdenwebb commented 6 years ago

@krux02 it doesn't change anything for me. With enabled and disabled electric-indent-mode in nim-mode hook the issue appears here.

As a sidenote, nim-indent-calculate-indentation returns 0 on the third line of code.

krux02 commented 6 years ago

@ogdenwebb you are totally right, I just tested it. My recommendation is to use var on every line. This doesn't fix but it makes the bug non relevant.

var  x, y: string
var a, b: float