Compare commits

..

12 Commits

15 changed files with 164 additions and 62 deletions

View File

@ -8,7 +8,7 @@ alias al-=unalias
# Edit configuration files # Edit configuration files
alias eba="nvim ~/.bashrc" alias eba="nvim ~/.bashrc"
alias eal="nvim ~/.bash_aliasrc" alias eal="nvim ~/.bash_aliasrc"
alias ev="nvim ~/.vimrc" alias ev="edit_editor_config"
# Navigation # Navigation
alias ..="cd .." alias ..="cd .."

38
.bashrc
View File

@ -4,36 +4,18 @@
source /etc/os-release source /etc/os-release
# Aliases {{{ # Editor & prompt configuration
[ -f "$HOME/.bashrc.d/editor" ] && source "$HOME/.bashrc.d/editor"
[ -f "$HOME/.bashrc.d/prompt" ] && source "$HOME/.bashrc.d/prompt"
# Load aliases dynamically # Load aliases dynamically
[ -f "$HOME/.bash_aliases/all" ] && source "$HOME/.bash_aliases/all" [ -f "$HOME/.bash_aliases/all" ] && source "$HOME/.bash_aliases/all"
[ -f "$HOME/.bash_aliases/$HOSTNAME" ] && source "$HOME/.bash_aliases/$HOSTNAME" [ -f "$HOME/.bash_aliases/hosts/$HOSTNAME" ] && source "$HOME/.bash_aliases/hosts/$HOSTNAME"
[ -f "$HOME/.bash_aliases/private" ] && source "$HOME/.bash_aliases/private" [ -f "$HOME/.bash_aliases/private" ] && source "$HOME/.bash_aliases/private"
# }}}
# Dynamic configuration {{{ # Host-specific and private configurations
[ -f "$HOME/.bashrc.d/$HOSTNAME" ] && source "$HOME/.bashrc.d/$HOSTNAME" [ -f "$HOME/.bashrc.d/hosts/$HOSTNAME" ] && source "$HOME/.bashrc.d/hosts/$HOSTNAME"
[ -f "$HOME/.bashrc.d/private" ] && source "$HOME/.bashrc.d/private" [ -f "$HOME/.bashrc.d/private" ] && source "$HOME/.bashrc.d/private"
# }}}
# Prompt {{{
get_branch_name() {
git symbolic-ref --quiet --short HEAD 2>/dev/null \
|| git rev-parse --short HEAD 2>/dev/null \
|| echo 'some branch'
}
get_git_info() {
git rev-parse --is-inside-work-tree &>/dev/null || return
echo -e "$(get_branch_name)"
}
PS1="\u \w ❭\[$(tput sgr0)\] "
# Ellipsis when deep in directory
export PROMPT_DIRTRIM=2
export PS1
# }}}
# Path {{{ # Path {{{
# Add ~/.bin to PATH # Add ~/.bin to PATH
@ -53,12 +35,6 @@ export MANWIDTH=80
export PAGER=nvimpager export PAGER=nvimpager
# }}} # }}}
# Editor {{{
# Set vim as default editor
export EDITOR=nvim
export SUDO_EDITOR=nvim
# }}}
# Nvm # Nvm
export PATH=~/.nvm/versions/node/v14.16.0/bin:$PATH export PATH=~/.nvm/versions/node/v14.16.0/bin:$PATH
export NVM_DIR="$HOME/.nvm" export NVM_DIR="$HOME/.nvm"

18
.bashrc.d/editor Normal file
View File

@ -0,0 +1,18 @@
# vim: set ft=bash :
# Set NeoVim as default editor
export EDITOR=nvim
export SUDO_EDITOR="$EDITOR"
declare -A -r EDITOR_CONFIGS=(
["nvim"]="$HOME/.config/nvim/init.lua"
["vim"]="$HOME/.vimrc"
)
edit_editor_config() {
for editor in "${!EDITOR_CONFIGS[@]}"; do
if [ "$EDITOR" = "$editor" ]; then
$EDITOR "${EDITOR_CONFIGS[$editor]}"
fi
done
}

View File

@ -1 +0,0 @@
# Laptop configuration

18
.bashrc.d/hosts/flex-arch Normal file
View File

@ -0,0 +1,18 @@
# Laptop configuration
# >>> mamba initialize >>>
# !! Contents within this block are managed by 'mamba init' !!
export MAMBA_EXE="/usr/bin/micromamba";
export MAMBA_ROOT_PREFIX="/home/h/.local/share/micromamba";
__mamba_setup="$("$MAMBA_EXE" shell hook --shell bash --prefix "$MAMBA_ROOT_PREFIX" 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__mamba_setup"
else
if [ -f "/home/h/.local/share/micromamba/etc/profile.d/micromamba.sh" ]; then
. "/home/h/.local/share/micromamba/etc/profile.d/micromamba.sh"
else
export PATH="/home/h/.local/share/micromamba/bin:$PATH" # extra space after export prevents interference from conda init
fi
fi
unset __mamba_setup
# <<< mamba initialize <<<

