From 8041c66a7b4a43de366c6cac42292f2122ed24b0 Mon Sep 17 00:00:00 2001 From: Jonas Forsberg Date: Fri, 10 Jul 2020 10:23:39 +0200 Subject: [PATCH] VimWiki configuration --- .alias | 1 - .functions.sh | 86 +++++++++++++++++++++++---------------- .vimrc | 41 ++++++++++++++++++- salt/pillars/packages.sls | 4 ++ 4 files changed, 96 insertions(+), 36 deletions(-) diff --git a/.alias b/.alias index d502f0e..c5440ad 100644 --- a/.alias +++ b/.alias @@ -6,4 +6,3 @@ alias dotf='/usr/bin/git --git-dir=$HOME/.dotfiles --work-tree=$HOME' alias ls_dotfiels='/usr/bin/git --git-dir=$HOME/.dotfiles ls-tree --full-tree -r --name-only HEAD' alias t="todo.sh" alias gl='git log --graph --pretty=format:'\''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'' --abbrev-commit --date=relative' -alias wiki="vim ~/vimwiki/wiki.wiki" diff --git a/.functions.sh b/.functions.sh index 4edbc50..c782250 100644 --- a/.functions.sh +++ b/.functions.sh @@ -1,57 +1,57 @@ function docker(){ - sudo docker "$@" + sudo docker "$@" } function pw(){ - FILE="$1" + FILE="$1" - [[ -z "$PWHOME" ]] && printf "\$PWHOME not set\n" && return + [[ -z "$PWHOME" ]] && printf "\$PWHOME not set\n" && return - [[ -z "$FILE" ]] && FILE="web.gpg" + [[ -z "$FILE" ]] && FILE="web.gpg" - if [[ ! "${FILE: -4}" == ".gpg" ]];then - FILE="${FILE}.gpg" - fi - cd "$PWHOME" - vi "$FILE" + if [[ ! "${FILE: -4}" == ".gpg" ]];then + FILE="${FILE}.gpg" + fi + cd "$PWHOME" + vi "$FILE" - cd "$OLDPWD" + cd "$OLDPWD" } _pw_completion() { - local cur prev suggestions - [[ -z "$PWHOME" ]] && return - cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" - cd "$PWHOME" - suggestions="$(ls *.gpg)" - cd "$OLDPWD" - if [[ "$prev" != "pw" ]];then - COMPREPLY=() - else - COMPREPLY=( $(compgen -W "${suggestions}" -- ${cur}) ) - fi + local cur prev suggestions + [[ -z "$PWHOME" ]] && return + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + cd "$PWHOME" + suggestions="$(ls *.gpg)" + cd "$OLDPWD" + if [[ "$prev" != "pw" ]];then + COMPREPLY=() + else + COMPREPLY=( $(compgen -W "${suggestions}" -- ${cur}) ) + fi } complete -F _pw_completion pw function doh() { - local options - options=(start stop restart status) - if [[ ! " ${options[@]} " =~ " ${1} " ]]; then - echo "wrong option, valid: ${options[@]}" - return - fi - if [[ "$1" == "status" ]]; then - systemctl status local-doh-proxy - else - sudo systemctl "$1" local-doh-proxy - fi + local options + options=(start stop restart status) + if [[ ! " ${options[@]} " =~ " ${1} " ]]; then + echo "wrong option, valid: ${options[@]}" + return + fi + if [[ "$1" == "status" ]]; then + systemctl status local-doh-proxy + else + sudo systemctl "$1" local-doh-proxy + fi } function copy_k8s_token(){ - grep "id-token" ~/.kube/config | awk '{print $2}' | xclip -sel clip + grep "id-token" ~/.kube/config | awk '{print $2}' | xclip -sel clip } function ip_to_hex(){ @@ -62,3 +62,21 @@ function ip_to_hex(){ function salt-call(){ sudo salt-call --local "$@" } + + +function wiki(){ + local selected_wiki + selected_wiki="$1" + + case $1 in + SUSE|suse|S|s|2) + vim -c "normal 2,ww" + ;; + Private|private|p|2) + vim -c "normal 3,ww" + ;; + *) + vim -c "normal 1,ww" + ;; + esac +} diff --git a/.vimrc b/.vimrc index 8d3972f..c8081ba 100644 --- a/.vimrc +++ b/.vimrc @@ -6,6 +6,7 @@ set encoding=utf-8 set autoindent set nocompatible syntax on +let mapleader="," filetype indent plugin on @@ -15,15 +16,38 @@ set shiftwidth=4 set softtabstop=4 set expandtab +" Pathogen +execute pathogen#infect() + +" vimwiki +let wiki_1 = {} +let wiki_1.path = '~/Nextcloud/vimwiki' +let wiki_1.syntax = 'markdown' +let wiki_1.ext = '.md' +let wiki_2 = {} +let wiki_2.path = '~/Nextcloud/vimwiki/suse' +let wiki_2.syntax = 'markdown' +let wiki_2.ext = '.md' +let wiki_3 = {} +let wiki_3.path = '~/Nextcloud/vimwiki/private' +let wiki_3.syntax = 'markdown' +let wiki_3.ext = '.md' +let g:vimwiki_list = [wiki_1, wiki_2, wiki_3] + " Set to show invisibles (tabs & trailing spaces) & their highlight color set list listchars=tab:»\ ,trail:· +" Mark characters 80+ on each line with red color function! Highlight() highlight OverLength ctermbg=red ctermfg=white guibg=#592929 match OverLength /\%81v.\+/ endfunction -nnoremap _h :call Highlight() +" remaps +noremap _h :call Highlight() +nmap i**=strftime("%Y-%m-%d %H:%M:%S")** +imap **=strftime("%Y-%m-%d %H:%M:%S")** +nmap c~"~ """""""""""""""""""" " GnuPG Extensions " @@ -70,3 +94,18 @@ if has("autocmd") " Set filetype tab settings autocmd FileType python,doctest set ai ts=4 sw=4 sts=4 et endif + + +" vim-instant-markdown settings +"Uncomment to override defaults: +let g:instant_markdown_slow = 0 +let g:instant_markdown_autostart = 0 +let g:instant_markdown_open_to_the_world = 0 +let g:instant_markdown_allow_unsafe_content = 0 +let g:instant_markdown_allow_external_content = 1 +"let g:instant_markdown_mathjax = 1 +"let g:instant_markdown_browser = "firefox --new-window" +"let g:instant_markdown_logfile = '/tmp/instant_markdown.log' +"let g:instant_markdown_autoscroll = 0 +"let g:instant_markdown_port = 8888 +"let g:instant_markdown_python = 1 diff --git a/salt/pillars/packages.sls b/salt/pillars/packages.sls index 9f95f8b..3298f73 100644 --- a/salt/pillars/packages.sls +++ b/salt/pillars/packages.sls @@ -9,3 +9,7 @@ packages: go: { status: installed } nextcloud-client: { status: installed } keepassxc: { status: installed } + vim-plugin-gnupg: { status: installed } +# vim-instant-markdown + xdg-utils: { status: installed } + nodejs10 { status: installed }