summaryrefslogtreecommitdiffstats
path: root/runtime/compiler/pandoc.vim
blob: 6c151930c5c0c87a67b0de27e8267f623ccf296f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
" Vim compiler file
" Compiler:     Pandoc
" Maintainer:   Konfekt
"
" Expects output file extension, say `:make html` or `:make pdf`.
" Passes additional arguments to pandoc, say `:make html --self-contained`.

if exists("current_compiler")
  finish
endif

let s:keepcpo = &cpo
set cpo&vim

let current_compiler = 'pandoc'

" As of 2024-04-08 pandoc supports the following text input formats with
" an ftplugin on Github:
let s:supported_filetypes =
      \ [ 'bibtex', 'markdown', 'creole', 'json', 'csv', 'tsv', 'docbook',
      \   'xml', 'fb2', 'html', 'jira', 'tex', 'mediawiki', 'nroff', 'org',
      \   'rtf', 'rst', 't2t', 'textile', 'twiki', 'typst', 'vimwiki' ]
" .. and out of those the following are included in Vim's runtime:
" 'xml', 'tex', 'html', 'rst', 'json', 'nroff', 'markdown'

silent! function s:PandocFiletype(filetype) abort
  let ft = a:filetype
  if ft ==# 'pandoc'
    return 'markdown'
  elseif ft ==# 'tex'
    return 'latex'
  elseif ft ==# 'xml'
    " Pandoc does not support XML as a generic input format, but it does support
    " EndNote XML and Jats XML out of which the latter seems more universal.
    return 'jats'
  elseif ft ==# 'text' || empty(ft)
    return 'markdown'
  elseif index(s:supported_filetypes, &ft) >= 0
      return ft
  else
    echomsg 'Unsupported filetype: ' . ft . ', falling back to Markdown as input format!'
    return 'markdown'
  endif
endfunction
execute 'CompilerSet makeprg=pandoc\ --standalone' .
      \ '\ --metadata\ title=%:t:r:S' .
      \ '\ --metadata\ lang=' . matchstr(&spelllang, '^\a\a') .
      \ '\ --from=' . s:PandocFiletype(&filetype) .
      \ '\ ' . escape(get(b:, 'pandoc_compiler_args', get(g:, 'pandoc_compiler_args', '')), ' ') .
      \ '\ --output\ %:r:S.$*\ %:S'

CompilerSet errorformat="%f",\ line\ %l:\ %m

let &cpo = s:keepcpo
unlet s:keepcpo
class="s2">"pkgs.disnix"; }; enableProfilePath = mkEnableOption (lib.mdDoc "exposing the Disnix profiles in the system's PATH"); profiles = mkOption { type = types.listOf types.str; default = [ "default" ]; description = lib.mdDoc "Names of the Disnix profiles to expose in the system's PATH"; }; }; }; ###### implementation config = mkIf cfg.enable { dysnomia.enable = true; environment.systemPackages = [ pkgs.disnix ] ++ optional cfg.useWebServiceInterface pkgs.DisnixWebService; environment.variables.PATH = lib.optionals cfg.enableProfilePath (map (profileName: "/nix/var/nix/profiles/disnix/${profileName}/bin" ) cfg.profiles); environment.variables.DISNIX_REMOTE_CLIENT = lib.optionalString (cfg.enableMultiUser) "disnix-client"; services.dbus.enable = true; services.dbus.packages = [ pkgs.disnix ]; services.tomcat.enable = cfg.useWebServiceInterface; services.tomcat.extraGroups = [ "disnix" ]; services.tomcat.javaOpts = "${optionalString cfg.useWebServiceInterface "-Djava.library.path=${pkgs.libmatthew_java}/lib/jni"} "; services.tomcat.sharedLibs = optional cfg.useWebServiceInterface "${pkgs.DisnixWebService}/share/java/DisnixConnection.jar" ++ optional cfg.useWebServiceInterface "${pkgs.dbus_java}/share/java/dbus.jar"; services.tomcat.webapps = optional cfg.useWebServiceInterface pkgs.DisnixWebService; users.groups.disnix.gid = config.ids.gids.disnix; systemd.services = { disnix = mkIf cfg.enableMultiUser { description = "Disnix server"; wants = [ "dysnomia.target" ]; wantedBy = [ "multi-user.target" ]; after = [ "dbus.service" ] ++ optional config.services.httpd.enable "httpd.service" ++ optional config.services.mysql.enable "mysql.service" ++ optional config.services.postgresql.enable "postgresql.service" ++ optional config.services.tomcat.enable "tomcat.service" ++ optional config.services.svnserve.enable "svnserve.service" ++ optional config.services.mongodb.enable "mongodb.service" ++ optional config.services.influxdb.enable "influxdb.service"; restartIfChanged = false; path = [ config.nix.package cfg.package config.dysnomia.package "/run/current-system/sw" ]; environment = { HOME = "/root"; } // (optionalAttrs (config.environment.variables ? DYSNOMIA_CONTAINERS_PATH) { inherit (config.environment.variables) DYSNOMIA_CONTAINERS_PATH; }) // (optionalAttrs (config.environment.variables ? DYSNOMIA_MODULES_PATH) { inherit (config.environment.variables) DYSNOMIA_MODULES_PATH; }); serviceConfig.ExecStart = "${cfg.package}/bin/disnix-service"; }; }; }; }