view: introduce view_selection_get
[vis.git] / visrc.lua
blob0cbc70eb53fa76b2338b1de602710a979eb12fac
1 vis.lexers = require('lexer')
3 vis.events = {}
5 vis.events.win_open = function(win)
7 local files = {
8 [".1|.2|.3|.4|.5|.6|.7|.8|.9|.1x|.2x|.3x|.4x|.5x|.6x|.7x|.8x|.9x"] = "man",
9 [".au3|.a3x"] = "autoit",
10 [".as|.asc"] = "actionscript",
11 [".adb|.ads"] = "ada",
12 [".g|.g4"] = "antlr",
13 [".ans|.inp|.mac"] = "apdl",
14 [".apl"] = "apl",
15 [".applescript"] = "applescript",
16 [".asm|.ASM|.s|.S"] = "asm",
17 [".asa|.asp|.hta"] = "asp",
18 [".awk"] = "awk",
19 [".bat|.cmd"] = "batch",
20 [".bib"] = "bibtex",
21 [".boo"] = "boo",
22 [".cs"] = "csharp",
23 [".c|.cc|.C"] = "ansi_c",
24 [".cpp|.cxx|.c++|.h|.hh|.hpp|.hxx|.h++"] = "cpp",
25 [".ck"] = "chuck",
26 [".cmake|.cmake.in|.ctest|.ctest.in"] = "cmake",
27 [".coffee"] = "coffeescript",
28 [".css"] = "css",
29 [".cu|.cuh"] = "cuda",
30 [".d|.di"] = "dmd",
31 [".dart"] = "dart",
32 [".desktop"] = "desktop",
33 [".diff|.patch"] = "diff",
34 [".dot"] = "dot",
35 [".e|.eif"] = "eiffel",
36 [".ex|.exs"] = "elixir",
37 [".erl|.hrl"] = "erlang",
38 [".dsp"] = "faust",
39 [".feature"] = "gherkin",
40 [".fs"] = "fsharp",
41 [".fish"] = "fish",
42 [".forth|.frt|.fs"] = "forth",
43 [".f|.for|.ftn|.fpp|.f77|.f90|.f95|.f03|.f08"] = "fortran",
44 [".g|.gd|.gi|.gap"] = "gap",
45 [".po|.pot"] = "gettext",
46 [".glslf|.glslv"] = "glsl",
47 [".dem|.plt"] = "gnuplot",
48 [".go"] = "go",
49 [".groovy|.gvy"] = "groovy",
50 [".gtkrc"] = "gtkrc",
51 [".hs"] = "haskell",
52 [".htm|.html|.shtm|.shtml|.xhtml"] = "html",
53 [".icn"] = "icon",
54 [".idl|.odl"] = "idl",
55 [".inf|.ni"] = "inform",
56 [".cfg|.cnf|.inf|.ini|.reg"] = "ini",
57 [".io"] = "io_lang",
58 [".bsh|.java"] = "java",
59 [".js|.jsfl"] = "javascript",
60 [".json"] = "json",
61 [".jsp"] = "jsp",
62 [".bbl|.dtx|.ins|.ltx|.tex|.sty"] = "latex",
63 [".less"] = "less",
64 [".lily|.ly"] = "lilypond",
65 [".ledger|.journal"] = "ledger",
66 [".cl|.el|.lisp|.lsp"] = "lisp",
67 [".litcoffee"] = "litcoffee",
68 [".lua"] = "lua",
69 ["GNUmakefile|.iface|.mak|.mk|makefile|Makefile"] = "makefile",
70 [".md"] = "markdown",
71 [".n"] = "nemerle",
72 [".nim"] = "nim",
73 [".nsh|.nsi|.nsis"] = "nsis",
74 [".m|.mm|.objc"] = "objective_c",
75 [".caml|.ml|.mli|.mll|.mly"] = "caml",
76 [".dpk|.dpr|.p|.pas"] = "pascal",
77 [".al|.perl|.pl|.pm|.pod"] = "perl",
78 [".inc|.php|.php3|.php4|.phtml"] = "php",
79 [".pike|.pmod"] = "pike",
80 [".PKGBUILD"] = "pkgbuild",
81 [".ps1"] = "powershell",
82 [".eps|.ps"] = "ps",
83 [".prolog"] = "prolog",
84 [".props|.properties"] = "props",
85 [".pure"] = "pure",
86 [".sc|.py|.pyw"] = "python",
87 [".R|.Rout|.Rhistory|.Rt|Rout.save|Rout.fail"] = "rstats",
88 [".r|.reb"] = "rebol",
89 [".rst"] = "rest",
90 [".orx|.rex"] = "rexx",
91 [".erb|.rhtml"] = "rhtml",
92 [".Rakefile|.rake|.rb|.rbw"] = "ruby",
93 [".rs"] = "rust",
94 [".sass|.scss"] = "sass",
95 [".scala"] = "scala",
96 [".sch|.scm"] = "scheme",
97 [".sno|.SNO"] = "snobol4",
98 [".bash|.bashrc|.bash_profile|.configure|.csh|.sh|.zsh"] = "bash",
99 [".changes|.st|.sources"] = "smalltalk",
100 [".ddl|.sql"] = "sql",
101 [".tcl|.tk"] = "tcl",
102 [".texi"] = "texinfo",
103 [".toml"] = "toml",
104 [".vala"] = "vala",
105 [".vcf|.vcard"] = "vcard",
106 [".v|.ver"] = "verilog",
107 [".vh|.vhd|.vhdl"] = "vhdl",
108 [".asa|.bas|.cls|.ctl|.dob|.dsm|.dsr|.frm|.pag|.vb|.vba|.vbs"] = "vb",
109 [".wsf"] = "wsf",
110 [".dtd|.svg|.xml|.xsd|.xsl|.xslt|.xul"] = "xml",
111 [".xtend"] = "xtend",
112 [".yaml"] = "yaml",
115 local filename = win.file.name
117 if filename ~= nil then
118 -- filename = string.lower(filename)
119 for patterns, lang in pairs(files) do
120 for pattern in string.gmatch(patterns, '[^|]+') do
121 if #filename >= #pattern then
122 local s, e = string.find(filename, pattern, -#pattern, true)
123 if s ~= e and e == #filename then
124 vis.command('set syntax '.. lang)
125 return;