⚙ A few tweakings: vimrc and lf preview mostly

This commit is contained in:
Etienne Werly 2021-07-16 19:32:17 +02:00
parent 48f3a1eed2
commit 93cfee450e
13 changed files with 237 additions and 64 deletions

View File

@ -8,7 +8,14 @@ export PATH=$PATH:$HOME/.bin
# Use vim as default editor
export EDITOR=/usr/bin/vim
# qutebrowser as default browser
export BROWSER=/usr/bin/qutebrowser
#export BROWSER='/usr/bin/qutebrowser --target tab'
export BROWSER='/usr/bin/luakit'
# bat theme
export BAT_THEME="OneHalfLight"
# Bluetooth devices
export GO2="70:99:1C:DB:41:B6"
export CHATS="00:42:79:A1:07:E0"
export HP="hpaio:/net/OfficeJet_3830_series?ip=192.168.0.34" # HP Printer
# }}}
## Personal Info Management {{{
@ -20,14 +27,20 @@ alias dots='git --git-dir=$HOME/.dotfiles.git/ --work-tree=$HOME'
alias skhal='khal calendar'
alias newcourse='khal new -a "Cours particuliers" --alarms 1hour'
## start email notifications upon starting mutt
#alias mutt='if [ -z $(pgrep -fa python | grep mail_notifications.py) ]; then python ~/.bin/mail_notifications.py & mutt; else mutt ;fi'
# start email notifications upon starting mutt
alias premutt='if [[ -z $(pgrep -fa mutt) ]]; then mutt; else mutt -e "set read_only = yes"; fi'
alias mut='if [[ -z $(pgrep -fa python | grep mail_notifications.py) ]]; then python ~/.bin/mail_notifications.py & premutt; else premutt ;fi'
# XMPP
alias xmpp='profanity -a me'
# }}}
## Documents {{{
# Compress pdf file (medium compression)
alias pdfcomp='gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf'
# Official letter template
alias lettre='git clone https://git.moqueur.chat/etienne/lettre-officielle'
alias lettre='git clone gitea@git.moqueur.chat:etienne/lettre-officielle.git'
alias pdfscan='function _(){ hp-scan -d $HP -o $1 && pdfcomp $1 && mv output.pdf $1; }; _'
# }}}
## Music {{{
# Wrapper for ncmpcpp
@ -38,3 +51,4 @@ alias oggconvert='function _(){ for i in *.$1; do ffmpeg -i "$i" "${i%.*}.ogg";
# extract disc to ogg/Vorbis (create the folder first)
alias extract_disc='function _(){ cdparanoia -w $1 && oggconvert wav && notify-send "Disc extraction" "extract complete"; }; _'
# }}}
#

14
.bin/lfpreviewer Executable file
View File

@ -0,0 +1,14 @@
#!/bin/sh
# A previewer for lf
# Arguments are filename, width, height, horizontal and vertical positions
#
case "$1" in
*.png|*.jpg|*.jpeg) chafa "$1" -s "${2}x${3}";;
*.mp3|*.ogg|*.wav|*.mp4|*.avi|*.mkv) mediainfo "$1";;
*.md) glow -s light "$1";;
*.pdf) pdftotext "$1" - | bat;;
*.zip) unzip -l "$1";;
*) bat "$1";;
esac

View File

@ -6,7 +6,7 @@
## Base settings {{{
# interpreter for shell commands (needs to be POSIX compatible)
set shell sh
set shell bash
# set '-eu' options for shell commands
# These options are used to have safer shell commands. Option '-e' is used to
@ -27,6 +27,8 @@ set ifs "\n"
# leave some space at the top and the bottom of the screen
set scrolloff 10
# lf previewer
set previewer ~/.bin/lfpreviewer
# }}}
## Commands {{{
# define a custom 'open' command

View File

