vimrc.d/syntax.vim

Enforce vim script implementation to reduce ambiguities and improve robustness:

scriptversion 4

Load a colour scheme, but only on first source:

if !exists('g:colors_name')
    colorscheme molokai
endif

Only enable Lua/Python/Ruby embedded syntax regardless of built-in support:

const g:vimsyn_embed = 'lPr'

awk

While system awk is never gawk for me, every time I write an awk script I’m targeting gawk.

let g:awk_is_gawk = v:true

.desktop

Highlight invalid entries:

let g:desktop_enable_nonstd = v:true

Manual pages

Support folding:

const g:ft_man_folding_enable = v:true

Prefer vertical splits:

const g:ft_man_open_mode = 'vert'

Python

Highlight everything possible for Python:

const g:python_highlight_all = v:true

quickfix

Don’t set the status line as vim-airline takes care of this already:

let g:qf_disable_statusline = v:true

reStructuredText

Disable reST’s default indentation rules:

const g:rst_style = v:false

Note

The indentation rules mostly work, but occasionally don’t seem to do the right thing… and that is far more annoying than always being wrong.

The folding configuration for reST files is quite poor, and the custom 'foldtext' makes using folds close to useless:

const g:rst_fold_enabled = v:false

Note

This isn’t enabled upstream, but has been toggled on in a few site files for reasons which are far beyond me.

Enable common — to me — highlighting support:

let g:rst_syntax_code_list = #{
\   c: ['c', ],
\   cpp: ['cpp', 'c++'],
\   lisp: ['emacs', 'lisp'],
\   python: ['python', ],
\   sh: ['sh', 'zsh'],
\   vim: ['vim', ],
\ }
Example of code block highlighting

Todo

This should probably be configured more locally as it includes the full syntax definitions for each language, and it considerably increase syntax parsing speed. The actual impact needs measuring properly first!

Rust

Use fancy conceal support for rust:

const g:rust_conceal = v:true
const g:rust_conceal_mod_path = v:true
const g:rust_conceal_pub = v:true

Todo

Add screenshot.

Enable folding support, but default to the global 'foldlevel':

const g:rust_fold = 1

Shell scripts

Default to bash for sh syntax, and POSIX is a more realistic default for me if g:is_bash is toggled:

const g:is_bash = v:true
const g:is_posix = v:true

Fold shell scripts as much as possible:

const g:sh_fold_enabled = 7

… and search a long way to keep syntax highlighting correct:

const g:sh_minlines = 400

… and disable highlighting errors that will be caught by linter:

const g:sh_no_error = v:true

XML

Support folding in XML:

const g:xml_syntax_folding = v:true

zsh

Support folding for zsh too, including the excellent alternative syntax:

const g:zsh_fold_enable = v:true