commit 5a1fd219a4bd77efac1183dbb74142ca0a8af90c
parent 37089116c513e3b10faa9b4a3415f4e0644e0606
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Wed, 30 Jul 2025 12:26:25 +0000
parent 37089116c513e3b10faa9b4a3415f4e0644e0606
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Wed, 30 Jul 2025 12:26:25 +0000
Merge branch 'main' of nonplanar.org:dotfiles
24 files changed, 932 insertions(+), 210 deletions(-)
M
|
102
++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------
A
|
589
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
M
|
88
++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------
M
|
79
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------
diff --git a/.config/cmd/setup.cmd b/.config/cmd/setup.cmd @@ -1,21 +1,39 @@ @echo on rem TODO Make this work for Administrator accounts - goto :main :set_var - set _tail=%* - call set _tail=%%_tail:*%1 =%% - echo Setting "%~1" to "%_tail%" - setx %~1 "%_tail%" - set %~1=%_tail% + set "_tail=%*" + call set "_tail=%%_tail:*%1 =%%" + echo.%~1 %_tail% + setx "%~1" "%_tail%" >nul + set "%~1=%_tail%" goto :eof :add_path - for /f "tokens=2* skip=2" %%i in ('reg query HKCU\Environment /v PATH') do ( - echo %%j | find /i "%~1" || call :set_var PATH %%j;%~1 + setlocal EnableDelayedExpansion + + for /f "skip=2 tokens=2*" %%i in ('reg query "HKCU\Environment" /v PATH 2^>nul') do ( + set "UserPath=%%j" ) + + if not defined UserPath set "UserPath=" + + echo !UserPath! | findstr /I /L /C:"%~1" >nul + if errorlevel 1 ( + if defined UserPath ( + set "NewUserPath=!UserPath!;%~1" + ) else ( + set "NewUserPath=%~1" + ) + echo Adding to PATH: %~1 + setx PATH "!NewUserPath!" >nul + set PATH="!NewUserPath!" + ) else ( + echo Skipping PATH add: %~1 + ) +endlocal goto :eof :update_shim <shim_file> <path> <args> @@ -24,30 +42,30 @@ goto :eof goto :eof :main -where scoop >nul 2>&1 -if not %errorlevel% equ 0 ( -rem Run this in powershell, before - echo Run this in powershell to install scoop and run this script again: - echo Set-ExecutionPolicy RemoteSigned -scope CurrentUser - echo powershell -Command "Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')" - rem Install only the absolute essentials - echo scoop config shim 71 - echo scoop reset -a - echo scoop install 7zip clink dos2unix grep gpg lf make mingit mpv sed sudo unzip vim - exit 1 -) - @call %~dp0\..\profile.cmd %1 -call :set_var XDG_ROOT %USERPROFILE% -if NOT "%1" == "" call :set_var XDG_ROOT "" - -call :add_path "C:\bin" -call :set_var XDG_ROOT %USERPROFILE% +if "%~1" == "" ( + call :set_var XDG_ROOT %USERPROFILE% +) else ( + call :set_var XDG_ROOT "%~1" +) call :set_var XDG_CONFIG_HOME %XDG_ROOT%\.config call :set_var XDG_DATA_HOME %XDG_ROOT%\.local\share call :set_var XDG_CACHE_HOME %XDG_ROOT%\.cache -call :set_var SCOOP %XDG_ROOT%\scoop +if "%SCOOP_DIR%"=="" set "SCOOP_DIR=%XDG_ROOT%\scoop" + +if not exist "%SCOOP_DIR%\shims\scoop.cmd" ( + + rem Run this in powershell to install scoop and run this script again: + rem Set-ExecutionPolicy RemoteSigned -scope CurrentUser + rem echo powershell -Command "Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')" + echo If you want to install scoop globally run the contents of + echo ^%XDG_ROOT^%\.config\cmd\global_scoop.ps1 + + rem Install only the absolute essentials + rem scoop install 7zip clink dos2unix grep gpg lf make mingit mpv sed sudo unzip vim + goto :EOF +) call :set_var VISUAL vim call :set_var EDITOR %VISUAL% @@ -60,28 +78,42 @@ call :set_var PASS_BASE_DIR %XDG_DATA_HOME%\pass call :set_var LYNX_CFG %XDG_CONFIG_HOME%/lynx/lynx.cfg call :set_var LYNX_LSS %XDG_CONFIG_HOME%/lynx/lynx.lss -call :set_var FUZZER fzf +call :set_var VIFM %XDG_CONFIG_HOME%\vifm -call :add_path %USERPROFILE%\.local\bin\cmd +call :set_var FUZZER fzf rem Apply config patches rem TODO Use mklink instead of xcopy, it will prevent overriding changed files in the destination dir. -xcopy /Y %XDG_ROOT%\.config\cmd\patch %XDG_ROOT%\ /S /E +xcopy /S /E /Y %XDG_ROOT%\.config\cmd\patch %XDG_ROOT%\ + +if not exist "%SYSTEMDRIVE%\bin" ( mkdir %SYSTEMDRIVE%\bin ) -mkdir %SYSTEMDRIVE%\bin if EXIST "%SCOOP%\apps\busybox\current\busybox.exe" ( copy "%SCOOP%\apps\busybox\current\busybox.exe" %SYSTEMDRIVE%\bin copy "%SCOOP%\apps\scoop\current\supporting\shims\71\shim.exe" %SYSTEMDRIVE%\bin\sh.exe call :update_shim C:\bin\sh.shim "C:\bin\busybox.exe" "sh -l" ) + if EXIST "%SCOOP%\apps\lynx\current\lynx.exe" ( call :update_shim "%SCOOP%\shims\lynx.shim" "%SCOOP%\apps\lynx\current\lynx.exe" "-cfg %XDG_CONFIG_HOME%\lynx\lynx.cfg" ) rem TODO Report this in scoop and remove this line -del %SCOOP%\apps\gpg\current\bin\gpgconf.ctl +if EXIST %SCOOP%\apps\gpg\current\bin\gpgconf.ctl ( + del %SCOOP%\apps\gpg\current\bin\gpgconf.ctl +) -call clink autorun install -- clink inject -q -call clink set clink.autostart "%XDG_CONFIG_HOME%\profile.cmd" -call clink set clink.autoupdate off +call :add_path "%XDG_ROOT%\scoop\shims" +rem Always use \\ infront of '.' (causes issue with findstr) +call :add_path "%XDG_ROOT%\\.local\bin\cmd" +call :add_path "%SYSTEMDRIVE%\bin" +set CLINK_EXE="%XDG_ROOT%\scoop\shims\clink.exe" + +if errorlevel 0 ( + echo Setting up clink + clink autorun set >nul + clink autorun install +) else ( + echo Cannot find clink in system +)
diff --git a/.config/profile.cmd b/.config/profile.cmd @@ -3,7 +3,7 @@ doskey n=cd $* doskey g=git $* doskey e=%EDITOR% $* -doskey l=lfcd.cmd +doskey l=vifm . doskey ls=dir /B $* doskey m=make $* doskey pwd=cd @@ -15,4 +15,8 @@ doskey hb=sh %USERPROFILE%\.local\bin\sh\hb $* doskey d=curl -fLO $* doskey x=7z x $* +set FM=vifm + +IF /I x"%COMSPEC%"==x%CMDCMDLINE% (cd /D %USERPROFILE%) + if exist "%XDG_CONFIG_HOME%\cmd\userenv.cmd" @call %XDG_CONFIG_HOME%\cmd\userenv.cmd
diff --git a/.config/sh/aliases b/.config/sh/aliases @@ -42,14 +42,15 @@ alias e='${EDITOR}' alias f=quickopen alias g=git # TODO Use nnncd -alias l=nnn +alias l='vifm .' alias le=less alias m=smartmake alias x=extract.sh there rc || alias rc='sudo systemctl' # [midlonghands] -alias op='cd $(open_project "$HOME/repo" | fzf)' +alias or='open_project ~/repo' +alias orr='open_project ~/resrepo' alias girl='grep -irl' alias gir='grep -ir' alias markdown=md2html
diff --git a/.config/sh/functions b/.config/sh/functions @@ -7,10 +7,12 @@ there() { open_project() { # search only dirs - search_loc=${1:-.}/* - for i in $search_loc/.git/ $search_loc/*/.git/; do - echo "$i.." - done + search_loc=${1:-.} + cd "${search_loc}" + projdir=$(ls -d */.git | sed 's/.git$//g' | $FUZZER) + if [ -d "${projdir}" ]; then + cd "${projdir}" + fi } && export $is_bash open_project attach() {
diff --git a/.config/vifm/vifmrc b/.config/vifm/vifmrc @@ -0,0 +1,589 @@ +" vim: filetype=vifm : +" Sample configuration file for vifm (last updated: 3 April, 2023) +" You can edit this file by hand. +" The " character at the beginning of a line comments out the line. +" Blank lines are ignored. +" The basic format for each item is shown with an example. + +" ------------------------------------------------------------------------------ +" Main settings +" ------------------------------------------------------------------------------ + +" Command used to edit files in various contexts. The default is vim. +" If you would like to use another vi clone such as Elvis or Vile +" you will need to change this setting. +if executable('vim') + set vicmd=vim +elseif executable('nvim') + set vicmd=nvim +elseif executable('elvis') + set vicmd=elvis\ -G\ termcap +elseif executable('vile') + set vicmd=vile +elseif $EDITOR != '' + echo 'Note: using `'.$EDITOR.'` as an editor' + let &vicmd = $EDITOR +endif + +" This makes vifm perform file operations on its own instead of relying on +" standard utilities like `cp`. While using `cp` and alike is a more universal +" solution, it's also much slower when processing large amounts of files and +" doesn't support progress measuring. +set syscalls + +" Trash Directory +" The default is to move files that are deleted with dd or :d to +" the trash directory. If you change this you will not be able to move +" files by deleting them and then using p to put the file in the new location. +" I recommend not changing this until you are familiar with vifm. +" This probably shouldn't be an option. +set trash + +" What should be saved automatically on restarting vifm. Drop "savedirs" +" value if you don't want vifm to remember last visited directories for you. +set vifminfo=dhistory,chistory,state,tui,shistory, + \phistory,fhistory,dirstack,registers,bookmarks,bmarks + +" This is how many directories to store in the directory history. +set history=100 + +" Automatically resolve symbolic links on l or Enter. +set nofollowlinks + +" Natural sort of (version) numbers within text. +set sortnumbers + +" Maximum number of changes that can be undone. +set undolevels=100 + +" Use Vim's format of help file (has highlighting and "hyperlinks"). +" If you would rather use a plain text help file set novimhelp. +set vimhelp + +" If you would like to run an executable file when you +" press Enter, l or Right Arrow, set this. +set norunexec + +" Format for displaying time in file list. For example: +" TIME_STAMP_FORMAT=%m/%d-%H:%M +" See man date or man strftime for details. +set timefmt='%Y/%m/%d %H:%M' + +" Show list of matches on tab completion in command-line mode +set wildmenu + +" Display completions in a form of popup with descriptions of the matches +set wildstyle=popup + +" Display suggestions in normal, visual and view modes for keys, marks and +" registers (at most 5 files). In other view, when available. +set suggestoptions=normal,visual,view,otherpane,keys,marks,registers + +" Ignore case in search patterns unless it contains at least one uppercase +" letter +set ignorecase +set smartcase + +" Don't highlight search results automatically +set nohlsearch + +" Use increment searching (search while typing) +set incsearch + +" Try to leave some space from cursor to upper/lower border in lists +set scrolloff=0 + +" Don't do too many requests to slow file systems +if !has('win') + set slowfs=curlftpfs +endif + +" Set custom status line look +set statusline=" Hint: %z%= %A %10u:%-7g %15s %20d " + + +" ------------------------------------------------------------------------------ +" Bookmarks +" ------------------------------------------------------------------------------ + +" :mark mark /full/directory/path [filename] + +mark b ~/.local/bin/ +mark h ~/ +mark l ~/AppData/Local + +" ------------------------------------------------------------------------------ +" Commands +" ------------------------------------------------------------------------------ + +" :com[mand][!] command_name action +" +" These are some of the macros that can be used in the action part: +" %a for user arguments +" %c for current file under the cursor +" %C for current file under the cursor of inactive pane +" %f for selected file(s) +" %F for selected file(s) of inactive pane +" %b is the same as %f %F +" %d for current directory name +" %D for current directory name of inactive pane +" %r{x} for list of files in register {x} +" %m runs the command in a menu window +" %u uses command's output to build a file list +" see `:help vifm-macros` and `:help vifm-filename-modifiers` for more + +command! df df -h %m 2> /dev/null +command! diff vim -d %f %F +command! zip zip -r %c.zip %f +command! run !! ./%f +command! make !!make %a +command! mkcd :mkdir %a | cd %a +command! vgrep vim "+grep %a" +command! reload :write | restart full + +" ------------------------------------------------------------------------------ +" File types association +" ------------------------------------------------------------------------------ + +" :filetype pattern1,pattern2 defaultprogram,program2 +" :fileviewer pattern1,pattern2 consoleviewer +" +" The first entry is the default program to be used with a matching file. +" The other programs for the file type can be accessed via :file command. +" The command macros like %f, %F, %d, %D may be used in the commands. +" The %a macro is ignored. To use a % you must put %%. +" Spaces in an app name must be escaped, for example: QuickTime\ Player.app + +" For automated FUSE mounts, you must register an extension with :file[x]type +" in one of the following formats: +" +" :filetype patterns FUSE_MOUNT|mount_cmd %SOURCE_FILE %DESTINATION_DIR +" +" %SOURCE_FILE and %DESTINATION_DIR are filled in at runtime. +" +" Example: +" :filetype *.zip,*.[jwe]ar FUSE_MOUNT|fuse-zip %SOURCE_FILE %DESTINATION_DIR +" +" :filetype patterns FUSE_MOUNT2|mount_cmd %PARAM %DESTINATION_DIR +" +" %PARAM and %DESTINATION_DIR are filled in at runtime. +" +" Example: +" :filetype *.ssh FUSE_MOUNT2|sshfs %PARAM %DESTINATION_DIR +" +" %PARAM value is the first line of the matched file, example: root@127.0.0.1:/ +" +" You can also add %CLEAR if you want to clear screen before running FUSE +" program. There is also %FOREGROUND, which is useful for entering passwords. + +" Pdf +filextype {*.pdf},<application/pdf> zathura %c %i, apvlv %c, xpdf %c +fileviewer {*.pdf},<application/pdf> pdftotext -nopgbrk %c - + +" PostScript +filextype {*.ps,*.eps,*.ps.gz},<application/postscript> + \ {View in zathura} + \ zathura %f, + \ {View in gv} + \ gv %c %i, + +" Djvu +filextype {*.djvu},<image/vnd.djvu> + \ {View in zathura} + \ zathura %f, + \ {View in apvlv} + \ apvlv %f, + +" Midi +filetype {*.mid,*.kar} + \ {Play using TiMidity++} + \ timidity %f, + +" Audio +filetype {*.wav,*.mp3,*.flac,*.m4a,*.wma,*.ape,*.ac3,*.og[agx],*.spx,*.opus, + \*.aac,*.mpga}, + \<audio/*> + \ {Play using MPlayer} + \ mplayer %f, + \ {Play using mpv} + \ mpv --no-video %f %s, + \ {Play using ffplay} + \ ffplay -nodisp -hide_banner -autoexit %c, +fileviewer {*.wav,*.mp3,*.flac,*.m4a,*.wma,*.ape,*.ac3,*.og[agx],*.spx,*.opus, + \*.aac,*.mpga}, + \<audio/*> + \ ffprobe -hide_banner -pretty %c 2>&1 + +" Video +filextype {*.avi,*.mp4,*.wmv,*.dat,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob, + \*.fl[icv],*.m2v,*.mov,*.webm,*.ts,*.mts,*.m4v,*.r[am],*.qt,*.divx, + \*.as[fx],*.unknown_video}, + \<video/*> + \ {View using Dragon} + \ dragon %f:p, + \ {View using mplayer} + \ mplayer %"f, + \ {Play using mpv} + \ mpv --no-video %"f, + \ {View using ffplay} + \ ffplay -fs -hide_banner -autoexit %"f, +fileviewer {*.avi,*.mp4,*.wmv,*.dat,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob, + \*.fl[icv],*.m2v,*.mov,*.webm,*.ts,*.mts,*.m4v,*.r[am],*.qt,*.divx, + \*.as[fx],*.unknown_video}, + \<video/*> + \ ffprobe -hide_banner -pretty %c 2>&1 + +" Web +filextype {*.xhtml,*.html,*.htm},<text/html> + \ {Open with qutebrowser} + \ qutebrowser %f %i, + \ {Open with firefox} + \ firefox %f &, +filetype {*.xhtml,*.html,*.htm},<text/html> links, lynx + +" Object +filetype {*.o},<application/x-object> nm %f | less + +" Man page +filetype {*.[1-8]},<text/troff> man ./%c +fileviewer {*.[1-8]},<text/troff> man ./%c | col -b + +" Images +filextype {*.svg,*.svgz},<image/svg+xml> + \ {Edit in Inkscape} + \ inkscape %f, + \ {View in Inkview} + \ inkview %f, +filextype {*.cr2} + \ {Open in Darktable} + \ darktable %f, + \ {Open in RawTherapee} + \ rawtherapee %f, +filextype {*.xcf} + \ {Open in GIMP} + \ gimp %f, +filextype {.kra} + \ {Open in Krita} + \ krita %f, +filextype {.blend} + \ {Open in Blender} + \ blender %c, +filextype {*.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm},<image/*> + \ {View in sxiv} + \ sxiv %f, + \ {View in gpicview} + \ gpicview %c, + \ {View in shotwell} + \ shotwell, +fileviewer {*.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm},<image/*> + \ magick %"c -resize %pw sixel:- %pd + " \ identify %f + +" OpenRaster +filextype *.ora + \ {Edit in MyPaint} + \ mypaint %f, + +" Mindmap +filextype *.vym + \ {Open with VYM} + \ vym %f &, + +" MD5 +filetype *.md5 + \ {Check MD5 hash sum} + \ md5sum -c %f %S, + +" SHA1 +filetype *.sha1 + \ {Check SHA1 hash sum} + \ sha1sum -c %f %S, + +" SHA256 +filetype *.sha256 + \ {Check SHA256 hash sum} + \ sha256sum -c %f %S, + +" SHA512 +filetype *.sha512 + \ {Check SHA512 hash sum} + \ sha512sum -c %f %S, + +" GPG signature +filetype {*.asc},<application/pgp-signature> + \ {Check signature} + \ !!gpg --verify %c, + +" Torrent +filetype {*.torrent},<application/x-bittorrent> ktorrent %f & +fileviewer {*.torrent},<application/x-bittorrent> + \ dumptorrent -v %c, + \ transmission-show %c + +" FuseZipMount +filetype {*.zip,*.jar,*.war,*.ear,*.oxt,*.apkg}, + \<application/zip,application/java-archive> + \ {Mount with fuse-zip} + \ FUSE_MOUNT|fuse-zip %SOURCE_FILE %DESTINATION_DIR, + \ {View contents} + \ unzip -l %f | less, + \ {Extract here} + \ unzip %c, +fileviewer *.zip,*.jar,*.war,*.ear,*.oxt unzip -l %f + +" ArchiveMount +filetype {*.tar,*.tar.bz2,*.tbz2,*.tgz,*.tar.gz,*.tar.xz,*.txz,*.tar.zst, + \*.tzst}, + \<application/x-tar> + \ {Mount with archivemount} + \ FUSE_MOUNT|archivemount %SOURCE_FILE %DESTINATION_DIR, +fileviewer *.tgz,*.tar.gz tar -tzf %c +fileviewer *.tar.bz2,*.tbz2 tar -tjf %c +fileviewer *.tar.xz,*.txz tar -tJf %c +fileviewer *.tar.zst,*.tzst tar -t --zstd -f %c +fileviewer {*.tar},<application/x-tar> tar -tf %c + +" Rar2FsMount and rar archives +filetype {*.rar},<application/x-rar> + \ {Mount with rar2fs} + \ FUSE_MOUNT|rar2fs %SOURCE_FILE %DESTINATION_DIR, +fileviewer {*.rar},<application/x-rar> unrar v %c + +" IsoMount +filetype {*.iso},<application/x-iso9660-image> + \ {Mount with fuseiso} + \ FUSE_MOUNT|fuseiso %SOURCE_FILE %DESTINATION_DIR, + +" SshMount +filetype *.ssh + \ {Mount with sshfs} + \ FUSE_MOUNT2|sshfs %PARAM %DESTINATION_DIR %FOREGROUND, + +" FtpMount +filetype *.ftp + \ {Mount with curlftpfs} + \ FUSE_MOUNT2|curlftpfs -o ftp_port=-,,disable_eprt %PARAM %DESTINATION_DIR %FOREGROUND, + +" Fuse7z and 7z archives +filetype {*.7z},<application/x-7z-compressed> + \ {Mount with fuse-7z} + \ FUSE_MOUNT|fuse-7z %SOURCE_FILE %DESTINATION_DIR, +fileviewer {*.7z},<application/x-7z-compressed> 7z l %c + +" Office files +filextype {*.odt,*.doc,*.docx,*.xls,*.xlsx,*.odp,*.pptx,*.ppt}, + \<application/vnd.openxmlformats-officedocument.*, + \application/msword, + \application/vnd.ms-excel> + \ libreoffice %f & +fileviewer {*.doc},<application/msword> catdoc %c +fileviewer {*.docx}, + \<application/ + \vnd.openxmlformats-officedocument.wordprocessingml.document> + \ docx2txt.pl %f - + +" TuDu files +filetype *.tudu tudu -f %c + +" Qt projects +filextype *.pro qtcreator %f & + +" Directories +filextype */ + \ {View in thunar} + \ Thunar %f &, + +" Syntax highlighting in preview +" +" Explicitly set highlight type for some extensions +" +" 256-color terminal +" fileviewer *.[ch],*.[ch]pp highlight -O xterm256 -s dante --syntax c %c +" fileviewer Makefile,Makefile.* highlight -O xterm256 -s dante --syntax make %c +" +" 16-color terminal +" fileviewer *.c,*.h highlight -O ansi -s dante %c +" +" Or leave it for automatic detection +" fileviewer *[^/] pygmentize -O style=monokai -f console256 -g + +" Displaying pictures in terminal +" fileviewer *.jpg,*.png shellpic %c + +" Open all other files with default system programs (you can also remove all +" :file[x]type commands above to ensure they don't interfere with system-wide +" settings). By default all unknown files are opened with 'vi[x]cmd' +" uncommenting one of lines below will result in ignoring 'vi[x]cmd' option +" for unknown file types. +" For *nix: +" filetype * xdg-open +" For OS X: +" filetype * open +" For Windows: +" filetype * explorer %"f & + +" ------------------------------------------------------------------------------ +" Panel configuration examples +" ------------------------------------------------------------------------------ + +" Customize view columns a bit (enable ellipsis for truncated file names) +" set viewcolumns=-{name}..,6{}. + +" Show vertical border +" set fillchars=vborder:ƒ.. + +" Filter-out build and temporary files +" filter! {*.lo,*.o,*.d,*.class,*.pyc,*.pyo,.*~} + +" ------------------------------------------------------------------------------ +" Sample keyboard mappings +" ------------------------------------------------------------------------------ + +" Start shell in current directory +nnoremap s :shell<cr> + +" Display sorting dialog +nnoremap S :sort<cr> + +" Toggle visibility of preview window +nnoremap w :view<cr> +vnoremap w :view<cr>gv + +if (has('win') || $DISPLAY) && executable('gvim') + " Open file in existing instance of gvim + nnoremap o :!gvim --remote-tab-silent %f<cr> + " Open file in new instance of gvim + nnoremap O :!gvim %f<cr> +endif + +" Open file in the background using its default program +nnoremap gb :file &<cr>l + +" Interaction with system clipboard +if has('win') + " Yank current directory path to Windows clipboard with forward slashes + nnoremap yp :!echo %"d:gs!\!/! %i | clip<cr> + " Yank path to current file to Windows clipboard with forward slashes + nnoremap yf :!echo %"c:gs!\!/! %i | clip<cr> +elseif $WAYLAND_DISPLAY + if executable('wl-copy') + " Yank current directory path into primary and selection clipboards + nnoremap yd :!echo -n %d | wl-copy %i && + \ echo -n %d | wl-copy -p %i<cr> + " Yank current file path into into primary and selection clipboards + nnoremap yf :!echo -n %c:p | wl-copy %i && + \ echo -n %c:p | wl-copy -p %i<cr> + endif +elseif $DISPLAY + if executable('xclip') + " Yank current directory path into the clipboard + nnoremap yd :!echo %d | xclip %i<cr> + " Yank current file path into the clipboard + nnoremap yf :!echo %c:p | xclip %i<cr> + elseif executable('xsel') + " Yank current directory path into primary and selection clipboards + nnoremap yd :!echo -n %d | xsel --input --primary %i && + \ echo -n %d | xsel --clipboard --input %i<cr> + " Yank current file path into into primary and selection clipboards + nnoremap yf :!echo -n %c:p | xsel --input --primary %i && + \ echo -n %c:p | xsel --clipboard --input %i<cr> + endif +endif + +" Mappings for faster renaming +nnoremap I cw<c-a> +nnoremap cc cw<c-u> +nnoremap A cw + +" As above, but without the file extension +" nnoremap I cW<c-a> +" nnoremap cc cW<c-u> +" nnoremap A cW + +" Open console in current directory +if $DISPLAY && executable('xterm') + nnoremap ,t :!xterm &<cr> +elseif $TERMINAL != '' + nnoremap ,t :!$TERMINAL &<cr> +endif + +" Open editor to edit vifmrc and apply settings after returning to vifm +nnoremap ,c :write | edit $MYVIFMRC | restart full<cr> + +" Open gvim to edit vifmrc +if $DISPLAY && executable('gvim') + nnoremap ,C :!gvim --remote-tab-silent $MYVIFMRC &<cr> +endif + +" Toggle wrap setting on ,w key +nnoremap ,w :set wrap!<cr> + +" Example of standard two-panel file managers mappings +nnoremap <f3> :!less %f<cr> +nnoremap <f4> :edit<cr> +nnoremap <f5> :copy<cr> +nnoremap <f6> :move<cr> +nnoremap <f7> :mkdir<space> +nnoremap <f8> :delete<cr> + +" Midnight commander alike mappings +" Open current directory in the other pane +nnoremap <a-i> :sync<cr> +" Open directory under cursor in the other pane +nnoremap <a-o> :sync %c<cr> +" Swap panes +" nnoremap <c-u> <c-w>x +nnoremap <c-u> <c-b> +nnoremap q :quit<cr> + +" ------------------------------------------------------------------------------ +" Various customization examples +" ------------------------------------------------------------------------------ + +" Use ag (the silver searcher) instead of grep +" set grepprg='ag --line-numbers %i %a %s' + +" Add additional place to look for executables +" let $PATH = $HOME.'/bin/fuse:'.$PATH + +" Block particular shortcut +" nnoremap <left> <nop> + +" Export IPC name of current instance as environment variable and use it to +" communicate with the instance later. +" +" It can be used in some shell script that gets run from inside vifm, for +" example, like this: +" vifm --server-name "$VIFM_SERVER_NAME" --remote +"cd '$PWD'" +" +" let $VIFM_SERVER_NAME = v:servername + +" Activate screen/tmux support +" screen! + +" ------------------------------------------------------------------------------ +" Icon decorations example +" ------------------------------------------------------------------------------ + +" https://github.com/cirala/vifm_devicons +colorscheme istib-solarized-dark + +command create : +\| let $last_char = expand(system("str=\"%a\"; echo \"${str: -1}\"")) +\| echom $last_char +\| if $last_char == "/" +\| mkdir "%a" +\| else +\| touch "%a" +\| endif + +nnoremap a :create<space> +nnoremap <space> :select<cr><down> +"nnoremap l :view<cr> +"nnoremap e :edit<cr> + +"windo set viewcolumns=-{name},6{size},11{perms} +windo set viewcolumns=-85%{name},15%{size} +set millerview +set milleroptions+=rpreview:all +set dotdirs-=nonrootparent
diff --git a/.config/vim/ftplugin/cpp.vim b/.config/vim/ftplugin/cpp.vim @@ -1,10 +0,0 @@ -augroup CppIAbbrevs - autocmd! - autocmd FileType c,cpp :iabbrev main@ int main(int argc, char* argv[]) {<cr><cr>}<up> - autocmd FileType c,cpp :iabbrev f@ <esc>bvedivoid <C-o>P() {<cr><cr>}<up> - autocmd FileType c,cpp :iabbrev p@ printf("\n");<esc>4hi - autocmd FileType c,cpp :iabbrev r@ return;<left> - autocmd FileType c,cpp :iabbrev i@ #include <><left> - autocmd FileType c,cpp :iabbrev l@ <esc>Bvedifor(int <c-o>P=0; <c-o>P < n; <c-o>P++) {<cr><cr>}<up> -augroup END -
diff --git a/.config/vim/ftplugin/openscad.vim b/.config/vim/ftplugin/openscad.vim @@ -1,10 +0,0 @@ -augroup OpenscadIAbbrevs - autocmd! - autocmd FileType scad :iabbrev function@ function {<cr><cr>}<up> - autocmd FileType scad :iabbrev fun@ <esc>bvedivoid <C-o>P() {<cr><cr>}<up> - autocmd FileType scad :iabbrev p@ printf("\n");<esc>4hi - autocmd FileType scad :iabbrev r@ return;<left> - autocmd FileType scad :iabbrev i@ #include <><left> - autocmd FileType scad :iabbrev for@ <esc>bvedifor(int <c-o>P=0; <c-o>P < n; <c-o>P++) {<cr><cr>}<up> -augroup END -
diff --git a/.local/share/vim/ftplugin/c.vim b/.local/share/vim/ftplugin/c.vim @@ -0,0 +1,6 @@ +iabbrev main@ int main(int argc, char* argv[]) {<cr><cr>}<up> +iabbrev f@ <esc>bvedivoid <C-o>P() {<cr><cr>}<up> +iabbrev p@ printf("\n");<esc>4hi +iabbrev r@ return;<left> +iabbrev i@ #include <><left> +iabbrev l@ <esc>Bvedifor(int <c-o>P=0; <c-o>P < n; <c-o>P++) {<cr><cr>}<up>
diff --git a/.local/share/vim/ftplugin/openscad.vim b/.local/share/vim/ftplugin/openscad.vim @@ -0,0 +1,6 @@ +iabbrev function@ function {<cr><cr>}<up> +iabbrev fun@ <esc>bvedivoid <C-o>P() {<cr><cr>}<up> +iabbrev p@ printf("\n");<esc>4hi +iabbrev r@ return;<left> +iabbrev i@ #include <><left> +iabbrev for@ <esc>bvedifor(int <c-o>P=0; <c-o>P < n; <c-o>P++) {<cr><cr>}<up>
diff --git a/.local/share/vim/hyper-red.vim b/.local/share/vim/hyper-red.vim @@ -3,57 +3,77 @@ " TODO handle light theme " Probably use a autogroup for handling tCo count change " Do it in lua + +if version > 580 + hi clear + if exists("syntax_on") + syntax reset + endif +endif + +hi! VertSplit term=NONE cterm=NONE gui=NONE +hi! SignColumn ctermbg=NONE guibg=NONE + if &background == "dark" + hi! Normal ctermbg=Black guibg=Black ctermfg=White guifg=White 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! Folded guifg=Blue ctermfg=Blue guibg=NONE ctermbg=NONE cterm=bold + hi! FoldColumn guifg=Blue ctermfg=Blue guibg=NONE ctermbg=NONE cterm=bold + hi! DiffChange guifg=NONE ctermfg=LightYellow guibg=LightYellow ctermbg=NONE + hi! DiffText guifg=NONE ctermfg=LightBlue guibg=LightBlue ctermbg=Yellow cterm=bold + hi! DiffAdd guibg=LightGreen ctermbg=LightGreen guifg=NONE ctermfg=NONE + hi! DiffDelete guifg=Red ctermfg=Red 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=NONE guifg=NONE - hi! Constant ctermfg=LightBlue guifg=LightBlue + hi! CursorLineNr cterm=NONE gui=NONE guibg=NONE ctermbg=NONE guifg=Red ctermfg=White + hi! StatusLineNC guibg=Black ctermbg=Black guifg=DarkGray ctermfg=DarkGray + hi! Statement ctermfg=DarkRed guifg=DarkRed + hi! Constant gui=bold ctermfg=Magenta guifg=Magenta 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! String ctermfg=Red guifg=Red + hi! Special cterm=NONE ctermfg=LightRed guifg=LightRed hi! Identifier ctermfg=White guifg=White hi! IncSearch ctermbg=Black ctermfg=Yellow guibg=Black guifg=Yellow - hi! Search ctermbg=DarkGray ctermfg=LightGray guibg=DarkGray guifg=Black - hi! Todo cterm=underline ctermbg=NONE ctermfg=LightYellow guibg=NONE guifg=LightYellow + hi! Search ctermbg=Blue ctermfg=White guibg=Blue guifg=White + hi! Todo gui=underline,bold cterm=underline,bold ctermfg=White ctermbg=Red guifg=White guibg=Red 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=LightGray guifg=LightGray - hi! MatchParen ctermbg=NONE cterm=underline ctermfg=LightMagenta - hi! ExtraWhitespace ctermbg=DarkRed guibg=DarkRed + hi! Visual ctermbg=LightGray ctermfg=NONE guibg=LightGray guifg=NONE + hi! Type gui=bold ctermfg=DarkYellow guifg=DarkYellow + hi! PreProc ctermfg=DarkGray guifg=DarkGray + hi! MatchParen ctermbg=Black cterm=underline ctermfg=LightMagenta 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 - hi! Statement ctermfg=Red guifg=Red - hi! Constant ctermfg=Green guifg=Green - hi! String ctermfg=DarkBlue guifg=DarkBlue - hi! Special cterm=bold ctermfg=DarkMagenta guifg=DarkMagenta + hi! Normal ctermbg=White guibg=White ctermfg=Black guifg=Black + hi! ColorColumn guifg=Black ctermfg=Black guibg=LightGray ctermbg=LightGray + hi! Folded guifg=Blue ctermfg=Blue guibg=NONE ctermbg=NONE cterm=bold + hi! FoldColumn guifg=Blue ctermfg=Blue guibg=NONE ctermbg=NONE cterm=bold + hi! DiffChange guifg=NONE ctermfg=LightYellow guibg=LightYellow ctermbg=NONE + hi! DiffText guifg=NONE ctermfg=LightBlue guibg=LightBlue ctermbg=Yellow cterm=bold + hi! DiffAdd guibg=LightGreen ctermbg=LightGreen guifg=NONE ctermfg=NONE + hi! DiffDelete guifg=Red ctermfg=Red guibg=NONE ctermbg=NONE + hi! LineNr cterm=NONE gui=NONE guibg=NONE ctermbg=NONE guifg=LightGray ctermfg=LightGray + hi! CursorLineNr cterm=NONE gui=NONE guibg=NONE ctermbg=NONE guifg=Red ctermfg=White + hi! StatusLineNC guibg=Black ctermbg=Black guifg=DarkGray ctermfg=DarkGray + hi! Constant gui=bold ctermfg=Magenta guifg=Magenta + hi! String ctermfg=LightRed guifg=LightRed hi! Identifier ctermfg=Black guifg=Black hi! IncSearch ctermbg=Black ctermfg=Yellow guibg=Black guifg=Yellow hi! Search ctermbg=Blue ctermfg=White guibg=Blue guifg=White - hi! Todo cterm=underline,bold ctermbg=NONE ctermfg=Yellow guibg=NONE guifg=Yellow + hi! Todo gui=underline,bold cterm=underline,bold ctermfg=White ctermbg=Red guifg=White guibg=Red + hi! Statement ctermfg=DarkRed guifg=DarkRed hi! Comment ctermfg=DarkGray guifg=DarkGray - hi! Visual ctermbg=Black ctermfg=white guibg=Black guifg=white - hi! Type ctermfg=Black guifg=Black - hi! PreProc ctermfg=DarkGray guifg=DarkGray - hi! MatchParen guibg=NONE ctermbg=NONE gui=underline cterm=underline guifg=DarkMagenta ctermfg=DarkMagenta + hi! Special cterm=bold gui=bold ctermbg=NONE ctermfg=LightBlue guibg=NONE guifg=LightBlue + hi! SpecialKey cterm=NONE ctermfg=Gray guifg=Gray + hi! NonText cterm=NONE ctermfg=LightGray guifg=LightGray + hi! Type gui=bold ctermfg=DarkYellow guifg=DarkYellow + hi! PreProc ctermfg=DarkMagenta guifg=DarkMagenta + hi! MatchParen guibg=LightGray ctermbg=LightGray gui=underline cterm=underline guifg=DarkMagenta ctermfg=DarkMagenta 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 + +set listchars=tab:\|\ ,lead:-,trail:-,eol:\. 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 @@ -1,9 +1,16 @@ " General keybindings -nnoremap <leader>co :copen<cr> -nnoremap <leader>cd :cdo<space>s/ +inoremap <C-{> <esc>: +nnoremap <C-{> : + +nnoremap <C-/> :vim9cmd scope#fuzzy#Grep('git grep')<cr> +nnoremap <C-`> :terminal<cr> + +nnoremap <F4> :call SaveAndBuild()<cr> + +nnoremap <leader>co :botright copen<cr> nnoremap <leader>cs :cdo<space>s/ -nnoremap <leader>ec :vsplit $HOME/.vimrc<cr> -nnoremap <leader>ek :vsplit $XDG_DATA_HOME/vim/keybindings.vim<cr> +nnoremap <leader>ec :call OpenSource("$XDG_HOME/.vimrc")<cr> +nnoremap <leader>ek :call OpenSource("$XDG_DATA_HOME/vim/keybindings.vim")<cr> nnoremap <leader>et :set expandtab<cr> nnoremap <leader>fa :find * nnoremap <leader>ff :find * @@ -22,13 +29,17 @@ nnoremap <leader>ta :tab * nnoremap <leader>vg :vimgrep<space> nnoremap <leader>/ :cdo %s/ nnoremap <leader>cd :cd %:p:h<cr> +nnoremap <leader>gcd :Gcd<cr> nnoremap <leader>qd :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> + +nnoremap <leader>ds :call DiffWithSaved()<cr> +" TODO Add du to diff with undo +" nnoremap <leader>ds :call DiffWithSaved()<cr> fun! SaveAndSuspend() :w @@ -58,12 +69,28 @@ nnoremap <c-z> :call SaveAndSuspend()<cr> inoremap <c-z> :call SaveAndSuspend()<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 inoremap <c-k> <c-o>D +inoremap <c-y> <c-o>p +inoremap <c-f> <Right> +inoremap <c-b> <Left> + +cnoremap <c-a> <home> +cnoremap <c-e> <end> +cnoremap <c-y> <c-r>" +cnoremap <c-p> <c-f> +cnoremap <c-f> <Right> +cnoremap <c-b> <Left> + +nnoremap <c-x><c-f> :Explore<cr>/ +nnoremap <c-x><c-c> :q<cr> +nnoremap <c-x><c-g> :G<cr>/ +nnoremap <c-x><c-s-g> :G<cr> +nnoremap <c-x><c-d> :Debugger<cr> +nnoremap <c-x><c-s> :w<cr> " Behave vim nnoremap Y y$ @@ -75,12 +102,9 @@ nnoremap <leader>oh :grepadd /:: % nnoremap <leader>fb :b * -nnoremap <c-/> :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 @@ -98,7 +122,8 @@ nnoremap <leader>tl :call ToggleList()<CR> nnoremap <leader>nn :set number<cr> " development -nnoremap <leader>bb :call SaveAndBuild()<CR> +nnoremap <M-F9> :call SaveAndBuild()<cr> +inoremap <M-F9> :call SaveAndBuild()<cr> nnoremap <leader>bc :Make clean<CR> nnoremap <leader>fmv :call FileMvHelper()<CR> @@ -110,8 +135,8 @@ 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>dg :Gvdiff<CR> +nnoremap <leader>gg :Ggrep -q <space> nnoremap <leader>gr :G reset %<cr> nnoremap <leader>gwq :Gwq<cr> nnoremap <leader>lg :Glgrep<space> @@ -120,7 +145,7 @@ nnoremap <leader>lg :Glgrep<space> " Generate ctags nnoremap<leader>gt :!sh -c "ctags `git ls-files`"<CR> -nnoremap <CR> :noh<CR><CR>:<backspace> +nnoremap <C-L> :nohl<CR><C-L> " Markdown - Add checkbox mode? nnoremap <leader>cc :ChecklistToggleCheckbox<cr> @@ -129,9 +154,6 @@ nnoremap <leader>ce :ChecklistEnableCheckbox<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 @@ -148,7 +170,7 @@ endfun fun! StartDebugging() doautocmd User DebuggingStarted - :call vimspector#Launch()<CR> + :Termdebug .\payredu.exe<cr> endfun " Easy save @@ -166,18 +188,21 @@ 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>ds :call GotoWindow(g:vimspector_session_windows.stack_trace)<CR> nnoremap <leader>do :call GotoWindow(g:vimspector_session_windows.output)<CR> nnoremap <S-F5> :call vimspector#Reset()<CR> nnoremap <leader>dtcb :call vimspector#CleanLineBreakpoint()<CR> fun! SetupDebuggingKeymaps() - nmap <c-n> <Plug>VimspectorStepOver + nmap <> <Plug>VimspectorStepOver nmap <c-i> <Plug>VimspectorStepInto nmap <m-i> <Plug>VimspectorStepOut nmap <c-s-r> <Plug>VimspectorRestart - nmap <F5> :call vimspector#Continue()<CR> + nmap <F9> :Break<cr> + nmap <C-S-F9> :Clear<CR> + nmap <F5> :Continue<CR> + nmap <S-F5> :Finish<CR> endfun augroup debugmode @@ -193,4 +218,18 @@ nnoremap cN *``cgN let g:mc = "y/\\V\<C-r>=escape(@\", '/')\<CR>\<CR>" vnoremap <expr> cn g:mc . "``cgn" +let g:ctrlp_map = '<F2>' +nnoremap <F1> :CtrlPBuffer<cr> +inoremap <F1> :CtrlPBuffer<cr> +nnoremap <S-F1> :CtrlPMRU<cr> +inoremap <S-F1> :CtrlPMRU<cr> +" +" TODO setup this up with fzf +nnoremap <F2> :vim9cmd scope#fuzzy#GitFile()<cr> +nnoremap <S-F2> :vim9cmd scope#fuzzy#File()<cr> + +nnoremap <F3> :vim9cmd call scope#fuzzy#Quickfix()<cr> +if has('macunix') + :imap <D-V> ^O"+p +en
diff --git a/.local/share/vim/minisnip/_c_i b/.local/share/vim/minisnip/_c_i @@ -1 +0,0 @@ -#include <{{++}}.{{+h+}}>
diff --git a/.local/share/vim/minisnip/_c_main b/.local/share/vim/minisnip/_c_main @@ -1,4 +0,0 @@ -int main(int argc, const char* argv[]) { - {{++}} - return 0; -}
diff --git a/.local/share/vim/minisnip/_c_p b/.local/share/vim/minisnip/_c_p @@ -1 +0,0 @@ -printf("{{+%s\n+}}", {{++}});
diff --git a/.local/share/vim/minisnip/_cmake_min b/.local/share/vim/minisnip/_cmake_min @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION {{++}}) - -project({{++}}) - -add_executable({{++}} PUBLIC {{++}})
diff --git a/.local/share/vim/minisnip/_cmake_p b/.local/share/vim/minisnip/_cmake_p @@ -1 +0,0 @@ -messages({{++}})
diff --git a/.local/share/vim/minisnip/_cpp_cout b/.local/share/vim/minisnip/_cpp_cout @@ -1 +0,0 @@ -std::cout << {{++}} << std::endl;
diff --git a/.local/share/vim/minisnip/_java_main b/.local/share/vim/minisnip/_java_main @@ -1,3 +0,0 @@ -public static void main(String args[]) { - {{++}} -}
diff --git a/.local/share/vim/minisnip/_java_p b/.local/share/vim/minisnip/_java_p @@ -1 +0,0 @@ -System.out.print({{++}});
diff --git a/.local/share/vim/minisnip/_sh_p b/.local/share/vim/minisnip/_sh_p @@ -1 +0,0 @@ -printf "{{+%s\n+}}" {{+""+}}
diff --git a/.local/share/vim/plugin.vim b/.local/share/vim/plugin.vim @@ -3,6 +3,30 @@ function! Chomp(str) return substitute(a:str, '\n$', '', '') endfunction +func! TryAndDelete() + try + source % + bdelete + catch + echom "Cannot source file '" .. expand('<afile>') .. "'" + endt +endfunc + +func! OpenOnce(fi) + :exec "vsplit" a:fi + aug EphemeralBuffer + au! + au! BufWritePost <buffer> bdelete + aug END +endfunc + +func! OpenSource(fi) + :exec "vsplit" a:fi + aug EphemeralBuffer + au! | au! BufWritePost <buffer> call TryAndDelete() + aug END +endfunc + " 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)) @@ -59,6 +83,7 @@ endfunction " Run Make function SaveAndBuild() + botright copen wall if exists(":Make") Make
diff --git a/.local/share/vim/vimrc b/.local/share/vim/vimrc @@ -1,11 +0,0 @@ -set packpath^=$XDG_DATA_HOME/vim - -let g:minisnip_dir=$XDG_DATA_HOME . '/vim/minisnip' -source $XDG_DATA_HOME/vim/keybindings.vim -set packpath^=$XDG_DATA_HOME/vim - -set background=dark - -source $XDG_DATA_HOME/vim/hyper-red.vim - -let g:birck_default_chan="irc.libera.chat"
diff --git a/.profile b/.profile @@ -43,7 +43,12 @@ PATH=${PATH}:${HOME}/.local/bin:${HOME}/.local/bin/sh:${XDG_DATA_HOME}/npm/bin:$ command -v vim && VISUAL=vim && EDITOR=vim } >/dev/null -FUZZER=$(command -v fzy) +if [ $(uname -s) = "Windows_NT" ]; then + FUZZER=$(command -v wlines) +else + FUZZER=$(command -v fzy) +fi +FM=vifm BROWSER=lynx SURFRAW_browser="$BROWSER"
diff --git a/.vimrc b/.vimrc @@ -1,12 +1,25 @@ +" Handle missing XDG_s gracefully +if !exists("$XDG_HOME") + let $XDG_HOME = has("win32") ? expand("$USERPROFILE") : expand("$HOME") +endif +if !exists("$XDG_DATA_HOME") | let $XDG_DATA_HOME=expand("$XDG_HOME/.local/share") | endif +if !exists("$XDG_CACHE_HOME") | let $XDG_CACHE_HOME=expand("$XDG_HOME/.cache") | endif + +if !exists("$VIM") | let $VIM=expand("$XDG_DATA_HOME/vim") | endif + +if has("&viminfofile") | set viminfofile=$XDG_CACHE_HOME/vim/viminfo | endif + +set rtp+=C:/Users/bhara/.local/share/vim + +filetype plugin indent on syntax on -" Handle XDG_ missing gracefully -if empty("$XDG_CACHE_HOME") - let $XDG_CACHE_HOME=$HOME/.cache -endif -if has("&viminfofile") - set viminfofile=$XDG_CACHE_HOME/vim/viminfo -endif +set packpath^=$XDG_DATA_HOME/vim + +source $XDG_DATA_HOME/vim/keybindings.vim +source $XDG_DATA_HOME/vim/hyper-red.vim + +let g:birck_default_chan="irc.libera.chat" " General set ai @@ -35,8 +48,6 @@ set hlsearch set incsearch set nowrapscan -" Pro tab -filetype plugin indent on set tabstop=4 set shiftwidth=4 set expandtab @@ -54,9 +65,11 @@ let g:netrw_liststyle = 3 let g:netrw_fastbrowse= 2 let g:netrw_dirhistmax = 0 let g:netrw_preview = 1 -let g:netrw_winsize = 20 +let g:netrw_winsize = 30 + +set updatetime=100 + -source $XDG_DATA_HOME/vim/vimrc au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif let g:loaded_vimballPlugin = 1 @@ -65,11 +78,12 @@ let g:loaded_getscriptPlugin = 1 let maplocalleader=" " set complete-=i -set foldmethod=marker +set foldmethod=marker set foldmarker={,} set foldlevel=20 set foldopen-=search + " Debug let g:termdebug_config = {'sign': '>>', 'winbar': 0, 'wide':163} @@ -91,29 +105,7 @@ function! FZYFiles() abort 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' - set synmaxcol=128 -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') @@ -124,32 +116,81 @@ set directory=$XDG_CACHE_HOME/vim/swap | call mkdir(&directory, 'p') set undodir=$XDG_CACHE_HOME/vim/undo | call mkdir(&undodir, 'p') function! s:load_plugins(t) abort - 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 - packadd termdebug - let g:termdebug_wide=163 - 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 + packadd ctrlp.vim + packadd conflict-marker.vim + packadd mru + + call s:plugin_post_conf() endfunction -augroup user_cmds - autocmd! - autocmd VimEnter * call timer_start(20, function('s:load_plugins')) -augroup END -source $XDG_CONFIG_HOME/vim/ftplugin/cpp.vim + +func! s:plugin_post_conf() + let g:ctrlp_by_filename = 1 + let g:ctrlp_reuse_window = 'netrw\|help\|quickfix' + + let g:ctrlp_prompt_mappings = { + \ 'PrtSelectMove("j")': ['<c-n>', '<down>'], + \'PrtSelectMove("k")': ['<c-p>', '<up>'], + \ 'PrtHistory(-1)': ['<c-j>'], + \ 'PrtHistory(1)': ['<c-k>'], + \ } + + if executable('ag') + " Use Ag over Grep + set grepprg=ag\ --nogroup\ --nocolor + + " Use ag in CtrlP for listing files. Lightning fast and respects .gitignore + let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' + endif + + packadd termdebug + let g:termdebug_wide=163 + + if !has("win32") + packadd vim-tmux-navigator + packadd notmuch-vim + 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[] + endif + endif + + 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' +endfunc + +aug user_cmds + au! + au VimEnter * call timer_start(20, function('s:load_plugins')) +aug END + source $XDG_DATA_HOME/vim/plugin.vim if has("gui") @@ -157,9 +198,11 @@ if has("gui") set mouse=a if has("win32") set guifont=FixedSys:h11:cANSI:qDRAFT - colorscheme default - set background=light endif + " TODO Implement fg or reverse <c-z> + nnoremap <c-z> :term<cr><c-w>o + inoremap <c-z> :term<cr><c-w>o + tnoremap <c-z> <c-w>:hide edit #<cr> endif if has("win32") @@ -171,14 +214,13 @@ else set shell=sh endif -" Map key chord `jk` to <Esc> -let g:esc_j_lasttime = 0 -let g:esc_k_lasttime = 0 -function! JKescape(key) - if a:key == 'j' | let g:esc_j_lasttime = reltimefloat(reltime()) | endif - if a:key == 'k' | let g:esc_k_lasttime = reltimefloat(reltime()) | endif - let l:timediff = abs(g:esc_j_lasttime - g:esc_k_lasttime) - return (l:timediff <= 0.05 && l:timediff >=0.001) ? "\b\e" : a:key -endfunction -inoremap <expr> j JKescape('j') -inoremap <expr> k JKescape('k') +source $XDG_DATA_HOME/vim/hyper-red.vim + +let g:table_mode_toggle_map = 'mm' +let g:table_mode_corner='|' + +if !exists('g:undotree_WindowLayout') + let g:undotree_WindowLayout = 4 + let g:undotree_ShortIndicators = 1 +endif +