Tiny, simple ftdetect, ftplugin and syntax scripts for OpenWRT's Unified Configuration Interface files.
Don't have vim on your router? I don't either, but this works great with sshfs.
ftplugin/uci.vim sets commentstring correctly, so tpope's
vim-commentary works as intended!
UCI tag-file generator by @efahl
If you want to be able to jump to tags (named sections or options, etc).
#!/usr/bin/ucode -S
// Create tags for uci files, specifically targeting two items:
// 1) named sections: config type 'thing'
// 2) sections containing a "name" option: option name 'thing'
// In both cases, the literal "thing" becomes the tag.
import {open, glob} from "fs";
let tags = [];
function save_tag(tag, path, line)
{
tag = replace(tag, /['"]/g, "");
line = replace(line, /\//g, "\\/"); // Feeble regex escaping...
push(tags, sprintf("%s\t%s\t/^%s$/\n", tag, path, line));
}
for (let path in glob("/etc/config/*")) {
let config = open(path, "r");
if (config) {
let line;
while (line = config.read("line")) {
line = replace(line, "\n", "");
let parts = split(trim(line), /[[:space:]]+/);
if (length(parts) < 3) continue;
if (parts[0] == "config" ||
parts[0] == "option" && parts[1] == "name") {
save_tag(parts[2], path, line);
}
}
config.close();
}
}
for (let line in sort(tags)) {
print(line);
}
If you don't have a preferred installation method, I recommend installing pathogen.vim, and then simply copy and paste:
cd ~/.vim/bundle
git clone git://github.com/cmcaine/vim-uci.git
Vundle, etc. will probably work fine too.
Copyright Colin Caine. GPL v3.