20
.bashrc.d/prompt Normal file
View File

@ -0,0 +1,20 @@
# vim: set ft=bash :
get_branch_name() {
git symbolic-ref --quiet --short HEAD 2>/dev/null \
|| git rev-parse --short HEAD 2>/dev/null \
|| echo 'some branch'
}
get_git_info() {
git rev-parse --is-inside-work-tree &>/dev/null || return
echo -e "($(get_branch_name))"
}
if [[ $SSH_CONNECTION ]]; then
PS1='\[\033[01;31m\]\u@\h\[\033[00m\] $(get_git_info)\W❭\[$(tput sgr0)\] '
else
PS1='\u $(get_git_info)\W❭\[$(tput sgr0)\] '
fi
# Ellipsis when deep in directory
export PROMPT_DIRTRIM=2
export PS1

View File

@ -1,4 +0,0 @@
let g:copilot_no_tab_map = v:true
imap <c-l> <plug>(copilot-next)
imap <c-h> <plug>(copilot-prev)
imap <silent><script><expr> <s-tab> copilot#Accept("\<CR>")

View File

@ -0,0 +1,5 @@
highlight QuickScopePrimary gui=underline cterm=underline
highlight QuickScopeSecondary gui=underline cterm=underline
let g:qs_max_chars=80
let g:qs_lazy_highlight = 1

View File

@ -1,2 +0,0 @@
let g:qs_max_chars=80
let g:qs_lazy_highlight = 1

View File

@ -11,34 +11,98 @@ nm <leader>ww <plug>(wiki-index)
" nm <leader>v <plug>(wiki-link-follow-vsplit) " nm <leader>v <plug>(wiki-link-follow-vsplit)
autocmd BufEnter *.md if expand('%:t') =~ '_' | echo 'hierarchical relation' | endif autocmd BufEnter *.md if expand('%:t') =~ '_' | echo 'hierarchical relation' | endif
autocmd BufEnter *.md if expand('%:t') =~ '--' | echo 'non-hierarchical relation' | endif autocmd BufEnter *.md if expand('%:t') =~ '--' | echo 'relation' | endif
autocmd BufEnter *.md if expand('%:t') =~ '<>' | echo 'dichotomy' | endif autocmd BufEnter *.md if expand('%:t') =~ '<>' | echo 'dichotomy' | endif
autocmd BufEnter *.md if expand('%:t') =~ 'my-' | echo 'personal file' | endif autocmd BufEnter *.md if expand('%:t') =~ 'my-' | echo 'personal file' | endif
autocmd BufEnter *.md if expand('%:t') =~ 'project-' | echo 'project file' | endif
autocmd BufEnter *.md if expand('%:t') =~ 'project_' | echo 'project file' | endif autocmd BufEnter *.md if expand('%:t') =~ 'project_' | echo 'project file' | endif
" Only load wiki.vim for zk directory " Only load wiki.vim for zk directory
let g:wiki_global_load=0
let g:wiki_root='~/.zk'
let g:wiki_index_name='index' let g:wiki_index_name='index'
let g:wiki_zotero_root='~/doc/Zotero'
let g:wiki_filetypes=['md']
let g:wiki_completion_case_sensitive=0
" Links " Links
let g:wiki_link_extension='' let g:wiki_link_extension=''
" Do not automatically transform to link, use `<leader>wf` for this " Do not automatically transform to link, use `<leader>wf` for this
let g:wiki_link_toggle_on_follow=0
let g:wiki_link_target_type='md' let g:wiki_link_target_type='md'
" E.g. transform `My link` into `[My link](my-link.md)`
function Slugify(text) abort
return [substitute(tolower(a:text), '\s\+', '-', 'g'), a:text]
endfunction
let g:wiki_map_text_to_link='Slugify'
vmap <leader>wf <plug>(wiki-link-toggle-visual) vmap <leader>wf <plug>(wiki-link-toggle-visual)
" Automatically save when navigation "
" Links
"
"
" Options
"
"
" Events
"
"
" Mappings and commands
"
"
" Completion
"
let g:wiki_completion_enabled=1
let g:wiki_completion_case_sensitive=0
"
" Tags
"
"
" Templates
"
let g:wiki_templates = [
\ { 'match_re': '^my-',
\ 'source_filename': '.my.md'},
\ { 'match_re': '^project[-_]',
\ 'source_filename': '.project.md'},
\ { 'match_re': '^blog[-_]',
\ 'source_filename': '.blog.md'},
\ { 'match_re': '^journal[-_]',
\ 'source_filename': '.journal.md'},
\ { 'match_func': { x -> v:true },
\ 'source_filename': '.md'},
\]
"
" Advanced configuration
"
let g:wiki_filetypes=['md']
let g:wiki_root='~/.zk'
let g:wiki_global_load=0
let g:wiki_link_creation = {
\ 'md': {
\ 'link_type': 'md',
\ 'url_extension': '',
\ 'url_transform': { x -> substitute(tolower(x), '\s\+', '-', 'g') },
\ },
\ '_': {
\ 'link_type': 'wiki',
\ 'url_extension': '',
\ },
\}
" let g:wiki_link_default_schemes
" let g:wiki_link_schemes
let g:wiki_link_toggle_on_follow=0
" let g:wiki_link_transforms
" let g:wiki_mappings_use_defaults
" let g:wiki_mappings_global
" let g:wiki_mappings_local
" let g:wiki_mappings_local_journal
" ... tags
" let g:wiki_template_month_names
" let g:wiki_template_title_month =
" let g:wiki_template_title_week
" let g:wiki_ui_method
let g:wiki_write_on_nav=1 let g:wiki_write_on_nav=1
let g:wiki_zotero_root='~/.local/share/zotero'
" ... mappings and commands
" ...

