mode

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2021 License: BSD-3-Clause Imports: 2 Imported by: 9

README

mode

  • Detect an editor mode based on a given filename
  • Detect an editor mode based on the given contents
General info
  • License: BSD3
  • Version: 0.1.1

Documentation

Index

Constants

View Source
const (
	// Mode "enum" values
	Blank          = iota
	Git            // Git commits and interactive rebases
	Markdown       // Markdown (and asciidoctor and rst files)
	Makefile       // Makefiles
	Shell          // Shell scripts and PKGBUILD files
	Config         // Config like yaml, yml, toml, and ini files
	Assembly       // Assembly
	GoAssembly     // Go-style Assembly
	Go             // Go
	Haskell        // Haskell
	OCaml          // OCaml
	StandardML     // Standard ML
	Python         // Python
	Text           // plain text documents
	CMake          // CMake files
	Vim            // Vim or NeoVim configuration, or .vim scripts
	V              // V programming language
	Clojure        // Clojure
	Lisp           // Common Lisp and Emacs Lisp
	Zig            // Zig
	Kotlin         // Kotlin
	Java           // Java
	HIDL           // the Android-related Hardware Abstraction Layer Interface Definition Language
	SQL            // Structured Query Language
	Oak            // Oak
	Rust           // Rust
	Lua            // Lua
	Crystal        // Crystal
	Nim            // Nim
	ObjectPascal   // Object Pascal and Delphi
	Bat            // DOS batch files
	Cpp            // C++
	C              // C
	Ada            // Ada
	HTML           // HTML
	Odin           // Odin
	XML            // XML
	PolicyLanguage // SE Linux configuration files
	Nroff          // editing man pages
	Scala          // Scala
	JSON           // JSON and iPython notebooks
	Battlestar     // Battlestar
	CS             // C#
	JavaScript     // JavaScript
	TypeScript     // TypeScript
	ManPage        // viewing man pages
	Amber          // Amber templates
	Bazel          // Bazel and Starlark
	D              // D
	Perl           // Perl
	M4             // M4 macros
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Mode

type Mode int

Mode is a per-filetype mode, like for Markdown

func Detect

func Detect(filename string) (Mode, bool)

Detect looks at the filename and tries to guess what could be an appropriate editor mode. This mainly affects syntax highlighting (which can be toggled with ctrl-t) and indentation.

func DetectFromContents added in v0.1.0

func DetectFromContents(firstLine string, getAllText func() string) Mode

DetectFromContents takes the first line of a file as a string, and a function that can return the entire contents of the file as a string, which will only be called if needed. Based on the contents, a Mode is detected and returned.

func (Mode) String

func (mode Mode) String() string

String will return a short lowercase string representing the given editor mode

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL