I saw this notice on Reddit early yesterday morning and ended up using Intero for most of the day. Love it! There are a lot of improvements over and above the Emacs Haskell mode. I really like how fast it is to control-c-l and be put n the correct module and be running in seconds. I also like the realtime syntax error hints, type information, etc.
There should be a warning that on first start of intero-mode, this will initiate a rather long stack operation, which I suppose is extra long if you hadn't used stack before. Also, it seems to insist on a stack'ised project. But I suppose one could say that should be obvious. I use cabal because stack misses some features and is a little weird and use stack when I have to. And even though I have intero installed and in $PATH, when opening an actual project with a stack file, it start building intero. Weird automatism.
This was a trade-off I went with. One thing that I learned from years of hacking on haskell-mode is that adding an option for every little decision adds up to a brittle user-experience. If you want this, enable that. If you want to enable that, install this. And so on. A survey showed that most people used about 20% of the features available in haskell-mode.
In the case of Intero I made every decision for the user; there are no customization options in the mode, and it leads to long (first-time) start-ups like this. But in the end I'd rather wait a minute and have every project always work reliably (and this isn't unheard-of for IDEs). It does build a version of intero for each project environment, because the GHC version and package set may differ. This is in contrast to e.g. ghc-mod or hdevtools which is locked to a specific GHC version, so switching between projects is not smooth.
You are correct about the initial first time build delay, and it is done for each separate project. After playing with Intero on one of my stack based projects, I took the background time effort to pre-build all of my projects while exercising. Then, there is no delay (until I start a new project).
Stack has changed my development workflow, in a very positive way, and I love Intero (at least in the first 24 hours of use).
* split-objects to create much smaller binaries. In cabal it's a single line in its global config file.
* Using my already available GHC builds, because stack's GHC builds do not work everywhere, not even across all Linux distros. If I have a musl-based Linux distro, FreeBSD, or Solaris it'll be a problem. Also, there are many users who prefer to use other builds than those downloaded via stack. This happens even if there is already the right GHC in PATH by default.
* I like cabal's new new-foo features and project file support.
* Not bailing out if I open a random .hs file where there's no associated stack config. In a sibling comment Chris says he wants it to work automagically, but then it should create a global stack file, which he says will be used if available.
* Offline mode.
* I will find more stuff I miss, once I have used stack more.
This looks great! My only complaint is that sometimes I do want to work on a quick script outside of a stack environment, and this seems like an all-or-nothing proposition. (I use haskell for pandoc filters quite a bit, for example, and setting up stack for that seems like overkill.) I'm sure a bit of elisp could make it fall back to haskell mode if it can't find a local .stack dir.
If there's no stack.yaml it uses the global ~/.stack/global/stack.yaml.
So you should be able to open any random file and it'll work out. E.g. if I open ~/X.hs and import Lucid, I can just run stack build lucid in my ~/ and now M-x intero-restart and it has access to that package.
I've been waiting for this release before finally trying to switch from Vim (MacVim) to Spacemacs. Anybody have any tips for somebody who's never really used Emacs?
I'm not using Spacemacs, but rather Evil mode in Emacs. I think the biggest thing I would caution is to expect small things to be different. For example underscores are word boundaries in Emacs. File selection is different. Some modes do not have vi key bindings set up by default. Escape doesn't always work to abort (you need to get used to pressing ctl-g). Omni complete is absent and completion in Emacs works quite differently. Searching through files and sorting through compilation errors works quite differently. I think that's most of the issues I've run into.
It took me about a month to get everything set up the way I wanted it and to get used to it. With Spacemacs, I imagine that things will generally be set up, but that it will take longer to get used to because it is pretty opinionated about things like leader keys. Right now my set up is good enough that if I accidentally run vim instead of emacs, it takes me about 15-20 minutes before I realise it (normally when I try to update an org mode file ;-) ).
My biggest advice is to take the transition slowly. Use Emacs/Spacemacs until you get annoyed with it and then put it away for a while. Eventually you will start to get used to Emacs-isms (like ctl-g) and Vim will start to annoy you. At that point cut over entirely.
One thing that's really annoying is that when you are modifying your .emacs/init.d file, it's easy to get it into a bad state. At that point Evil and also probably your theme won't be set up properly. So you have to fix everything using emacs keystrokes. I used emacs for 20 years before I switched to vim and even still it seems I am no longer able to use vanilla emacs ;-)
One you get it set up and are used to it, though, it works surprisingly well. For me the absolute biggest advantage to emacs is Org mode and I basically can't give it up now. Good luck on your switch!
> For example underscores are word boundaries in Emacs
This is configurable [1]
>The word commands’ understanding of word boundaries is controlled by the syntax table. Any character can, for example, be declared to be a word delimiter.
Thanks for that. My understanding of the documentation leads me to believe that I will have to change it for every single major mode, which is a bit of a pain. But at least it is mostly possible.
You could probably do something hacky like modify the current syntax map in
after-change-major-mode-hook to apply it to every buffer. Or use something fancier like subword mode.
My experience was very straightforward. It's easy to configure for most scenarios if you follow the documentation and use any of its layers (see https://github.com/syl20bnr/spacemacs/tree/master/layers). Most Vim key bindings work beautifully. For be its best feature is how discoverable it is.
Every command has a name, and you can do M-x and type in that name, with tab completion, if you forget the keyboard shortcut. Even better, you can enable ido-mode and install ido-vertical-mode, and see a list of possible command completions without pressing tab.
I also highly recommend remapping your caps lock key to control.
Turn on god-mode. It turns off e.g. the arrow keys and the delete key, forcing you to use the movement keys and keybindings for deleting word, character, etc. It'll yell at you in the minibuffer with the command you SHOULD have hit, so you'll know. It builds the muscle memory super quickly.
Keyboard macros are dope. My keys are bound to f3 and f4 but I don't remember if that's standard. Basically you hit f3 to open a macro, do some stuff, and then hit f4 to close it. Then you hit C-x e to execute it from the point, and hit e repeatedly to keep executing it. Super convenient. As an example, you might make a macro where you move the point to the beginning of the line, deletes 2 characters of whitespace, then moves to the next line. But you gotta be careful it's actually gonna do what you want; you'll get better at this over time. You generally have to imagine the point exists at a random point in a line, and find how to get it to where it needs to go, before you're able to do the real work of the macro.
Get Projectile. It's fantastic for navigating projects. It binds its key prefix to C-c p, and binding ANYTHING to C-c whatever is frowned upon heavily, so be aware of that. Doing things like project wide searches (C-c p s s) is super fast, and makes navigating codebases manageable.
I LOVE Helm. It's a huge departure from vanilla emacs, so know that going into it. That said, I love what it does. Basically you have a minibuffer chilling at the bottom of the screen above the normal minibuffer, and it is usually hidden until activated. Then when you activate it (e.g. in the projectile search) it shows the results of the operation in the helm minibuffer. http://tuhdo.github.io/helm-intro.html is a good intro to it.
But really, pay attention to what you like and don't like about everything. Then find things that scratch your itches. I really encourage you to start from vanilla emacs, bringing in packages as you find you need them, so you fall onto your own unique, special editor, built just for you. That said, I sort of understand the appeal of starting with a config that's curated for you already. Though if you decide to make your own configs, use-package is fantastic for managing the complexity of it all. Emacs is a wonderful editor, and you're in for a wonderful experience. You just have to be willing to put up with some annoyance before you make it your own. As a datapoint, it took about a month and a half when I started using it to get it behaving the way I wanted. It's still a thing I tinker with occasionally, especially when I venture into a new language, but I leave it alone most of the time.
<Keyboard macros are dope. My keys are bound to f3 and f4 but I don't remember if that's standard. Basically you hit f3 to open a macro, do some stuff, and then hit f4 to close it. Then you hit C-x e to execute it from the point, and hit e repeatedly to keep executing it. Super convenient. As an example, you might make a macro where you move the point to the beginning of the line, deletes 2 characters of whitespace, then moves to the next line. But you gotta be careful it's actually gonna do what you want; you'll get better at this over time. You generally have to imagine the point exists at a random point in a line, and find how to get it to where it needs to go, before you're able to do the real work of the macro.
Macros combine great with another amazing feature: registers. Hit C-x C-k b [0-9] and the macro can be called with C-x C-k [number chosen]. This way you can quickly use multiple macros. You can also C-x C-k n NAME to save the macro as a callable function and if you then decide that it would be useful in the future, just call insert-kbd-macro and emacs will generate the lisp code that defines your macro and you can put that in your init.el.
Interesting, I'll have to try that. When I found macros, I did open with C-x ( and close with C-x ), so C-x e makes sense. Then I found f3 and f4 and didn't bother to unlearn that binding.
I had used IDE's, windows based text editors like UltraEdit, and vi/vim for the longest time before I decided it was time to go back to Emacs. I dedicated two weeks to using it almost exclusively to pick up the muscle memory of major keybindings. I haven't looked back since.
The keys I really needed out of the gate:
* F3/F4 - building macros, then C-x e to execute (after that, just plain e)
* C-s - search
* M-s o - occur (you define a regular expression, it lists all the lines that match it, so something like `def (` for python functions
C-v/M-v - page up/page down
* C-f/C-b - forward and back character
* M-f/M-b - forward and back word
* C-/ - undo
* M-w - copy
* C-y - paste
* C-o - open new line
* M-z - zap-to-character (try it, it's awesome)
* C-M-e / C-M-h - beginning/end of function
* C-a / C-e - beginning/end of line
* C-l - center window on cursor
* C-[space] - mark cursor / unmark cursor
* C-d/M-D - delete char/word
* C-k - kill line
* M-/ - autocomplete word (works in any file, any language, and cycles through suggestions on repeated calls)
...
Those and then getting yasnippet installed and working was probably the most important plugin. It's real simple templates for any language and there are a lot of decent default ones. (so for instance, you type html, then tab and it'll build a basic html file for you and put your cursor in the <head> tag, or def, then tab and you have a structured function definition and your cursor stops where the name goes, tab again it puts it in the parameters, tab again, docstring, tab again, coding area).
If you dedicate two weeks to it, you'll begin to see the power that everyone talks about. The first day or two will be frustrating because even the basics I just listed are a pain to remember out of the gate, let alone have the muscle memory to do without thinking.
This list seems really useful for general emacs, but does not help for spacemacs which has it's own equivalents (with vim-ey keybindings). I've been using spacemacs for a few years as my editor every day, and have not needed any of these.
Hear hear. Ctrl on caps lock changed my life. Then I bought a TECK^, which comes with a split spacebar and put left alt on caps (or where caps is usually, teck has control there) and right control on the right spacebar. This is honestly the best setup ever and I don't even use Emacs, I use Vim.
^ truly ergonomic computer keyboard. It's nice, but the hardware can be a bit wonky.
I forgot about that. Caps lock is useless 99% of the time and having that control available easily with your left pinky makes emacs (and everything else) work.
I'm so confused when I get on other people's computers and caps lock is actually caps lock.
Since he is looking at spacemacs, I'd recommend mapping caps lock to escape when it's tapped, but ctrl when it's pressed in conjunction with other keys. Very useful,
(though I suffer from the same problem when on other peoples computers)
I wish I could get a similar utility for Python and Javascript as this seems to show off some cool FP auto complete.
I'm basically looking for a way to remove my dependency on my 5-7 IDEs and I don't know how. I wish someone could show me a very good, simple, alternative to all of them. I work in C, Java, JavaScript, Python, PHP, and C# and I'd like to be able to use a single IDE solution for all of them. Sadly I cant find anything with good auto completion and nice features (like things offered by Eclipse).
This has some really promising features, I've got to say I'm amazed.
For javascript, I use js2-mode for syntax highlighting. I haven't ever tried js3-mode, but I understand it does better indentation. ac-js2 does autocomplete for js2-mode. You can throw in web-beautify as well - https://github.com/yasuyk/web-beautify
For many languages, I use yasnippet as well. Yasnippet rocks.
Languages like C# and Java (especially) are painful to use without code completion. The modern style of explicit imports in Java in particular simply can't be reasonably maintained without IDE support.
For everything else, emacs works fairly well. I find myself requiring code completion in languages like C and C++ a lot less, because I edit slower and more carefully, but also C and C++ codebases tend to have fewer random dependencies than Java and C# make it easy to add.
As far as python is concerned, if you mostly care about code navigation and autocompletion, try jedi-mode, it's fast, leightweight and works pretty well (I've used it successfully with virtualenv and conda, although the later required me to manually pip install epc-server and jedi and maybe one or two other deps). If you want refactorings, you're out of luck (rope is not even alpha quality, and I don't know of anything else). But firing up your IDE every few days or weeks for a bigger refactoring might be acceptable.
Javascript has js2-refactor, but I haven't tried that.
Lastly, instead of having 5-7 IDEs you could just get an Intellij license – it can basically do all that more specialized offerings like Webstorm and Pycharm can, and it's unlikely you'll ever have similar semantic support in a plain editor. I'm currently using emacs exclusively myself, but have also used products of the intellij family extensively, and might do so again depending on the project. The javascript livecoding and mixed-language-fragment support is pretty neat for example.
For C++, I use https://github.com/abingham/emacs-ycmd which gives completion (uses company-mode) and code navigation. It can also do C, C#, js, go, python etc. Requires a little setup (you have to install the ycmd daemon and, depending on language, a per-project conf file), but worth it.
An alternative to ycmd is https://github.com/Andersbakken/rtags which I think can list all usages of a symbol – ycmd only lets you go from usage to definition. I like how ycmd.el runs the ycmd daemon for me though.
Have another shout out for rtags (there's also a vim plugin). It can not only list usages, but find virtual function implementations, show class hierarchies, and rename symbols.
> I wish I could get a similar utility for Python and Javascript as this seems to show off some cool FP auto complete.
Since neither Python not Javascript is "as typed" as Haskell there are limits to what you can expect.
That said, I'm mostly happy with "elpy" in Emacs. Just make sure you configure it for the same version of Python you are targetting, and the rest should work out of the box.
as an emacs distro, spacemacs has everything I need for every language I've tried to work with (usually with auto-completion e.t.c.). sometimes requires a tiny bit of setup (usually no more a than a line or two) first time you use a new langauge, but that should is usually documented in the layer/README.org file.
I'm a emacs convert from vim (big reason is because module support is just leagues ahead of vim, Vundle, Pathogen, or anything else don't come close to emacs package management). A huge reason why I stuck with it is because evil. evil is very mature and is incredibly close to vim, some say it's a better vim than vim.
I tried a lot of "vi modes" in several IDEs but none of them cut it, you can map anything to evil and you can, of course, map commands to different states. Something I found very usefil is that you can even set states for different buffers, for example, for magit buffers (another amazing emacs module and a very good reason to use emacs) I default those to "insert" mode.
I haven't used Intero myself, but I've yet to find any kind of conflict between evil or any other module.
Evil seems to get some things wrong or weird. If I use the mouse, then using . to repeat last edit doesn't work. I've also had issues using macros sometime.
It also seems to have severe performance issues. Maybe it's Emacs, or rust-mode. But, say, running a macro 1000 times on a 10K line file is far slower than using vim.
But overall it's pretty great. I have the feeling it's easier to configure, once I get familiar with Emacs/elisp.
I tried to use Spacemacs but in vim I have hjkl mapped to jkl;. I simply could not find a way to do this in Spacemacs. All the solutions suggested did not apply to every mode and there was always some mode where I had to revert to hjkl. Is there any solution for this problem?
I use spacemacs and want to play with the vim part more, but I type dvorak, so I wanted to do a similar remapping and remap hjkl to htns so I would also be curious to hear if anyone has a good way to do that.
There appears to be a keyboard layout layer on develop[0] with support for dvorak.
Personally, I started looking into this when I started, but just got used to how hjkl are on dvorak (I still need the ability to be able to pick up with any random vim/vi I find on any random box, and don't find the utility in trading that).
I spent a couple of days trying it out exclusively before giving up. Really nice all-in-all to keep me using it for so long, but eventually I ran into some big issues:
A) evil-mode doesn't support :next and :prev for navigating between filenames given on the commandline.
B) Emacs's mindset towards indentation fundamentally seems incompatible with Vi's.
- Emacs
RET - indent current line, then create new one
TAB - indent current line
- Vim
RET - create new line and add indent to it
TAB - insert some characters at point (nowhere else)
I tried to spend some time configuring it, but it's too hard to catch every language minor mode. Hitting tab sometimes moves forward two spaces, sometimes to the next mod-8 column and sometimes indents the current line, refusing to do anything else if it's already correct to Emacs's puny mind. It doesn't look like evil-mode is able to patch all the places this mindset leaks through.
A particularly egregious example is in the lisp minor-mode. Try this on a vanilla Emacs install without any startup files (I used v24.5.1 on OS X):
1. $ emacs x.lisp
2. Type in '; abc'. That's a lisp comment with a single comment leader semi-colon.
3. Hit enter.
The line gets right-justified to column 40 (5 tabs) before the cursor moves to the next line.
Apparently Emacs thinks all full-line comments in lisp should start with ';;'.
Needless to say, this behaves the same way even with evil-mode. I spent some time trying to track it down, but RET is just bound to vanilla newline, not indent-and-insert-newline or something like that. So I'll stop here.
Comments that begin with a single semicolon are all aligned to the same column at the right (sometimes called the “comment column”). The text of such a comment generally applies only to the line on which it appears. Occasionally two or three contain a single sentence together; this is sometimes indicated by indenting all but the first with an additional space (after the semicolon).
2.4.4.2.2 Use of Double Semicolon
Comments that begin with a double semicolon are all aligned to the same level of indentation as a form would be at that same position in the code. The text of such a comment usually describes the state of the program at the point where the comment occurs, the code which follows the comment, or both.
2.4.4.2.3 Use of Triple Semicolon
Comments that begin with a triple semicolon are all aligned to the left margin. Usually they are used prior to a definition or set of definitions, rather than within a definition.
2.4.4.2.4 Use of Quadruple Semicolon
Comments that begin with a quadruple semicolon are all aligned to the left margin, and generally contain only a short piece of text that serve as a title for the code which follows, and might be used in the header or footer of a program that prepares code for presentation as a hardcopy document.
Are you sure that you launched the correct emacs? (`M-x version RET` in Emacs to check) This is an extremely common error for people using the built-in version which, as of El Capitan, is still Emacs 22.1 (almost 10 years old).
If you want a little more terminal magic here are my emacs related shortcuts:
alias et='TERM=xterm-256color emacsclient -t'
alias ec='emacsclient -c -a=emacs'
alias ed='emacs --daemon'
alias kill-emacs='emacsclient -e "(kill-emacs)"'
alias e='TERM=xterm-256color f -e "emacsclient -c -a=emacs"'
The reason for these is that emacs is a little slow to start up (in comparison to vim at least). So you can set up a daemon running ( ed command above, for emacs daemon. I don't have ed on my system)
You can then open up a new frame (window) of emacs with the ec command, or a new terminal session of emacs with the et command.
My favourite is the e command, which makes use of fasd[0] to find any "frecent" file, tries to open it with emacsclient, but, if emacs daemon is not running will fall back to opening a new emacs (which with spacemacs will start a new daemon running). This way I can open files in completely different directories if need be.
It didn't "just work (TM)" for me, I had to customize the intero-package-version in my .emacs when using it with a project with the latest stack-nightly, to bump it up to "0.1.16".
But other than that, wow! I was already very happy whenever I could get ghc-mod and haskell-mode to work, but this takes the responsiveness to a whole different level.
Very nice! But is there currently no way to get any information about third party code other than the type signature (C-c C-t or C-C C-i)? Ideally I'd like to be able to both navigate to the source code and see the documentation.
It might also be good to mention that you need to apt-get install libcurses5-dev for the haskell code to build.
I confess I have similar thoughts when I look at things that are getting reinvented all over the place. I have come to feel this is actually a counterproductive thought. Exploring in obscure tools is the definition of tinkering exploration. Which is often a big driver in pushing progress. (Same for reinvention.)
Me too. Got its quirks (I wish it noticed stack-relevant changes and ran intero-restart itself) but I find it really valuable, especially with Anthony Cowley's suggestion-handling stuff.