dotfiles

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

commit 4f8291584be6a899e852df63a9b334f03bae1405
parent eae741cfb1ee31192a1bf6b3e14bebbc5754658b
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date:   Tue, 10 Oct 2023 14:06:48 +0530

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

Diffstat:
M.config/alacritty/alacritty.yml | 17+----------------
M.config/clink/clink_settings | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
D.config/cmd/env.bat | 16----------------
M.config/cmd/profile.cmd | 20+++++++++++++++++---
R.gitignore -> .config/git/ignore | 0
A.config/mac/.cache/alacritty_unstaged.yml | 8++++++++
A.config/mac/hard.sh | 11+++++++++++
M.config/nvim/init.lua | 26++++++++++----------------
M.config/nvim/lua/keybindings.lua | 2+-
A.config/nvim/plugins | 2++
M.config/sh/aliases | 7+++++--
M.config/sh/functions | 23+++++++++++++++++------
M.config/user-dirs.dirs | 16++++++++--------
D.config/vim/keybindings.vim | 164-------------------------------------------------------------------------------
D.config/vim/plugin/plugin.vim | 76----------------------------------------------------------------------------
D.config/vim/vimrc | 124-------------------------------------------------------------------------------
D.gitmodules | 21---------------------
M.local/bin/sh/cam | 2+-
M.local/bin/sh/extract.sh | 1+
A.local/run/.gitkeep | 0
M.local/share/vim/hyper-red.vim | 21++++++++++++++++-----
A.local/share/vim/keybindings.vim | 180+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A.local/share/vim/plugin.vim | 78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
M.local/share/vim/plugins | 59+++++++++++++++++++++++++++++++++--------------------------
M.local/share/vim/vimrc | 3+++
M.profile | 68+++++++++++++++++++++++++++++++++++---------------------------------
A.vimrc | 166+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
27 files changed, 662 insertions(+), 520 deletions(-)

