mode

package module
v0.4.9 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2022 License: BSD-3-Clause Imports: 3 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: BSD-3
  • Version: 0.4.9

Documentation

Index

Constants

View Source
const (
	Blank          = iota // No file mode found
	Git                   // Git commits and interactive rebases
	Markdown              // Markdown
	Doc                   // asciidoctor, rst files, sdoc etc
	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
	Gradle                // Gradle
	HIDL                  // Android-related: Hardware Abstraction Layer Interface Definition Language
	AIDL                  // Android-related: Android Interface Definition Language
	SQL                   // Structured Query Language
	Oak                   // Oak
	Rust                  // Rust
	Lua                   // Lua
	Crystal               // Crystal
	Erlang                // Erlang
	Nim                   // Nim
	ObjectPascal          // Object Pascal and Delphi
	Bat                   // DOS and Windows batch files
	Cpp                   // C++
	C                     // C
	Ada                   // Ada
	HTML                  // HTML
	Odin                  // Odin
	Hare                  // Hare
	Jakt                  // Jakt
	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
	Prolog                // Prolog
	M4                    // M4 macros
	Agda                  // Agda
	Basic                 // FreeBasic, Gambas 3
	Log                   // All sorts of log files
	Teal                  // Teal
	Email                 // For using o with ie. Mutt
)

Variables

View Source
var DefaultTabsSpaces = TabsSpaces{4, true}

DefaultTabsSpaces is the default setting: 4 spaces

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

Detect looks at the filename and tries to guess what could be an appropriate editor mode.

func DetectFromContents added in v0.1.0

func DetectFromContents(initial Mode, firstLine string, allTextFunc func() string) (Mode, bool)

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. Pass inn mode.Blank as the initial Mode if that is the best guess so far.

func SimpleDetect added in v0.3.1

func SimpleDetect(contents string) Mode

SimpleDetect tries to return a Mode given a string of file contents

func (Mode) Spaces added in v0.2.0

func (m Mode) Spaces() bool

Spaces returns true if spaces should be used for the current mode

func (Mode) String

func (mode Mode) String() string

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

func (Mode) TabsSpaces added in v0.2.0

func (m Mode) TabsSpaces() TabsSpaces

TabsSpaces tries to return the appropriate settings for tabs and spaces as a TabsSpaces struct

type TabsSpaces added in v0.2.0

type TabsSpaces struct {
	PerTab int  // number of spaces per tab/indentation
	Spaces bool // use spaces, or tabs?
}

TabsSpaces contains all info needed about tabs and spaces for a file

func (TabsSpaces) String added in v0.2.0

func (ts TabsSpaces) String() string

String returns the string for one indentation

func (TabsSpaces) WSLen added in v0.2.0

func (ts TabsSpaces) WSLen(whitespaceString string) int

WSLen will count the length of the given whitespace string, in terms of spaces

Jump to

Keyboard shortcuts

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