vim-rec
vim-rec copied to clipboard
GNU Recutils syntax highlighting support for Vim
GNU Recutils syntax support for Vim
This plugin provides syntax highlighting and runtime support for GNU Recutils' .rec files.
https://user-images.githubusercontent.com/39915/148492614-d88d21cf-a6a2-4a18-a50d-06c6935b9080.mov
Installation
-
If you're on Vim 8.x then you can use the built-in package support by running:
mkdir -p ~/.vim/pack/default/start/vim-rec git clone [email protected]:zaid/vim-rec.git ~/.vim/pack/default/start/vim-rec -
If you're using vim-plug then you can install it by adding the following to your
.vimrc:Plug 'zaid/vim-rec' -
If you're using minpac then you can install it by adding the following to your
.vimrc:call minpac#add('zaid/vim-rec')
Features
- Syntax highlighting.
- Folding for records. (can be disabled by setting the
g:recutils_no_foldingvariable to1). - Command wrappers for
recsel,recfix,recinfandrec2csv. - Auto-completion of record set properties.
- Record navigation commands and maps.
- Preview record descriptor in a popup/floating/preview window.
See help :recutils for more information.
Examples
Recfix
To find any syntax errors in the file, you can run :Recfix in any .rec buffer
and the syntax errors will be loaded in a local location-list where you'll be
able to navigate the list and jump straight to the line with the error.
Note The location-list will not open if there are no errors in the file.
Recsel
To query the Title of any book with a rating over 4, you can execute the following:
:Recsel -t Book -p Title -e Rating>4
Recinf
To query the descriptors of records stored in a specifc .rec buffer, you can execute the following:
:Recinf -d
Rec2csv
To convert Rec data into CSV format and populate it in a split buffer, you can execute the following:
:Rec2csv -tBook
Notes
Whitespace might need to be escaped in certain scenarios. For example, the following line:
:Recsel -t Book -p Title -e Rating>4
can be rewritten as:
:Recsel -t Book -p Title -e Rating\ >\ 4
To close the floating window in Neovim, you can use any of the q, Esc, <localleader>, Ctrl-C or <Cr> keys.
Command maps
There are 6 command maps defined (which can be disabled by setting the g:recutils_no_maps variable to 1):
<localleader>rfInvokes:Recfix --checkon the current buffer.<localleader>rnpopulates the Vim command line with:Recinf.<localleader>rspopulates the Vim command line with:Recsel.<localleader>rvpopulates the Vim command line with:Rec2csv.<localleader>r]jumps to the next record descriptor.<localleader>r[jumps to the previous record descriptor.<localleader>r?show the current record descriptor in a popup/floating/preview window.
Auto-completion
Basic support for auto-completing record set properties is available (by using C-x C-o when in insert mode).
It can be disabled by setting the g:recutils_no_autocompletion variable to 1.
TODO
- Keymaps for formatting text.
License
Copyright Zaid Al-Jarrah. Distributed under the same terms as Vim itself. See :help license.