@ -35,7 +35,7 @@ layout_cmd () {
# fields to be used
URL_field='URL'
USERNAME_field='LOGIN'
AUTOTYPE_field='autotype'
#AUTOTYPE_field='AUTO'
# delay to be used for :delay keyword
delay=1
@ -48,17 +48,17 @@ xdotool_delay=12
## Programs to be used
# Editor
EDITOR='gvim -f'
#EDITOR='vim -f'
# Browser
BROWSER='xdg-open'
#BROWSER='xdg-open'
## Misc settings
default_do='menu' # menu, autotype, copyPass, typeUser, typePass, copyUser, copyUrl, viewEntry, typeMenu, actionMenu, copyMenu, openUrl
default_autotype='user :tab pass'
auto_enter='false'
notify='false'
default_autotype='user :tab pass'
# color of the help messages
# leave empty for autodetection
@ -85,7 +85,7 @@ edit_new_pass="true"
autotype="Alt+1"
type_user="Alt+2"
type_pass="Alt+3"
open_url="Alt+4"
open_url="Ctrl+o"
copy_name="Alt+u"
copy_url="Alt+l"
copy_pass="Alt+p"

View File

@ -8,7 +8,9 @@ set header_cache = "~/.cache/mutt"
set mail_check = 60
set mbox_type=Maildir
set editor=vim
set mailcap_path = ~/.mutt/mailcap
auto_view text/html
alternative_order text/plain text/html
# }}}
## Shortcuts {{{
macro index S "<shell-escape>mbsync -a^M" "Update through mbsync"
@ -36,6 +38,8 @@ bind index,pager <F73> sidebar-prev # Shift + Up
bind index,pager <F72> sidebar-next # Shift + Down
bind index,pager <S-Right> sidebar-open
# View mail in graphical browser
macro attach 'V' "<pipe-entry>iconv -c --to-code=UTF8 > ~/.cache/mutt/mail.html<enter><shell-escape>$BROWSER ~/.cache/mutt/mail.html<enter>"
# }}}
## Appearance {{{
set date_format = "%d/%m/%Y (%H:%M)" # Date as day/month

View File

@ -23,55 +23,3 @@ ${VISUAL}║ $1 ║
`!p snip.rv = snip.v.text+'╚' + '═' * (len(t[1]) + 2) + '╝'`
$0
endsnippet
# Snippets mathématiques
snippet FRL "Forall" wA
endsnippet
snippet EXS "Exists" wA
endsnippet
snippet DLT "Delta" wA
endsnippet
snippet PI "PI" wA
π
endsnippet
snippet '(\d)PI' "kπ" wrA
`!p snip.rv = match.group(1)`π
endsnippet
snippet IN "In" wA
endsnippet
snippet SUM "Sum" wA
endsnippet
snippet PRD "Prod" wA
endsnippet
snippet ROOT "Root" wA
endsnippet
snippet ITG "Integral" wA
endsnippet
snippet IFT "IFT" wA
endsnippet
snippet SQRT "SQRT" wA
endsnippet

View File

@ -0,0 +1,17 @@
snippet art "art" bA
@article{$1,
title = {$2},
volume = {$3},
issn = {$4},
abstract = {$5},
journal = {$6},
author = {$7},
month = $8,
year = {$9},
keywords = {$10},
pages = {$11},
file = {$12}
}
$0
endsnippet

View File

@ -0,0 +1,13 @@
snippet div "div"
<div>
$1
</div>
$0
endsnippet
snippet p "p"
<p>$1</p>
$0
endsnippet

View File

@ -17,3 +17,64 @@ ${4:Etienne}
endsnippet
# HTML Mails
snippet img "img" bA
<img src="${1:${VISUAL}}" width="${2:500px}">
$0
endsnippet
# Snippets mathématiques
snippet FRL "Forall" wA
endsnippet
snippet EXS "Exists" wA
endsnippet
snippet DLT "Delta" wA
endsnippet
snippet PI "PI" wA
π
endsnippet
snippet '(\d)PI' "kπ" wrA
`!p snip.rv = match.group(1)`π
endsnippet
snippet IN "In" wA
endsnippet
snippet SUM "Sum" wA
endsnippet
snippet PRD "Prod" wA
endsnippet
snippet ROOT "Root" wA
endsnippet
snippet ITG "Integral" wA
endsnippet
snippet IFT "IFT" wA
endsnippet
snippet SQRT "SQRT" wA
endsnippet

View File

@ -0,0 +1,16 @@
snippet snp "create a snippet" bA
snippet $1 "$1" ${2:wA}
$3
`!p snip.rv = 'endsnippet'`
$0
endsnippet
snippet mat "create a math context snippet" bA
context "math()"
snippet $1 "$1" ${2:wA}
$3
`!p snip.rv='endsnippet'`
$0
endsnippet

View File

@ -0,0 +1,18 @@
#
# LaTeX snippets for beamer
#
snippet frm "new frame" wA
\begin{frame}
\frametitle{$1}
$2
\end{frame}
$0
endsnippet
snippet pau "pause" wA
\pause $0
endsnippet

View File

@ -0,0 +1,19 @@
#┌───────────────┐
#│ TikZ snippets │
#└───────────────┘
snippet node "node" bA
\node ($1) at ($2,$3) {\$$4\$};
$0
endsnippet
snippet graphv "graph vertex" bA
\node ($1) at ($2,$3) [circle, draw= black, fill= white] {\$$4\$};
$0
endsnippet
snippet graphe "graph edge" bA
\draw[${1:thick}] ($2) -- ($3);
endsnippet

51
.vimrc
View File

@ -5,6 +5,8 @@
" Base {{{
" Fundamental settings
set modelines=1 " Enables the use of modelines to tweak things on a single document scale (see last line for an example
set nocompatible " Don't try to be compatible with vi
set path+=**
" }}}
" Tabs and spaces {{{
"Set the size and type of space made by a TAB stroke
@ -28,12 +30,37 @@ nnoremap <C-f> : silent exec '!inkscape-figures edit "'.b:vimtex.root.'/figures/
" Various shortcuts called by the <leader> char
let mapleader="," " the <leader> char is , (\ by default)
let maplocalleader=","
nnoremap <leader>t :tabnew<CR>
" Split screen and move between splits with fewer strokes
" Split screen vertically and move to the left split
nnoremap <leader>h :vertical split
" Same but move to the right Split
nnoremap <leader>l :vertical split<CR><C-w><C-l>
" Split screen horizontally and move to the top / bottom split
nnoremap <leader>j :split<CR><C-w><C-j>
nnoremap <leader>k :split<CR>
" Move through splits with less keystrokes
nnoremap <C-h> <C-w><C-h>
nnoremap <C-l> <C-w><C-l>
nnoremap <C-j> <C-w><C-j>
nnoremap <C-k> <C-w><C-k>
" }}}
" Spelling {{{
" Spelling and autocompletion {{{
" Get and correct spelling mistakes
setlocal spell
set spelllang=fr,en_gb
inoremap <C-l> <c-g>u<Esc>[s1z=`]a<c-g>u
set complete+=kspell " Add dictionary to completion
set completeopt=menuone,longest " the way completion are displayed: the longest match first, even displayed if there is only one match
set shortmess+=c " Remove the completion info in the bottom left
" Navigate the autocompletion menu with arrows
inoremap <expr> <Down> pumvisible() ? "<C-n>" :"<Down>"
inoremap <expr> <Up> pumvisible() ? "<C-p>" :"<Up>"
inoremap <expr> <Right> pumvisible() ? "<C-y>" : "<Right>"
inoremap <expr> <CR> pumvisible() ? "<C-y>" : "<CR>"
inoremap <expr> <Left> pumvisible() ? "<C-e>" : "<Left>"
" }}}
" Searching {{{
" How search results are displayed
@ -59,6 +86,7 @@ augroup configgroup
autocmd VimEnter * highlight clear SignColumn
autocmd Filetype conf setlocal foldmethod=marker " I like to fold my rc files
autocmd Filetype conf setlocal foldlevel=0
autocmd Filetype twig setlocal filetype=htmldjango
""" livetex files : basic tex with autowrite to have real-time compilation
autocmd TextChanged,TextChangedI *.livetex silent write
autocmd BufNewFile,BufRead *.livetex setlocal filetype=tex
@ -90,11 +118,30 @@ Plug 'SirVer/ultisnips'
let g:UltiSnipsExpandTrigger='<tab>' " Expand snippets with a TAB
let g:UltiSnipsJumpForwardTrigger='<tab>' " Use TAB to navigate the different zones of your snippet
let g:UltiSnipsJumpBackwardTrigger='<s-tab>' " Use SUPER+TAB to naviguate backwards
let g:UltiSnipsSnippetDirectories=['~/.vim/ultisnips']
let g:UltiSnipsSnippetDirectories=['ultisnips', 'UltiSnips']
" Pop completion menu automatically
Plug 'vim-scripts/AutoComplPop'
" palenight theme
Plug 'drewtempelmeyer/palenight.vim'
" Lightline, a nice bottom status line
Plug 'itchyny/lightline.vim'
set laststatus=2
set noshowmode
let g:lightline = {
\ 'colorscheme' : 'one',
\ }
" fzf
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
inoremap <leader>o <Esc>:Files<CR>
nnoremap <leader>o :Files<CR>
inoremap <leader>b <Esc>:Buffers<CR>
nnoremap <leader>b :Buffers<CR>
" Declare plugins to vim
call plug#end()