dot

packages and services management
Log | Files | Refs | README

commit 66b30154bfc031a8ccdf2a40c838fe11793025b7
parent 0ee544e90fb803e96da0bc63d063da8ed3b41ae4
Author: josuah <mail@josuah.net>
Date:   Tue, 20 Sep 2016 11:03:04 -0400

Improved vim worflow

Diffstat:
MREADME | 1-
Mbin/buffers | 27+++++++++++++++------------
Abin/complete | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
Dbin/filter | 159-------------------------------------------------------------------------------
Mbin/piped | 3++-
Mvim/.vimrc | 56++++++++++++++++++++++++++++++++++++++------------------
Mzathura/.config/zathura/zathurarc | 2+-
7 files changed, 107 insertions(+), 192 deletions(-)

diff --git a/README b/README @@ -45,7 +45,6 @@ SHELL SCRIPTS VIM -------------------------------------------------------------------------------- - syntastic http://github.com/scrooloose/syntastic undotree http://github.com/mbbill/undotree surround http://github.com/tpope/vim-surround lion http://github.com/tommcdo/vim-lion diff --git a/bin/buffers b/bin/buffers @@ -57,32 +57,35 @@ r | run ) feeds ) opt='read' ;; irc ) opt='-i' ;; htop | s-nail | rirc | agenda | music ) : ;; - vi | vim | vis | less | ex-vi | ex | ed | emacsclient ) - opt="$(find ./ -type f ! -path '*/.git/*' | fzy)" file="$opt" + vi | vis | less | ex-vi | ex | ed ) + path="$(find ./ -type f ! -path '*/.git/*' | fzy)" + ;; + vim ) + path="$(find ./ -type d ! -path '*/.git/*' ! -name .git | fzy)" ;; * ) read opt if [ -z "${opt##*\**}" -a "$opt" ] then - file="$(find ./ -type f | fzy)" - opt="${opt##*\*} $file ${opt%%\**}" + path="$(find -type f ./ | fzy)" + opt="${opt##*\*} $path ${opt%%\**}" fi ;; esac # Update the name using the file path - if [ "$file" ] + if [ "$path" ] then - file="$PWD/${file#./}" - [ -z "${file##$HOME*}" ] && file="~${file#$HOME}" - file=" $file" + path="$PWD/${path#./}" + [ -d "$path" ] && cd "$path" || opt="$path" + [ -z "${path##$HOME*}" ] && path="~${path#$HOME}" + path=" $path" fi # Set the name of the abduco session and create it - printf '\033]0;%s%s\007' "$name" "$file" - TERM=screen ABDUCO="$cmd" abduco \ - -e '^z' \ - -A "$(printf '%s%s' "$cmd" "$file" | tr '/' '!')" $cmd $opt + printf '\033]0;%s%s\007' "$name" "$path" + TERM=screen ABDUCO="$cmd" abduco -e '^z' \ + -A "$(printf '%s%s' "$cmd" "$path" | tr '/' '!')" $cmd $opt ;; a | attach ) # If already on a session, print its name and exit diff --git a/bin/complete b/bin/complete @@ -0,0 +1,51 @@ +#!/bin/sh +# /\ /\ +# ____ ____ ________ ____ / / ___ / /_ ___ +# / ___\ / __ \ / __ __ \ / __ \ / /.'__ \ / ___\.'__ \ +# / /__ / /_/ // / / / / // /_/ // // ____// / / ____/ +# \____\ \____/ \/ \/ \// ____/ \/ \___\ \/ \___\ +#=========================\/==================================================== +# Complete string with a word from a file. + +help=' +NAME + Complete - complete word or line from stdin with candidates from a file +USAGE + complete OPTION FILE + +DESCRIPTION + STDIN part to match from the words, and to remove from the candidates. + FILE file to search candidates from +OPTION + -w complete by word + -l complete by line +' NL=' +' + +[ "$#" = 0 ] && printf '%s\n' "$help" && exit 0 +while [ "$#" -gt 0 ] +do + case "$1" in + -w | -l ) ACTION="$1" ;; + -* ) printf '%s\n' "$help" && exit 0 ;; + * ) FILE="$1" ;; + esac + + shift +done + +PREFIX="$(tee)" + +case "$ACTION" in +-w ) + sed 's/[[:space:]]/\n/g' "$FILE" | sort -u | while read word + do [ -z "${word##$PREFIX*}" ] && printf '%s\n' "$word" + done | fzy | { + IFS="$NL" read -r word + printf '%s\n' "$word" + } + ;; +-l ) + fzy -q "$PREFIX" < "$FILE" + ;; +esac diff --git a/bin/filter b/bin/filter @@ -1,159 +0,0 @@ - ____ __ /\ /\ - .' ___\ \/ / // /_ ___ _____ - / .'_ /\ / // ___\.'__ \ / ____\ - / ___/ / // // / / ____// / - \/ \/ \/ \/ \___\ \/ 2016-09-19 -================================================================================ -Filter lines form stdin to print to stdout using user keyboard input - - I will hopefully write this in ANSI C some day... At least I - really wish I will ever be able to! - - The goal is to learn (ANSI) C, and mostly to be able to do - interfaces like those of vimperator. - - -OPTIONS / FEATURES 2016-09-19 --------------------------------------------------------------------------------- -Description of the features I will possibly implement. - - Lower case switches for interface, uppercase switches for - input/output. - - -p PROMPT - Aditionnal part of the prompt to add before the '> '. - - -n - Display line number before the match. - - -N - Only return the line number. - - -k VALIDATEKEY - Aditionnal key to use to return current selection. - This can a space for use as a word completion engine - (Ctrl + N in vim). - - -s SEPARATOR - Separator for the output: The selected candidate will be - printed up to this separator, rather than being printed - completely. The separator will be aligned according - to 2 rules: 1. The biggest part before separator; 2. Do - not outreach the half of the screen horizontally. - - The right part will also be grayed, and not printed in - the prompt. - - This is why this needs to be dynamic and be coded in - the source rather than in the integration tools (do ONE - THING and do it well...). - - -c COMMENT - Comment char: Every line starting with this character - will be treated as a header. Header are always visible - and bold (\033[1m), even when not matched. This is - convenient to prompt the user items from multiple - categories at the same time. - - -l LINES - Number of lines to display at once. Default is 10. - - -b - Display (and update) the prompt to be at the bottom of - the candidates, and at the bottom of the screen. - - -t - Display (and update) the prompt to be at the top of the - candidates, and at the bottom of the screen. - - -d DEFAULT - Set the input a DEFAULT string before to start. - - -KEYBINDINGS 2016-09-18 --------------------------------------------------------------------------------- - - Ctrl + I - Tab - Switch between candidates, and finally come back to the - original input without completion. - - Ctrl + H - Backspace - Delete one char backward, but if there is no char - backward, it should return an error code of 1. - - Ctrl + C - Cancel, and make filter return the error code of 1. - - Ctrl + V KEY - Insert the next KEY pressed literally. - - Ctrl + W - Deletes the last entered word. - - Ctrl + U - Deletes the entire input. - -MATCHING 2016-09-19 --------------------------------------------------------------------------------- - - I like the lines order to be preserved while matching. This can - be convenient to pipe a file through filter, moreover. - - Spaces are considered as a '*' wildchar or '.*' regular - expression. All other characters are consecutive characters - to match. This is hence not a fuzzy matching. There are fzf - and the very good fzy for that - - While numbers are displayed (-n option), the number typed at - the beginning of input match in priority these displayed numbers. - - -INTERFACE 2016-09-18 --------------------------------------------------------------------------------- -Differences and similarity with vimperator input. - - In adition to vimperator behavior, a count would be displayed - in top right hand corner of the current input line, not used as - the completion may be rather small. I will need a way to manage - long line in input anyway, because the case with long lines and - small screen _will_ occur. - - In vimperator, there is a grayed text after the input, - corresponding to the completion. This is a nice feature and I - plan to do this: \033[1;0m can output gray text even it TTY. - - The matched string should be highlighted in candidates. - - The current candidate should be highlighted with '\033[7m' prevent - the matched string to appear liht yellow on white background. - - It could be nice if the candidates could be loaded dynamically, - to act like `fzf` does. Because it look good, and I would not - have to wait find on ~ to find a file to select it. - - -USAGE 2016-09-18 --------------------------------------------------------------------------------- -Example that can replicate advanced vimperator completion features - - In vimperator, while space is pressed, it prompts for the next - input to enter, and still keep the current input onscreen. - Backspace delete the input. - - This can be performed with filter: - - By setting '-k' to a space, at every word, the completion - is stored. - - Then a new prompt is generated using the previous word as a prompt - - By checking for the return value, and if it is >0 (there was - an error, the user cancelled (Ctrl + C) or pressed backspace at - the beginning of the line), then reiterate the previous prompt. - - This then permits to select from a first level input (like - commands), then according to the command, select second level - input different for each command (like flags or 'empty'), and - then, select a third level input (like filename)... diff --git a/bin/piped b/bin/piped @@ -1,10 +1,11 @@ +#!/bin/sh # __ /\ # ____ \/ ____ ___ ___/ / # / __ \ /\ / __ \ .'__ \ .'__ / # / /_/ / / // /_/ // ____// /_/ / # / ____/ \// ____/ \___\ \____/ #=\/=========\/================================================================= -# Pipe from stdin to stdout with $EDITOR +# Put stdin to a file, open EDITOR on it, and then print the file out. tmp="$(mktemp)" diff --git a/vim/.vimrc b/vim/.vimrc @@ -2,9 +2,9 @@ " __ /\ \/ ________ _____ ____ " / / / / /\ / __ __ \ / ____\/ ___\ " \ \/ / / // / / / / // / / /__ -" \_,' \/ \/ \/ \/ \/ \____\ 2016-09-18 +" \_,' \/ \/ \/ \/ \/ \____\ 2016-09-20 "=============================================================================== -" Simple config for vim +" Config for vim using vim's features rather than a lot of plugins " OPTIONS 2016-09-18 @@ -15,35 +15,55 @@ set laststatus=0 " Status set smartcase ignorecase " Case set showmatch " Highlight set list listchars=tab::\ ,trail:.,nbsp:.,extends:>,precedes:< " Listchars -set ruler rulerformat=%40(%t%4m%=%l,%-7(%c%V%)%4P%) +set ruler rulerformat=%40(%t%4m%=%l,%-7(%c%V%)%4P%) " Ruler set number numberwidth=5 cursorline nowrap " Interface set scrolloff=3 " Scroll set backupdir=~/.cache/vim// directory=~/.cache/vim// " Backup, cache -set virtualedit=block -set formatprg=fmt -set wildmenu wildmode=longest:full " Completion +set virtualedit=block formatprg=fmt " Editing +set wildmenu wildmode=longest:full,full " Completion -" MAPPINGS 2016-09-18 +" MAPPINGS 2016-09-20 "------------------------------------------------------------------------------- let mapleader = ' ' +" <leader> menu nmap <leader><leader> : -nmap <leader>s :set <c-d> +\ ec '_______________________________________________________________________'\| +\ ec ' <w> write <b> buffers <c> clist <s> set </> search ' \| +\ ec ' <e> edit <T> tabs <t> tags <h> help <"> registers' \| +\ ec ' <m> make '"<'>"'marks' \| +\ <cr>: nmap <leader>w :w<cr> -nmap <leader>b :pwd \| echo '' \| ls \| echo ''<cr>:b -nmap <leader>h :help -nmap <leader>/ :exec ':'.system("swiper '".expand("%:p")."'") \| redraw!<cr> - -nmap col :set list !<cr> :set list ?<cr> -nmap con :set number !<cr> :set number ?<cr> -nmap cop :set paste !<cr> :set paste ?<cr> -nmap coh :set hlsearch !<cr> :set hlsearch ?<cr> +nmap <leader>s :set <c-d> +nmap <leader>h :help +nmap <leader>b :pwd \| echo '' \| ls \| echo ''<cr>:b +nmap <leader>T :pwd \| echo '' \| tabs \| echo ''<cr>:tab +nmap <leader>c :pwd \| echo '' \| clist \| echo ''<cr> +nmap <leader>t :pwd \| echo '' \| tags \| echo ''<cr>:tag +nmap <leader>" : echo '' \| registers <cr> +nmap <leader>' : echo '' \| marks <cr>:' +nmap <leader>m : make <cr> +nmap <leader>/ :exe ':' . system("swiper '" . expand("%:p") . "'") +\ \| redraw!<cr> +nmap <leader>e :exe 'e' . system("find . -type f ! -path '*/.git/*' \| fzy") +\ \| redraw!<cr> + +" <c>hange <o>ption <...> +nmap col :set list !<cr>:set list ?<cr> +nmap con :set number !<cr>:set number ?<cr> +nmap cop :set paste !<cr>:set paste ?<cr> +nmap coh :set hlsearch !<cr>:set hlsearch ?<cr> nmap cov :set ve=<c-r>=(&ve =~# "all") ? 'block' : 'all'<cr><cr>:set ve ?<cr> nmap cos :if exists("g:syntax_on") \| sy off \| else \| sy enable \| end<cr> -nmap cot :set tw=<c-r>=(&tw =~# "80" ) ? '0' : '80' <cr><cr>:set tw ?<cr> +nmap cot :set tw=<c-r>=(&tw != "0" ) ? '0' : '75' <cr> <cr>:set tw ?<cr> + +" <[> previous <]> next +nmap [c :cprevious<cr> | nmap ]c :cnext<cr> +nmap [C :cfirst<cr> | nmap ]C :clast<cr> +" Editing nmap [<leader> mzO<Esc>k`z<C-e> nmap ]<leader> mzo<Esc>k`z @@ -83,7 +103,7 @@ autocmd WinEnter * :match ErrorMsg /\%81v.\+/ execute pathogen#infect() " UndoTree -map <leader>u :UndotreeToggle<cr> +nmap <leader>u :UndotreeToggle<cr> " GitGutter let g:gitgutter_sign_column_always = 1 diff --git a/zathura/.config/zathura/zathurarc b/zathura/.config/zathura/zathurarc @@ -2,7 +2,7 @@ # ______ _____ / /_ / /_ __ /\ _____ _____ # /__ /.'__ // ___\/ __ \ / / / // ____\.'__ / # ,-' _-'/ /_/ // / / / / // /_/ // / / /_/ / -# /_____\ \____/ \/ \/ \/ \____/ \/ \____/ +# /_____\ \____/ \/ \/ \/ \____/ \/ \____/ 2016-09-20 #=============================================================================== set recolor true