Add emacs

This commit is contained in:
Marco Thomas
2021-03-02 20:28:21 +01:00
parent a20bbb0dbc
commit 7e4c400469
7 changed files with 436 additions and 10 deletions

View File

@@ -12,7 +12,7 @@
+ WM: i3
## Programs
+ Editor: nvim
+ Editor: emacs / nvim
+ File-Browser: ranger
+ Image-Viewer: sxiv
+ Info: neofetch

View File

@@ -83,7 +83,7 @@
# Set to 0 to disable.
# A client can set the 'transient' hint to bypass this. See the rules
# section for how to disable this if necessary
idle_threshold = 0
idle_threshold = 10
### Text ###

View File

@@ -16,13 +16,6 @@ shadow-exclude = [
"class_g *?= 'i3-frame'",
]
corner-radius = 12
rounded-corners-exclude = [
"class_g *?= 'polybar'",
"class_g *?= 'dmenu'",
"class_g *?= 'i3-frame'",
]
#backend = "glx";
#blur: {
# method: "dual_kawase";

View File

@@ -38,6 +38,7 @@ export EDITOR="nvim"
export VISUAL="nvim"
export LANG="en_US.UTF-8"
export PATH=$PATH:$HOME/.local/bin:$HOME/scripts:$HOME/.cargo/bin
[ -f "/home/marc/.ghcup/env" ] && source "/home/marc/.ghcup/env" # Haskell
export GTK_IM_MODULE='fcitx'
export QT_IM_MODULE='fcitx'
@@ -53,6 +54,8 @@ if [[ -x $(which nvim 2> /dev/null) ]]; then
alias vim="nvim"
fi
alias emacs="emacs -nw"
if [[ -x $(which swallow 2> /dev/null) ]]; then
alias zathura="swallow zathura"
fi
@@ -151,7 +154,7 @@ export FZF_DEFAULT_OPTS='--preview="head {}" --layout=reverse --bind=tab:down --
## fzf Bindings in zsh (C-r and C-t)
if [[ -x $(which fzf 2> /dev/null) ]]
then
source ~/.vim/plugged/fzf/shell/key-bindings.zsh
source ~/scripts/key-bindings.zsh
else
bindkey '^R' history-incremental-search-backward
fi

299
files/init.el Normal file
View File