View File

@ -5,6 +5,9 @@ hi! link pandocCiteKey Comment
hi! link pandocCiteAnchor Comment hi! link pandocCiteAnchor Comment
hi! link pandocCiteLocator Comment hi! link pandocCiteLocator Comment
" Don't show the CiteKey within the CiteLocator
syn match pandocCiteKey /\v\[[^]]+\]/ contained
" Match cloze delimiters e.g. `{{c1::` and `}}` " Match cloze delimiters e.g. `{{c1::` and `}}`
syn match ClozeDelimiter /{{c\d\+::/ conceal containedin=pandocUListItem,pandocListItem syn match ClozeDelimiter /{{c\d\+::/ conceal containedin=pandocUListItem,pandocListItem
syn match ClozeDelimiter /}}/ conceal containedin=pandocUListItem,pandocListItem syn match ClozeDelimiter /}}/ conceal containedin=pandocUListItem,pandocListItem

View File

@ -10,9 +10,16 @@ func! GetContext()
echo 'math_inline' echo 'math_inline'
elseif index(matches, 'pandocLaTeXMathBlock') >= 0 elseif index(matches, 'pandocLaTeXMathBlock') >= 0
echo 'math_block' echo 'math_block'
elseif !empty(matches)
echo matches[0]
else else
echo '' echo ''
endif endif
endfunc endfunc
com! -nargs=0 GetContext :call GetContext() com! -nargs=0 GetContext :call GetContext()
function! Put(str)
put = a:str
endfunction
com! -nargs=0 AnkiDeck call fzf#run(fzf#wrap({'source': 'get-anki-decks', 'sink': function('Put')}))

View File

@ -6,11 +6,11 @@ let maplocalleader = ";"
nm s <c-w> " Split horizontal nm s <c-w> " Split horizontal
nm ss :sp<CR><c-w>w| " Split horizontal nm ss :sp<CR><c-w>w| " Split horizontal
nm sv :vs<CR><c-w>w| " Split vertical nm sv :vs<CR><c-w>w| " Split vertical
nn sw <c-w>w| " Navigate splits nm sw <c-w>w| " Navigate splits
nn sh <c-w>h| " nm sh <c-w>h| "
nn sj <c-w>j| " nm sj <c-w>j| "
nn sk <c-w>k| " nm sk <c-w>k| "
nn sl <c-w>l| " nm sl <c-w>l| "
nn sH <c-w>8<| " Resize splits nn sH <c-w>8<| " Resize splits
nn sJ <c-w>8-| " nn sJ <c-w>8-| "
nn sK <c-w>8+| " nn sK <c-w>8+| "

View File

@ -5,10 +5,8 @@
call plug#begin() call plug#begin()
Plug 'unblevable/quick-scope' Plug 'unblevable/quick-scope'
Plug 'tpope/vim-commentary' Plug 'tpope/vim-commentary'
Plug 'tpope/vim-obsession'
Plug 'machakann/vim-sandwich' Plug 'machakann/vim-sandwich'
Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'github/copilot.vim'
Plug 'Shougo/context_filetype.vim' Plug 'Shougo/context_filetype.vim'
Plug 'editorconfig/editorconfig-vim' Plug 'editorconfig/editorconfig-vim'
Plug 'honza/vim-snippets' Plug 'honza/vim-snippets'