Module textadept.mime_types

Handles file-specific settings.

Overview

Files can be recognized and associated with programming language lexers in three ways:

  • By file extension.
  • By keywords in the file's shebang (#!/path/to/exe) line.
  • By a pattern that matches the file's first line.

If a lexer is not associated with a file you open, first make sure the lexer exists in lexers/. If it does not, you will need to write one. Consult the lexer module for a tutorial.

Configuration File

core/ext/mime_types.conf is the configuration file for mime-type detection.

Detection by File Extension

file_ext lexer

Note: file_ext should not start with a . (period).

Detection by Shebang Keywords

#shebang_word lexer

Examples of shebang_word's are lua, ruby, python.

Detection by Pattern

/pattern lexer

Only the last space, the one separating the pattern from the lexer, is significant. No spaces in the pattern need to be escaped.

Extras

This module adds an extra function to buffer:

  • buffer:set_lexer (language)
    Replacement for buffer:set_lexer_language().
    Sets a buffer._lexer field so it can be restored without querying the mime-types tables. Also if the user manually sets the lexer, it should be restored.
    Loads the language-specific module if it exists.
    • lang: The string language to set.

Overview

Files can be recognized and associated with programming language lexers in three ways:

  • By file extension.
  • By keywords in the file's shebang (#!/path/to/exe) line.
  • By a pattern that matches the file's first line.

If a lexer is not associated with a file you open, first make sure the lexer exists in lexers/. If it does not, you will need to write one. Consult the lexer module for a tutorial.

Configuration File

core/ext/mime_types.conf is the configuration file for mime-type detection.

Detection by File Extension

file_ext lexer

Note: file_ext should not start with a . (period).

Detection by Shebang Keywords

#shebang_word lexer

Examples of shebang_word's are lua, ruby, python.

Detection by Pattern

/pattern lexer

Only the last space, the one separating the pattern from the lexer, is significant. No spaces in the pattern need to be escaped.

Extras

This module adds an extra function to buffer:

  • buffer:set_lexer (language)
    Replacement for buffer:set_lexer_language().
    Sets a buffer._lexer field so it can be restored without querying the mime-types tables. Also if the user manually sets the lexer, it should be restored.
    Loads the language-specific module if it exists.
    • lang: The string language to set.

Overview

Files can be recognized and associated with programming language lexers in three ways:

  • By file extension.
  • By keywords in the file's shebang (#!/path/to/exe) line.
  • By a pattern that matches the file's first line.

If a lexer is not associated with a file you open, first make sure the lexer exists in lexers/. If it does not, you will need to write one. Consult the lexer module for a tutorial.

Configuration File

core/ext/mime_types.conf is the configuration file for mime-type detection.

Detection by File Extension

file_ext lexer

Note: file_ext should not start with a . (period).

Detection by Shebang Keywords

#shebang_word lexer

Examples of shebang_word's are lua, ruby, python.

Detection by Pattern

/pattern lexer

Only the last space, the one separating the pattern from the lexer, is significant. No spaces in the pattern need to be escaped.

Extras

This module adds an extra function to buffer:

  • buffer:set_lexer (language)
    Replacement for buffer:set_lexer_language().
    Sets a buffer._lexer field so it can be restored without querying the mime-types tables. Also if the user manually sets the lexer, it should be restored.
    Loads the language-specific module if it exists.
    • lang: The string language to set.

Tables

extensions File extensions with their associated lexers.
patterns First-line patterns and their associated lexers.
shebangs Shebang words and their associated lexers.


Tables

extensions
File extensions with their associated lexers.
patterns
First-line patterns and their associated lexers.
shebangs
Shebang words and their associated lexers.

Valid XHTML 1.0!