Skip to content

luffah/vim-accessibility

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Set of scripts attempting to implement accessibility features

NOTE: new version : dropped the old format

This project group things intended to make Vim more accessible for people.

  • Text to Speech dispatcher : keybinds and commands to make Vim speak
    (require speech-dispatcher on linux - if you use Orca it shall be already installed)

    " (can setup lang and voice with  g:speak_lang and g:speak_voice_type
    "  else use spd-say default)

    :SpeakLine speak (send text at) the current line (to speech-dispatcher).
    :SpeakWORD speak the following word in the text; intended to be followed by W in order to read text word by word.

    Anyway, in a GVim just hit <C-s> (Ctrl + s) to toggle a screen reader mode.
    This probably needs to be improved (Emacs-speak users suggestions are welcome).

  • Easy-to-use alias feature which are equivalent of cabbrev including expansion condition
    In short, it can be written like that (vimkm format):

    alias qa           confirm qa
    alias tnc          tabnew $VIMPWD/<C-d>
    alias tn/   <cmap> tabnew  /<C-d>
    alias tn.   <cmap> tabnew ./<C-d>
  • Documented keymapping : to force yourself to document your keybind and allow to create tutorials
    In short, it can be written like that (vimkm format) :

    " Here 8 mapping in 2 lines
    "Modes are separated by ','; first char is mode; next chars are some action to prepend
    "Modes         " Keys     ''Description ''        Vim action
    km(i<c-o>,n,v) <C-l> <A-l> "Enter command line"   :
    km(i,ni)       <A-Right>   "Compl. filename "     <expr> pumvisible()?"<Cr>":"<C-x><C-f>"
    
    " ':call keybindings#PrintCurrentLayer()' to see the list of key binding
    " to group shortcuts by categories :
    " example 1 : a tutorial mode for <C-w>
    km(n)      <C-w>       "C-w"                  <OneShot=wincmd>
    km()       T           ":Move to a new tab"   T
    " example 2 : emacs-like behavior 
    km(n)     <C-x>       "~Emacs C-x"           <Layer>
    km()      <C-f>       ":Search file"         <ExitLayer>:e! %:p:h/*
    See the details about keymapping Every lines above are a short format the following lines (vim script):
    " <C-l> enter in command line mode from insert, normal, and visual mode
    " cal ..Map('Description', keys, action, modes_and_things_related_to_the_mode)
    cal keybindings#Map('Enter command line' , ['<C-l>','<A-l>']   , ':' , ['i<c-o>','n','v'])
    
    " <A-Right> complete filename in insert and normal mode
    " 'i' is for insert mode 
    " 'ni'  is for normal mode; but force the use of <C-x><C-f> in insert mode
    cal keybindings#Map('Complete filename' , '<A-Right>' , '<expr> pumvisible()? "<Cr>":"<C-x><C-f>"'   , ['i' , 'ni'])
    
    " Following example is usefull for re-discovering keys
    " When you hit <C-w>, a window with 'T -> Move to a new tab' is shown
    " If you hit 'T' then ':wincmd T' is applied
    " Too, if you hit 'w' then ':wincmd w' is applied (no need to document everything)
    cal keybindings#Map('C-w'            , '<C-w>' , "<OneShot=wincmd>"  , ['n'])
    cal keybindings#Map(':Move to a new tab' , 'T'       , "T" , [])
    
    " Here a way to have a thousand of keybinds
    " It define a new keybind temporary layer,
    " '~' just say to not show the window which shows activated keybinds
    cal keybindings#Map('~Emacs C-x'    , '<C-x>' , '<Layer>' , ['n'])
    cal keybindings#Map(':Search file'    , '<C-f>' , '<ExitLayer>:e! %:p:h/*' , ['n'])

  • Limitation and security : alias and keybindings do not use recursive mapping by default

Installation

Get the repository.

# 'ui' is abitrary chosen for 'user interface'
mkdir -p ~/.vim/pack/ui/start
git clone https://github.com/luffah/vim-accessibility.git ~/.vim/pack/ui/start/accessibility
packloadall

" Example
call keybindings#Source('$VIMPLUGINS/vim-accessibility/doc/samples/common.vimkm')
My Vim doesn't support +packages If you have an old version of Vim (< 8), it is useless to create `~/.vim/pack/`. Just use the path where you install your plugins.
" let $VIMPLUGINS = <Path to directory containing your plugins>
"
" [Optional]
" This allows to access to documentation.
" Add to runtime path
set rtp+=$VIMPLUGINS/vim-accessibility
" Activate plugins
filetype indent plugin on

" [Required]
so $VIMPLUGINS/vim-accessibility/loader.vim
" Example
call keybindings#Source('$VIMPLUGINS/vim-accessibility/doc/samples/common.vimkm')

License

Vim is distributed under GPL-compatible Charityware License.
The content of this project itself is licensed under the Creative Commons Attribution-ShareAlike 4.0 license,
and source code contained in this repository is licensed under the GPLv3 license.

About

This project group things needed to make Vim more accessible for people.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors