263 points · by ashton314 · 3y ago · 129 comments
Treesitter is baked in for syntax, eglot is baked in for language servers (intellisense), project and tab-bar give you scoped workspaces. use-package is baked in for downloading and configuring dependencies.
Modus-themes are also built in now, so you can use modus-operandi and modus-vivendi out of the box. Two incredible themes with a lot of research invested in them.
My config is a few hundred lines of unadulterated elisp now and most of the code is around completion and fuzzy searching.
The point being, modern emacs is a lot more viable from a vanilla config now than it ever has been.
Edit: changed emacs 28 to emacs 29
This was actually the motivating factor for the creation of this framework. The creator posted this to reddit:
> Hi, author here. I created this in response to a few of my lab mates wanting to get started with Emacs. Additionally, Emacs 29 has so much awesome stuff out-of-the box (use-package, eglot, tree-sitter, minibuffer completion improvements, etc.) that I wanted to see how nice I could make Emacs using just the defaults. I failed a little bit (gotta have which-key—best package for discoverability IMO, wish it were built-in) but by and large I think this project is a success. :) I've gotten several people started by just pointing them to this repository.
Compare with Mason on Neovim which is much closer to "everything just works" (and niche treesitter modes seem to be available there long before they are available on Emacs)
> Isn't even a list of URLs for grammars
Actually there is: if you run `treesit-install-language-grammar` and answer, say, `python`, it will auto-populate with the right URL. This doesn't work with every language, (e.g. Elixir isn't on the list) but it's a start.
Again: definitely needs some more work.
Similar to evil, people will figure it out over time, producing packages similar to evil-collection, but it is again a half-assed step from emacs where I can only applaud to neovim for making right, if brave, decisions. If you have decided that TS is the future, go all-in.
It is also cool how much emacs29 supports, but the quality is often meh. Project.el is an arcane mode, which updates the cache of projects very unreliably and also what it considers a project is a bit magic. Eglot is cool, but again, as everything in emacs, has big tradeoffs - DAP is bound to lsp, which brings in something like 30 packages, including treemacs - why?
In short: I gave my custom config a good run, and the good stuff is good: vertico, marginalia, embark(!!), corfu are pretty cool packages. Elpaca is also very good, doing for emacs the same stuff lazy.nvim is doing for neovim. But once I've descended a level deeper into configuring it for non-lisp programming, I was clearly in for a huge yak shaving. Neovim is for me a better editor for programming, sorry for the rant.
Meanwhile, each new version seems to break something in my crusty old .emacs file. My latest frustration is that drag and drop stopped working after upgrading from 28 to 29.
I don't know if a starter kit is necessarily the answer, but there's something to be said for a batteries included approach.
From downsides, it won't compile with xwidgets support (webkit).
Sadly the two of them don't seem to mix well together (eg rust-mode works well with eglot but rust-ts-mode makes eglot ask for LSP server binary and then still does not connect).
Looks like it's early toothing problems but it's not that straightforward (at least yet).
My config is pretty threadbare these days, which is a relief when I plan to rewrite it in literate format.
Why can't something that is built into IDEs like Intellij be built into Emacs even after 30+ years of development?
(cua-mode)
Well this will have the greybeards frothing at the mouth :)that said, `cua-mode` is kinda terrible/half-assed b/c it implements a tiny fraction of what I think most people would consider "CUA". If you want a real CUA-mode use `ergoemacs`. Then Emacs will start to behave like every other GUI since the last mass extinction. It comes with a nice illustration of all the keybindings which leads to good discoverability of features. The only downside I saw was it had really slow launch times. Once you're comfortable with ELisp you can just rolled your own keybindings though
Is there some reason ergoemacs has never caught on?
"That's just like uh… your opinion man." —"The Big Lebowski", I think ;-)
I'm mostly of the opinion that vanilla Emacs has some bad opinions with regards to discoverability and ease-of-use-for-newbies, which is what this starter kit is targeting.
CUA-mode is on because without it you're gonna have newbies footgunning themselves super hard right out the gate, and that's the biggest thing I want to avoid.
If you consider this setup opinionated, then great—I'll embrace that. :) I think they're the kind of opinions that help newbies.
> ergoemacs
Are you referring to Xah Lee's stuff? Or something else? I'd love to see what you're referring to—please send me a link here or on my contact page. That said, Xah himself said at one point that `cua-mode` should be on by default,[1] so I think it's good enough for this kit.
I don't think we disagree. cua-mode is better than nothing.. but just enabling CUA feels kinda lazy bc it's easily improved
from Xah Lee himself:
There is Google, you know.
It's the biggest thing to happen to Emacs in 30 years. That is presumably why all the beardies ignore it.
I used to know 20-30 totally different editors. That all went away circa 1990 when the CUA UI swept the world.
https://en.wikipedia.org/wiki/IBM_Common_User_Access
All late-era DOS stuff, and Windows >= 3.x, Mac OS X and ~all Linux GUIs are compliant.
I refuse to learn any other editor UI. Life is too short. Comply with CUA, or die in a fire.
CUA was "influenced" by the old Mac OS Human Interface Guide mid/end 80s.
The influence on macOS (as it is called now) is tiny. macOS is mostly not compliant.
Clearly bearing the costs of a wrong decision - learn vim keybindings 30 years ago, and use it in every popular editor and ide, including emacs, ever since. Only half-joking.
While I used to like xemacs back in the day, neither emacs nor vim really clicked, the basics are just to alien.
This brings emacs back to the list of usable options.
What is the simpler choice? Choosing the defaults that are built-in already, or the defaults new users will expect?
This is the first time I'm hearing of digital tooling used as legacy in the actual meaning of the word. I can't really be surprised that Emacs is the one that pops up, but I'm wondering if anybody has had (or heard) similar experiences
Btw, one thing that probably all starter kits should do is disable JIT compilation warnings:
`(setq native-comp-async-report-warnings-errors 'silent)`
Maybe JIT-enabled builds aren't generally available right now, but once they are this default would scare a lot of new users right off the bat.
Ok, well, then. Time to uninstall.
My additions/removals are just a few lines now and I find the whole setup a lot more maintainable than rolling my own: https://github.com/fhd/prelude/tree/personal/personal
But yeah, all I can say is that it works for me (with a little investment), YMMV.
I've never used prelude before. I just ran it for the very first time and this is what I did to discover what to change:
C-h k <down>
Help buffer comes up for that key. It looks like it's bound to a lambda, which is actually a bit annoying as you can't jump to the definition or anything, but it's enough to see that it's in `guru-mode-map'.
Then I grepped the project for "guru" (I used C-c p s g because I figured out it was using Projectile and familiar with its default key bindings, but you could use M-x grep, M-x rgrep or just grep in whatever way you are familiar with).
I found this in the docs: https://prelude.emacsredux.com/en/latest/troubleshooting/#wa... (Note, I found and read this in emacs, in docs/troubleshooting.md, I'm just giving the web link here for convenience).
Basically just add `(setq prelude-guru nil)` to your init file.
Btw, for anyone wondering, to run these kind of starter kits "standalone", clone the repo and from within the repo run `emacs -Q --load init.el --init-directory=$(pwd)`. Otherwise it will try to use your actual init dir by default.
For what it's worth, I happened across bbatsov/prelude in 2011, not long after it started being developed, having no prior emacs experience. The notice you mentioned was one of several that nudged me to learn and use the various key combinations, so I'm grateful for the notices, but I understand that not everyone would be.
So far I like the bundling of lsp and so on, it worked nicely out of the box to bring in my Rust projects ... it's nice to have it all set up.
But there's more... opinionated stuff in here that's frustrating. C-x u for undo is wonky, and C-g does not appear to be working to abort/get out of prompts. My fingers were tripping all over the place.
I feel like by the time I'd unpeeled enough of this guy's opinions and undone all the non-standard stuff in here, I'd be best to just start over.
I was in the same position as you initially and it took a week or two to get the muscle memory but it's so smooth to navigate using keys near the home row compared to arrow keys.
Dug out a quote from Guy Steele on why the key bindings in emacs got this way:
[...] not being a human-factors guy at all, I
didn't think at all about convenience for touch typists. I was
principally concerned with mnemonic value. And so that's why Meta-C and
Meta-L and Meta-U stand for capitalize and lowercase and uppercase.
(from Peter Siebel's Coders At Work, quoted here https://classiccmp.org/pipermail/cctech/2015-August/008498.h...)Not only that but, the basic forward/back char, up/down line are caveman style navigation. Obviously they come in useful, but emacs has a much richer set of navigation options: M-f, M-b move forward/back by words, M-}, M-{ by paragraphs etc.
More seriously, I'm just the same with hjkl and vim - cool if it works for you, when I am scrolling through I don't need to be efficient (which is highly subjective anyway), I need to have it how I like it.
I generally like it but the one thing I’m really missing is the spacebar concept from spacemacs / doom. Anyone know a way to shoehorn that in? Or any tips for how to do without it?
but I think the things you want to look for, if you start from scratch, are 1. evil mode https://evil.readthedocs.io/en/latest/overview.html#installa... 2. the leader key https://github.com/noctuid/evil-guide#leader-key
these are random search results that may or may not be authoritative, but they should be a good start.
1. https://github.com/noctuid/general.el
2. https://github.com/gekoke/dotfiles/blob/main/modules/program...
Starter kits are usually opinionated, have too much in them that I may not want, I may want to do things differently, and like was said in a sibling reply, I would also want to understand my own config better...
i couldn’t get that to work with
https://github.com/viksit/prelude/blob/master/init.el
as someone else said - need to get work done :))
I am still using „lsp-mode“ as a language server client which works well for me and it comes with „company-mode“ integration for good autocompletion:
https://emacs-lsp.github.io/lsp-mode/page/lsp-typescript/
Later that day I can paste you the relevant lines out of my init.el.
Starting with Emacs 29 you can also use the treesitter mode „typescript-ts-mode“ for better syntax highlighting an navigation.
(use-package flycheck
:diminish flycheck-mode
:init
(global-flycheck-mode))
This will underline syntax errors for you. (It'll use the language server as a backend once lsp-mode runs.)Next we install and set up "company-mode" for simple autocompletion. Basically, it starts the (minor) company mode after starting "lsp-mode", sets up key bindings and reduces the delay to zero:
(use-package company
:after lsp-mode
:hook (lsp-mode . company-mode)
:bind
(:map company-active-map
("<tab>" . company-complete-selection))
(:map lsp-mode-map
("<tab>" . company-indent-or-complete-common))
:custom
(company-minimum-prefix-length 1)
(company-idle-delay 0.0))
This stuff is for basic JSX/TSX support you'll need to work on React projects. "web-mode" is old-school but it still works for me quite well. Since Emacs 29 you can use "typescript-ts-mode" instead but I haven't tried it out yet: (use-package web-mode
:config
;; plain HTML may also contain JS
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
;; JSX
(add-to-list 'auto-mode-alist '("\\.jsx\\'" . web-mode))
; TSX
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode))
;; web-mode overrides these key strokes with "link" and "reload"
;; which I *never* needed. But I love compile mode:
:bind (:map web-mode-map
("C-c C-l" . 'compile)
("C-c C-r" . 'recompile)))
The next stuff is for setting up lsp mode integrating the various language modes and company mode in a single user experience: (defun gernoti/lsp-mode-setup ()
"Gernot's Emacs: My personal modifications to lsp mode."
(setq lsp-headerline-breadcrumb-segments '(path-up-to-project file symbols))
(lsp-headerline-breadcrumb-mode)
(lsp-treemacs-sync-mode 1))
;; I am still using "web-mode" for react projects. The function
;; activates lsp mode only if the file actually contains
;; javascript/typescript (IIRC it'll also work for TSX):
(defun gernoti/lsp-deferred-maybe-jsx ()
(if (string= web-mode-content-type "jsx")
(lsp-deferred)))
(use-package lsp-mode
:commands (lsp lsp-deferred)
:hook
(lsp-mode . gernoti/lsp-mode-setup)
(js-mode . lsp-deferred)
(typescript-mode . lsp-deferred)
;; We only turn lsp-mode on if web-mode runs in JSX or TSX mode.
(web-mode . gernoti/lsp-deferred-maybe-jsx)
:init
(setq lsp-keymap-prefix "C-c l") ;; Or 'C-l', 's-l'
:config
;; You want this if you want to discover all lsp mode's goodies.
;; Though I found I actually don't use many features, really.
(lsp-enable-which-key-integration t))
At first startup it'll download and run the default js/ts language server. It seems to be working well for me.You definitely want the "lsp-ui" extensions for jumping around in definitions, too:
(use-package lsp-ui
:after lsp-mode
:hook (lsp-mode . lsp-ui-mode)
:custom
(lsp-ui-doc-position 'bottom)
;; remap "M-." and "M-?" to point to the nice looking lsp-ui
;; replacements
:config
(define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions)
(define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references))will check this out this week thank you!
Good, clear comments on sensible defaults. I've already copied some into my init.el. Plus I've started using early-init.el too.
Thank you!
One thing I feel is a strange one to optimize for: startup times. Typical Emacs use is to start it once when the graphical interface of the system starts, and never turn it off. What's even the point of this optimization?
My personal experience is that most of the new dev tooling is Linux/MacOS only, and maaaaybe sometimes it's ported badly to Windows.
Are people using Emacs with LSPs for Java, Python, for example? Are they solid? Would you be able to use them day to day for software engineering work?
The one thing in Emacs that does not really work for me are these fancier new completion frameworks (Vertico, Orderless etc) as the performance is abysmal. So I switched back to Helm.
I have looked at other starter kits to find leaner things, but they don't seem to bring much to seasoned Emacs users like me.
I'm tempted to try it out, but knowing the community is (righteously) Unix-fist I'm not so sure it's worth the trouble.
My life improved a lot when I switched to Doom emacs, which takes care of a lot of emacs stuff I don't know that well.
Part of Git appeal is speed, because it works locally, magit on windows take that away
I hope on Linux it is actually fast, otherwise I would not know how to explain its fame and reputation
Here's what I recall were the major pain points then:
* You need to choose between MSYS2 and "native" Windows binaries (add WSL today for more choices).
* The choice above will influence how you interact with various shells. Getting shell encoding right and filtering out escape sequences that don't render well in Emacs terminal emulator of choice was a headache.
* All interactions with filesystem are slower. If a mode depends on interaction with filesystem a lot, like Magit, you are going to have a bad time. At the time CEDET was still a thing, but on Windows it was absolutely unusable. (Very infrequently I need to look at wife's laptop which runs some more modern Windows, and that's usually because she has some problems with Git or other infra, and I installed Emacs there to make dealing with this stuff easier: Maigt is awfully slow there).
* I don't know if Tramp has any kind of support for the convoluted and bizarre Windows user permission management -- I never had enough time to figure that out. On Linux, if I need to edit files owned by root, I do C-x f /sudo::/..., but there doesn't seem to be anything like that for Windows.
* In general, you will be missing stuff that you could easily accomplish in Emacs by pressing "!" in Dired buffer -- because there's nothing / very little of useful stuff you can call on files. If you don't install emacs with other MSYS2 utilities, your search options in Dired will be bad (default Windows find), similarly bad is the find in files that normally relies on grep to work. Same situation with spellchecker which relies on an external program.
I'd still take it over something like VSCode, but I would have to invest a lot of effort into bringing it up to the possible / desired level of comfort. It's definitely not the best place to use Emacs. Luckily, today, I'm in the place where I can, for the most part, forget MS Windows exists.
1. We are on version 30. By this time emacs should have come with some better defaults. It's 2023, not 1960 people.
2. Why are 90% of emacs frameworks trying to make it into vi?? I choose emacs, if I wanted vi-ish I would have used vi from the beginning
A lot of people want the power of emacs without the RSI that so often goes with it :)
Idk, I can navigate in Emacs using native bindings, though I like vi modal editing more, it just feels more natural when working with text. Also I can't say about 90%, but in Doom Emacs you can easily switch between native and vi bindings (even on the fly, via the keyboard chord), it's not forced in any way.
(I just checked - you can disable evil mode in spacemacs too).
People were saying that when I started using it, over 20 years ago. Apparently I was supposed to be using Notepad++ or some MS program du jour which no one remembers now. I wouldn't be surprised if I keep using it for the rest of my career.
> it can take weeks of configuring
More like decades ;)
> to get it anywhere near as productive as something like VS Code or Jetbrains IDE
Nope - it's significantly more productive. At least for me - I can't speak for you, but I do seem to be much faster at processing text than any of my colleagues who are using those other editors.
All the configuring is by design. You can set up the editor to take advantage of your strengths and paper over your weaknesses.
This can only work if the editor internalizes the corresponding language. That does not scale for all languages available.
That’s exactly what the language server protocol is all about (and certainly what parsers like tree sitter are there for). Emacs can connect to those and acquire semantic analysis capabilities. The degree to which such a semantic language features will work for you will also depend strongly on the language, of course.
If you use a commercial editor it’ll jump start you for the popular languages. But, say, you wanted to program in Raku or Scheme you’ll also going to need to fiddle around.
It's true.
The thing is, so is Unix.
And yet we use it.
So is macOS because it's a Unix™. So is Windows, it's just a newer relic (from 1993 instead of ~1973).
We don't have anything left that are not relics any more. The relics got good enough that we stopped trying.
Nicely put.
Yes, I think there is room for a lot of innovation yet in many areas: OS design, programming language design, input devices, GUIs, and much more besides.
Saying that, when implemented well, there's a lot of stuff that's pretty good.
I think one aspect that's neglected is that yes, some tech we all use is very old and legacy-inspired. But often, it's not that we use some ancient thing because it's ancient and it hasn't changed. It's because it had lots of competitors but it beat them all.
For instance, QWERTY. Yes it is very old and yes it came from typewriters.
But I own 2 computers with
ABCDEF
GHIJKL
MNOPQR
STUVWX
YZ
... layouts. There are also QWERTZ and AZERTY used by millions. Dvorak failed to its inventors' deep misery. (No, not Dvořák, although Dvorak was a descendant of Dvořák.)
There have been tonnes of others tried.
The survivors are the ones that beat out the competition.
And in some instances, the competition survives and does OK in its little niche, and that is fine, too...