summaryrefslogtreecommitdiffstats
path: root/tv/5pkgs/vim/showsyntax.nix
blob: a5547e46af3821d5bf46b457645e0663ed53cfcd (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
{ pkgs }:

(rtp: rtp // { inherit rtp; }) (pkgs.writeTextFile (let
  name = "showsyntax";
in {
  name = "vim-plugin-${name}-1.0.0";
  destination = "/plugin/${name}.vim";
  text = /* vim */ ''
    if exists('g:loaded_showsyntax')
      finish
    endif
    let g:loaded_showsyntax = 0

    fu! ShowSyntax()
      let id = synID(line("."), col("."), 1)
      let name = synIDattr(id, "name")
      let transName = synIDattr(synIDtrans(id),"name")
      if name != transName
        let name .= " (" . transName . ")"
      endif
      echo "Syntax: " . name
    endfu

    command! -n=0 -bar ShowSyntax :call ShowSyntax()
  '';
}))