aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--lexers/lexer.lua119
-rw-r--r--visrc.lua127
3 files changed, 128 insertions, 120 deletions
diff --git a/Makefile b/Makefile
index 5e71790..f247162 100644
--- a/Makefile
+++ b/Makefile
@@ -74,7 +74,7 @@ install: vis
@chmod 755 ${DESTDIR}${PREFIX}/bin/vis-open
@echo installing support files to ${DESTDIR}${SHAREPREFIX}
@mkdir -p ${DESTDIR}${SHAREPREFIX}
- @cp -r lexers ${DESTDIR}${SHAREPREFIX}
+ @cp -r visrc.lua lexers ${DESTDIR}${SHAREPREFIX}
@echo installing manual page to ${DESTDIR}${MANPREFIX}/man1
@mkdir -p ${DESTDIR}${MANPREFIX}/man1
@sed "s/VERSION/${VERSION}/g" < vis.1 > ${DESTDIR}${MANPREFIX}/man1/vis.1
diff --git a/lexers/lexer.lua b/lexers/lexer.lua
index cb9138a..36f68d8 100644
--- a/lexers/lexer.lua
+++ b/lexers/lexer.lua
@@ -1594,123 +1594,4 @@ function M.get_style(lexer, lang, token_name)
return lexer['STYLE_'..string_upper(token_name)] or lang._EXTRASTYLES[token_name]
end
-local files = {
- [".1|.2|.3|.4|.5|.6|.7|.8|.9|.1x|.2x|.3x|.4x|.5x|.6x|.7x|.8x|.9x"] = "man",
- [".as|.asc"] = "actionscript",
- [".adb|.ads"] = "ada",
- [".g|.g4"] = "antlr",
- [".ans|.inp|.mac"] = "apdl",
- [".apl"] = "apl",
- [".applescript"] = "applescript",
- [".asm|.ASM|.s|.S"] = "asm",
- [".asa|.asp|.hta"] = "asp",
- [".awk"] = "awk",
- [".bat|.cmd"] = "batch",
- [".bib"] = "bibtex",
- [".boo"] = "boo",
- [".cs"] = "csharp",
- [".c|.cc|.C"] = "ansi_c",
- [".cpp|.cxx|.c++|.h|.hh|.hpp|.hxx|.h++"] = "cpp",
- [".ck"] = "chuck",
- [".cmake|.cmake.in|.ctest|.ctest.in"] = "cmake",
- [".coffee"] = "coffeescript",
- [".css"] = "css",
- [".cu|.cuh"] = "cuda",
- [".d|.di"] = "dmd",
- [".dart"] = "dart",
- [".desktop"] = "desktop",
- [".diff|.patch"] = "diff",
- [".dot"] = "dot",
- [".e|.eif"] = "eiffel",
- [".ex|.exs"] = "elixir",
- [".erl|.hrl"] = "erlang",
- [".dsp"] = "faust",
- [".fs"] = "fsharp",
- [".fish"] = "fish",
- [".forth|.frt|.fs"] = "forth",
- [".f|.for|.ftn|.fpp|.f77|.f90|.f95|.f03|.f08"] = "fortran",
- [".g|.gd|.gi|.gap"] = "gap",
- [".po|.pot"] = "gettext",
- [".glslf|.glslv"] = "glsl",
- [".dem|.plt"] = "gnuplot",
- [".go"] = "go",
- [".groovy|.gvy"] = "groovy",
- [".gtkrc"] = "gtkrc",
- [".hs"] = "haskell",
- [".htm|.html|.shtm|.shtml|.xhtml"] = "html",
- [".idl|.odl"] = "idl",
- [".inf|.ni"] = "inform",
- [".cfg|.cnf|.inf|.ini|.reg"] = "ini",
- [".io"] = "io_lang",
- [".bsh|.java"] = "java",
- [".js|.jsfl"] = "javascript",
- [".json"] = "json",
- [".jsp"] = "jsp",
- [".bbl|.dtx|.ins|.ltx|.tex|.sty"] = "latex",
- [".less"] = "less",
- [".lily|.ly"] = "lilypond",
- [".ledger|.journal"] = "ledger",
- [".cl|.el|.lisp|.lsp"] = "lisp",
- [".litcoffee"] = "litcoffee",
- [".lua"] = "lua",
- ["GNUmakefile|.iface|.mak|.mk|makefile|Makefile"] = "makefile",
- [".md"] = "markdown",
- [".n"] = "nemerle",
- [".nim"] = "nim",
- [".nsh|.nsi|.nsis"] = "nsis",
- [".m|.mm|.objc"] = "objective_c",
- [".caml|.ml|.mli|.mll|.mly"] = "caml",
- [".dpk|.dpr|.p|.pas"] = "pascal",
- [".al|.perl|.pl|.pm|.pod"] = "perl",
- [".inc|.php|.php3|.php4|.phtml"] = "php",
- [".pike|.pmod"] = "pike",
- [".PKGBUILD"] = "pkgbuild",
- [".ps1"] = "powershell",
- [".eps|.ps"] = "ps",
- [".prolog"] = "prolog",
- [".props|.properties"] = "props",
- [".pure"] = "pure",
- [".sc|.py|.pyw"] = "python",
- [".R|.Rout|.Rhistory|.Rt|Rout.save|Rout.fail"] = "rstats",
- [".r|.reb"] = "rebol",
- [".rst"] = "rest",
- [".orx|.rex"] = "rexx",
- [".erb|.rhtml"] = "rhtml",
- [".Rakefile|.rake|.rb|.rbw"] = "ruby",
- [".rs"] = "rust",
- [".sass|.scss"] = "sass",
- [".scala"] = "scala",
- [".sch|.scm"] = "scheme",
- [".bash|.bashrc|.bash_profile|.configure|.csh|.sh|.zsh"] = "bash",
- [".changes|.st|.sources"] = "smalltalk",
- [".ddl|.sql"] = "sql",
- [".tcl|.tk"] = "tcl",
- [".texi"] = "texinfo",
- [".toml"] = "toml",
- [".vala"] = "vala",
- [".vcf|.vcard"] = "vcard",
- [".v|.ver"] = "verilog",
- [".vh|.vhd|.vhdl"] = "vhdl",
- [".asa|.bas|.cls|.ctl|.dob|.dsm|.dsr|.frm|.pag|.vb|.vba|.vbs"] = "vb",
- [".wsf"] = "wsf",
- [".dtd|.svg|.xml|.xsd|.xsl|.xslt|.xul"] = "xml",
- [".xtend"] = "xtend",
- [".yaml"] = "yaml",
-}
-
-function M.lexer_name(filename)
- -- filename = string.lower(filename)
- for patterns, lang in pairs(files) do
- for pattern in string.gmatch(patterns, '[^|]+') do
- if #filename >= #pattern then
- local s, e = string.find(filename, pattern, -#pattern, true)
- if s ~= e and e == #filename then
- return lang
- end
- end
- end
- end
- return nil
-end
-
return M
diff --git a/visrc.lua b/visrc.lua
new file mode 100644
index 0000000..8dde244
--- /dev/null
+++ b/visrc.lua
@@ -0,0 +1,127 @@
+vis.lexers = require('lexer')
+
+vis.events = {}
+
+vis.events.win_open = function(win)
+
+ local files = {
+ [".1|.2|.3|.4|.5|.6|.7|.8|.9|.1x|.2x|.3x|.4x|.5x|.6x|.7x|.8x|.9x"] = "man",
+ [".as|.asc"] = "actionscript",
+ [".adb|.ads"] = "ada",
+ [".g|.g4"] = "antlr",
+ [".ans|.inp|.mac"] = "apdl",
+ [".apl"] = "apl",
+ [".applescript"] = "applescript",
+ [".asm|.ASM|.s|.S"] = "asm",
+ [".asa|.asp|.hta"] = "asp",
+ [".awk"] = "awk",
+ [".bat|.cmd"] = "batch",
+ [".bib"] = "bibtex",
+ [".boo"] = "boo",
+ [".cs"] = "csharp",
+ [".c|.cc|.C"] = "ansi_c",
+ [".cpp|.cxx|.c++|.h|.hh|.hpp|.hxx|.h++"] = "cpp",
+ [".ck"] = "chuck",
+ [".cmake|.cmake.in|.ctest|.ctest.in"] = "cmake",
+ [".coffee"] = "coffeescript",
+ [".css"] = "css",
+ [".cu|.cuh"] = "cuda",
+ [".d|.di"] = "dmd",
+ [".dart"] = "dart",
+ [".desktop"] = "desktop",
+ [".diff|.patch"] = "diff",
+ [".dot"] = "dot",
+ [".e|.eif"] = "eiffel",
+ [".ex|.exs"] = "elixir",
+ [".erl|.hrl"] = "erlang",
+ [".dsp"] = "faust",
+ [".fs"] = "fsharp",
+ [".fish"] = "fish",
+ [".forth|.frt|.fs"] = "forth",
+ [".f|.for|.ftn|.fpp|.f77|.f90|.f95|.f03|.f08"] = "fortran",
+ [".g|.gd|.gi|.gap"] = "gap",
+ [".po|.pot"] = "gettext",
+ [".glslf|.glslv"] = "glsl",
+ [".dem|.plt"] = "gnuplot",
+ [".go"] = "go",
+ [".groovy|.gvy"] = "groovy",
+ [".gtkrc"] = "gtkrc",
+ [".hs"] = "haskell",
+ [".htm|.html|.shtm|.shtml|.xhtml"] = "html",
+ [".idl|.odl"] = "idl",
+ [".inf|.ni"] = "inform",
+ [".cfg|.cnf|.inf|.ini|.reg"] = "ini",
+ [".io"] = "io_lang",
+ [".bsh|.java"] = "java",
+ [".js|.jsfl"] = "javascript",
+ [".json"] = "json",
+ [".jsp"] = "jsp",
+ [".bbl|.dtx|.ins|.ltx|.tex|.sty"] = "latex",
+ [".less"] = "less",
+ [".lily|.ly"] = "lilypond",
+ [".ledger|.journal"] = "ledger",
+ [".cl|.el|.lisp|.lsp"] = "lisp",
+ [".litcoffee"] = "litcoffee",
+ [".lua"] = "lua",
+ ["GNUmakefile|.iface|.mak|.mk|makefile|Makefile"] = "makefile",
+ [".md"] = "markdown",
+ [".n"] = "nemerle",
+ [".nim"] = "nim",
+ [".nsh|.nsi|.nsis"] = "nsis",
+ [".m|.mm|.objc"] = "objective_c",
+ [".caml|.ml|.mli|.mll|.mly"] = "caml",
+ [".dpk|.dpr|.p|.pas"] = "pascal",
+ [".al|.perl|.pl|.pm|.pod"] = "perl",
+ [".inc|.php|.php3|.php4|.phtml"] = "php",
+ [".pike|.pmod"] = "pike",
+ [".PKGBUILD"] = "pkgbuild",
+ [".ps1"] = "powershell",
+ [".eps|.ps"] = "ps",
+ [".prolog"] = "prolog",
+ [".props|.properties"] = "props",
+ [".pure"] = "pure",
+ [".sc|.py|.pyw"] = "python",
+ [".R|.Rout|.Rhistory|.Rt|Rout.save|Rout.fail"] = "rstats",
+ [".r|.reb"] = "rebol",
+ [".rst"] = "rest",
+ [".orx|.rex"] = "rexx",
+ [".erb|.rhtml"] = "rhtml",
+ [".Rakefile|.rake|.rb|.rbw"] = "ruby",
+ [".rs"] = "rust",
+ [".sass|.scss"] = "sass",
+ [".scala"] = "scala",
+ [".sch|.scm"] = "scheme",
+ [".bash|.bashrc|.bash_profile|.configure|.csh|.sh|.zsh"] = "bash",
+ [".changes|.st|.sources"] = "smalltalk",
+ [".ddl|.sql"] = "sql",
+ [".tcl|.tk"] = "tcl",
+ [".texi"] = "texinfo",
+ [".toml"] = "toml",
+ [".vala"] = "vala",
+ [".vcf|.vcard"] = "vcard",
+ [".v|.ver"] = "verilog",
+ [".vh|.vhd|.vhdl"] = "vhdl",
+ [".asa|.bas|.cls|.ctl|.dob|.dsm|.dsr|.frm|.pag|.vb|.vba|.vbs"] = "vb",
+ [".wsf"] = "wsf",
+ [".dtd|.svg|.xml|.xsd|.xsl|.xslt|.xul"] = "xml",
+ [".xtend"] = "xtend",
+ [".yaml"] = "yaml",
+ }
+
+ local filename = win.file.name
+
+ if filename ~= nil then
+ -- filename = string.lower(filename)
+ for patterns, lang in pairs(files) do
+ for pattern in string.gmatch(patterns, '[^|]+') do
+ if #filename >= #pattern then
+ local s, e = string.find(filename, pattern, -#pattern, true)
+ if s ~= e and e == #filename then
+ vis.command('set syntax '.. lang)
+ return;
+ end
+ end
+ end
+ end
+ end
+end