@@ -0,0 +1,299 @@
(setq make-backup-files nil) ;; We dont need these
(setq auto-save-default nil) ;; Not this one either
(menu-bar-mode -1) ;; The menu bar looks ugly in terminal
(tool-bar-mode -1) ;; Nobody needs this
(toggle-scroll-bar -1) ;; Or this
(setq inhibit-startup-screen t) ;; Leave me alone with your tutorials
(setq tramp-default-method "ssh") ;; speed up tramp mode
(set-face-attribute 'default nil :font "FiraCode Nerd Font Mono" :height 100) ;; Set font size
;; Make ESC quit prompts
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
;; Relative line numbers
(setq-default display-line-numbers 'visual
display-line-numbers-widen t
;; this is the default
display-line-numbers-current-absolute t)
(defun noct:relative ()
(setq-local display-line-numbers 'visual))
(defun noct:absolute ()
(setq-local display-line-numbers t))
(add-hook 'evil-insert-state-entry-hook #'noct:absolute)
(add-hook 'evil-insert-state-exit-hook #'noct:relative)
;; Show trailing whitespaces
(setq-default show-trailing-whitespace t)
(require 'package)
(setq package-enable-at-startup nil)
(setq package-archives '(("org" . "http://orgmode.org/elpa/")
("melpa" . "https://melpa.org/packages/")
("elpa" . "http://elpa.gnu.org/packages/")
))
(package-initialize)
;; Bootstrap `use-package'
(unless (package-installed-p 'use-package) ; unless it is already installed
(package-refresh-contents) ; updage packages archive
(package-install 'use-package)) ; and install the most recent version of use-package
(eval-when-compile
(require 'use-package))
;; General things
;; Themes and icons
(use-package doom-themes
:ensure t
:init
(load-theme 'doom-vibrant t))
(use-package doom-modeline
:ensure t
:init (doom-modeline-mode 1)
:custom ((doom-modeline-height 10)))
(use-package all-the-icons
:ensure t)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages
'(lsp-haskell haskell-mode lsp-java auctex rust-mode flycheck yasnippet counsel-projectile projectile company-box company lsp-ivy lsp-ui lsp-mode magit counsel evil-collection evil which-key general all-the-icons doom-themes use-package)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;; auto indent change like vim sleuth
(use-package dtrt-indent
:ensure t
:hook
(prog-mode . dtrt-indent-mode)
(markdown-mode . dtrt-indent-mode))
;; auto parens
(use-package smartparens
:ensure t
:diminish smartparens-mode
:config
(require 'smartparens-config)
(setq sp-highlight-pair-overlay nil) ;; to hide this fucking highlighting
:hook
(prog-mode . smartparens-mode)
(markdown-mode . smartparens-mode))
;; general
(use-package general
:ensure t
:init
;; Space as leader key
(general-create-definer vim-leader-def :prefix "SPC"))
;; help to find keybindings
(use-package which-key
:ensure t
:init (which-key-mode)
:diminish which-key-mode
:config
(setq which-key-idle-delay 1))
;; vim mode
(use-package evil
:ensure t
:init
(setq evil-toggle-key "C-~") ;; so C-z works for background
(setq evil-want-C-d-scroll t)
(setq evil-want-C-u-scroll t)
(setq evil-want-integration t)
(setq evil-want-keybinding nil)
:config
(evil-mode))
(use-package evil-collection
:after evil
:ensure t
:config
(evil-collection-init))
;; completion
(use-package ivy
:ensure t
:diminish
:bind (("C-s" . swiper) ; TODO: possibly map this to / at some point?
:map ivy-minibuffer-map
("TAB" . ivy-alt-done)
("C-l" . ivy-alt-done)
("C-j" . ivy-next-line)
("C-k" . ivy-previous-line)
:map ivy-switch-buffer-map
("C-k" . ivy-previous-line)
("C-l" . ivy-done)
("C-d" . ivy-switch-buffer-kill)
:map ivy-reverse-i-search-map
("C-k" . ivy-previous-line)
("C-d" . Ivy-reverse-i-search-kill))
:config
(ivy-mode 1))
(use-package counsel
:ensure t
:bind (("M-x" . counsel-M-x)
("C-x b" . counsel-ibuffer)
("C-x C-f" . counsel-find-file)
:map minibuffer-local-map
("C-r" . 'counsel-minibuffer-history)))
;; Development
;; giiiiiiiiit
(use-package magit
:ensure t
:general
(vim-leader-def 'normal 'global
"gj" 'magit-blame
"gs" 'magit-status
"gl" 'magit-log
"gc" 'magit-checkout
"gb" 'magit-branch))
;; lsp
(use-package lsp-mode
:ensure t
:commands (lsp lsp-deferred)
:init
(setq lsp-keymap-prefix "C-l")
(setq gc-cons-threshold 100000000) ;; 100 mb
(setq read-process-output-max (* 1024 1024)) ;; 1mb
:config
(lsp-enable-which-key-integration t)
(setq lsp-rust-server 'rust-analyzer)
(setq lsp-auto-guess-root t)
(setq lsp-idle-delay 1.)
:hook
(rust-mode . lsp)
(java-mode . lsp)
(python-mode . lsp))
(use-package lsp-ui
:ensure t
:config
(setq lsp-ui-peek-enable nil)
(setq lsp-ui-sideline-show-code-actions nil)
(setq lsp-modeline-code-actions-enable nil)
(setq lsp-ui-doc-enable nil))
;; tags
(use-package lsp-ivy
:ensure t
:after lsp-mode
:bind(:map lsp-mode-map ("C-l g a" . lsp-ivy-workspace-symbol)))
;; completion for lsp
(use-package company
:ensure t
:hook
(lsp-mode . company-mode)
(prog-mode . company-mode)
(LaTeX-mode . company-mode)
:custom
(company-minimum-prefix-length 2)
(company-idle-delay 0.4)
:bind (:map company-active-map
("C-j" . company-select-next-or-abort) ;; down
("C-k" . company-select-previous-or-abort) ;; up
("C-l" . company-complete-selection) ;; right, as in complete towards the right
))
;; frontend for company
(use-package company-box
:ensure t
:hook (company-mode . company-box-mode))
;; for lsp workspaces
(use-package projectile
:ensure t
:config
(setq projectile-completion-system 'ivy)
(projectile-mode +1))
(use-package counsel-projectile
:ensure t
:init
(define-key projectile-mode-map (kbd "M-p") 'projectile-command-map))
;; snippet support
(defun company-mode/backend-with-yas (backend)
(if (and (listp backend) (member 'company-yasnippet backend))
backend
(append (if (consp backend) backend (list backend))
'(:with company-yasnippet))))
(defun company-mode/add-yasnippet ()
(setq company-backends (mapcar #'company-mode/backend-with-yas company-backends)))
(use-package yasnippet
:ensure t
:init
:hook
(company-mode . yas-minor-mode)
(company-mode . company-mode/add-yasnippet))
;; compiling for lsp
(use-package flycheck
:ensure t)
;; rust
(use-package rust-mode
:ensure t
:hook
(rust-mode . prettify-symbols-mode)
(rust-mode . (lambda ()
(push '("->" . ?→) prettify-symbols-alist)
(push '("=>" . ?⇒) prettify-symbols-alist)
(push '("!=" . ?≠) prettify-symbols-alist)
(push '("<=" . ?≤) prettify-symbols-alist)
(push '(">=" . ?≥) prettify-symbols-alist))))
;; LaTeX
(use-package auctex
:ensure t
:defer t
:init
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq preview-scale-function 1.5))
;; Java
(use-package lsp-java
:ensure t
:config
(setq lsp-java-format-on-type-enabled nil))
(add-hook 'java-mode-hook 'prettify-symbols-mode)
(add-hook 'java-mode-hook (lambda ()
(push '("!=" . ?≠) prettify-symbols-alist)
(push '("<=" . ?≤) prettify-symbols-alist)
(push '(">=" . ?≥) prettify-symbols-alist)))
;; Haskell
(use-package haskell-mode
:ensure t
:hook
(haskell-mode . interactive-haskell-mode))
(use-package lsp-haskell
:ensure t
:hook
(haskell-mode . lsp)
(haskell-literate-mode . lsp))

View File

@@ -9,6 +9,10 @@ path=$(pwd)
rm -rf $HOME/scripts
ln -sf $path/scripts $HOME/scripts
# emacs
mkdir -p $HOME/.emacs.d
ln -sf $path/init.el $HOME/.emacs.d/init.el
# Home directory
home_files=".bashrc .dir_colors .gitconfig .tmux.conf .vimrc .Xresources .zshrc .zsh-highlighting"
for file in $home_files

View File

@@ -0,0 +1,127 @@
# ____ ____
# / __/___ / __/
# / /_/_ / / /_
# / __/ / /_/ __/
# /_/ /___/_/ key-bindings.zsh
#
# - $FZF_TMUX_OPTS
# - $FZF_CTRL_T_COMMAND
# - $FZF_CTRL_T_OPTS
# - $FZF_CTRL_R_OPTS
# - $FZF_ALT_C_COMMAND
# - $FZF_ALT_C_OPTS
# Key bindings
# ------------
# The code at the top and the bottom of this file is the same as in completion.zsh.
# Refer to that file for explanation.
if 'zmodload' 'zsh/parameter' 2>'/dev/null' && (( ${+options} )); then
__fzf_key_bindings_options="options=(${(j: :)${(kv)options[@]}})"
else
() {
__fzf_key_bindings_options="setopt"
'local' '__fzf_opt'
for __fzf_opt in "${(@)${(@f)$(set -o)}%% *}"; do
if [[ -o "$__fzf_opt" ]]; then
__fzf_key_bindings_options+=" -o $__fzf_opt"
else
__fzf_key_bindings_options+=" +o $__fzf_opt"
fi
done
}
fi
'emulate' 'zsh' '-o' 'no_aliases'
{
[[ -o interactive ]] || return 0
# CTRL-T - Paste the selected file path(s) into the command line
__fsel() {
local cmd="${FZF_CTRL_T_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
-o -type f -print \
-o -type d -print \
-o -type l -print 2> /dev/null | cut -b3-"}"
setopt localoptions pipefail no_aliases 2> /dev/null
eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS" $(__fzfcmd) -m "$@" | while read item; do
echo -n "${(q)item} "
done
local ret=$?
echo
return $ret
}
__fzfcmd() {
[ -n "$TMUX_PANE" ] && { [ "${FZF_TMUX:-0}" != 0 ] || [ -n "$FZF_TMUX_OPTS" ]; } &&
echo "fzf-tmux ${FZF_TMUX_OPTS:--d${FZF_TMUX_HEIGHT:-40%}} -- " || echo "fzf"
}
fzf-file-widget() {
LBUFFER="${LBUFFER}$(__fsel)"
local ret=$?
zle reset-prompt
return $ret
}
zle -N fzf-file-widget
bindkey '^T' fzf-file-widget
# Ensure precmds are run after cd
fzf-redraw-prompt() {
local precmd
for precmd in $precmd_functions; do
$precmd
done
zle reset-prompt
}
zle -N fzf-redraw-prompt
# ALT-C - cd into the selected directory
fzf-cd-widget() {
local cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
-o -type d -print 2> /dev/null | cut -b3-"}"
setopt localoptions pipefail no_aliases 2> /dev/null
local dir="$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m)"
if [[ -z "$dir" ]]; then
zle redisplay
return 0
fi
if [ -z "$BUFFER" ]; then
BUFFER="cd ${(q)dir}"
zle accept-line
else
print -sr "cd ${(q)dir}"
cd "$dir"
fi
local ret=$?
unset dir # ensure this doesn't end up appearing in prompt expansion
zle fzf-redraw-prompt
return $ret
}
zle -N fzf-cd-widget
bindkey '\ec' fzf-cd-widget
# CTRL-R - Paste the selected command from history into the command line
fzf-history-widget() {
local selected num
setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases 2> /dev/null
selected=( $(fc -rl 1 | perl -ne 'print if !$seen{(/^\s*[0-9]+\**\s+(.*)/, $1)}++' |
FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS --query=${(qqq)LBUFFER} +m" $(__fzfcmd)) )
local ret=$?
if [ -n "$selected" ]; then
num=$selected[1]
if [ -n "$num" ]; then
zle vi-fetch-history -n $num
fi
fi
zle reset-prompt
return $ret
}
zle -N fzf-history-widget
bindkey '^R' fzf-history-widget
} always {
eval $__fzf_key_bindings_options
'unset' '__fzf_key_bindings_options'
}