Live data from Hacker News

Emacs Bedrock: A minimal Emacs starter kit

sr.ht

41–50 of 132 posts

Re: Emacs Bedrock: A minimal Emacs starter kit

#41
post #40

I have switched last year from custom configuration to Doom Emacs. I liked the framework, but over time, I think this makes me rely on external people too much and some of the stuff is too overengineered (but the good design makes it easy to tweak). I would prefer to keep things lean and I am pondering using Doom Emacs without any builtin modules as the framework itself is very good. I have looked at other starter ki…

What issues you had with your custom configuration?

Re: Emacs Bedrock: A minimal Emacs starter kit

#42
I would probably recommend this to new users. I don't generally recommend starter kits because it defeats the real purpose of emacs which is to hack it. But this one seems to just get over the initial barrier of it looking ugly by default which enables happy hacking more quickly. I like it! (And isn't Emacs 29 great?!)

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.

Re: Emacs Bedrock: A minimal Emacs starter kit

#43
post #29

Earlier quoted context omitted.

I'm a casual emacs user for 30 years. Decided to give prelude a try after reading this... 2 minutes in: "" keybinding is discouraged! Use instead." Ok, well, then. Time to uninstall.

It's very much worth taking it as true. 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.

Plus those keys work in bash shells (anything that uses readline) and a lot of other places too.

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.

Re: Emacs Bedrock: A minimal Emacs starter kit

#44
post #26
post #10

yes But can someone please tell me how to get typescript auto complete like vscode (eg auto import, linting) that also works for jsx. running tests. oh and simple auto complete. 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 :))

For good autocompletion you‘ll need both an autocompletion framework and a language server client. 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…

First, for every IDE experience you definitely need flycheck mode:

  (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
            ("" . company-complete-selection))
      (:map lsp-mode-map
            ("" . 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))

Re: Emacs Bedrock: A minimal Emacs starter kit

#45
post #29

Earlier quoted context omitted.

I'm a casual emacs user for 30 years. Decided to give prelude a try after reading this... 2 minutes in: "" keybinding is discouraged! Use instead." Ok, well, then. Time to uninstall.

It's very much worth taking it as true. 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.

It interferes with my thinking mode - right hand on the mouse and probably scrolling in docs on the other screen, left hand stroking my beard.

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.

Re: Emacs Bedrock: A minimal Emacs starter kit

#46

bbatsov's prelude is another nice kit to get started with and learn from: https://github.com/bbatsov/prelude https://prelude.emacsredux.com/en/latest/

I'm a casual emacs user for 30 years. Decided to give prelude a try after reading this... 2 minutes in: "" keybinding is discouraged! Use instead." Ok, well, then. Time to uninstall.

The thing is about emacs, it makes you self-sufficient. You can always change any behaviour you want to, including this.

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

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.

Re: Emacs Bedrock: A minimal Emacs starter kit

#48
post #3

If you’re running emacs 29+ I posit you get less value out of a starter kit or framework than beforehand. 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 in…

Thanks for the pointer to modus-theme. Vivendi-tinted is very close to what I normally run. Time to update to 29 and get rid of more customisation!

Re: Emacs Bedrock: A minimal Emacs starter kit

#49

Emacs is a relic, it can take weeks of configuring to get it anywhere near as productive as something like VS Code or Jetbrains IDEs. If you want to procrastinate for a few months it's the perfect tool.

2 weeks for 20+ years of use doesn't seem to bad!

Re: Emacs Bedrock: A minimal Emacs starter kit

#50

Earlier quoted context omitted.

I own no windows machines but afaik it should run OK on windows. Emacs is a pretty good application platform that glosses over lots of OS inconsistencies. :)

I heard that some addons (like magit and vterm) run much worse on Windows than on Unix-like. That's my main concern. Maybe it's an outdated view tho.

From what I remember magit is only slow on WSL, when interacting with a repository that is not located in the Linux subsystem i.e. laying in the windows user directory. But that might be wrong or also depend on other factors.
Post reply on HN