diff --git a/.config/alacritty/alacritty.yml b/.config/alacritty/alacritty.yml @@ -1,17 +1,5 @@ import: - - ~/.config/alacritty/windows.yml - - ~/.config/alacritty/unstaged.yml - -key_bindings: - - { key: N, mods: Control|Shift, action: CreateNewWindow} - -colors: - primary: - background: '0x000000' - foreground: '0xffffff' - cursor: - text: '0xF81CE5' - cursor: '0xffffff' + - ~/.cache/alacritty_unstaged.yml live_config_reload: true @@ -21,6 +9,3 @@ bell: selection: save_to_clipboard: true -# No title bar, use shortcuts -window: - decorations: none diff --git a/.config/clink/clink_settings b/.config/clink/clink_settings @@ -1,2 +1,69 @@ -clink.autostart=%XDG_CONFIG_HOME%\cmd\profile.cmd -clink.logo=none +# name: Command to run when injected +# type: string +clink.autostart = %XDG_CONFIG_HOME%\cmd\profile.cmd + +# name: Auto-update the Clink program files +# type: boolean +clink.autoupdate = False + +# name: Controls what startup logo to show +# type: enum +# options: none,full,short +clink.logo = none + +# name: Argument color +# type: color +color.arg = bold + +# name: Argument info color +# type: color +color.arginfo = yellow + +# name: Shell command completions +# type: color +color.cmd = bold + +# name: Color for < and > redirection symbols +# type: color +color.cmdredir = bold + +# name: Color for & and | command separators +# type: color +color.cmdsep = bold + +# name: Color for comment row +# type: color +color.comment_row = bright white on cyan + +# name: Description completion color +# type: color +color.description = bright cyan + +# name: Doskey completions +# type: color +color.doskey = bold cyan + +# name: Filtered completion color +# type: color +color.filtered = bold + +# name: Flag color +# type: color +color.flag = default + +# name: For user-interaction prompts +# type: color +color.interact = bold + +# name: Message area color +# type: color +color.message = default + +# name: Color for suggestion text +# type: color +color.suggestion = bright black + +# name: Unexpected argument color +# type: color +color.unexpected = default + diff --git a/.config/cmd/env.bat b/.config/cmd/env.bat @@ -1,16 +0,0 @@ -set HOME=%USERPROFILE% -set XDG_CONFIG_HOME=%USERPROFILE%\.config -set XDG_DATA_HOME=%USERPROFILE%\.local\share -set XDG_CACHE_HOME=%USERPROFILE%\.cache -set VISUAL=vim -set EDITOR=%VISUAL% - -set GNUPGHOME=%XDG_DATA_HOME%\gnupg -set GPGHOME=%XDG_DATA_HOME%\gnupg -set PASSWORD_STORE_DIR=%XDG_DATA_HOME%\pass -set PASS_BASE_DIR=%XDG_DATA_HOME%\pass -set NB_PATH=%XDG_DATA_HOME%\notebook - -set MYVIMRC=%XDG_CONFIG_HOME%\vim\vimrc -set VIMINIT=source $MYVIMRC -set PATH=%PATH%;%USERPROFILE%\.local\bin\cmd diff --git a/.config/cmd/profile.cmd b/.config/cmd/profile.cmd @@ -2,6 +2,20 @@ cd %USERPROFILE% -@call %XDG_CONFIG_HOME%\cmd\env.bat -@call %XDG_CONFIG_HOME%\cmd\userenv.bat -@call %XDG_CONFIG_HOME%\cmd\aliases.bat +set HOME=%USERPROFILE% +set XDG_CONFIG_HOME=%HOME%/.config +set XDG_DATA_HOME=%HOME%/.local/share +set XDG_CACHE_HOME=%HOME%/.cache +set VISUAL=vim +set EDITOR=%VISUAL% + +set GNUPGHOME=%XDG_DATA_HOME%/gnupg +set GPGHOME=%XDG_DATA_HOME%/gnupg +set PASSWORD_STORE_DIR=%XDG_DATA_HOME%/pass +set PASS_BASE_DIR=%XDG_DATA_HOME%/pass +set NB_PATH=%XDG_DATA_HOME%/notebook + +set PATH=%PATH%;%USERPROFILE%/.local/bin/cmd + +@call %XDG_CONFIG_HOME%/cmd/aliases.bat +@call %XDG_CONFIG_HOME%/cmd/userenv.bat diff --git a/.gitignore b/.config/git/ignore 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 @@ -29,13 +29,11 @@ g.netrw_liststyle = 3 vim.cmd([[ source $XDG_DATA_HOME/vim/hyper-red.vim + source $XDG_DATA_HOME/vim/plugin.vim ]]) function load_plugns() vim.cmd([[ - set packpath+=$XDG_DATA_HOME/vim - packadd fzf - packadd fzf.vim packadd vim-fugitive packadd vim-ninja-feet packadd vim-surround @@ -43,22 +41,18 @@ function load_plugns() packadd vim-unimpaired packadd vim-xcode packadd vim-dispatch - - packadd nvim-dap - packadd nvim-dap-ui - packadd nvim-lspconfig ]]) - require"dapui".setup() - require"lspconfig".clangd.setup{} - require"unstaged" + --require"dapui".setup() + --require"lspconfig".clangd.setup{} + --require"unstaged" - require('dap').adapters.cppdbg = { - type = 'executable', - command = 'lldb-vscode', - name = 'cppdbg' - } + --require('dap').adapters.cppdbg = { + -- type = 'executable', + -- command = 'lldb-vscode', + -- name = 'cppdbg' + --} - require('dap.ext.vscode').load_launchjs(nil, { cppdbg = {'c', 'cpp'} }) + --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,6 +1,6 @@ local map = vim.keymap.set -vim.cmd[[source $XDG_CONFIG_HOME/vim/keybindings.vim]] +vim.cmd[[source $XDG_DATA_HOME/vim/keybindings.vim]] vim.api.nvim_create_autocmd('LspAttach', { callback = function(args) diff --git a/.config/nvim/plugins b/.config/nvim/plugins @@ -0,0 +1,2 @@ +mfussenegger/nvim-dap +rcarriga/nvim-dap-ui diff --git a/.config/sh/aliases b/.config/sh/aliases @@ -44,11 +44,14 @@ alias g=git alias l=lfcd alias le=less alias m=smartmake -alias v="VIMINIT='' nvim" +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 @@ -2,13 +2,24 @@ 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) - abduco -a $sesh_name || { - echo "Do you want to create session: $sesh_name? (press any key)"; - read a && abduco -c $sesh_name mtm; - } + test -z "$sesh_name" && return + abduco -a $sesh_name || abduco -c $sesh_name mtm; fi [ $# -gt 0 ] && abduco -a $1 } @@ -36,7 +47,7 @@ thwart() { quickopen() { if ! there "${FUZZER}"; then printf '${FUZZER} not available\n' - exit 1 + return fi # TODO maybe add -type in the future TODO add $name @@ -58,7 +69,7 @@ quickopen() { cd "$somethin" else printf '%s: is neither a file nor a directory\n' "$somethin" - exit 1 + return fi } 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,164 +0,0 @@ -" General keybindings -nnoremap <leader>aa :argadd **<cr> -nnoremap <leader>co :copen<cr> -nnoremap <leader>cd :cdo<space>s/ -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>fa :find * -nnoremap <leader>ff :find * -nnoremap <leader>lb :ls<cr>:b<space> -nnoremap <leader>ld :ldo<space>s/ -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>spp :set paste<cr> -nnoremap <leader>spa :set path+=**<cr> -nnoremap <leader>tt :tabnew<cr> -nnoremap <leader>ta :tab * -nnoremap <leader>vg :vimgrep<space> -" Buffer Creation -nnoremap <leader>sc :source $XDG_CONFIG_HOME/vim/vimrc<cr> -nnoremap <leader>ss :split<cr> -nnoremap <leader>vv :vsplit<cr> -nnoremap <leader>wd :call DiffWithSaved()<cr> - -" netrw keybindings -nnoremap <leader>sf :Ex<cr> - -" 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$ - -" development -nnoremap <leader>oc :grepadd /:: % -nnoremap <leader>oh :grepadd /:: % - -nnoremap <leader>fb :b * - -fun! SaveAndBuild() - :wall - :Make -endfun - -" quick navigation -nnoremap \f :GFiles<cr> -nnoremap \F :Files<cr> -" TODO setup this up with fzf -nnoremap \g :Ggrep<cr> - -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> - -" useful -nnoremap <leader>nn :set number<cr> - -" development -nnoremap <leader>bb :call SaveAndBuild()<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> - -" vim-fugitive -nnoremap <leader>gb :G blame<cr> -nnoremap <leader>gd :Gvdiff<CR> -nnoremap <leader>gg :Ggrep<space> -nnoremap <leader>gr :G reset %<cr> -nnoremap <leader>gwq :Gwq<cr> -nnoremap <leader>lg :Glgrep<space> - - -" Generate ctags -nnoremap<leader>gt :!sh -c "ctags `git --ls-files`"<CR> - -nnoremap <CR> :noh<CR><CR>:<backspace> - -" Markdown - Add checkbox mode? -nnoremap <leader>cc :ChecklistToggleCheckbox<cr> -nnoremap <leader>ct :ChecklistToggleCheckbox<cr> -nnoremap <leader>ce :ChecklistEnableCheckbox<cr> -"nnoremap <leader>cd :ChecklistDisableCheckbox<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 - -" 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 - -" nb -" TODO open a fuzzy finder quickly. Even better use fuzzy finder without chdir -nnoremap <leader>nb :chdir $NB_PATH<cr> - -nnoremap cn *``cgn -nnoremap cN *``cgN -let g:mc = "y/\\V\<C-r>=escape(@\", '/')\<CR>\<CR>" -vnoremap <expr> cn g:mc . "``cgn" diff --git a/.config/vim/plugin/plugin.vim b/.config/vim/plugin/plugin.vim @@ -1,76 +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 - - -function! DiffWithSaved() - let filetype=&ft - diffthis - vnew | r # | normal! 1Gdd - diffthis - exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype -endfunction - - diff --git a/.config/vim/vimrc b/.config/vim/vimrc @@ -1,124 +0,0 @@ -if has('nvim') - luafile ~/.config/nvim/init.lua - finish -else - if has("&viminfofile") - set viminfofile=$XDG_CACHE_DIR/vim/viminfo - endif -endif - -set complete-=i - -" 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 fzf - packadd fzf.vim - 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= -endif diff --git a/.gitmodules b/.gitmodules @@ -1,21 +0,0 @@ -[submodule ".local/share/vim/pack/general/opt/vim-better-whitespace"] - path = .config/nvim/vim-vinegar - url = https://github.com/tpope/vim-vinegar -[submodule ".local/share/nvim/pack/general/start/vim-vinegar"] - path = .local/share/vim/pack/general/start/vim-vinegar - url = https://github.com/tpope/vim-vinegar -[submodule ".local/share/vim/pack/general/opt/birck.vim"] - path = .local/share/vim/pack/general/opt/vim-ninja-feet/birck.vim - url = https://git.sr.ht/~torresjrjr/birck.vim -[submodule ".local/share/vim/pack/general/opt/vim-maildir"] - path = .local/share/vim/pack/general/opt/vim-maildir - url = https://github.com/ferranpm/vim-maildir -[submodule ".local/share/nvim/pack/dev/opt/nvim-dap-ui"] - path = .local/share/nvim/pack/dev/opt/nvim-dap-ui - url = https://github.com/rcarriga/nvim-dap-ui -[submodule ".local/share/nvim/pack/dev/start/nvim-lspconfig"] - path = .local/share/nvim/pack/dev/opt/nvim-lspconfig - url = https://github.com/neovim/nvim-lspconfig -[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/extract.sh b/.local/bin/sh/extract.sh @@ -7,6 +7,7 @@ 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" ;; diff --git a/.local/run/.gitkeep b/.local/run/.gitkeep diff --git a/.local/share/vim/hyper-red.vim b/.local/share/vim/hyper-red.vim @@ -4,13 +4,21 @@ " 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=NONE + hi! DiffText guifg=DarkBlue ctermfg=DarkYellow 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! Special cterm=bold ctermfg=LightMagenta guifg=LightMagenta + hi! Statement ctermfg=NONE guifg=NONE + hi! Constant ctermfg=LightBlue guifg=LightBlue + hi! Error ctermbg=NONE guibg=NONE ctermfg=DarkRed guifg=DarkRed + hi! String ctermfg=DarkGray guifg=DarkGray + hi! Special cterm=NONE ctermfg=LightMagenta guifg=NONE hi! Identifier ctermfg=White guifg=White hi! IncSearch ctermbg=Black ctermfg=Yellow guibg=Black guifg=Yellow hi! Search ctermbg=LightBlue ctermfg=Black guibg=DarkGray guifg=Black @@ -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/keybindings.vim b/.local/share/vim/keybindings.vim @@ -0,0 +1,180 @@ +" General keybindings +nnoremap <leader>aa :argadd **<cr> +nnoremap <leader>co :copen<cr> +nnoremap <leader>cd :cdo<space>s/ +nnoremap <leader>cs :cdo<space>s/ +nnoremap <leader>ec :edit $HOME/.vimrc<cr> +nnoremap <leader>ek :edit $XDG_DATA_HOME/vim/keybindings.vim<cr> +nnoremap <leader>et :set expandtab<cr> +nnoremap <leader>fa :find * +nnoremap <leader>ff :find * +nnoremap <leader>lb :ls<cr>:b<space> +nnoremap <leader>ld :ldo<space>s/ +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>spp :set paste<cr> +nnoremap <leader>spa :set path+=**<cr> +nnoremap <leader>tt :tabnew<cr> +nnoremap <leader>ta :tab * +nnoremap <leader>vg :vimgrep<space> +nnoremap <leader>/ :cdo %s/ + +" Buffer Creation +nnoremap <leader>sc :source $XDG_CONFIG_HOME/vim/vimrc<cr> +nnoremap <leader>ss :split<cr> +nnoremap <leader>vv :vsplit<cr> +nnoremap <leader>wd :call DiffWithSaved()<cr> + +fun! SaveAndSuspend() + :w + :suspend +endfun + +nnoremap <silent> <leader>zj :call NextClosedFold('j')<cr> +nnoremap <silent> <leader>zk :call NextClosedFold('k')<cr> + +function! NextClosedFold(dir) + let cmd = 'norm!z'..a:dir + let view = winsaveview() + let [l0, l, open] = [0, view.lnum, 1] + while l != l0 && open + exe cmd + let [l0, l] = [l, line('.')] + let open = foldclosed(l) < 0 + endwhile + if open + call winrestview(view) + endif +endfunction + + +" Control +nnoremap <c-z> :call SaveAndSuspend()<cr> +inoremap <c-z> :call SaveAndSuspend()<cr> + +nnoremap <c-f> :bnext<cr> +nnoremap <c-b> :bprevious<cr> + +" 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$ +nnoremap Q :noh<cr> + +" development +nnoremap <leader>oc :grepadd /:: % +nnoremap <leader>oh :grepadd /:: % + +nnoremap <leader>fb :b * + +nnoremap <c-p> :call FZYFiles()<cr> +" TODO reflect on whether <leader><leader> is productive, I keep hitting it +" accidentally +"nnoremap <leader><leader> :Rg<cr> +" TODO setup this up with fzf +nnoremap \g :Ggrep<cr> + +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> + +" useful +nnoremap <leader>nn :set number<cr> + +" development +nnoremap <leader>bb :call SaveAndBuild()<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> + +" vim-fugitive +nnoremap <leader>gb :G blame<cr> +nnoremap <leader>gd :Gvdiff<CR> +nnoremap <leader>gg :Ggrep<space> +nnoremap <leader>gr :G reset %<cr> +nnoremap <leader>gwq :Gwq<cr> +nnoremap <leader>lg :Glgrep<space> + + +" Generate ctags +nnoremap<leader>gt :!sh -c "ctags `git ls-files`"<CR> + +nnoremap <CR> :noh<CR><CR>:<backspace> + +" Markdown - Add checkbox mode? +nnoremap <leader>cc :ChecklistToggleCheckbox<cr> +nnoremap <leader>ct :ChecklistToggleCheckbox<cr> +nnoremap <leader>ce :ChecklistEnableCheckbox<cr> +"nnoremap <leader>cd :ChecklistDisableCheckbox<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 + +nnoremap <leader>h1 :call QuickUnderline(1)<cr> +nnoremap <leader>h2 :call QuickUnderline(2)<cr> + +fun! GotoWindow(id) + call win_gotoid(a:id) +endfun + +" 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 + +" nb +" TODO open a fuzzy finder quickly. Even better use fuzzy finder without chdir +nnoremap <leader>nb :chdir $NB_PATH<cr> + +nnoremap cn *``cgn +nnoremap cN *``cgN +let g:mc = "y/\\V\<C-r>=escape(@\", '/')\<CR>\<CR>" +vnoremap <expr> cn g:mc . "``cgn" + + diff --git a/.local/share/vim/plugin.vim b/.local/share/vim/plugin.vim @@ -0,0 +1,78 @@ +" 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 + +" 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 + + diff --git a/.local/share/vim/plugins b/.local/share/vim/plugins @@ -1,32 +1,39 @@ -cfdrake/vim-pbxproj -christoomey/vim-tmux-navigator -evansalter/vim-checklist -ferranpm/vim-maildir -gfontenot/vim-xcode -jerrymarino/xcodebuild.vim -joereynolds/vim-minisnip/ -junegunn/fzf -junegunn/fzf.vim -kana/vim-submode -keith/swift.vim -nachumk/systemverilog.vim -ntpeters/vim-better-whitespace.git -omniSharp/omnisharp-vim -pope/vim-repeat.git -radenling/vim-dispatch-neovim -tommcdo/vim-ninja-feet.git -tpope/vim-commentary.git +tpope/vim-commentary tpope/vim-dispatch tpope/vim-fugitive -tpope/vim-surround.git +tpope/vim-surround tpope/vim-unimpaired -tpope/vim-vinegar -tpope/vim-vinegar -vim-scripts/gitignore -torrancew/vim-openscad -yegappan/mru -https://github.com/bfrg/vim-jqplay -notmuch-vim/notmuch-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 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 @@ -5,59 +5,61 @@ 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_HOME="$XDG_ROOT/.runtime" +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 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 CARGO_HOME="$XDG_DATA_HOME"/cargo -export GEM_HOME="$XDG_DATA_HOME"/gem -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 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 " diff --git a/.vimrc b/.vimrc @@ -0,0 +1,166 @@ +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 | fzf > ' . 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 + +" TODO load this automatically +source $XDG_CONFIG_HOME/vim/ftplugin/cpp.vim +source $XDG_DATA_HOME/vim/plugin.vim + +let g:birck_default_chan="irc.libera.chat"