- About Scala
- In the Enterprise
- Scala Community
- Language Research
- In the Press
- The Scala Team
- Scala's Prehistory
- Contact Us
- Learning Scala
- Tour of Scala
- Scala API
- Setup & Getting Started
- Programming Guides
- Other Guides
- Code Examples
- Scala Developers
Re: Vim ENSIME Thingy
Yeah, I'm well aware of the lack of context in Vim's indenter...
Normally that's great, unless you're very context-sensitive, and Scala
Well, if you've got something that's working well, then I'll happily
and shamelessly rip it off.
Thanks a lot,
On Aug 29, 4:36 pm, Daniel Spiewak wrote:
> Actually, the way that Vim does auto-indentation (by default) is very, *very
> * close to the way that jEdit does it. You could probably just copy/paste
> my regular expressions, change the declaration syntax a shade and call it a
> day. Neither editor actually uses parse context to determine
> auto-indentation. In fact, jEdit doesn't really have an accessible notion
> of parse context (which is why my hack to get XML literals highlighted is so
> cool). This lack of context also makes auto-completion nearly impossible,
> since ENSIME requires the editor to supply the parse context, and neither
> jEdit nor Vim actually have it.
> So anyway, you should take a look! I've written some basic Vim modes in the
> past, and the way things like auto-indentation are handled is very, very
> close to how jEdit does it. If anything, it might be slightly easier for
> you since you won't have to deal with some of the more annoying bugs in
> jEdit's parser (generally relating to line delimiters).
> On Mon, Aug 29, 2011 at 3:23 PM, Derek Wyatt wrote:
> > That's awesome... I'm sure I could port it to Vim but I'd really
> > rather not. Do you think there'd be any value in one (or both) of us
> > porting it to ENSIME? Do you think it's possible, or is it necessary
> > to use the context that's already known to the editor?
> > On Aug 29, 4:18 pm, Daniel Spiewak wrote:
> > > +1 on speaking swank. I've only been working with ENSIME for a little
> > while
> > > and emulating the emacs mode's semantics has already paid dividends.
> > > Regarding indentation, I agree that simple brace counting isn't even
> > > remotely sufficient. My jEdit mode actually does a pretty decent job of
> > > auto-indentation (note: *not* the same as the jEdit mode included in the
> > > Scala distro, which is actually quite awful). The main thing it gets
> > wrong
> > > are multi-line case expressions without curly braces. For example:
> > > case foo =>
> > > bar
> > > baz
> > > Context sensitivity is a horrible thing.
> > > The nice thing about it is the indentation mode is entirely specified in
> > > terms of regular expressions and brace matching (which jEdit has
> > built-in).
> > > So, the auto-indent specification is quite concise and fairly easy to
> > adapt
> > > to other languages with similar edit mode specification capabilities
> > (like
> > > Vim).
> > > Daniel
> > > On Mon, Aug 29, 2011 at 2:56 PM, Derek Wyatt
> > wrote:
> > > >
> > > > So, let me get this straight... an operating system / editor with a
> > > > strong bent toward a lisp dialect already has code to match up
> > > > braces??? Awesome!
> > > >
> > > > Actually Vim has the same thing, but like Emacs, the Vim scala
> > > > indenter leaves me wanting... I'm the maintainer of it, and I don't
> > > > want to be anymore :) Figuring out a cheap function to assess the
> > > > Scala indent level is painful.
> > > > Assuming I can get this going, it would possibly be beneficial to have
> > > > the indenter in ENSIME - I've already contacted the Scalariform author
> > > > to see if I could rip off his code to do it but, not surprisingly,
> > > > it's not designed for that - it croaks on "incomplete" code, which is
> > > > the state that the file will be in most of the time.
> > > > I'm going to poke at ENSIME with a stick for the next few days and see
> > > > what I can get out of it without having to modify the server. The
> > > > fact that Daniel's managed to get it going noninvasively has spurred
> > > > me on to give it a go myself.
> > > > Thanks for all the hard work! (Could this be the first time that Vim
> > > > makes use of code that was largely written for Emacs? Could there be a
> > > > scandal?)
> > > > On Aug 29, 2:38 pm, Aemon Cannon wrote:
> > > > > Hey Derek,
> > > > > Sounds great!
> > > > > I agree that speaking swank will be better in the long run.
> > > > > You are correct that ENSIME's line-at-a-time indentation is handled
> > > > > in elisp. The method I use is the one that Steve Yegge cooked up for
> > > > > counts open,close parens/braces/brackets. It's by no means perfect,
> > > > > but it's good enough to tide me over between calls to the full-file
> > > > > formatter
> > > > > (scalariform) in the server.
> > > > > -Aemon
> > > > > On Mon, Aug 29, 2011 at 1:50 PM, Derek Wyatt
> > > > wrote:
> > > > > > I've decided to try and follow in Daniel's footsteps and get ENSIME
> > > > > > working for Vim. My previous attempt to pull Scala into Vim was a
> > sad
> > > > > > - basically functional, but I want more.
> > > > > > It looks like Marc Weber (https://github.com/MarcWeber/ensime)
> > > > > > starting hacking this together but hasn't touched it in a while.
> > It
> > > > > > also looks like he's ignored the swank protocol and made a fork
> > that
> > > > > > does JSON; I'd rather just speak swank.
> > > > > > This email has two purposes:
> > > > > > 1) Canvassing for help - if you're a Vim guy and want to help,
> > > > > > please... please do :)
> > > > > > 2) I haven't been able to see if ENSIME would solve my indent-woes.
> > > > > > It looks like it's the elisp code that calculates the current
> > indent
> > > > > > level, not the ENSIME server. True?
> > > > > > I haven't been able to get a solid indent calculator yet and I was
> > > > > > hoping that ENSIME would be the silver bullet to solve that
> > problem.
> > > > > > I could port the elisp, of course, but I'd rather not - I just want
> > to
> > > > > > stand on the shoulders of the ENSIME server, and be lazy :)