Documentation
¶
Overview ¶
Package mode tries to find the correct editor mode, given a filename and/or file data
Index ¶
- Constants
- Variables
- type Mode
- func Detect(filename string) Mode
- func DetectFromContentBytes(initial Mode, firstLine []byte, allBytesFunc func() []byte) (Mode, bool)
- func DetectFromContents(initial Mode, firstLine string, allTextFunc func() string) (Mode, bool)
- func SimpleDetect(contents string) Mode
- func SimpleDetectBytes(contents []byte) Mode
- type TabsSpaces
Constants ¶
const ( Blank = iota // Blank is used if no file mode is found ABC // ABC music notation AIDL // Android-related: Android Interface Definition Language Ada // Ada Agda // Agda Algol68 // ALGOL 68 Amber // Amber templates Arduino // Arduino ASCIIDoc // ASCII doc Assembly // Assembly Basic // FreeBasic, Gambas 3 Bat // DOS and Windows batch files Battlestar // Battlestar Bazel // Bazel and Starlark C // C C3 // C3 CMake // CMake files CS // C# CSound // Csound CSS // CSS Clojure // Clojure Config // Config like yaml, yml, toml, and ini files Cpp // C++ Crystal // Crystal D // D Dart // Dart Diff // Diff / patch Docker // For Dockerfiles Email // For using o with ie. Mutt Elm // Elm Erlang // Erlang Faust // Faust Fortran77 // Fortran 77 Fortran90 // Fortran 90 FSharp // F# FSTAB // Filesystem table Garnet // Garnet GDScript // Godot Script Git // Git commits and interactive rebases Go // Go GoMod // go.mod files GoAssembly // Go-style Assembly Gradle // Gradle Haxe // Haxe: .hx and .hxml files HIDL // Android-related: Hardware Abstraction Layer Interface Definition Language HTML // HTML HTTP // .http files are used by IntelliJ and Visual Studio for testing HTTP services Hare // Hare Haskell // Haskell Ignore // .gitignore and .ignore files Ini // INI Configuration Inko // Inko Ivy // Ivy JSON // JSON and iPython notebooks Jakt // Jakt Java // Java JavaScript // JavaScript Just // Just Koka // Koka Kotlin // Kotlin Lilypond // Lilypond Lisp // Common Lisp and Emacs Lisp Log // All sorts of log files Lua // Lua M4 // M4 macros Make // Makefiles ManPage // viewing man pages Markdown // Markdown document Mojo // Mojo Nim // Nim Nmap // Nmap scripts Nroff // editing man pages OCaml // OCaml Oak // Oak ObjC // Objective-C ObjectPascal // Object Pascal and Delphi Odin // Odin Ollama // For Modelfiles Perl // Perl PHP // PHP PolicyLanguage // SE Linux configuration files Prolog // Prolog Python // Python R // R ReStructured // reStructuredText Ruby // Ruby Rust // Rust Scala // Scala SCDoc // SC Doc Scheme // Scheme Shader // GLSL Shader Shell // Shell scripts and PKGBUILD files StandardML // Standard ML Starlark // Starlark SQL // Structured Query Language Subversion // Subversion commits Swift // Swift Teal // Teal Terra // Terra Text // plain text documents TypeScript // TypeScript V // V programming language Vim // Vim or NeoVim configuration, or .vim scripts XML // XML Zig // Zig )
Variables ¶
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 ¶
Detect looks at the filename and tries to guess what could be an appropriate editor mode.
func DetectFromContentBytes ¶ added in v0.5.0
func DetectFromContentBytes(initial Mode, firstLine []byte, allBytesFunc func() []byte) (Mode, bool)
DetectFromContentBytes takes the first line of a file as a byte slice, and a function that can return the entire contents of the file as a byte slice, 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. Returns true if a mode is found.
func DetectFromContents ¶ added in v0.1.0
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. Returns true if a mode is found.
func SimpleDetect ¶ added in v0.3.1
SimpleDetect tries to return a Mode given a string of file contents
func SimpleDetectBytes ¶ added in v0.5.0
SimpleDetectBytes tries to return a Mode given a byte slice of file contents
func (Mode) Spaces ¶ added in v0.2.0
Spaces returns true if spaces should be used for the current 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