summaryrefslogtreecommitdiffstats
path: root/dotfiles
diff options
context:
space:
mode:
Diffstat (limited to 'dotfiles')
-rw-r--r--dotfiles/vimrc.vim139
-rw-r--r--dotfiles/zshrc242
2 files changed, 381 insertions, 0 deletions
diff --git a/dotfiles/vimrc.vim b/dotfiles/vimrc.vim
new file mode 100644
index 0000000..a0451c6
--- /dev/null
+++ b/dotfiles/vimrc.vim
@@ -0,0 +1,139 @@
1" Some global variables are defined in ../vim.nix
2
3" Better default options {{{
4
5set undofile
6set backup
7set backupdir-=.
8
9set mouse=a
10
11set ignorecase
12set smartcase
13
14set smartindent
15set tabstop=4
16set shiftwidth=4
17
18set inccommand=split
19
20set scrolloff=1
21set sidescrolloff=5
22
23set colorcolumn=80
24set cursorline
25
26set modeline
27
28set title
29
30set wildmode=longest:full,full
31
32let g:maplocalleader = ','
33let g:mapleader = ';'
34
35" If previously opened jump to the last position in the file
36au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
37
38let &grepprg = g:ripgrep_path . ' --vimgrep $*'
39let &grepformat = '%f:%l:%c:%m,' . &grepformat
40
41let g:tex_flavor = 'latex'
42
43" }}}
44
45" Colors, Statusline, Tabline, Code display {{{
46
47set termguicolors
48let g:gruvbox_contrast_dark = 'soft'
49let g:gruvbox_italic = 1
50set background=dark
51colorscheme gruvbox
52
53" Doesn't do anything because the tabline gets overwritten by lightline
54"exe 'hi! TabLineSel guifg=' . g:dominant_color
55
56let g:lightline = {
57 \ 'colorscheme': 'gruvbox',
58 \ 'subseparator': { 'left': '|', 'right': '|' },
59 \ 'tab_linesubseparator': { 'left': '|', 'right': '|' },
60 \ }
61
62set noshowmode
63
64" Do not set "trail:-" because it messes up the highlighting
65set listchars=tab:│\ ,extends:>,precedes:<,nbsp:+
66set list
67
68set fillchars=fold:─,vert:│
69
70highlight ExtraWhitespace term=inverse cterm=inverse gui=inverse
71" Show trailing whitespace and spaces before tabs:
72autocmd Syntax * syn match ExtraWhitespace /\s\+$\| \+\ze\t/ containedin=ALL
73
74" }}}
75
76" Mappings {{{
77
78call camelcasemotion#CreateMotionMappings(g:maplocalleader)
79
80nmap =of :set <C-R>=(&formatoptions =~ "a") ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>
81
82" }}}
83
84set completefunc=syntaxcomplete#Complete
85set completeopt+=noinsert,noselect
86
87" Deoplete {{{
88
89let g:deoplete#enable_at_startup = 1
90
91" }}}
92
93" Neosnippets {{{
94
95imap <C-k> <Plug>(neosnippet_expand_or_jump)
96smap <C-k> <Plug>(neosnippet_expand_or_jump)
97xmap <C-k> <Plug>(neosnippet_expand_target)
98
99set conceallevel=2
100set concealcursor=nv
101
102" }}}
103
104" CtrlP {{{
105let g:ctrlp_user_command = g:fd_path . ' --type f --color never "" %s'
106let g:ctrlp_use_caching = 0
107" }}}
108
109" LanguageClient {{{
110let g:LanguageClient_loggingFile = stdpath('data') . '/LanguageClient.log'
111let g:LanguageClient_serverStderr = stdpath('data') . '/LanguageServer.log'
112" }}}
113
114" VimWiki {{{
115 " {'path': '~/Documents/Wiki', 'path_html': '~/Documents/Wiki/html'} \
116let g:vimwiki_list = [
117 \ {'path': '~/Documents/Wiki/personal',
118 \ 'path_html': '~/Documents/Wiki/personal/html',
119 \ 'auto_tags': 1},
120 \ {'path': '~/Documents/Wiki/science', 'path_html': '~/Documents/Wiki/science/html', 'auto_tags': 1},
121 \ {'path': '~/Documents/Wiki/work', 'path_html': '~/Documents/Wiki/work/html', 'auto_tags': 1},
122\ ]
123
124let g:vimwiki_global_ext = 0
125
126let g:vimwiki_auto_header = 1
127let g:vimwiki_hl_headers = 1
128let g:vimwiki_hl_cb_checked = 1
129let g:vimwiki_html_header_numbering = 2
130let g:vimwiki_html_header_numbering_sym = '.'
131
132let g:vimwiki_links_header_level = 2
133let g:vimwiki_tags_header_level = 2
134let g:vimwiki_toc_header_level = 2
135
136call deoplete#custom#var('omni', 'input_patterns', { 'vimwiki': '\[\[\w*|\:\w+' })
137" }}}
138
139" vim: fdm=marker
diff --git a/dotfiles/zshrc b/dotfiles/zshrc
new file mode 100644
index 0000000..1263eeb
--- /dev/null
+++ b/dotfiles/zshrc
@@ -0,0 +1,242 @@
1# Some variables are defined in ../commandline.nix
2
3# For users using home-manager
4if [ -f "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" ]; then
5 . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh"
6fi
7
8# Grml Zsh configuration {{{
9# ==========================
10
11# With prompt specific sequences
12local dominated="%{${dominant_escape_code}%}"
13local dimmed="%{${dim_fg_escape_code}%}"
14
15# Use the dominant color in the prompt
16# In the username item for non-root, in the host item for root
17if [ "$EUID" -ne 0 ]; then
18 zstyle ':prompt:grml:left:items:user' pre "${dominated}%B"
19else
20 zstyle ':prompt:grml:left:items:host' pre "${dominated}"
21 zstyle ':prompt:grml:left:items:host' post "%f"
22fi
23
24# Change the style of VCS prompt info
25zstyle ':vcs_info:*' check-for-changes true
26zstyle ':vcs_info:*' stagedstr "s"
27zstyle ':vcs_info:*' unstagedstr "u"
28zstyle ':vcs_info:*' formats "${dimmed}(%f%s${dimmed})-[${dominated}%b${dimmed}]-{%f%c%u${dimmed}}%f " "zsh: %r"
29zstyle ':vcs_info:*' actionformats "${dimmed}(%f%s${dimmed})-[${dominated}%b${dimmed}|%F{yellow}%a${dimmed}]-{%f%c%u${dimmed}}%f " "zsh: %r"
30
31# }}}
32
33# Completion system {{{
34# =====================
35
36# Change completion messages
37zstyle ':completion:*:corrections' format "${dominated}%BFTFY: %b${dominated}(errors: %e)%f"
38zstyle ':completion:*:descriptions' format "${dominated} -- So you want a %B%d%b${dominated}? --%f"
39zstyle ':completion:*:messages' format "${dominated}You got mail: %f%d"
40zstyle ':completion:*:warnings' format "%F{red}I'm sorry Dave, but I cannot allow you to find%f %d"
41
42# Always activate selection in completion
43zstyle ':completion:*' menu select
44
45# Case insensitive completion and substring completion
46zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
47
48# Increase the number of errors based on the length of the typed word. But make
49# sure to cap (at 7) the max-errors to avoid hanging.
50zstyle -e ':completion:*:approximate:*' max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3>7?7:($#PREFIX+$#SUFFIX)/3))numeric)'
51
52# Tmux Completion {{{
53# -------------------
54
55# From: https://blog.plenz.com/2012-01/zsh-complete-words-from-tmux-pane.html
56# And: https://gist.github.com/blueyed/6856354
57
58_tmux_pane_words() {
59 local expl
60 local -a w
61 if [[ -z "$TMUX_PANE" ]]; then
62 _message "not running inside tmux!"
63 return 1
64 fi
65
66 # Based on vim-tmuxcomplete's splitwords function.
67 # https://github.com/wellle/tmux-complete.vim/blob/master/sh/tmuxcomplete
68 _tmux_capture_pane() {
69 tmux capture-pane -J -p -S -100 $@ |
70 # Remove "^C".
71 sed 's/\^C\S*/ /g' |
72 # copy lines and split words
73 sed -e 'p;s/[^a-zA-Z0-9_]/ /g' |
74 # split on spaces
75 tr -s '[:space:]' '\n' |
76 # remove surrounding non-word characters
77 =grep -o "\w.*\w"
78 }
79 # Capture current pane first.
80 w=( ${(u)=$(_tmux_capture_pane)} )
81 echo $w > /tmp/w1
82 local i
83 for i in $(tmux list-panes -F '#D'); do
84 # Skip current pane (handled before).
85 [[ "$TMUX_PANE" = "$i" ]] && continue
86 w+=( ${(u)=$(_tmux_capture_pane -t $i)} )
87 done
88 _wanted values expl 'word from current tmux pane' compadd -a w
89}
90
91zle -C tmux-pane-words-prefix complete-word _generic
92zle -C tmux-pane-words-anywhere complete-word _generic
93
94zstyle ':completion:tmux-pane-words-(prefix|anywhere):*' completer _tmux_pane_words
95zstyle ':completion:tmux-pane-words-(prefix|anywhere):*' ignore-line current
96# Display the menu on first execution of the hotkey.
97zstyle ':completion:tmux-pane-words-(prefix|anywhere):*' menu yes select
98zstyle ':completion:tmux-pane-words-anywhere:*' matcher-list 'b:=* m:{A-Za-z}={a-zA-Z}'
99
100# }}}
101
102# }}}
103
104# Bindkeys {{{
105# ============
106
107bindkey -v
108
109bindkey '^X^T' tmux-pane-words-prefix
110
111bindkey '^[[A' history-substring-search-up
112bindkey '^[[B' history-substring-search-down
113bindkey '^[OA' history-substring-search-up
114bindkey '^[OB' history-substring-search-down
115
116# }}}
117
118# Aliases {{{
119# ===========
120
121# Some aliases taken from the Prezo zsh configuration framework:
122# https://github.com/sorin-ionescu/prezto
123
124# Git {{{
125# -------
126
127alias g='git'
128
129# Branch (b)
130alias gb='git branch'
131
132# Commit (c)
133alias gc='git commit --verbose'
134alias gca='git commit --verbose --all'
135alias gcf='git commit --amend --reuse-message HEAD'
136alias gcs='git show'
137
138alias gco='git checkout'
139alias gcO='git checkout --patch'
140
141# Fetch (f)
142alias gf='git fetch'
143alias gfm='git pull'
144alias gfc='git clone'
145alias gfcr='git clone --recurse-submodules'
146
147# Index (i)
148alias gia='git add'
149alias giA='git add --patch'
150alias gid='git diff --cached'
151alias giD='git diff --cached --word-diff'
152
153# Log (l)
154logMediumFormat='%C(bold)Commit:%C(reset) %C(green)%H%C(red)%d%n%C(bold)Author:%C(reset) %C(cyan)%an <%ae>%n%C(bold)Date:%C(reset) %C(blue)%ai (%ar)%C(reset)%n%+B'
155logBriefFormat='%C(green)%h%C(reset) %s%n%C(blue)(%ar by %an)%C(red)%d%C(reset)%n'
156logOnelineFormat='%C(green)%h%C(reset) %s%C(red)%d%C(reset)%n'
157
158alias gl='git log --topo-order --pretty=format:"${logMediumFormat}"'
159alias gls='git log --topo-order --stat --pretty=format:"${logMediumFormat}"'
160alias gld='git log --topo-order --stat --patch --full-diff --pretty=format:"${logMediumFormat}"'
161alias glg='git log --topo-order --all --graph --pretty=format:"${logOnelineFormat}"'
162alias glo='git log --topo-order --pretty=format:"${logOnelineFormat}"'
163alias glb='git log --topo-order --pretty=format:"${logBriefFormat}"'
164alias glc='git shortlog --summary --numbered'
165
166# Merge (m)
167alias gm='git merge'
168alias gmt='git mergetool'
169
170# Push (p)
171alias gp='git push'
172alias gpf='git push --force-with-lease'
173alias gpt='git push --tags'
174
175# Rebase (r)
176alias gr='git rebase'
177
178# Stash (s)
179alias gs='git stash'
180
181# Working Copy (w)
182alias gws='git status --ignore-submodules=none'
183alias gwd='git diff'
184alias gwD='git diff --word-diff'
185
186# }}}
187
188# Prevents some mistakes
189alias cp='cp -i'
190alias mv='mv -i'
191alias rm='rm -i'
192
193# }}}
194
195# Helpful functions {{{
196# =====================
197
198function ssht
199{
200 /usr/bin/env ssh -t "$@" "tmux new-session -A -s 'ssh-$HOST'"
201}
202
203compdef ssht=ssh
204
205# }}}
206
207# Abbreviations {{{
208# =================
209
210# Abbreviation system provided by the grml config
211# More info here:
212# http://www.zshwiki.org/home/examples/zleiab
213
214abk=(
215 'P' '|& ${(z)PAGER}'
216 'L' '|& ${(z)PAGER}'
217
218 'HL' ' --help |& ${(z)PAGER}'
219
220 'G' '|& rg'
221 'FG' '|& rg -F'
222
223 'H' '| head'
224 'T' '| tail'
225 'C' '| wc -l'
226)
227
228# }}}
229
230# GPG / SSH agents {{{
231# ====================
232
233#function _gpg-agent-update-tty
234#{
235# gpg-connect-agent UPDATESTARTUPTTY /bye >/dev/null
236#}
237#
238#add-zsh-hook preexec _gpg-agent-update-tty
239
240# }}}
241
242# vim: fdm=marker