dotfiles

Cross platform dotfiles for linux, mac and windows
git clone git@getsh.org:dotfiles.git
Log | Files | Refs

commit 1a11bf9f1c74839e1b3e740065f96930995e5362
parent 3140c3fd7ecb976b34c2084e725811eeba2e332f
Author: Bharatvaj <bharatvaj@yahoo.com>
Date:   Thu, 31 Aug 2023 14:27:37 +0530

Merge branch 'main' of https://github.com/bharatvaj/dotfiles

Diffstat:
M.bash_profile | 4+++-
M.config/.gitignore | 2--
M.config/alacritty/alacritty.yml | 8+-------
D.config/alacritty/bindings.yml | 2--
D.config/bash/aliases | 4----
D.config/bash/bashrc | 9---------
D.config/bash/plugin/shorthand | 9---------
M.config/git/config | 13+++++++++----
R.gitignore -> .config/git/ignore | 0
A.config/git/template/hooks/ctags | 5+++++
A.config/git/template/hooks/post-checkout | 2++
A.config/git/template/hooks/post-commit | 2++
A.config/git/template/hooks/post-merge | 2++
A.config/git/template/hooks/post-rewrite | 4++++
A.config/mac/.cache/alacritty_unstaged.yml | 8++++++++
A.config/mac/hard.sh | 11+++++++++++
M.config/nvim/init.lua | 43+++++++++++++++++++++----------------------
M.config/nvim/lua/keybindings.lua | 133+------------------------------------------------------------------------------
M.config/sh/aliases | 21++++++++++++---------
M.config/sh/functions | 99+++++++++++++++++++++++++++++++++++++++++++++++++------------------------------
M.config/user-dirs.dirs | 16++++++++--------
D.config/vim/keybindings.vim | 125-------------------------------------------------------------------------------
D.config/vim/plugin/plugin.vim | 65-----------------------------------------------------------------
D.config/vim/vimrc | 111-------------------------------------------------------------------------------
D.gitmodules | 12------------
M.local/bin/sh/cam | 2+-
M.local/bin/sh/ci | 2+-
A.local/bin/sh/extract.sh | 26++++++++++++++++++++++++++
M.local/bin/sh/irc | 10+++++++---
M.local/bin/sh/pofs | 2+-
A.local/run/.gitkeep | 0
D.local/share/nvim/pack/general/start/nvim-comment | 1-
M.local/share/vim/hyper-red.vim | 19+++++++++++++++----
M.local/share/vim/plugins | 59++++++++++++++++++++++++++++++++++++-----------------------
M.local/share/vim/vimrc | 3+++
M.profile | 91+++++++++++++++++++++++++++++++++++++++++--------------------------------------
A.vimrc | 244+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
37 files changed, 532 insertions(+), 637 deletions(-)

