aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md4
-rw-r--r--doc/08_Preferences.md67
-rw-r--r--doc/14_Appendix.md6
-rw-r--r--modules/textadept/file_types.lua (renamed from modules/textadept/mime_types.lua)30
-rw-r--r--modules/textadept/keys.lua2
-rw-r--r--modules/textadept/menu.lua2
-rw-r--r--modules/textadept/mime_types.conf404
-rwxr-xr-xscripts/gen_plist.lua19
8 files changed, 41 insertions, 493 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index aef71fee..7ab88428 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -121,7 +121,7 @@ Changes:
[Textadept 6.6 -- Linux x86_64]: download/textadept_6.6.x86_64.tgz
[Textadept 6.6 -- Source]: download/textadept_6.6.src.zip
[Textadept 6.6 -- Modules]: download/textadept_6.6.modules.zip
-[`events.LANGUAGE_MODULE_LOADED`]: api/_M.textadept.mime_types.html#_G.events.LANGUAGE_MODULE_LOADED
+[`events.LANGUAGE_MODULE_LOADED`]: api/_M.textadept.file_types.html#_G.events.LANGUAGE_MODULE_LOADED
[Scintilla]: http://scintilla.org
## 6.6 beta (01 May 2013)
@@ -1312,7 +1312,7 @@ Changes:
[Textadept 3.7 beta -- Linux x86_64]: download/textadept_3.7_beta.x86_64.tgz
[Textadept 3.7 beta -- Source]: download/textadept_3.7_beta.src.zip
[Adeptsense]: 6_AdeptEditing.html#Adeptsense
-[`language_module_loaded`]: api/_M.textadept.mime_types.html#Mime-type.Events
+[`language_module_loaded`]: api/_M.textadept.file_types.html#_G.events.LANGUAGE_MODULE_LOADED
[`gui.filteredlist()`]: api/gui.html#filteredlist
[`char_matches`]: api/_M.textadept.editing.html#char_matches
[`braces`]: api/_M.textadept.editing.html#braces
diff --git a/doc/08_Preferences.md b/doc/08_Preferences.md
index 75ed019b..ba4ea399 100644
--- a/doc/08_Preferences.md
+++ b/doc/08_Preferences.md
@@ -131,6 +131,24 @@ Learn more about snippet syntax in the [snippets LuaDoc][].
[snippets LuaDoc]: api/_M.textadept.snippets.html
+### File Types
+
+Textadept recognizes a wide range of programming language files either by file
+extension, by a keyword in the shebang ("#!/path/to/exe") line, or by a
+[Lua pattern][] that matches the text of the first line. The editor does this by
+consulting a set of tables in [`_M.textadept.file_types`][] that are modifiable
+from *~/.textadept/init.lua*. For example:
+
+ -- Recognize .luadoc files as Lua code.
+ _M.textadept.file_types.extensions.luadoc = 'lua'
+ -- Change .html files to be recognized as XML files.
+ _M.textadept.file_types.extensions.html = 'xml'
+ -- Recognize a shebang line like "#!/usr/bin/zsh" as shell code.
+ _M.textadept.file_types.shebangs.zsh = 'bash'
+
+[Lua pattern]: 14_Appendix.html#Lua.Patterns
+[`_M.textadept.file_types`]: api/_M.textadept.file_types.html
+
## Buffer Properties
Since Textadept runs *~/.textadept/init.lua* only once on startup, it is not the
@@ -170,52 +188,3 @@ send the modified *locale.conf* file to [me][]. I will include it in a future
release.
[me]: README.html#Contact
-
-## File Types
-
-Textadept recognizes a wide range of programming language files by any of the
-following:
-
-* File extension.
-* Keywords in the file's shebang ("#!/path/to/exe") line.
-* A pattern that matches the text of the file's first line.
-
-*modules/textadept/mime_types.conf* contains built-in file types. Override or
-add to them in your *~/.textadept/mime_types.conf*:
-
- % Recognize .luadoc files as Lua code.
- luadoc lua
-
- % Change .html files to be recognized as XML files.
- html xml
-
-### Detect by Extension
-
-The syntax for mapping a file extension to a lexer is:
-
- file_ext lexer
-
-Note: `file_ext` should not start with a '.' (period).
-
-### Detect by Shebang
-
-The syntax for mapping a word contained in a shebang line (the first line of a
-file whose first two characters are "#!") to a lexer is:
-
- #shebang_word lexer
-
-Examples of `shebang_word`s are "lua", "ruby", "python" which match lines like
-"#!/usr/bin/lua", "#!/usr/env/ruby", and "#!/usr/bin/python3", respectively.
-
-### Detect by Pattern
-
-The syntax for mapping a Lua pattern that matches the first line of a file to a
-lexer is:
-
- /pattern lexer
-
-Patterns use [Lua pattern syntax][] with only the last space, the one separating
-the pattern from the lexer, being significant. No spaces in the pattern need
-escaping.
-
-[Lua pattern syntax]: 14_Appendix.html#Lua.Patterns
diff --git a/doc/14_Appendix.md b/doc/14_Appendix.md
index a3f21a08..f92f4f35 100644
--- a/doc/14_Appendix.md
+++ b/doc/14_Appendix.md
@@ -157,6 +157,7 @@ buffer\_new() |Renamed |\_G.[buffer.new()][]
**_M.textadept** | |
filter\_through |Removed |N/A
filter\_through.filter\_through() |Renamed |editing.[filter\_through()][]
+mime\_types |Renamed |[file\_types][]<sup>†</sup>
**_M.textadept.bookmark** | |
N/A |New |[goto\_mark()][]
MARK\_BOOKMARK\_COLOR |Renamed |[BOOKMARK\_COLOR][]
@@ -184,10 +185,13 @@ try\_encodings |Renamed |[encodings][]
<sup>\*</sup>`arg` is `nil` when resetting.
-<sup>†</sup>Changed arguments too.
+<sup>†</sup>Removed *mime_types.conf* files. Interact with Lua tables directly.
+
+<sup>‡</sup>Changed arguments too.
[buffer.new()]: api/buffer.html#new
[filter\_through()]: api/_M.textadept.editing.html#filter_through
+[file\_types]: api/_M.textadept.file_types.html
[goto\_mark()]: api/_M.textadept.bookmarks.html#goto_mark
[BOOKMARK\_COLOR]: api/_M.textadept.bookmarks.html#BOOKMARK_COLOR
[HIGHLIGHT\_COLOR]: api/_M.textadept.editing.html#HIGHLIGHT_COLOR
diff --git a/modules/textadept/mime_types.lua b/modules/textadept/file_types.lua
index 4f6aa3a6..965af060 100644
--- a/modules/textadept/mime_types.lua
+++ b/modules/textadept/file_types.lua
@@ -12,7 +12,7 @@ local M = {}
-- Arguments:
--
-- * *`lang`*: The language lexer name.
-module('_M.textadept.mime_types')]]
+module('_M.textadept.file_types')]]
-- Events.
events.LANGUAGE_MODULE_LOADED = 'language_module_loaded'
@@ -24,7 +24,7 @@ events.LANGUAGE_MODULE_LOADED = 'language_module_loaded'
-- each file extension is matched against the file's extension.
-- @class table
-- @name extensions
-M.extensions = {}
+M.extensions = {--[[Actionscript]]as='actionscript',asc='actionscript',--[[ADA]]ada='ada',adb='ada',ads='ada',--[[ANTLR]]g='antlr',--[[APDL]]ans='apdl',inp='apdl',mac='apdl',--[[Applescript]]applescript='applescript',--[[ASP]]asa='asp',asp='asp',hta='asp',--[[AWK]]awk='awk',--[[Batch]]bat='batch',cmd='batch',--[[Bibtex]]bib='bibtex',--[[Boo]]boo='boo',--[[C/C++]]c='cpp',cc='cpp',C='cpp',cpp='cpp',cxx='cpp',['c++']='cpp',h='cpp',hh='cpp',hpp='cpp',hxx='cpp',['h++']='cpp',--[[C#]]cs='csharp',--[[Chuck]]ck='chuck',--[[CMake]]cmake='cmake',['cmake.in']='cmake',ctest='cmake',['ctest.in']='cmake',--[[CoffeeScript]]coffee='coffeescript',--[[CSS]]css='css',--[[CUDA]]cu='cuda',cuh='cuda',--[[D]]d='dmd',di='dmd',--[[Desktop]]desktop='desktop',--[[diff]]diff='diff',patch='diff',--[[dot]]dot='dot',--[[Eiffel]]e='eiffel',eif='eiffel',--[[Erlang]]erl='erlang',hrl='erlang',--[[F#]]fs='fsharp',--[[Forth]]f='forth',forth='forth',frt='forth',fs='forth',--[[Fortran]]['for']='fortran',fort='fortran',fpp='fortran',f77='fortran',f90='fortran',f95='fortran',f03='fortran',f08='fortran',--[[Gap]]g='gap',gd='gap',gi='gap',gap='gap',--[[Gettext]]po='gettext',pot='gettext',--[[GLSL]]glslf='glsl',glslv='glsl',--[[GNUPlot]]dem='gnuplot',plt='gnuplot',--[[Go]]go='go',--[[Groovy]]groovy='groovy',gvy='groovy',--[[Gtkrc]]gtkrc='gtkrc',--[[Haskell]]hs='haskell',--[[HTML]]htm='hypertext',html='hypertext',shtm='hypertext',shtml='hypertext',xhtml='hypertext',--[[IDL]]idl='idl',odl='odl',--[[Inform]]inf='inform',--[[ini]]cfg='ini',cnf='ini',inf='ini',ini='ini',reg='ini',--[[Io]]io='Io',--[[Java]]bsh='java',java='java',--[[Javascript]]js='javascript',jsfl='javascript',--[[JSP]]jsp='jsp',--[[JSON]]json='json',--[[Latex]]bbl='latex',dtx='latex',ins='latex',ltx='latex',tex='latex',sty='latex',--[[Less]]less='less',--[[Lilypond]]lily='lilypond',ly='lilypond',--[[Lisp]]cl='lisp',el='lisp',lisp='lisp',lsp='lisp',--[[Literate Coffeescript]]litcoffee='litcoffee',--[[Lua]]lua='lua',--[[Makefile]]GNUmakefile='makefile',iface='makefile',mak='makefile',makefile='makefile',Makefile='makefile',--[[Markdown]]md='markdown',--[[Nemerle]]n='nemerle',--[[NSIS]]nsh='nsis',nsi='nsis',nsis='nsis',--[[Objective C]]m='objective_c',mm='objective_c',objc='objective_c',--[[OCAML]]caml='caml',ml='caml',mli='caml',mll='caml',mly='caml',--[[Octave]]--[[Pascal]]dpk='pascal',dpr='pascal',p='pascal',pas='pascal',--[[Perl]]al='perl',perl='perl',pl='perl',pm='perl',pod='perl',--[[PHP]]inc='php',php='php',php3='php',php4='php',phtml='php',--[[Pike]]pike='pike',pmod='pike',--[[Postscript]]eps='ps',ps='ps',--[[Prolog]]prolog='prolog',--[[Properties]]props='props',properties='props',--[[Python]]sc='python',py='python',pyw='python',--[[R]]R='rstats',Rout='rstats',Rhistory='rstats',Rt='rstats',['Rout.save']='rstats',['Rout.fail']='rstats',S='rstats',--[[Rebol]]r='rebol',reb='rebol',--[[Rexx]]orx='rexx',rex='rexx',--[[RHTML]]erb='rhtml',rhtml='rhtml',--[[Ruby]]Rakefile='ruby',rake='ruby',rb='ruby',rbw='ruby',--[[Sass CSS]]sass='sass',scss='sass',--[[Scala]]scala='scala',--[[Scheme]]sch='scheme',scm='scheme',--[[Shell]]bash='bash',bashrc='bash',bash_profile='bash',configure='bash',csh='bash',sh='bash',zsh='bash',--[[Smalltalk]]changes='smalltalk',st='smalltalk',sources='smalltalk',--[[SQL]]ddl='sql',sql='sql',--[[TCL]]tcl='tcl',tk='tcl',--[[Vala]]vala='vala',--[[Verilog]]v='verilog',ver='verilog',--[[VHDL]]vh='vhdl',vhd='vhdl',vhdl='vhdl',--[[Visual Basic]]asa='vb',bas='vb',cls='vb',ctl='vb',dob='vb',dsm='vb',dsr='vb',frm='vb',pag='vb',vb='vb',vba='vb',vbs='vb',--[[XML]]dtd='xml',svg='xml',xml='xml',xsd='xml',xsl='xml',xslt='xml',xul='xml'}
---
-- Map of shebang words to their associated lexers.
@@ -32,7 +32,7 @@ M.extensions = {}
-- line in the file, each shebang word is matched against that line.
-- @class table
-- @name shebangs
-M.shebangs = {}
+M.shebangs = {awk='awk',lua='lua',octave='matlab',perl='perl',php='php',python='python',ruby='ruby',bash='bash',sh='bash'}
---
-- Map of first-line patterns to their associated lexers.
@@ -40,7 +40,7 @@ M.shebangs = {}
-- against the first line in the file.
-- @class table
-- @name patterns
-M.patterns = {}
+M.patterns = {['^%s*class%s+%S+%s*<%s*ApplicationController']='rails',['^%s*class%s+%S+%s*<%s*ActionController::Base']='rails',['^%s*class%s+%S+%s*<%s*ActiveRecord::Base']='rails',['^%s*class%s+%S+%s*<%s*ActiveRecord::Migration']='rails',['^%s*<%?xml%s']='xml'}
---
-- List of available lexers.
@@ -131,28 +131,6 @@ function M.select_lexer()
if lexer then buffer:set_lexer(lexer) end
end
--- Load mime-types.
-local function process_line(line)
- if line:find('^%s*%%') then return end
- if line:find('^%s*[^#/]') then -- extension definition
- local ext, lexer_name = line:match('^%s*(.+)%s+(%S+)$')
- if ext and lexer_name then M.extensions[ext] = lexer_name end
- else -- shebang or pattern
- local ch, text, lexer_name = line:match('^%s*([#/])(.+)%s+(%S+)$')
- if ch and text and lexer_name then
- (ch == '#' and M.shebangs or M.patterns)[text] = lexer_name
- end
- end
-end
-local f = io.open(_HOME..'/modules/textadept/mime_types.conf', 'rb')
-for line in f:lines() do process_line(line) end
-f:close()
-f = io.open(_USERHOME..'/mime_types.conf', 'rb')
-if f then
- for line in f:lines() do process_line(line) end
- f:close()
-end
-
-- Generate lexer list.
local lexers_found = {}
for _, dir in ipairs{_HOME..'/lexers', _USERHOME..'/lexers'} do
diff --git a/modules/textadept/keys.lua b/modules/textadept/keys.lua
index 44ba66b8..17c403ea 100644
--- a/modules/textadept/keys.lua
+++ b/modules/textadept/keys.lua
@@ -526,7 +526,7 @@ keys[not OSX and (not CURSES and 'cai' or 'mi')
-- TODO: {utils.set_encoding, 'MacRoman'}
-- TODO: {utils.set_encoding, 'UTF-16LE'}
keys[not OSX and not CURSES and 'cL'
- or 'mL'] = _M.textadept.mime_types.select_lexer
+ or 'mL'] = _M.textadept.file_types.select_lexer
keys.f5 = {buffer.colourise, buffer, 0, -1}
if CURSES then keys.cl = keys.f5 end
diff --git a/modules/textadept/menu.lua b/modules/textadept/menu.lua
index 4791a7c5..5af1f0a9 100644
--- a/modules/textadept/menu.lua
+++ b/modules/textadept/menu.lua
@@ -157,7 +157,7 @@ local menubar = {
{_L['UTF-1_6 Encoding'], {utils.set_encoding, 'UTF-16LE'}},
},
SEPARATOR,
- {_L['Select _Lexer...'], _M.textadept.mime_types.select_lexer},
+ {_L['Select _Lexer...'], _M.textadept.file_types.select_lexer},
{_L['_Refresh Syntax Highlighting'], {buffer.colourise, buffer, 0, -1}},
},
{ title = _L['_View'],
diff --git a/modules/textadept/mime_types.conf b/modules/textadept/mime_types.conf
deleted file mode 100644
index 03676d20..00000000
--- a/modules/textadept/mime_types.conf
+++ /dev/null
@@ -1,404 +0,0 @@
-% Copyright 2007-2013 Mitchell mitchell.att.foicica.com. See LICENSE.
-%
-% Configuration file for mime-types.
-% Each line defines a mime-type (by extension, shebang word, or Lua pattern) and
-% its associated lexer. A shebang word is one that is contained in the file's
-% shebang line (#!). Only the last space, the one separating the mime-type from
-% its lexer, in a definition is significant.
-%
-% Syntax:
-% % Comment (must start a line)
-% ext lexer_name
-% #shbang_word lexer_name
-% /lua_pattern lexer_name
-
-% Actionscript
-as actionscript
-asc actionscript
-
-% ADA
-ada ada
-adb ada
-ads ada
-
-% ANTLR
-g antlr
-
-% APDL
-ans apdl
-inp apdl
-mac apdl
-
-% Applescript
-applescript applescript
-
-% ASP
-asa asp
-asp asp
-hta asp
-
-% AWK
-awk awk
-#awk awk
-
-% Batch
-bat batch
-cmd batch
-
-% Bibtex
-bib bibtex
-
-% Boo
-boo boo
-
-% C/C++
-c cpp
-cc cpp
-C cpp
-cpp cpp
-cxx cpp
-c++ cpp
-h cpp
-hh cpp
-hpp cpp
-hxx cpp
-h++ cpp
-
-% C#
-cs csharp
-
-% Chuck
-ck chuck
-
-% CMake
-cmake cmake
-cmake.in cmake
-ctest cmake
-ctest.in cmake
-
-% CoffeeScript
-coffee coffeescript
-
-% CSS
-css css
-
-% CUDA
-cu cuda
-cuh cuda
-
-% D
-d dmd
-di dmd
-
-% Desktop
-desktop desktop
-
-% diff
-diff diff
-patch diff
-
-% dot
-dot dot
-
-% Eiffel
-e eiffel
-eif eiffel
-
-% Erlang
-erl erlang
-hrl erlang
-
-% F#
-fs fsharp
-
-% Forth
-f forth
-forth forth
-frt forth
-fs forth
-
-% Fortran
-for fortran
-fort fortran
-fpp fortran
-f77 fortran
-f90 fortran
-f95 fortran
-f03 fortran
-f08 fortran
-
-% Gap
-g gap
-gd gap
-gi gap
-gap gap
-
-% Gettext
-po gettext
-pot gettext
-
-% GLSL
-glslf glsl
-glslv glsl
-
-% GNUPlot
-dem gnuplot
-plt gnuplot
-
-% Go
-go go
-
-% Groovy
-groovy groovy
-gvy groovy
-
-% Gtkrc
-gtkrc gtkrc
-
-% Haskell
-hs haskell
-
-% HTML
-htm hypertext
-html hypertext
-shtm hypertext
-shtml hypertext
-xhtml hypertext
-
-% IDL
-idl idl
-odl odl
-
-% Inform
-inf inform
-
-% ini
-cfg ini
-cnf ini
-inf ini
-ini ini
-reg ini
-
-% Io
-io Io
-
-% Java
-bsh java
-java java
-
-% Javascript
-js javascript
-jsfl javascript
-
-% JSP
-jsp jsp
-
-% JSON
-json json
-
-% Latex
-bbl latex
-dtx latex
-ins latex
-ltx latex
-tex latex
-sty latex
-
-% Less
-less less
-
-% Lilypond
-lily lilypond
-ly lilypond
-
-% Lisp
-cl lisp
-el lisp
-lisp lisp
-lsp lisp
-
-% Literate Coffeescript
-litcoffee litcoffee
-
-% Lua
-lua lua
-#lua lua
-
-% Makefile
-GNUmakefile makefile
-iface makefile
-mak makefile
-makefile makefile
-Makefile makefile
-
-% Markdown
-md markdown
-
-% Nemerle
-n nemerle
-
-% NSIS
-nsh nsis
-nsi nsis
-nsis nsis
-
-% Objective C
-m objective_c
-mm objective_c
-objc objective_c
-
-% OCAML
-caml caml
-ml caml
-mli caml
-mll caml
-mly caml
-
-% Octave
-#octave matlab
-
-% Pascal
-dpk pascal
-dpr pascal
-p pascal
-pas pascal
-
-% Perl
-al perl
-perl perl
-pl perl
-pm perl
-pod perl
-#perl perl
-
-% PHP
-inc php
-php php
-php3 php
-php4 php
-phtml php
-#php php
-
-% Pike
-pike pike
-pmod pike
-
-% Postscript
-eps ps
-ps ps
-
-% Prolog
-prolog prolog
-
-% Properties
-props props
-properties props
-
-% Python
-sc python
-py python
-pyw python
-#python python
-
-% R
-R rstats
-Rout rstats
-Rhistory rstats
-Rt rstats
-Rout.save rstats
-Rout.fail rstats
-S rstats
-
-% Rebol
-r rebol
-reb rebol
-
-% Rexx
-orx rexx
-rex rexx
-
-% RHTML
-erb rhtml
-rhtml rhtml
-
-% Ruby
-Rakefile ruby
-rake ruby
-rb ruby
-rbw ruby
-#ruby ruby
-/^%s*class%s+%S+%s*<%s*ApplicationController rails
-/^%s*class%s+%S+%s*<%s*ActionController::Base rails
-/^%s*class%s+%S+%s*<%s*ActiveRecord::Base rails
-/^%s*class%s+%S+%s*<%s*ActiveRecord::Migration rails
-
-% Sass CSS
-sass sass
-scss sass
-
-% Scala
-scala scala
-
-% Scheme
-sch scheme
-scm scheme
-
-% Shell
-bash bash
-bashrc bash
-bash_profile bash
-configure bash
-csh bash
-sh bash
-zsh bash
-#bash bash
-#sh bash
-
-% Smalltalk
-changes smalltalk
-st smalltalk
-sources smalltalk
-
-% SQL
-ddl sql
-sql sql
-
-% TCL
-tcl tcl
-tk tcl
-
-% Vala
-vala vala
-
-% Verilog
-v verilog
-ver verilog
-
-% VHDL
-vh vhdl
-vhd vhdl
-vhdl vhdl
-
-% Visual Basic
-asa vb
-bas vb
-cls vb
-ctl vb
-dob vb
-dsm vb
-dsr vb
-frm vb
-pag vb
-vb vb
-vba vb
-vbs vb
-
-% XML
-dtd xml
-svg xml
-xml xml
-xsd xml
-xsl xml
-xslt xml
-xul xml
-/^%s*<%?xml%s xml
diff --git a/scripts/gen_plist.lua b/scripts/gen_plist.lua
index fc47203c..54ae0d38 100755
--- a/scripts/gen_plist.lua
+++ b/scripts/gen_plist.lua
@@ -7,16 +7,17 @@ local lang, exts
local languages, extensions = {}, {}
-- Read languages and extensions.
-local f = io.open('../modules/textadept/mime_types.conf')
-for line in f:lines() do
- if line:find('^%%') then
- lang, exts = line:match('^%%%s*(.+)$'), {}
+local f = io.open('../modules/textadept/file_types.lua')
+local types = f:read('*all'):match('M.extensions = (%b{})'):sub(2)
+f:close()
+for type in types:gmatch('(.-)[%],}]+') do
+ if type:find('^%-%-') then
+ lang, exts = type:match('([^%[]+)$'), {}
if lang then languages[#languages + 1], extensions[lang] = lang, exts end
- elseif line:find('^%a') then
- exts[#exts + 1] = line:match('^%S+')
+ else
+ exts[#exts + 1] = type:match('^%[?\'?([^\'=]+)')
end
end
-f:close()
-- Generate and write the XML.
local xml = {[[
@@ -68,7 +69,7 @@ xml[#xml + 1] = [[
</dict>
</array>
<key>CFBundleExecutable</key>
- <string>textadept</string>
+ <string>textadept_osx</string>
<key>CFBundleIconFile</key>
<string>textadept.icns</string>
<key>CFBundleIdentifier</key>
@@ -82,7 +83,7 @@ xml[#xml + 1] = [[
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>7.0 alpha</string>
+ <string>7.0 alpha 2</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>