Intero for Emacs: complete interactive development program for Haskell
commercialhaskell.github.io
commercialhaskell.github.io
* 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.
Stack has changed my development workflow, in a very positive way, and I love Intero (at least in the first 24 hours of use).
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.
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.
(global-set-key (kbd "M-P") 'scroll-down-line)
(global-set-key (kbd "M-N") 'scroll-up-line)
Has also been indispensable for scrolling (though you may choose to do so differently, coming from vim).
I'm so confused when I get on other people's computers and caps lock is actually caps lock.
(though I suffer from the same problem when on other peoples computers)
^ truly ergonomic computer keyboard. It's nice, but the hardware can be a bit wonky.
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!
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.
[1] https://www.gnu.org/software/emacs/manual/html_node/emacs/Wo...
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.
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.
I also highly recommend remapping your caps lock key to control.
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 is spacemacs, just use the leader key...
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.
Out of curiosity, have you tried the relevant JetBrains IDE(s)?
I also don't like using 7 different IDEs.
Flycheck handles syntax issues for many languages, including Python. https://github.com/flycheck/flycheck
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.
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.
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.
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.
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.
+ Stick with NeoVim and hope one of the Intero ports to that editor takes off (as I understand it there are a couple right now)
+ Switch to Emacs+Evil+Intero. I've never used Emacs before (even with Evil) so it would be a little work.
If someone more up-to-date on the situation has advice that would be awesome:)
http://blog.aaronbieber.com/2015/05/24/from-vim-to-emacs-in-... https://www.youtube.com/watch?v=JWD1Fpdd4Pc
One of my vim-using coworkers found it. He, along with another colleague, have since found emacs compelling enough to use as their main text editor.
(require 'package)
The error I get is: File error: "Cannot open load file", "package".
I installed emacs on OS X using: $ brew install emacs
But it looks like version 24.5 on OS X El Capitan doesn't come with something called 'package.el'. Oh well, back to Vim..Edit 10 minutes later: Ok, it's installed now. And I've set this up in my .zshrc:
-alias vi=vim
+alias vi=emacs
Let's see how this goes. 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.
"If the value of [the alternate editor] is the empty string, run `emacs --daemon' to start Emacs in daemon mode, and try to connect to it."
So your aliases would continue to work if you replace -a=emacs with -a=''. And you'd only pay the startup cost the first time you run ec or e.
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.
Not exactly. ;; aligns to the current indentation level of the code.
It's a usual Lisp indenting convention.
The Emacs Lisp manual recommends:
https://www.gnu.org/software/emacs/manual/html_node/elisp/Co...
Common Lisp uses it also. See the ANSI CL spec.
2.4.4.2.1 Use of Single Semicolon
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.
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.
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.
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).
[0] https://github.com/syl20bnr/spacemacs/tree/develop/layers/%2...
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.
It might also be good to mention that you need to apt-get install libcurses5-dev for the haskell code to build.
[1]: https://ianchanning.wordpress.com/2016/08/11/installing-haskell-emacs-on-windows/