Docbook Editor Configuration

From NixOS Wiki
Revision as of 22:05, 1 November 2017 by imported>Disassembler (Adds vim editor for docbook settings)

For Emacs

The following creates an Emacs with a custom module, which configures nXML for the NixOS / Nixpkgs docbook codebase:

let
  pkgs = import <nixpkgs> {};
  inherit (pkgs) emacsPackagesNg docbook5 writeText;

  schemas = writeText "schemas.xml" ''
    <locatingRules xmlns="http://thaiopensource.com/ns/locating-rules/1.0">
      <documentElement localName="section" typeId="DocBook"/>
      <documentElement localName="chapter" typeId="DocBook"/>
      <documentElement localName="article" typeId="DocBook"/>
      <documentElement localName="book" typeId="DocBook"/>
      <typeId id="DocBook" uri="${docbook5}/xml/rng/docbook/docbookxi.rnc" />
    </locatingRules>
  '';

in emacsPackagesNg.emacsWithPackages (epkgs: [
  (emacsPackagesNg.trivialBuild {
    pname = "nix-docbook-mode";
    version = "1970-01-01";
    src = writeText "default.el" ''
      (eval-after-load 'rng-loc
        '(add-to-list 'rng-schema-locating-files "${schemas}"))
    '';
  })
])

For Vim/Neovim

let
  pkgs = import <nixpkgs> {};
  buildVimPlugin = pkgs.vimUtils.buildVimPluginFrom2Nix;
  custom_plugins = {
    "vim_docbk" = buildVimPlugin {
      name = "vim-docbk";
      src = pkgs.fetchgit {
        url = "https://github.com/jhradilek/vim-docbk";
        rev = "6ac0346ce96dbefe982b9e765a81c072997f2e9e";
        sha256 = "1jnx39m152hf9j620ygagaydg6h8m8gxkr1fmxj6kgqf71jr0n9d";
      };
      dependencies = [];
    };
    "jhradilek_snippets" = buildVimPlugin {
      name = "jhradilek_snippets";
      src = pkgs.fetchgit {
        url = "https://github.com/jhradilek/vim-snippets";
        rev = "bf7e6742ac0a2ddc6bab5593bd2a2c6b75269bb8";
        sha256 = "1h7cp0p1z8r7w9bg2l79n5gg047xp8j8kg1xnn0finxqyb45lqif";
      };
      dependencies = [];
    };
  };
  nvim = pkgs.neovim.override {
    configure = {
      vam = {
        knownPlugins = pkgs.vimPlugins // custom_plugins;
        pluginDictionaries = [
          {
            names = [
              "vim_docbk"
              "jhradilek_snippets"
              "syntastic"
              "UltiSnips"
            ];
          }
        ];
      };
    };
  };
in
pkgs.stdenv.mkDerivation rec {
  name = "Docbook_Vim";
  buildInputs = [ nvim ];
}