diff --git a/.bash_profile b/.bash_profile @@ -1,4 +1,6 @@ [ -n "$1" ] && XDG_ROOT="$1" || XDG_ROOT="$HOME" [ -f "${XDG_ROOT}"/.profile ] && . "${XDG_ROOT}"/.profile -[ -f "${XDG_CONFIG_HOME}"/bash/bashrc ] && . "${XDG_CONFIG_HOME}"/bash/bashrc +set -o vi +PS1='\w> ' +[ -f "$XDG_CONFIG_HOME/bash_unstaged" ] && . "$XDG_CONFIG_HOME/bash_unstaged" diff --git a/.config/.gitignore b/.config/.gitignore @@ -8,8 +8,6 @@ !X11/xinitrc !alacritty/ !alacritty/** -!bash/ -!bash/bashrc !clink !clink/clink_settings !cmd/ diff --git a/.config/alacritty/alacritty.yml b/.config/alacritty/alacritty.yml @@ -1,8 +1,5 @@ import: - - ~/.config/alacritty/mac.yml - - ~/.config/alacritty/windows.yml - - ~/.config/alacritty/bindings.yml - - ~/.config/alacritty/unstaged.yml + - ~/.cache/alacritty_unstaged.yml live_config_reload: true @@ -12,6 +9,3 @@ bell: selection: save_to_clipboard: true -# No title bar, use shortcuts -window: - decorations: none diff --git a/.config/alacritty/bindings.yml b/.config/alacritty/bindings.yml @@ -1,2 +0,0 @@ -key_bindings: - - { key: N, mods: Control|Shift, action: CreateNewWindow} diff --git a/.config/bash/aliases b/.config/bash/aliases @@ -1,4 +0,0 @@ -which startx >&/dev/null && alias startx="startx \"$XDG_CONFIG_HOME/X11/xinitrc\" vt1" -which wget >&/dev/null && alias wget="wget --hsts-file=\"$XDG_CACHE_HOME/wget-hsts\"" -which nvim >&/dev/null && alias vim="nvim" && alias vi="nvim" -which elinks >&/dev/null && alias elinks="elinks ddg.gg" diff --git a/.config/bash/bashrc b/.config/bash/bashrc @@ -1,9 +0,0 @@ -set -o vi - -PATH_EXPORTS=( "${ESSENTIAL_PATH_EXPORTS[@]}" "${OTHER_PATH_EXPORTS[@]}" ) - -export PATH="${PATH}:${PATH_EXPORTS[*]}" - -PS1='\w> ' - -[ -f "$XDG_CONFIG_HOME/bash/unstaged" ] && . "$XDG_CONFIG_HOME/bash/unstaged" diff --git a/.config/bash/plugin/shorthand b/.config/bash/plugin/shorthand @@ -1,9 +0,0 @@ -# One letter bindings for important commands - -[ ! -z "${EDITOR}" ] && alias e=${EDITOR} - -alias c=clear - -which git >&/dev/null && alias g=git - -which pass >&/dev/null & alias p=pass diff --git a/.config/git/config b/.config/git/config @@ -7,6 +7,8 @@ cl = clone cm = commit --message co = checkout + cot = checkout --theirs + coo = checkout --ours con = config d = diff ds = diff --staged @@ -20,14 +22,17 @@ pu = push put = push --tags puo = push -u origin - rs = remote set-url - rso = remote set-url origin - rv = remote --verbose + r = reset + rs = reset --soft + res = remote set-url + reso = remote set-url origin + rev = remote --verbose sm = submodule st = status suir = submodule update --init --recursive wt = worktree wta = worktree add + ctags = !.git/hooks/ctags [push] autoSetupRemote = true @@ -40,4 +45,4 @@ templatedir = ~/.config/git/template [include] - path = config.user + path = ~/.config/git/user diff --git a/.gitignore b/.config/git/ignore diff --git a/.config/git/template/hooks/ctags b/.config/git/template/hooks/ctags @@ -0,0 +1,5 @@ +#!/bin/sh -e + +trap 'rm -f "$$.tags"' EXIT +ctags -f"$$.tags" $(git ls-files) +mv "$$.tags" "tags" diff --git a/.config/git/template/hooks/post-checkout b/.config/git/template/hooks/post-checkout @@ -0,0 +1,2 @@ +#!/bin/sh +.git/hooks/ctags >/dev/null 2>&1 & diff --git a/.config/git/template/hooks/post-commit b/.config/git/template/hooks/post-commit @@ -0,0 +1,2 @@ +#!/bin/sh +.git/hooks/ctags >/dev/null 2>&1 & diff --git a/.config/git/template/hooks/post-merge b/.config/git/template/hooks/post-merge @@ -0,0 +1,2 @@ +#!/bin/sh +.git/hooks/ctags >/dev/null 2>&1 & diff --git a/.config/git/template/hooks/post-rewrite b/.config/git/template/hooks/post-rewrite @@ -0,0 +1,4 @@ +#!/bin/sh +case "$1" in + rebase) exec .git/hooks/post-merge ;; +esac diff --git a/.config/mac/.cache/alacritty_unstaged.yml b/.config/mac/.cache/alacritty_unstaged.yml @@ -0,0 +1,8 @@ +font: + normal: + family: ProggyCleanTT + style: Regular + +# No title bar, use shortcuts +# window: +# decorations: none diff --git a/.config/mac/hard.sh b/.config/mac/hard.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# TODO Use a general script to shadow copy all +cp $XDG_ROOT/.config/mac/.cache/alacritty_unstaged.yml $XDG_ROOT/.cache/alacritty_unstaged.yml + +# map caps lock to esc +hidutil property --set '{"UserKeyMapping":[ +{ + "HIDKeyboardModifierMappingSrc": 0x700000039, + "HIDKeyboardModifierMappingDst": 0x700000029 + } +]}' diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua @@ -2,8 +2,6 @@ vim.g.mapleader = ' ' local set = vim.opt local g = vim.g -set.packpath="$XDG_DATA_HOME/nvim" - g.loaded_node_provider = 0 g.loaded_ruby_provider = 0 g.loaded_perl_provider = 0 @@ -30,30 +28,31 @@ g.netrw_banner = 0 g.netrw_liststyle = 3 vim.cmd([[ -" TODO use lua api -source $XDG_DATA_HOME/vim/vimrc - -function! s:load_plugins(t) abort - packadd fzf.vim - packadd nvim-dap - packadd nvim-dap-ui - packadd nvim-lspconfig + source $XDG_DATA_HOME/vim/hyper-red.vim +]]) + +function load_plugns() + vim.cmd([[ packadd vim-fugitive packadd vim-ninja-feet packadd vim-surround packadd vim-tmux-navigator packadd vim-unimpaired packadd vim-xcode - - lua require"dapui".setup() - lua require"lspconfig".clangd.setup{} - lua require"unstaged" -endfunction - -augroup user_cmds - autocmd! - autocmd VimEnter * call timer_start(20, function('s:load_plugins')) -augroup END -]]) - + packadd vim-dispatch + ]]) + --require"dapui".setup() + --require"lspconfig".clangd.setup{} + --require"unstaged" + + --require('dap').adapters.cppdbg = { + -- type = 'executable', + -- command = 'lldb-vscode', + -- name = 'cppdbg' + --} + + --require('dap.ext.vscode').load_launchjs(nil, { cppdbg = {'c', 'cpp'} }) +end + +vim.defer_fn(function() load_plugns() end, 20) diff --git a/.config/nvim/lua/keybindings.lua b/.config/nvim/lua/keybindings.lua @@ -1,26 +1,6 @@ --- keybindings local set = vim.opt -function save_and_build() --- TODO require vim-dispatch - vim.cmd('wall') - vim.cmd('Make') -end - -function toggle_list(is_local_buffer) - -- TODO implement toggle for all buffers - local optset=vim.o - if optset.list then - optset.list=false - else - optset.list=true - end -end - local map = vim.keymap.set -map('n', "U", '<c-r>') -map('n', "<c-r>", '"') - -map('n', "z/", ':%s/') +vim.cmd[[source $XDG_DATA_HOME/vim/keybindings.vim]] vim.api.nvim_create_autocmd('LspAttach', { callback = function(args) @@ -41,50 +21,13 @@ vim.api.nvim_create_autocmd('LspAttach', { end }) -vim.cmd([[ -function! DiffWithSaved() - let filetype=&ft - diffthis - vnew | r # | normal! 1Gdd - diffthis - exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype -endfunction -]]) - function file_mv_helper() vim.cmd('normal! 0i"A"0y$A p0imv j0') end -- general -map("n", "<leader>H", ":Lex<cr>") -map("n", "<leader>aa", ":argadd **<cr>") -map("n", "<leader>cd", ":cdo<space>s/") -map("n", "<leader>co", ":copen<cr>") map("n", "<leader>ec", ":edit $XDG_CONFIG_HOME/nvim/init.lua<cr>") -map("n", "<leader>ek", ":edit $XDG_CONFIG_HOME/nvim/lua/keybindings.lua<cr>") -map("n", "<leader>et", ":set expandtab<cr>") -map("n", "<leader>lb", ":ls<CR>:b<space>") -map("n", "<leader>ld", ":ldo<space>s/") -map("n", "<leader>lo", ":lopen<cr>") -map("n", "<leader>p", ":Rg<cr>") map("n", "<leader>sc", ":source $XDG_CONFIG_HOME/nvim/init.lua<cr>") -map("n", "<leader>so", ":source %<cr>") -map("n", "<leader>spa", ":set path+=**<cr>") -map("n", "<leader>spp", ":set paste<cr>") -map("n", "<leader>tl", ":lua toggle_list(true)<CR>") -map("n", "<leader>tt", ":tabnew<cr>") -map("n", "<leader>vg", ":vimgrep<space>") -map("n", "<leader>wd", ":call DiffWithSaved()<cr>") - --- quick write and quit -map("n", "<Leader>qq", ":q<CR>") -map("n", "<Leader>ww", ":w<CR>") -map("n", "<leader><cr>", ":noh<CR>") - --- buffers -map("n", "<leader>sc", ":source ~/.config/vim/vimrc<enter>") -map("n", "<leader>ss", ":split<enter>") -map("n", "<leader>vv", ":vsplit<enter>") -- nvim-dap map("n", "<leader>dd", ":lua require'dap'.continue()<cr>") @@ -109,79 +52,5 @@ map("n", "<leader>dcb", ":lua require'dap'.ToggleConditionalBreakpoint()") -- map("n", "<leader>do", ":call GotoWindow(require'dap'.session_windows.output)<CR>") -- map("n", "<leader>dtcb", ":call vimspector#CleanLineBreakpoint()<CR>") -map("n", "<leader>bb", ":lua save_and_build()<CR>") -map("n", "<leader>be", ":AbortDispatch<CR>") -map("n", "<leader>bc", ":Make clean<CR>") - - --- development -map("n", "<leader>oc", ":grepadd /:: %") -map("n", "<leader>oh", ":grepadd /:: %") - -vim.keymap.set('n', '\\a', ":A<cr>") -vim.keymap.set('n', '\\f', ":GFiles<cr>") -vim.keymap.set('n', '\\F', ":Files<cr>") -vim.keymap.set('n', '\\g', ":CommandTGit<cr>") -map("n", "\\b", ":lua save_and_build()<CR>") - - --- quick navigation -map("n", "<leader>fb", ":b *") -map("n", "<leader>ff", ":find *") -map("n", "<leader>fs", ":set foldmethod=syntax<cr>") - - --- file helpers -map("n", "<leader>fmv", "lua file_mv_helper()") - --- doc functions -function doc_quick_underline(n) - if (n == 1) then - vim.cmd('normal! yypv$r=') - else - vim.cmd('normal! yypv$r-') - end -end - -function reverse_date() - vim.cmd('normal! dt/wwpldeBP') -end - -map("n", "<leader>h1", ":lua doc_quick_underline(1)<cr>") -map("n", "<leader>h2", ":lua doc_quick_underline(2)<cr>") - - -map("n", "<leader>ct", ":ChecklistToggleCheckbox<cr>") -map("n", "<leader>ce", ":ChecklistEnableCheckbox<cr>") --- map("n", "<leader>cd", ":ChecklistDisableCheckbox<cr>") - --- vim.g.checklist_filetypes:append('adoc', 'md') - --- vim-fugitive -map("n", "<leader>gb", ":G blame<cr>") -map("n", "<leader>gd", ":Gvdiff<cr>") -map("n", "<leader>gg", ":Ggrep<space>") -map("n", "<leader>gr", ":G reset %<cr>") -map("n", "<leader>gwq", ":Gwq<cr>") -map("n", "<leader>lg", ":Glgrep<space>") - --- useful -map("n", "<leader>nn", ":set number<cr>") - -- neovim diagnostics map("n", "<leader>sd", ":lua vim.diagnostic.open_float()<cr>") - --- netrw keybindings -map("n", "<leader>sf", ":Ex<cr>") - --- subst with power -map("n", "cn", "*``cgn") -map("n", "cN", "*``cgN") -vim.cmd([[ -let g:mc = "y/\\V\<C-r>=escape(@\", '/')\<CR>\<CR>" -vnoremap <expr> cn g:mc . "``cgn" -]]) - --- nb --- TODO open a fuzzy finder quickly. Even better use fuzzy finder without chdir -map("n", "<leader>nb", ":chdir $NB_PATH<cr> | :pwd<cr>") diff --git a/.config/sh/aliases b/.config/sh/aliases @@ -1,7 +1,6 @@ # [xdg] alias abook='abook --config "$XDG_CONFIG_HOME"/abook/abookrc --datafile "$XDG_DATA_HOME"/abook/addressbook' alias abook='abook -C "$XDG_CONFIG_HOME"/abook/abookrc --datafile "$XDG_DATA_HOME"/abook/addressbook' -alias btpd='btpd -d "$XDG_DATA_HOME"/btpd' alias dict='dict -c "$XDG_CONFIG_HOME"/dict/dictrc' alias mbsync='mbsync -c "$XDG_CONFIG_HOME"/isync/mbsyncrc' alias startx='startx "$XDG_CONFIG_HOME/X11/xinitrc" vt1' @@ -28,27 +27,31 @@ alias n='cd_and_ls' alias cf="quickopen cd d" alias ef="quickopen ${EDITOR} f" alias gf='$EDITOR $(git ls-files | ${FUZZER})' -alias vf="quickopen ${VISUAL} f" # TODO make it work for linux alias of="quickopen open f" # This won't work with dash # dash want's alias \- -# alias -- -='cd -' +alias -- -='cd -' # [shorthands] +alias a=attach alias '?d'='sr duckduckgo' alias cls=clear alias d='download' alias e='${EDITOR}' -alias f=find_ -alias g='git' +alias f=quickopen alias g=git alias l=lfcd alias le=less -alias m=make -alias v="VIMINIT='' nvim" -alias x=extract_archive +alias m=smartmake +alias v="$EDITOR" +alias x=extract.sh -# [longhands] +# [midlonghands] +alias op='cd $(open_project "$HOME/repo" | fzf)' alias girl='grep -irl' alias gir='grep -ir' +alias markdown=md2html +alias fy='fzf | pbcopy' + +alias voom='VIM_DIR=$XDG_DATA_HOME/vim voom' diff --git a/.config/sh/functions b/.config/sh/functions @@ -1,53 +1,80 @@ -# TODO implement [dest_dir] functionality -# Iterate over each arguments -# Treat last argument as dest folder? or use -d -extract_archive () { - test $# -lt 1 && { printf "Usage: $0 <archive>\n"; exit 1; } - test -f $1 || { printf "$0: $1: No such file \n"; exit 1; } - lowercase_ext=$(printf "%s" "$1" | rev | cut -d '.' -f1 | tr '[:upper:]' '[:lower:]' | rev) - case $lowercase_ext in - z) 7z x "$1" ;; - bz2) bzip2 -d "$1" ;; - bz) bzip2 -d "$1" ;; - gz) gunzip -d "$1" ;; - rar) unrar x "$1" ;; - tar) tar -xvf "$1" ;; - tgz) tar -zxvf "$1" ;; - zip) unzip "$1" ;; - *) printf "'$1' Error. Unsupported filetype.\n" >&2 ;; - esac -} - md() { mkdir "$@" && cd "$@" } +open_project() { + # search only dirs + search_dir=${1:-.} + for i in $search_dir/*/; do + if [ -d "$i/.git" ]; then + echo "$i" + else + # if does not have .git, search the subdirs + open_project "$i" + fi + done +} + +attach() { + if there abduco && [ $# -eq 0 ]; then + sesh_name=$(abduco -l | tail -n +2 | cut -f3 | $FUZZER) + test -z "$sesh_name" && return + abduco -a $sesh_name || abduco -c $sesh_name mtm; + fi + [ $# -gt 0 ] && abduco -a $1 +} + # TODO make it non-interruptable insult() { - if type sl 1>/dev/null; then - sl - else - printf "You are a noob for typing '$1'\n" + if there sl; then + sl else printf "You are a noob for typing '$1'\n" sleep 5 fi } +smartmake() { + if there fmake && there errorformat; then + $(fmake) $* | errorformat + else + make + fi +} + thwart() { - alias $1="insult '$1'" + alias $1="insult '$1'" } quickopen() { - if ! type "${FUZZER}" 2>/dev/null; then + if ! there "${FUZZER}"; then printf '${FUZZER} not available\n' + return + fi + + # TODO maybe add -type in the future TODO add $name + #if [ $# -gt 0 ]; then + # name="-name $@" + #fi + # 2>/dev/null + if [ -d .git ]; then + optional_files="$(git ls-files) |" + somethin="$(git ls-files | ${FUZZER})" + else + maxdepth=${1:-3} somethin="$(find . -maxdepth $maxdepth | ${FUZZER})" + fi + if [ -z "$somethin" ]; then + return; + elif [ -f "$somethin" ]; then + $EDITOR "$somethin" + elif [ -d "$somethin" ]; then + cd "$somethin" else - test "$#" -lt 1 && print "usage: $0 <command> [find -type]" - test -z "$2" && 2=f - ${1} "$(find . -type $2 -maxdepth 3 2>/dev/null | ${FUZZER})" + printf '%s: is neither a file nor a directory\n' "$somethin" + return fi } cd_and_ls() { - cd $* && ls + cd $* && ls } download() { @@ -59,14 +86,12 @@ find_() { find . -name "*$**" } -vim_plug() { - export VIM_PLUGINS_DIR="$XDG_DATA_HOME"/vim/pack/voom/opt - export VIM_DIR="$XDG_DATA_HOME"/vim - voom $@ +vim_plug() { export + VIM_PLUGINS_DIR="$XDG_DATA_HOME"/vim/pack/voom/opt export + VIM_DIR="$XDG_DATA_HOME"/vim voom $@ } nvim_plug() { - export VIM_PLUGINS_DIR="$XDG_DATA_HOME"/nvim/pack/voom/opt - export VIM_DIR="$XDG_DATA_HOME"/nvim - voom $@ + export VIM_PLUGINS_DIR="$XDG_DATA_HOME"/nvim/pack/voom/opt + export VIM_DIR="$XDG_DATA_HOME"/nvim voom $@ } diff --git a/.config/user-dirs.dirs b/.config/user-dirs.dirs @@ -1,8 +1,8 @@ -XDG_DESKTOP_DIR="$XDG_DATA_HOME/desktop" -XDG_DOCUMENTS_DIR="$XDG_DATA_HOME/documents" -XDG_DOWNLOAD_DIR="$XDG_CACHE_HOME/downloads" -XDG_MUSIC_DIR="$XDG_DATA_HOME/music" -XDG_PICTURES_DIR="$XDG_DATA_HOME/pictures" -XDG_PUBLICSHARE_DIR="$XDG_DATA_HOME/public" -XDG_TEMPLATES_DIR="$XDG_DATA_HOME/templates" -XDG_VIDEOS_DIR="$XDG_DATA_HOME/videos" +XDG_DESKTOP_DIR="$XDG_ROOT/desktop" +XDG_DOCUMENTS_DIR="$XDG_ROOT/documents" +XDG_DOWNLOAD_DIR="$XDG_ROOT/downloads" +XDG_MUSIC_DIR="$XDG_ROOT/music" +XDG_PICTURES_DIR="$XDG_ROOT/pictures" +XDG_PUBLICSHARE_DIR="$XDG_ROOT/public" +XDG_TEMPLATES_DIR="$XDG_ROOT/templates" +XDG_VIDEOS_DIR="$XDG_ROOT/videos" diff --git a/.config/vim/keybindings.vim b/.config/vim/keybindings.vim @@ -1,125 +0,0 @@ -" General keybindings -nnoremap <leader>aa :argadd **<cr> -nnoremap <leader>co :copen<cr> -nnoremap <leader>cs :cdo<space>s/ -nnoremap <leader>ec :edit $XDG_CONFIG_HOME/vim/vimrc<cr> -nnoremap <leader>ek :edit $XDG_CONFIG_HOME/vim/keybindings.vim<cr> -nnoremap <leader>et :set expandtab<cr> -nnoremap <leader>ff :find * -nnoremap <leader>fb :buffer * -nnoremap <leader>lb :ls<cr>:b<space> -nnoremap <leader>lo :lopen<cr> -nnoremap <leader>ls :ldo<space>s/ -nnoremap <leader>pp :Rg<cr> -nnoremap <leader>pv :packadd vimspector<cr> -nnoremap <leader>sc :source $XDG_CONFIG_HOME/vim/vimrc<cr> -nnoremap <leader>so :source %<cr> -nnoremap <leader>sp :set paste<cr> -nnoremap <leader>tt :tabnew<cr> -nnoremap <leader>vg :vimgrep<space> -" Buffer Creation -nnoremap <leader>sc :source $XDG_CONFIG_HOME/vim/vimrc<enter> -nnoremap <leader>ss :split<enter> -nnoremap <leader>vv :vsplit<enter> - -" Accessible completions -inoremap <c-f> <c-x><c-f> -inoremap <c-l> <c-x><c-l> -" Emacs line navigation in insert mode -inoremap <c-a> <c-o>0 -inoremap <c-e> <c-o>A -" Behave vim -nnoremap Y y$ - -fun! SetupCommandAlias(from, to) - exec 'cnoreabbrev <expr> '.a:from - \ .' ((getcmdtype() is# ":" && getcmdline() is# "'.a:from.'")' - \ .'? ("'.a:to.'") : ("'.a:from.'"))' -endfun -call SetupCommandAlias("W","w") -call SetupCommandAlias("Wq","wq") -call SetupCommandAlias("man","help") - -nnoremap <leader>tb :call ToggleBackground()<CR> -nnoremap <leader>tl :call ToggleList()<CR> - -" development -nnoremap <leader>bb :call SaveAndBuild()<CR> -nnoremap <leader>be :AbortDispatch<CR> -nnoremap <leader>bc :Make clean<CR> - -nnoremap <leader>fmv :call FileMvHelper()<CR> - -" Quick save and write -nnoremap <leader>wq :wq<cr> -nnoremap <leader>ww :w<cr> -nnoremap <leader>qq :q<cr> - -" Fugitive -nnoremap <space>gd :Gvdiff<CR> - - -" Generate ctags -map <leader>gt :!sh -c "ctags `rg --files`"<CR> -set tags+=.git/tags - -nnoremap <CR> :noh<CR><CR>:<backspace> - -" Markdown -nnoremap <leader>cc :ChecklistToggleCheckbox<cr> - -let g:gutentags_file_list_command = 'rg --files' - -" vim-fugitive -nnoremap <leader>gg :Ggrep<space> -nnoremap <leader>lg :Glgrep<space> - -autocmd FileType markdown set cursorline - -" Hide and format markdown elements like **bold** -autocmd FileType markdown set conceallevel=2 - -function QuickUnderline(n) - if a:n == 1 - normal! yypv$r= - else - normal! yypv$r- - endif -endfunction - -function ReverseDate() - normal! dt/wwpldeBP -endfunction - -nnoremap <leader>h1 :call QuickUnderline(1)<cr> -nnoremap <leader>h2 :call QuickUnderline(2)<cr> - -fun! GotoWindow(id) - call win_gotoid(a:id) -endfun - -" Navigation maps -nnoremap \f :GFiles<CR> -nnoremap \F :Files<CR> - -" Debugger remaps -nnoremap <leader>dd :call vimspector#Launch()<CR> -nnoremap <leader>dc :call GotoWindow(g:vimspector_session_windows.code)<CR> -nnoremap <leader>dt :call GotoWindow(g:vimspector_session_windows.tagpage)<CR> -nnoremap <leader>dv :call GotoWindow(g:vimspector_session_windows.variables)<CR> -nnoremap <leader>dw :call GotoWindow(g:vimspector_session_windows.watches)<CR> -nnoremap <leader>ds :call GotoWindow(g:vimspector_session_windows.stack_trace)<CR> -nnoremap <leader>do :call GotoWindow(g:vimspector_session_windows.output)<CR> -nnoremap <leader>de :call vimspector#Reset()<CR> - -nnoremap <leader>dtcb :call vimspector#CleanLineBreakpoint()<CR> - -nmap <leader>dl <Plug>VimspectorStepInto -nmap <leader>dj <Plug>VimspectorStepOver -nmap <leader>dk <Plug>VimspectorStepOut -nmap <leader>d_ <Plug>VimspectorRestart -nnoremap <leader>d<space> :call vimspector#Continue()<CR> - -nmap <leader>drc <Plug>VimspectorRunToCursor -nmap <leader>dbp <Plug>VimspectorToggleBreakpoint -nmap <leader>dcbp <Plug>VimspectorToggleConditionalBreakpoint diff --git a/.config/vim/plugin/plugin.vim b/.config/vim/plugin/plugin.vim @@ -1,65 +0,0 @@ -function! ToggleList() - if &list == "nolist" - set list - else - set nolist - endif -endfunction - -function! ToggleBackground() - if &background == "light" - set background=dark - else - set background=light - endif -endfunction - -function! FileMvHelper() - :normal! 0i"A"0y$A p0imv j0 -endfunction -" Run Make - -function SaveAndBuild() - wall - Make -endfunction - -" TODO load this automatically -source $XDG_CONFIG_HOME/vim/ftplugin/cpp.vim - - -" Mail -set rtp+=~/.local/share/nvim/pack/general/start/himalaya/vim - - -let g:birck_default_chan="irc.libera.chat" - -" Strip the newline from the end of a string -function! Chomp(str) - return substitute(a:str, '\n$', '', '') -endfunction - -" Find a file and pass it to cmd -function! DmenuOpen(cmd) - let fname = Chomp(system("git ls-files | dmenu-mac -i -l 20 -p " . a:cmd)) - if empty(fname) - return - endif - execute a:cmd . " " . fname -endfunction - -" find file in git repo -function! ChooseFile() - let dir = expand("%:h") - if empty(dir) | let dir = getcwd() | endif - - let root = system("cd " . dir . " && git rev-parse --show-toplevel") - if v:shell_error != 0 | echo "Not in a git repo" | return | endif - let root = root[0:-2] - - let selection = system("cd " . root . " && git ls-files -co --exclude-standard | choose") - if empty(selection) | echo "Canceled" | return | end - - echo "Finding file..." - exec ":e " . root . "/" . selection -endfunction diff --git a/.config/vim/vimrc b/.config/vim/vimrc @@ -1,111 +0,0 @@ -if has('nvim') - luafile ~/.config/nvim/init.lua - finish -else - if has("&viminfofile") - set viminfofile=$XDG_CACHE_DIR/vim/viminfo - endif -endif - -" General -set nocompatible -set mouse= -set cursorline -if has('cursorlineopt') - set cursorlineopt=number -endif -set exrc - -" Turn backup off -set nobackup -set nowb -set noswapfile - -" Map leader to space -nnoremap <space> <Nop> -let mapleader = " " - -" Enable hidden buffers -set hidden - -" Disable auto fixing end of line -" Useful when opening binary files -set nofixendofline - -" Disable vim intro message -set shortmess=Iat - -" Search -set hlsearch -set incsearch -set nowrapscan - -" Pro tab -filetype plugin indent on -set tabstop=4 -set shiftwidth=4 -set expandtab - -" Netrw customization -let g:netrw_banner = 0 -let g:netrw_liststyle = 3 - -" Disable status -set laststatus=1 - -set lazyredraw -set ttyfast -set nospell - -syntax on indent off - -" Plugins -source $XDG_CONFIG_HOME/vim/plugin/plugin.vim - -" Keybindings -source $XDG_CONFIG_HOME/vim/keybindings.vim - -" Common vimrc -source $XDG_DATA_HOME/vim/vimrc - -set packpath^=$XDG_DATA_HOME/vim - -function! s:load_plugins(t) abort - set synmaxcol=128 - " Use XDG Paths for vim - " TODO compile hard constants somewhere based on OS - set runtimepath^='$XDG_CONFIG_HOME/vim' - set runtimepath+='$XDG_DATA_HOME/vim' - set runtimepath+='$XDG_CONFIG_HOME/vim/after' - - let g:netrw_home = $XDG_DATA_HOME . "/vim" - call mkdir($XDG_DATA_HOME . "/vim/spell", 'p') - set viewdir=$XDG_DATA_HOME/vim/view | call mkdir(&viewdir, 'p') - - set backupdir=$XDG_CACHE_HOME/vim/backup | call mkdir(&backupdir, 'p') - set directory=$XDG_CACHE_HOME/vim/swap | call mkdir(&directory, 'p') - set undodir=$XDG_CACHE_HOME/vim/undo | call mkdir(&undodir, 'p') - packadd vim-tmux-navigator - packadd vim-commentary - packadd vim-surround - packadd vim-ninja-feet - packadd vim-fugitive - packadd vim-unimpaired - packadd vim-better-whitespace -endfunction - -augroup user_cmds - autocmd! - autocmd VimEnter * call timer_start(20, function('s:load_plugins')) -augroup END - -if has("gui") - source $XDG_CONFIG_HOME/vim/gvimrc -endif - -if has("win32") - set shell=cmd - set shellquote=\" - " shellxquote must be a literal space character. - set shellxquote= -endif diff --git a/.gitmodules b/.gitmodules @@ -1,12 +0,0 @@ -[submodule ".local/share/vim/pack/general/opt/vim-ninja-feet"] - path = .local/share/vim/pack/general/opt/vim-ninja-feet/vim-ninja-feet - url = https://git::@github.com/tommcdo/vim-ninja-feet.git -[submodule ".local/share/nvim/pack/general/start/vim-dispatch-neovim"] - path = .local/share/nvim/pack/general/start/vim-dispatch-neovim - url = https://github.com/radenling/vim-dispatch-neovim -[submodule ".config/nvim/vim-vinegar"] - path = .config/nvim/vim-vinegar - url = https://github.com/tpope/vim-vinegar -[submodule ".local/share/vim/pack/dev/start/omnisharp-vim"] - path = .local/share/vim/pack/dev/start/omnisharp-vim - url = https://github.com/OmniSharp/omnisharp-vim diff --git a/.local/bin/sh/cam b/.local/bin/sh/cam @@ -5,5 +5,5 @@ c_os="$(uname -s)" if [ "$c_os" == "Windows_NT" ]; then ffplay -f dshow -i video="Integrated Webcam" else - ffplay -f avfoundation -i 1:0 -video_size 1280x720 -framerate 30 + ffplay -f avfoundation -i 0:0 -video_size 1280x720 -framerate 30 fi diff --git a/.local/bin/sh/ci b/.local/bin/sh/ci @@ -1,7 +1,7 @@ #!/bin/sh # ci - computer index -s_db=~/.local/share/personal/systems.json +s_db="$XDG_DATA_HOME/personal/systems.json" s_system=$(jq -r 'keys[]' "$s_db" | fzf) s_addr=$(jq -r ".$s_system" "$s_db") diff --git a/.local/bin/sh/extract.sh b/.local/bin/sh/extract.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# TODO implement [dest_dir] functionality +# Currently extracts to the current directory +# Iterate over each arguments +# Treat last argument as dest folder? or use -d +# Allow extraction of multple archives in the order +test $# -lt 1 && { printf "Usage: $(basename $0) <archive>\n"; exit 1; } +test -f $1 || { printf "$0: $1: No such file \n"; exit 1; } +case $1 in + *.a) ar x "$1" ;; + *.z) 7z x "$1" ;; + *.bz2) bzip2 -d "$1" ;; + *.bz) bzip2 -d "$1" ;; + *.gz) gunzip -d "$1" ;; + *.rar) unrar x "$1" ;; + *.tar) tar -xvf "$1" ;; + *.tar.gz) tar -xvf "$1" ;; + *.tgz) tar -zxvf "$1" ;; + *.zip) unzip "$1" ;; + *.mp4) + audio_codec=$(ffprobe -show_streams -select_streams a "$1" | grep codec_name | cut -f2 -d "=") + ffmpeg -i "$1" -c:a copy $(basename $1).${audio_codec} + ;; + +*) printf "'$1' Error. Unsupported filetype.\n" >&2 ;; +esac diff --git a/.local/bin/sh/irc b/.local/bin/sh/irc @@ -2,10 +2,13 @@ test -z "${FUZZER}" && { printf "FUZZER not set\n"; exit 1; } -CHATS="irc.freenode.net\nirc.libera.chat" +type ii || exit 1 + +CHATS="irc.freenode.net +irc.libera.chat" startii() { - pick=`echo ${CHATS} | ${FUZZER}` + pick=`echo "${CHATS}" | ${FUZZER}` ii -s "${pick}" -n $IRC_NICK & } @@ -18,8 +21,9 @@ iipid="$(pgrep ii)" if [ -n "${iipid}" ]; then printf "ii is already running with pid: %s\n" "${iipid}" + startvim else startii + startvim fi -startvim diff --git a/.local/bin/sh/pofs b/.local/bin/sh/pofs @@ -4,6 +4,6 @@ cd "${PASSWORD_STORE_DIR}" || exit 1 -selection="$(find -L totp -name "*.gpg" | sed 's/.gpg$//g' | ${FUZZER} -q "$*")" +selection="$(find -L . -wholename "./*totp/*.gpg" | sed 's/.gpg$//g' | ${FUZZER} -q "$*")" test -z "${selection}" || pass otp "${selection}" diff --git a/.local/run/.gitkeep b/.local/run/.gitkeep diff --git a/.local/share/nvim/pack/general/start/nvim-comment b/.local/share/nvim/pack/general/start/nvim-comment @@ -1 +0,0 @@ -Subproject commit 861921706a39144ea528a6200a059a549b02d8f0 diff --git a/.local/share/vim/hyper-red.vim b/.local/share/vim/hyper-red.vim @@ -4,12 +4,20 @@ " Probably use a autogroup for handling tCo count change " Do it in lua if &background == "dark" + hi! ColorColumn guifg=White ctermfg=White guibg=DarkGray ctermbg=DarkGray + hi! Folded guifg=LightBlue ctermfg=LightBlue guibg=NONE ctermbg=NONE cterm=bold + hi! FoldColumn guifg=LightBlue ctermfg=LightBlue guibg=NONE ctermbg=NONE cterm=bold + hi! DiffChange guifg=LightYellow ctermfg=LightYellow guibg=NONE ctermbg=NONE cterm=bold + hi! DiffText guifg=DarkBlue ctermfg=DarkBlue guibg=LightYellow ctermbg=LightYellow cterm=bold + hi! DiffAdd guibg=NONE ctermbg=NONE guifg=LightGreen ctermfg=LightGreen + hi! DiffDelete guifg=DarkRed ctermfg=DarkRed guibg=NONE ctermbg=NONE hi! LineNr guibg=NONE ctermbg=NONE guifg=DarkGray ctermfg=DarkGray hi! CursorLineNr cterm=NONE gui=NONE guibg=NONE ctermbg=NONE guifg=White ctermfg=White hi! StatusLineNC guibg=LightGray ctermbg=LightGray guifg=Black ctermfg=Black - hi! Statement ctermfg=Red guifg=Red - hi! Constant ctermfg=LightGreen guifg=LightGreen - hi! String ctermfg=LightBlue guifg=LightBlue + hi! Statement ctermfg=NONE guifg=NONE + hi! Constant ctermfg=Red guifg=Red + hi! Error ctermbg=DarkRed guifg=DarkRed + hi! String ctermfg=DarkGray guifg=DarkGray hi! Special cterm=bold ctermfg=LightMagenta guifg=LightMagenta hi! Identifier ctermfg=White guifg=White hi! IncSearch ctermbg=Black ctermfg=Yellow guibg=Black guifg=Yellow @@ -18,8 +26,9 @@ if &background == "dark" hi! Comment ctermfg=DarkGray guifg=DarkGray hi! Visual ctermbg=White ctermfg=Black guibg=White guifg=Black hi! Type ctermfg=LightGray guifg=LightGray - hi! PreProc ctermfg=DarkGray guifg=DarkGray + hi! PreProc ctermfg=LightGray guifg=LightGray hi! MatchParen ctermbg=NONE cterm=underline ctermfg=LightMagenta + hi! ExtraWhitespace ctermbg=DarkRed guibg=DarkRed else hi! LineNr cterm=NONE gui=NONE guibg=NONE ctermbg=NONE guifg=DarkGray ctermfg=DarkGray hi! StatusLineNC guibg=Black ctermbg=Black guifg=White ctermfg=White @@ -40,9 +49,11 @@ endif if has('fillchars') set fillchars=vert:\│ endif +set listchars=eol:$,tab:>\ hi! VertSplit term=NONE cterm=NONE gui=NONE hi! SignColumn ctermbg=NONE guibg=NONE if (&t_Co == 8) hi! Comment ctermfg=NONE endif +match ExtraWhitespace /\s\+$/ diff --git a/.local/share/vim/plugins b/.local/share/vim/plugins @@ -1,29 +1,39 @@ -ntpeters/vim-better-whitespace.git -tpope/vim-commentary.git -tpope/vim-surround.git +tpope/vim-commentary +tpope/vim-dispatch tpope/vim-fugitive -tommcdo/vim-ninja-feet.git +tpope/vim-surround tpope/vim-unimpaired -pope/vim-repeat.git -christoomey/vim-tmux-navigator -tpope/vim-dispatch -yegappan/mru -radenling/vim-dispatch-neovim -evansalter/vim-checklist -tpope/vim-vinegar -tpope/vim-vinegar -ferranpm/vim-maildir -joereynolds/vim-minisnip/ -keith/swift.vim -preservim/tagbar -cfdrake/vim-pbxproj -kana/vim-submode -jerrymarino/xcodebuild.vim -gfontenot/vim-xcode -junegunn/fzf.vim -vim-scripts/gitignore -OmniSharp/omnisharp-vim +tpope/vim-repeat +natebosch/vim-lsc +dradtke/vim-dap +Bestoa/SearchComplete +tpope/vim-projectionist +junegunn/goyo.vim + +#cfdrake/vim-pbxproj +#ervandew/supertab +#vim-scripts/vimacs +#vim-scripts/SearchComplete +#christoomey/vim-tmux-navigator +#evansalter/vim-checklist +#ferranpm/vim-maildir +#https://github.com/bfrg/vim-jqplay +#joereynolds/vim-minisnip/ +#nachumk/systemverilog.vim +#notmuch-vim/notmuch-vim +#ntpeters/vim-better-whitespace.git +#radenling/vim-dispatch-neovim +#tommcdo/vim-ninja-feet.git +#torrancew/vim-openscad +#yegappan/mru +#vim-scripts/gitignore +#kana/vim-submode +#omniSharp/omnisharp-vim +#bfrg/vim-fzy +#jerrymarino/xcodebuild.vim +#gfontenot/vim-xcode +#keith/swift.vim # https://git.sr.ht/~torresjrjr/birck.vim # rcarriga/nvim-dap-ui @@ -31,3 +41,6 @@ OmniSharp/omnisharp-vim # terrortylor/nvim-comment # neovim/nvim-lspconfig # puremourning/vimspector +# xolox/vim-misc +# xolox/vim-easytags +# preservim/tagbar diff --git a/.local/share/vim/vimrc b/.local/share/vim/vimrc @@ -2,9 +2,12 @@ set packpath^=$XDG_DATA_HOME/vim let g:minisnip_dir=$XDG_DATA_HOME . '/vim/minisnip' +set nocursorline set background=dark source $XDG_DATA_HOME/vim/hyper-red.vim +set noexpandtab + set path+=** set wildignore+=**/out/** diff --git a/.profile b/.profile @@ -1,76 +1,72 @@ #!/bin/sh -export GREP_COLOR='1;35;40' - [ -n "$1" ] && XDG_ROOT="$1" || XDG_ROOT="$HOME" # XDG export XDG_CONFIG_HOME="$XDG_ROOT/.config" export XDG_DATA_HOME="$XDG_ROOT/.local/share" export XDG_CACHE_HOME="$XDG_ROOT/.cache" +export XDG_RUNTIME_DIR="$XDG_ROOT/.local/run" +export XDG_STATE_HOME="$XDG_ROOT/.local/state" -export XDG_DESKTOP_DIR="$XDG_DATA_HOME/desktop" -export XDG_DOCUMENTS_DIR="$XDG_DATA_HOME/documents" -export XDG_DOWNLOAD_DIR="$XDG_CACHE_HOME/downloads" -export XDG_MUSIC_DIR="$XDG_DATA_HOME/music" -export XDG_PICTURES_DIR="$XDG_DATA_HOME/pictures" -export XDG_PUBLICSHARE_DIR="$XDG_DATA_HOME/public" -export XDG_TEMPLATES_DIR="$XDG_DATA_HOME/templates" -export XDG_VIDEOS_DIR="$XDG_DATA_HOME/videos" +export ABDUCO_SOCKET_DIR="$XDG_STATE_HOME"/abuco +export LESSHISTFILE="$XDG_STATE_HOME"/lesshst # Global programs -export VIMINIT="if !has('nvim') -source $XDG_CONFIG_HOME/vim/vimrc -endif" +export BUNDLE_USER_CONFIG="$XDG_CONFIG_HOME"/bundle +export DOCKER_CONFIG="$XDG_CONFIG_HOME"/docker +export ELINKS_CONFDIR="$XDG_CONFIG_HOME/elinks" +export INPUTRC="$XDG_CONFIG_HOME"/readline/inputrc export LESSHISTFILE=- export LYNX_CFG="$XDG_CONFIG_HOME/lynx/lynx.cfg" export LYNX_LSS="$XDG_CONFIG_HOME/lynx/lynx.lss" -export PSQLRC="$XDG_CONFIG_HOME/pg/psqlrc" +export NOTMUCH_CONFIG="$XDG_CONFIG_HOME/notmuch/config" +export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME"/npm/npmrc +export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME/npm/npmrc" +export PARALLEL_HOME="$XDG_CONFIG_HOME"/parallel export PGPASSFILE="$XDG_CONFIG_HOME/pg/pgpass" export PGSERVICEFILE="$XDG_CONFIG_HOME/pg/pg_service.conf" +export PSQLRC="$XDG_CONFIG_HOME/pg/psqlrc" +export SCREENRC="$XDG_CONFIG_HOME"/screen/screenrc export TASKRC="$XDG_CONFIG_HOME/task/taskrc" +export WGETRC="$XDG_CONFIG_HOME/wgetrc" +export XAUTHORITY="$XDG_RUNTIME_DIR"/Xauthority export XINITRC="$XDG_CONFIG_HOME"/X11/xinitrc export XSERVERRC="$XDG_CONFIG_HOME"/X11/xserverrc -export XAUTHORITY="$XDG_RUNTIME_DIR"/Xauthority -export WGETRC="$XDG_CONFIG_HOME/wgetrc" -export SCREENRC="$XDG_CONFIG_HOME"/screen/screenrc -export DOCKER_CONFIG="$XDG_CONFIG_HOME"/docker -export INPUTRC="$XDG_CONFIG_HOME"/readline/inputrc -export NOTMUCH_CONFIG="$XDG_CONFIG_HOME/notmuch/config" -export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME/npm/npmrc" -export ELINKS_CONFDIR="$XDG_CONFIG_HOME/elinks" +export ANDROID_HOME="$XDG_DATA_HOME"/android +export BUNDLE_USER_PLUGIN="$XDG_DATA_HOME"/bundle +export CARGO_HOME="$XDG_DATA_HOME"/cargo export FFMPEG_DATADIR="$XDG_DATA_HOME"/ffmpeg +export GEM_HOME="$XDG_DATA_HOME"/gem export GNUPGHOME="$XDG_DATA_HOME/gnupg" -export ATOM_HOME="$XDG_DATA_HOME"/atom -export NODE_REPL_HISTORY="$XDG_DATA_HOME"/node_repl_history -export PASSWORD_STORE_DIR="$XDG_DATA_HOME"/pass -export HISTFILE="$XDG_DATA_HOME"/history -export RUSTUP_HOME="$XDG_DATA_HOME"/rustup -export MACHINE_STORAGE_PATH="$XDG_DATA_HOME"/docker-machine export GOPATH="$XDG_DATA_HOME"/go -export NB_PATH="$XDG_DATA_HOME/notebook" -export EM_PORTS="$XDG_DATA_HOME"/emscripten/cache -export CARGO_HOME="$XDG_DATA_HOME"/cargo -export GEM_HOME="$XDG_DATA_HOME"/gem -export TERMINFO="$XDG_DATA_HOME/terminfo" -export TERMINFO_DIRS="$XDG_DATA_HOME/terminfo":/usr/share/terminfo -export VSCODE_PORTABLE="$XDG_DATA_HOME/vscode" export GRADLE_USER_HOME="$XDG_DATA_HOME"/gradle -export SQLITE_HISTORY="$XDG_DATA_HOME/sqlite_history" +export HISTFILE="$XDG_DATA_HOME"/history +export MACHINE_STORAGE_PATH="$XDG_DATA_HOME"/docker-machine export MYSQL_HISTFILE="$XDG_DATA_HOME/mysql_history" +export NB_PATH="$XDG_DATA_HOME/notebook" +export NODE_REPL_HISTORY="$XDG_DATA_HOME"/node_repl_history +export PASSWORD_STORE_DIR="$XDG_DATA_HOME"/pass +export RUSTUP_HOME="$XDG_DATA_HOME"/rustup export SONGDL_HOME="${XDG_DATA_HOME}/music/" +export SQLITE_HISTORY="$XDG_DATA_HOME/sqlite_history" +export TERMINFO="$XDG_DATA_HOME"/terminfo +export TERMINFO_DIRS="$XDG_DATA_HOME"/terminfo:/usr/share/terminfo +export VSCODE_PORTABLE="$XDG_DATA_HOME/vscode" +export W3M_DIR="$XDG_DATA_HOME"/w3m +export _Z_DATA="$XDG_DATA_HOME/z" -export PSQL_HISTORY="$XDG_CACHE_HOME/pg/psql_history" -export NUGET_PACKAGES="$XDG_CACHE_HOME"/NuGetPackages -export EM_CACHE="$XDG_CACHE_HOME"/emscripten/cache +export BUNDLE_USER_CACHE="$XDG_CACHE_HOME"/bundle export GEM_SPEC_CACHE="$XDG_CACHE_HOME"/gem +export NUGET_PACKAGES="$XDG_CACHE_HOME"/NuGetPackages +export PSQL_HISTORY="$XDG_CACHE_HOME/pg/psql_history" # Make `history` print timestamp HISTTIMEFORMAT="%F %T " HISTCONTROL=erasedups # Local executables -export PATH=${PATH}:${HOME}/.local/bin:${HOME}/.local/bin/sh:${XDG_DATA_HOME}/npm/bin:${XDG_DATA_HOME}/.cargo/bin:${XDG_DATA_HOME}/gem/bin +export PATH=${PATH}:${HOME}/.local/bin:${HOME}/.local/bin/sh:${XDG_DATA_HOME}/npm/bin:${XDG_DATA_HOME}/.cargo/bin:${GOPATH}/bin:${XDG_DATA_HOME}/gem/bin chance() { # Hit or miss @@ -83,10 +79,15 @@ there() { } # Setup editor - -export VISUAL=vim -export EDITOR="$(there nvi && echo nvi || echo vi)" -export FUZZER=sk +# TODO until I grok the shell and able to control the clipboard and +# registers with terminal level keybings. I am not going back to vi/nvi +#alias vim=vi +#alias nvim=vi +export VISUAL=nvim +export EDITOR=nvim +there $EDITOR || unset $EDITOR +export FUZZER=fzy +there $FUZZER || unset $FUZZER export BROWSER=lynx export SURFRAW_browser="$BROWSER" @@ -102,3 +103,5 @@ export LESS_TERMCAP_se=$'\e[0m' export CLICOLOR=1 export LSCOLORS="xxexcxdxbxegxdxbagxcxd" export LS_COLORS="di=0:ln=34:so=32:pi=33:ex=31:bd=34;46:cd=0;43:su=0;41:sg=30;46:tw=0;42:ow=0;43" +export GREP_COLOR='1;35;40' + diff --git a/.vimrc b/.vimrc @@ -0,0 +1,244 @@ +syntax on indent off +if has("&viminfofile") + set viminfofile=$XDG_CACHE_DIR/vim/viminfo +endif + +" reject netrw, embrace ls +"let loaded_netrwPlugin = 1 + +set complete-=i +set foldmethod=marker +set foldmarker={,} +set foldlevel=20 +set foldopen-=search + +" General +set nocompatible +set mouse= +set cursorline +if has('cursorlineopt') + set cursorlineopt=number +endif +set exrc + +" Turn backup off +set nobackup +set nowb +set noswapfile + +" Map leader to space +nnoremap <space> <Nop> +let mapleader = " " + +" Enable hidden buffers +set hidden + +" Disable auto fixing end of line +" Useful when opening binary files +set nofixendofline + +" Disable vim intro message +set shortmess=Iat +set shortmess-=F + +" Search +set hlsearch +set incsearch +set nowrapscan + +" Pro tab +filetype plugin indent on +set tabstop=4 +set shiftwidth=4 +set expandtab + +" Netrw customization +let g:netrw_banner = 0 +let g:netrw_liststyle = 3 +let g:netrw_fastbrowse= 2 + +" Disable status +set laststatus=1 + +set nolazyredraw +set ttyfast +set nospell + + +" Common vimrc +source $XDG_DATA_HOME/vim/vimrc + +source $XDG_DATA_HOME/vim/keybindings.vim + +set packpath^=$XDG_DATA_HOME/vim + +function! FZYFiles() abort + let l:tempname = tempname() + " fzf | awk '{ print $1":1:0" }' > file + execute 'silent !git ls-files --recurse-submodules | fzy > ' . fnameescape(l:tempname) + let l:tcontents = join(readfile(l:tempname)) + try + " TODO Add option to add multiple files to argslist + "execute 'argadd ' . l:tcontents + let bufnr = bufadd(l:tcontents) + call bufload(bufnr) + "call setbufline(bufnr, 1, ['some', 'text']) + execute 'edit ' . l:tcontents + redraw! + finally + call delete(l:tempname) + endtry +endfunction +let g:lsc_server_commands = {'cpp': 'clangd --log=error'} +let g:lsc_auto_map = { + \ 'GoToDefinition': '<C-]>', + \ 'GoToDefinitionSplit': ['<C-W>]', '<C-W><C-]>'], + \ 'FindReferences': 'gr', + \ 'FindImplementations': 'gI', + \ 'FindCodeActions': 'ga', + \ 'Rename': 'gR', + \ 'ShowHover': v:true, + \ 'DocumentSymbol': 'go', + \ 'WorkspaceSymbol': 'gS', + \ 'SignatureHelp': 'gm', + \ 'Completion': 'completefunc', + \} +let g:lsc_enable_autocomplete = v:true +let g:lsc_enable_diagnostics = v:true +let g:lsc_reference_highlights = v:false +let g:lsc_trace_level = 'off' + +function! s:load_plugins(t) abort + set synmaxcol=128 + " Use XDG Paths for vim + " TODO compile hard constants somewhere based on OS + set runtimepath^='$XDG_CONFIG_HOME/vim' + set runtimepath+='$XDG_DATA_HOME/vim' + set runtimepath+='$XDG_CONFIG_HOME/vim/after' + + let g:netrw_home = $XDG_DATA_HOME . "/vim" + call mkdir($XDG_DATA_HOME . "/vim/spell", 'p') + set viewdir=$XDG_DATA_HOME/vim/view | call mkdir(&viewdir, 'p') + + set backupdir=$XDG_CACHE_HOME/vim/backup | call mkdir(&backupdir, 'p') + set directory=$XDG_CACHE_HOME/vim/swap | call mkdir(&directory, 'p') + set undodir=$XDG_CACHE_HOME/vim/undo | call mkdir(&undodir, 'p') + packadd vim-tmux-navigator + packadd vim-commentary + packadd vim-surround + packadd vim-ninja-feet + packadd vim-fugitive + packadd vim-unimpaired + packadd vim-better-whitespace + packadd notmuch-vim + packadd vim-dispatch + let g:notmuch_use_fzf = 1 + let g:notmuch_open_command = 'fzf' + let g:notmuch_fzf_command = 'fzf --reverse' + let g:notmuch_use_conversation_view = 1 + let sendmail_path = systemlist('sed -n "s/^set sendmail=\(.*\)$/\1/p; $!d" ~/.mailrc') + if len(sendmail_path) > 0 + let g:notmuch_sendmail=sendmail_path[0] + endif +endfunction +augroup user_cmds + autocmd! + autocmd VimEnter * call timer_start(20, function('s:load_plugins')) +augroup END + +if has("gui") + source $XDG_CONFIG_HOME/vim/gvimrc +endif + +if has("win32") +set shell=cmd + set shellquote=\" + " shellxquote must be a literal space character. + set shellxquote= +else + set shell=sh +endif + +" Move to a file common to nvim and vim +function! ToggleList() + if &list == "nolist" + set list + else + set nolist + endif +endfunction + +function! ToggleBackground() + if &background == "light" + set background=dark + else + set background=light + endif +endfunction + +function! FileMvHelper() + :normal! 0i"A"0y$A p0imv j0 +endfunction +" Run Make + +function SaveAndBuild() + wall + Make +endfunction + +function QuickUnderline(n) + if a:n == 1 + normal! yypv$r= + else + normal! yypv$r- + endif +endfunction + +function ReverseDate() + normal! dt/wwpldeBP +endfunction + + +" TODO load this automatically +source $XDG_CONFIG_HOME/vim/ftplugin/cpp.vim + +let g:birck_default_chan="irc.libera.chat" + +" Strip the newline from the end of a string +function! Chomp(str) + return substitute(a:str, '\n$', '', '') +endfunction + +" Find a file and pass it to cmd +function! DmenuOpen(cmd) + let fname = Chomp(system("git ls-files | dmenu-mac -i -l 20 -p " . a:cmd)) + if empty(fname) + return + endif + execute a:cmd . " " . fname +endfunction + +" find file in git repo +function! ChooseFile() + let dir = expand("%:h") + if empty(dir) | let dir = getcwd() | endif + + let root = system("cd " . dir . " && git rev-parse --show-toplevel") + if v:shell_error != 0 | echo "Not in a git repo" | return | endif + let root = root[0:-2] + + let selection = system("cd " . root . " && git ls-files -co --exclude-standard | choose") + if empty(selection) | echo "Canceled" | return | end + + echo "Finding file..." + exec ":e " . root . "/" . selection +endfunction + +function! DiffWithSaved() + let filetype=&ft + diffthis + vnew | r # | normal! 1Gdd + diffthis + exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype +endfunction +