stockholm/jeschli/2configs/emacs.nix

263 lines
7.5 KiB
Nix
Raw Normal View History

2018-03-20 16:38:26 +00:00
{ config, pkgs, ... }:
let
pkgsWithOverlay = import <nixpkgs-unstable> {
overlays = [
(import (builtins.fetchTarball {
url = https://github.com/nix-community/emacs-overlay/archive/master.tar.gz;
}))
];
};
orgAgendaView = import ./emacs-org-agenda.nix;
2018-03-21 07:59:35 +00:00
packageRepos = ''
(require 'package) ;; You might already have this line
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
(not (gnutls-available-p))))
(url (concat (if no-ssl "http" "https") "://melpa.org/packages/")))
(add-to-list 'package-archives (cons "melpa" url) t)
(add-to-list 'package-archives
'("org" . "http://orgmode.org/elpa/") t)
)
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize)
'';
2018-11-02 08:43:08 +00:00
2018-03-21 07:59:35 +00:00
evilMode = ''
;; Evil Mode
(require 'evil)
(evil-mode 1)
2018-07-31 14:32:39 +00:00
;; (require 'evil-org)
;; (add-hook 'org-mode-hook 'evil-org-mode)
;; (evil-org-set-key-theme '(navigation insert textobjects additional calendar))
;; (require 'evil-org-agenda)
;; (evil-org-agenda-set-keys)
2018-03-21 07:59:35 +00:00
'';
2018-11-02 08:41:47 +00:00
goMode = ''
2019-09-24 03:34:09 +00:00
(setq godoc-and-godef-command "go doc") ;godoc has no cli support any more, thats go doc now
2018-11-02 08:41:47 +00:00
(add-to-list 'exec-path "~/go/bin")
(add-hook 'go-mode-hook
(lambda ()
(setq-default)
(setq tab-width 2)
(setq standard-indent 2)
(setq indent-tabs-mode nil)))
'';
2018-10-26 09:53:19 +00:00
ido = ''
(require 'ido)
(ido-mode t)
'';
2018-11-02 08:41:47 +00:00
2019-10-21 05:42:39 +00:00
helm = ''
(helm-mode 1)
(global-set-key (kbd "M-x") #'helm-M-x)
(global-set-key (kbd "C-x r b") #'helm-filtered-bookmarks)
(global-set-key (kbd "C-x C-f") #'helm-find-files)
'';
2019-09-11 20:57:18 +00:00
magit = ''
(global-set-key (kbd "C-x g") 'magit-status) ; "Most Magit commands are commonly invoked from the status buffer"
'';
2018-03-21 07:59:35 +00:00
windowCosmetics = ''
2018-07-31 14:32:39 +00:00
(menu-bar-mode -1)
2018-03-21 07:59:35 +00:00
(tool-bar-mode -1) ; Disable the button bar atop screen
(scroll-bar-mode -1) ; Disable scroll bar
2018-07-31 14:32:39 +00:00
(toggle-scroll-bar -1)
2018-03-21 07:59:35 +00:00
(setq inhibit-startup-screen t) ; Disable startup screen with graphics
(setq-default indent-tabs-mode nil) ; Use spaces instead of tabs
2018-03-26 08:15:29 +00:00
(setq default-tab-width 2) ; Two spaces is a tab
2018-03-21 07:59:35 +00:00
(setq tab-width 2) ; Four spaces is a tab
(setq visible-bell nil) ; Disable annoying visual bell graphic
(setq ring-bell-function 'ignore) ; Disable super annoying audio bell
'';
2018-11-02 08:43:08 +00:00
2018-03-22 15:19:29 +00:00
orgMode = ''
(add-to-list 'auto-mode-alist '("\\.\\(org\\|org_archive\\|txt\\)$" . org-mode))
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)
(global-set-key "\C-c L" 'org-insert-link-global)
(global-set-key "\C-c o" 'org-open-at-point-global)
2018-07-31 14:32:39 +00:00
(setq org-link-frame-setup '((file . find-file))) ; open link in same frame.
2018-03-22 15:19:29 +00:00
(if (boundp 'org-user-agenda-files)
(setq org-agenda-files org-user-agenda-files)
(setq org-agenda-files (quote ("~/projects/notes_privat")))
2018-03-22 15:19:29 +00:00
)
'';
2018-11-02 08:41:47 +00:00
2018-07-31 14:32:39 +00:00
theme = ''
(load-theme 'monokai-alt t)
(load-theme 'whiteboard t)
(disable-theme 'monokai-alt)
(disable-theme 'whiteboard)
(defun mh/load-whiteboard-theme ()
"load whiteboard theme"
(interactive)
(message "whiteboard loaded")
(disable-theme 'monokai-alt)
(enable-theme 'whiteboard)
)
(defun mh/load-monokai-theme ()
"load monokai theme"
(interactive)
(message "monokai loaded")
(disable-theme 'whiteboard)
(enable-theme 'monokai-alt)
)
(global-set-key "\C-ctw" 'mh/load-whiteboard-theme)
(global-set-key "\C-ctm" 'mh/load-monokai-theme)
2018-07-31 14:32:39 +00:00
'';
2018-11-02 08:41:47 +00:00
2019-09-17 07:09:00 +00:00
# Configuration for rust development
# inspired by
# https://github.com/bbatsov/prelude/blob/master/modules/prelude-rust.el
2019-09-24 03:35:11 +00:00
#
# This requires rls and racer to be installed on the system
2019-09-17 07:09:00 +00:00
rustDevelopment = ''
(add-hook 'rust-mode-hook #'racer-mode)
(add-hook 'rust-mode-hook (lambda()
(local-set-key (kbd "C-c C-d") 'racer-describe)
(local-set-key (kbd "C-c .") 'racer-find-definition)
(local-set-key (kbd "C-c ,") 'pop-tag-mark))
)
(add-hook 'racer-mode-hook #'eldoc-mode)
(add-hook 'racer-mode-hook #'company-mode)
(require 'rust-mode)
(define-key rust-mode-map (kbd "TAB") #'company-indent-or-complete-common)
(setq company-tooltip-align-annotations t)
'';
2018-03-26 08:16:09 +00:00
recentFiles = ''
(recentf-mode 1)
(setq recentf-max-menu-items 25)
(global-set-key "\C-x\ \C-r" 'recentf-open-files)
'';
2018-11-02 08:41:47 +00:00
myFunctionKeys = ''
2019-09-24 03:37:16 +00:00
(fset 'kill-actual-buffer
[?\C-x ?k return])
(defun mh/open-term-and-rename (name)
"open a new bash and rename it"
(interactive "sName of new terminal: ")
(term "/run/current-system/sw/bin/bash")
(rename-buffer name)
)
(global-set-key (kbd "M-<f8>") 'kill-actual-buffer)
(global-set-key (kbd "<f5>") 'mh/open-term-and-rename)
(global-set-key (kbd "<f6>") 'other-window)
(global-set-key (kbd "<f7>") 'split-window-right)
(global-set-key (kbd "<f8>") 'delete-other-windows)
2019-09-24 03:37:16 +00:00
'';
2019-11-14 14:34:49 +00:00
lspMode = ''
(require 'lsp-mode)
(add-hook 'rust-mode-hook #'lsp)
'';
2018-03-26 08:16:09 +00:00
dotEmacs = pkgs.writeText "dot-emacs" ''
${packageRepos}
2018-08-01 11:53:46 +00:00
${evilMode}
2018-11-02 08:41:47 +00:00
${goMode}
2019-10-21 05:42:39 +00:00
${helm}
2019-09-11 20:57:18 +00:00
${magit}
2018-03-26 08:16:09 +00:00
${orgMode}
2019-09-17 07:09:00 +00:00
${rustDevelopment}
2018-07-31 14:32:39 +00:00
${theme}
2018-04-17 16:43:09 +00:00
${windowCosmetics}
${orgAgendaView}
${myFunctionKeys}
2019-11-14 14:34:49 +00:00
${lspMode}
2018-03-20 16:38:26 +00:00
'';
#emacsWithCustomPackages
emacsPkgs= epkgs: [
2019-11-14 14:34:49 +00:00
# testing lsp mode
epkgs.melpaPackages.lsp-ui
epkgs.melpaPackages.company-lsp
epkgs.melpaPackages.lsp-treemacs
epkgs.melpaPackages.helm-lsp
epkgs.melpaPackages.dap-mode
epkgs.melpaPackages.lsp-mode
# testing
2019-10-21 05:42:39 +00:00
epkgs.melpaPackages.web-mode
epkgs.melpaPackages.js2-mode
epkgs.melpaPackages.xref-js2
epkgs.melpaPackages.academic-phrases
2019-09-24 03:40:40 +00:00
epkgs.melpaPackages.gitlab
2019-10-21 05:42:39 +00:00
epkgs.melpaPackages.helm
epkgs.melpaPackages.weechat
2019-09-24 03:40:40 +00:00
# emacs convenience
epkgs.melpaPackages.ag
epkgs.melpaPackages.company
2019-09-24 03:40:40 +00:00
epkgs.melpaPackages.direnv
2018-07-31 14:32:39 +00:00
epkgs.melpaPackages.evil
2019-09-24 03:40:40 +00:00
epkgs.melpaPackages.google-this
epkgs.melpaPackages.monokai-alt-theme
2019-11-14 14:34:49 +00:00
epkgs.melpaPackages.zenburn-theme
2019-09-24 03:40:40 +00:00
# development
epkgs.melpaPackages.magit
2018-03-21 07:59:35 +00:00
epkgs.melpaPackages.nix-mode
2018-03-24 10:30:30 +00:00
epkgs.melpaPackages.go-mode
epkgs.melpaPackages.haskell-mode
2019-09-17 07:09:00 +00:00
# rust
epkgs.melpaPackages.rust-mode
2019-11-14 14:34:49 +00:00
# epkgs.melpaPackages.flycheck-rust
2019-09-17 07:09:00 +00:00
epkgs.melpaPackages.racer
2019-09-24 03:40:40 +00:00
# python
2019-09-11 21:00:00 +00:00
epkgs.melpaPackages.elpy
2019-09-24 03:40:40 +00:00
# org-mode
2019-09-17 07:09:00 +00:00
epkgs.elpaPackages.bbdb
epkgs.orgPackages.org-plus-contrib
epkgs.melpaPackages.smex
epkgs.melpaPackages.org-mime
2019-11-14 14:34:49 +00:00
epkgs.melpaPackages.orgit
epkgs.elpaPackages.which-key
];
2019-11-14 14:34:49 +00:00
emacsWithOverlay = pkgsWithOverlay.emacsWithPackagesFromUsePackage {
config = builtins.readFile dotEmacs; # builtins.readFile ./emacs.el;
# Package is optional, defaults to pkgs.emacs
package = pkgsWithOverlay.emacsGit;
# Optionally provide extra packages not in the configuration file
extraEmacsPackages = emacsPkgs;
};
2018-03-20 19:16:12 +00:00
myEmacs = pkgs.writeDashBin "my-emacs" ''
exec ${emacsWithOverlay}/bin/emacs -q -l ${dotEmacs} "$@"
2018-03-20 19:16:12 +00:00
'';
myEmacsWithDaemon = pkgs.writeDashBin "my-emacs-daemon" ''
exec ${emacsWithOverlay}/bin/emacs -q -l ${dotEmacs} --daemon
'';
myEmacsClient = pkgs.writeDashBin "meclient" ''
exec ${emacsWithOverlay}/bin/emacsclient --create-frame
'';
2018-03-20 16:38:26 +00:00
in {
environment.systemPackages = [
myEmacs myEmacsWithDaemon myEmacsClient
2018-03-20 16:38:26 +00:00
];
}