An Emacs configuration for Norwegian keyboard on OSX (lol), as seen on emacsrocks.com and parens-of-the-dead.com.
Download Emacs for Mac OSX.
-
Spell checking:
brew install aspell --lang=en -
Static analysis for Clojure with LSP
brew install clojure-lsp/brew/clojure-lsp-nativeor get the nightly:
bash <(curl https://raw.githubusercontent.com/clojure-lsp/clojure-lsp/master/install) --version nightly --dir ~/bin(place somewhere on your path before homebrew)
-
Fast grepping:
brew install ripgrep -
Make dired happy, install
glsas replacement forls:brew install xz coreutils -
Stop clojure-lsp from adding duplicate namespace declarations:
Open
~/.config/clojure-lsp/config.ednand add:{:auto-add-ns-to-new-files? false}This is already handled better by clj-refactor (which also inserts test declarations in relevant namespaces).
-
Add dependencies to the project without CIDER running:
brew install babashka/brew/neil -
Static analysis for CSS with LSP
npm install -g vscode-langservers-extracted -
On a Mac you might want to do this, to disable
C-M-din your OS, making it available forparedit-forward-down:defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 70 '<dict><key>enabled</key><false/></dict>'
If you want to use my settings straight out of the box, here are some things to note:
-
This is my personal emacs configuration. I am constantly tuning it to my preferences. You should consider doing the same. Maybe start with a blank emacs + Technomancy's better-defaults package, and then dig through this repo for useful nuggets, instead of forking it directly.
-
The key bindings are optimized for a norwegian keyboard layout.
-
You quit emacs with
C-x r q, mnemonic Really Quit. -
Find file in project with
C-x p f, in dir withC-x C-f, recent withC-x f -
Switch to a project with
C-x p p -
Add your user- and project-specific stuff in .emacs.d/users/[machine name]/*.el
-
C-his rebound to backspace, like in the shell. Get help onF1instead. -
Autocomplete with
C-,orC-., try both to get a feel for them. (autocomplete entire lines withC-:) -
expand-region is your friend. Find its bound key by doing
F1 f er/expand-region -
Undo with
C-_and redo withM-_. Watch the undo-tree withC-x u -
Indent and clean up white space in the entire buffer with
C-c n -
On a mac, the Meta key
Mis bound to Command. -
I recommend rebinding Caps Lock to Ctrl and use that instead of the often badly placed Ctrl-key.
-
Watch emacsrocks.com
When you start using emacs for the first time, your habits fight you every inch of the way. Your fingers long for the good old familiar keybindings. Here's an overview of the most commonly used shortcuts to get you through this pain:
CShorthand for the ctrl-keyMShorthand for the meta-key (bound to command on my mac settings)SShorthand for the shift-keysShorthand for the super-key (bount to option on my mac settings)
C-x C-fOpen a file. Starts in the current directoryC-x fOpen a recently visited fileC-x p fOpen a file in the current project (based on .git ++)C-x C-sSave this fileC-x C-wSave as ...C-x C-jJump to this files' current directoryC-x bSwitch to another open file (buffer)C-x C-bList all open files (buffers)
C-spaceStart marking stuff. C-g to cancel.C-wCut (aka kill)C-kCut till end of lineM-wCopyC-yPaste (aka yank)M-yCycle last paste through previous killsC-x C-yChoose what to paste from previous killsC-@Mark stuff quickly. Press multiple times
C-gQuit out of whatever mess you've gotten yourself intoM-xRun a command by nameC-.AutocompleteC-_UndoM-_RedoC-x uShow the undo-treeC-x mOpen magit. It's a magical git interface for emacs
C-arrowMove past words/paragraphsC-aGo to start of lineC-eGo to end of lineM-g M-gGo to line numberC-x C-iGo to symbolC-sSearch forward. PressC-sagain to go further.C-rSearch backward. PressC-ragain to go further.
C-x 0Close this windowC-x 1Close other windowsC-x 2Split window horizontallyC-x 3Split window verticallyS-arrowJump to window to the left/right/up/down
F1 tBasic tutorialF1 kHelp for a keybindingF1 rEmacs' extensive documentation