Vim support for XMLTV tv_augment programme fixups
Vim script Perl
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
ftdetect
ftplugin
syntax
syntax_checkers/xmltvfixup
README.md

README.md

Vim plugin for managing XMLTV tv_augment programme fixups

A Vim plugin providing functionality to make maintaining an XMLTV grabber programme fixups file (e.g. augment.rules for tv_augment) easier and less error-prone.

This plugin provides:

  • Automatic filetype detection
  • Syntax highlighting
  • Automatic folding
  • Error detection within fixup entries
  • Automatic creation of new fixups from current selection (quote-star buffer)
  • Automatic sorting of fixups when saving file
  • Mappable sort/insert commands

The fixup error detection support integrates with Syntastic, a Vim plugin that uses external source code checkers (linters) to provide editor notification of errors.

Features

Automatic filetype detection

Filenames of prog_titles_to_process and augment.rules are automatically set to the 'xmltvfixup' filetype.

Other fixup files can be assigned the 'xmltvfixup' filetype automatically by adding the following to your .vimrc:

autocmd BufNewFile,BufRead */path/to/fixup/file set filetype=xmltvfixup

Syntax highlighting

Highlighting of the 'xmltvfixup' filetype is used to distinguish the following elements in a fixups file:

  • Fixup type ID (number)
  • Fixup type separator (bar)
  • Fixup text fields
  • Fixup text separator (tilde)

Automatic folding

All fixups of the same type are automatically folded when a fixups file is opened. This can make navigation through a large fixups file much quicker.

Error detection within fixup entries

The linter script xmltvfixuplint is run automatically by Syntastic. Typically this can be whenever a fixup file is opened and/or saved, or when Vim is idle.

The linter script runs directly from the plugin directory. No further installation is necessary.

The linter script checks a fixups file for errors such as:

  • Unknown fixup type
  • Missing fixup text
  • Wrong number of fixup fields in a fixup entry

The script will also try to suggest when a fixup might be better rewritten as a different fixup type.

Automatic creation of new fixups

New fixups can be created automatically in the correct section of the file by either calling:

:InsertXMLTVFixup(type)

or by using the relevant mapping (see below). Text to create the new fixup entry with is taken from the current X selection. The fixup text inserted is edited and formatted as far a possible to make fixup insertion as fast as possible.

Automatic sorting of fixups

Whenever the prog_titles_to_process file is saved, each section of fixups is automatically sorted in place. To sort the fixups file at any time, call:

:SortXMLTVFixups

Mappable sort/insert commands

The plugin provides a set of commands that can be mapped. Default mappings can be disabled by setting g:xmltvfixup_no_mappings=1 in your .vimrc

By default, the following convenience mappings are provided (for the xmltvfixup filetype only, and only for the current buffer):

<LocalLeader>xS   <Plug>SortXMLTVFixups
<LocalLeader>x1   <Plug>InsertXMLTVType1Fixup
<LocalLeader>x2   <Plug>InsertXMLTVType2Fixup
<LocalLeader>x3   <Plug>InsertXMLTVType3Fixup
<LocalLeader>x4   <Plug>InsertXMLTVType4Fixup
<LocalLeader>x5   <Plug>InsertXMLTVType5Fixup
<LocalLeader>x6   <Plug>InsertXMLTVType6Fixup
<LocalLeader>x7   <Plug>InsertXMLTVType7Fixup
<LocalLeader>x8   <Plug>InsertXMLTVType8Fixup
<LocalLeader>x9   <Plug>InsertXMLTVType9Fixup
<LocalLeader>xa   <Plug>InsertXMLTVType10Fixup
<LocalLeader>xb   <Plug>InsertXMLTVType11Fixup
<LocalLeader>xc   <Plug>InsertXMLTVType12Fixup
<LocalLeader>xd   <Plug>InsertXMLTVType13Fixup
<LocalLeader>xe   <Plug>InsertXMLTVType14Fixup
<LocalLeader>xf   <Plug>InsertXMLTVType15Fixup

Prerequisites

For full functionality, this plugin requires:

Installation (plugin)

Installing vim-xmltvfixup is straightforward. Use of a Vim plugin manager is recommended (I currently use vim-plug).

vim-plug

If you are using vim-plug you need to have the following 2 lines in your .vimrc:

Plug 'scrooloose/syntastic'
Plug 'knowledgejunkie/vim-xmltvfixup'

To install the plugin from within Vim, run:

:PlugInstall vim-xmltvfixup

To install the plugin from the command line, run:

$ vim +PlugInstall vim-xmltvfixup +qall

Vundle

For Vundle you need to make sure you have the following 2 lines in your .vimrc:

Bundle 'scrooloose/syntastic'
Bundle 'knowledgejunkie/vim-xmltvfixup'

To install the plugin from within Vim, run:

:PluginInstall

To install the plugin from the command line, run:

$ vim +PluginInstall +qall

Pathogen

For Pathogen, execute:

cd ~/.vim/bundle
git clone https://github.com/knowledgejunkie/vim-xmltvfixup
vim +Helptags +q

Usage

Filetype detection, syntax highlighting and folding should "just work" once the plugin is installed.

The fixup linter should work automatically if Syntastic is installed. Check Syntastic's detailed help (:h syntastic) to see how it can be configured to your specific requirements.

To use the linter as a standalone utility (must be in your $PATH):

$ xmltvfixuplint prog_titles_to_process

TODO

  • Refactor linter, add more checks

License

Copyright (c) 2014-16 Nick Morrott. Distributed under the same terms as Vim itself. See :help license.