mirror of
https://github.com/zyedidia/micro
synced 2024-09-29 20:54:50 +00:00
Fix some golint warnings
This commit is contained in:
parent
28acfc6d3f
commit
46ced988eb
|
@ -15,7 +15,7 @@ type Colorscheme map[string]tcell.Style
|
|||
// The current colorscheme
|
||||
var colorscheme Colorscheme
|
||||
|
||||
// This takes in a syntax group and returns the colorscheme's style for that group
|
||||
// GetColor takes in a syntax group and returns the colorscheme's style for that group
|
||||
func GetColor(color string) tcell.Style {
|
||||
st := defStyle
|
||||
if color == "" {
|
||||
|
|
|
@ -2,7 +2,7 @@ package highlight
|
|||
|
||||
import "regexp"
|
||||
|
||||
// DetectFiletype will use the list of syntax definitions provided and the filename and first line of the file
|
||||
// MatchFiletype will use the list of syntax definitions provided and the filename and first line of the file
|
||||
// to determine the filetype of the file
|
||||
// It will return the corresponding syntax definition for the filetype
|
||||
func MatchFiletype(ftdetect [2]*regexp.Regexp, filename string, firstLine []byte) bool {
|
||||
|
|
|
@ -54,6 +54,7 @@ type Loc struct {
|
|||
X, Y int
|
||||
}
|
||||
|
||||
// Diff returns the distance between two locations
|
||||
func Diff(a, b Loc, buf *Buffer) int {
|
||||
if a.Y == b.Y {
|
||||
if a.X > b.X {
|
||||
|
|
|
@ -28,6 +28,7 @@ func init() {
|
|||
L.SetGlobal("import", luar.New(L, Import))
|
||||
}
|
||||
|
||||
// LoadFile loads a lua file
|
||||
func LoadFile(module string, file string, data string) error {
|
||||
pluginDef := "local P = {};" + module + " = P;setmetatable(" + module + ", {__index = _G});setfenv(1, P);"
|
||||
|
||||
|
@ -39,40 +40,43 @@ func LoadFile(module string, file string, data string) error {
|
|||
}
|
||||
}
|
||||
|
||||
// Import allows a lua plugin to import a package
|
||||
func Import(pkg string) *lua.LTable {
|
||||
switch pkg {
|
||||
case "fmt":
|
||||
return ImportFmt()
|
||||
return importFmt()
|
||||
case "io":
|
||||
return ImportIo()
|
||||
case "ioutil":
|
||||
return ImportIoUtil()
|
||||
return importIo()
|
||||
case "io/ioutil":
|
||||
return importIoUtil()
|
||||
case "net":
|
||||
return ImportNet()
|
||||
return importNet()
|
||||
case "math":
|
||||
return ImportMath()
|
||||
return importMath()
|
||||
case "math/rand":
|
||||
return importMathRand()
|
||||
case "os":
|
||||
return ImportOs()
|
||||
return importOs()
|
||||
case "runtime":
|
||||
return ImportRuntime()
|
||||
return importRuntime()
|
||||
case "path":
|
||||
return ImportPath()
|
||||
return importPath()
|
||||
case "filepath":
|
||||
return ImportFilePath()
|
||||
return importFilePath()
|
||||
case "strings":
|
||||
return ImportStrings()
|
||||
return importStrings()
|
||||
case "regexp":
|
||||
return ImportRegexp()
|
||||
return importRegexp()
|
||||
case "errors":
|
||||
return ImportErrors()
|
||||
return importErrors()
|
||||
case "time":
|
||||
return ImportTime()
|
||||
return importTime()
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func ImportFmt() *lua.LTable {
|
||||
func importFmt() *lua.LTable {
|
||||
pkg := L.NewTable()
|
||||
|
||||
L.SetField(pkg, "tErrorf", luar.New(L, fmt.Errorf))
|
||||
|
@ -98,7 +102,7 @@ func ImportFmt() *lua.LTable {
|
|||
return pkg
|
||||
}
|
||||
|
||||
func ImportIo() *lua.LTable {
|
||||
func importIo() *lua.LTable {
|
||||
pkg := L.NewTable()
|
||||
|
||||
L.SetField(pkg, "Copy", luar.New(L, io.Copy))
|
||||
|
@ -122,7 +126,7 @@ func ImportIo() *lua.LTable {
|
|||
return pkg
|
||||
}
|
||||
|
||||
func ImportIoUtil() *lua.LTable {
|
||||
func importIoUtil() *lua.LTable {
|
||||
pkg := L.NewTable()
|
||||
|
||||
L.SetField(pkg, "ReadAll", luar.New(L, ioutil.ReadAll))
|
||||
|
@ -133,7 +137,7 @@ func ImportIoUtil() *lua.LTable {
|
|||
return pkg
|
||||
}
|
||||
|
||||
func ImportNet() *lua.LTable {
|
||||
func importNet() *lua.LTable {
|
||||
pkg := L.NewTable()
|
||||
|
||||
L.SetField(pkg, "CIDRMask", luar.New(L, net.CIDRMask))
|
||||
|
@ -201,7 +205,7 @@ func ImportNet() *lua.LTable {
|
|||
return pkg
|
||||
}
|
||||
|
||||
func ImportMath() *lua.LTable {
|
||||
func importMath() *lua.LTable {
|
||||
pkg := L.NewTable()
|
||||
|
||||
L.SetField(pkg, "Abs", luar.New(L, math.Abs))
|
||||
|
@ -269,7 +273,7 @@ func ImportMath() *lua.LTable {
|
|||
return pkg
|
||||
}
|
||||
|
||||
func ImportMathRand() *lua.LTable {
|
||||
func importMathRand() *lua.LTable {
|
||||
pkg := L.NewTable()
|
||||
|
||||
L.SetField(pkg, "ExpFloat64", luar.New(L, rand.ExpFloat64))
|
||||
|
@ -289,7 +293,7 @@ func ImportMathRand() *lua.LTable {
|
|||
return pkg
|
||||
}
|
||||
|
||||
func ImportOs() *lua.LTable {
|
||||
func importOs() *lua.LTable {
|
||||
pkg := L.NewTable()
|
||||
|
||||
L.SetField(pkg, "Args", luar.New(L, os.Args))
|
||||
|
@ -380,7 +384,7 @@ func ImportOs() *lua.LTable {
|
|||
return pkg
|
||||
}
|
||||
|
||||
func ImportRuntime() *lua.LTable {
|
||||
func importRuntime() *lua.LTable {
|
||||
pkg := L.NewTable()
|
||||
|
||||
L.SetField(pkg, "GC", luar.New(L, runtime.GC))
|
||||
|
@ -392,7 +396,7 @@ func ImportRuntime() *lua.LTable {
|
|||
return pkg
|
||||
}
|
||||
|
||||
func ImportPath() *lua.LTable {
|
||||
func importPath() *lua.LTable {
|
||||
pkg := L.NewTable()
|
||||
|
||||
L.SetField(pkg, "Base", luar.New(L, path.Base))
|
||||
|
@ -408,7 +412,7 @@ func ImportPath() *lua.LTable {
|
|||
return pkg
|
||||
}
|
||||
|
||||
func ImportFilePath() *lua.LTable {
|
||||
func importFilePath() *lua.LTable {
|
||||
pkg := L.NewTable()
|
||||
|
||||
L.SetField(pkg, "Join", luar.New(L, filepath.Join))
|
||||
|
@ -434,7 +438,7 @@ func ImportFilePath() *lua.LTable {
|
|||
return pkg
|
||||
}
|
||||
|
||||
func ImportStrings() *lua.LTable {
|
||||
func importStrings() *lua.LTable {
|
||||
pkg := L.NewTable()
|
||||
|
||||
L.SetField(pkg, "Contains", luar.New(L, strings.Contains))
|
||||
|
@ -484,7 +488,7 @@ func ImportStrings() *lua.LTable {
|
|||
return pkg
|
||||
}
|
||||
|
||||
func ImportRegexp() *lua.LTable {
|
||||
func importRegexp() *lua.LTable {
|
||||
pkg := L.NewTable()
|
||||
|
||||
L.SetField(pkg, "Match", luar.New(L, regexp.Match))
|
||||
|
@ -499,7 +503,7 @@ func ImportRegexp() *lua.LTable {
|
|||
return pkg
|
||||
}
|
||||
|
||||
func ImportErrors() *lua.LTable {
|
||||
func importErrors() *lua.LTable {
|
||||
pkg := L.NewTable()
|
||||
|
||||
L.SetField(pkg, "New", luar.New(L, errors.New))
|
||||
|
@ -507,7 +511,7 @@ func ImportErrors() *lua.LTable {
|
|||
return pkg
|
||||
}
|
||||
|
||||
func ImportTime() *lua.LTable {
|
||||
func importTime() *lua.LTable {
|
||||
pkg := L.NewTable()
|
||||
|
||||
L.SetField(pkg, "After", luar.New(L, time.After))
|
||||
|
|
|
@ -56,6 +56,7 @@ func Max(a, b int) int {
|
|||
return b
|
||||
}
|
||||
|
||||
// FSize gets the size of a file
|
||||
func FSize(f *os.File) int64 {
|
||||
fi, _ := f.Stat()
|
||||
// get the size
|
||||
|
@ -246,6 +247,7 @@ func lcs(a, b string) string {
|
|||
return lcs
|
||||
}
|
||||
|
||||
// CommonSubstring gets a common substring among the inputs
|
||||
func CommonSubstring(arr ...string) string {
|
||||
commonStr := arr[0]
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/zyedidia/tcell"
|
||||
)
|
||||
|
||||
// The ViewType defines what kind of view this is
|
||||
type ViewType struct {
|
||||
kind int
|
||||
readonly bool // The file cannot be edited
|
||||
|
@ -210,15 +211,10 @@ func (v *View) CanClose() bool {
|
|||
//if char == 'y' {
|
||||
if choice {
|
||||
v.Save(true)
|
||||
return true
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
// OpenBuffer opens a new buffer in this view.
|
||||
|
@ -449,6 +445,7 @@ func (v *View) MoveToMouseClick(x, y int) {
|
|||
v.Cursor.LastVisualX = v.Cursor.GetVisualX()
|
||||
}
|
||||
|
||||
// Execute actions executes the supplied actions
|
||||
func (v *View) ExecuteActions(actions []func(*View, bool) bool) bool {
|
||||
relocate := false
|
||||
readonlyBindingsList := []string{"Delete", "Insert", "Backspace", "Cut", "Play", "Paste", "Move", "Add", "DuplicateLine", "Macro"}
|
||||
|
@ -478,6 +475,7 @@ func (v *View) ExecuteActions(actions []func(*View, bool) bool) bool {
|
|||
return relocate
|
||||
}
|
||||
|
||||
// SetCursor sets the view's and buffer's cursor
|
||||
func (v *View) SetCursor(c *Cursor) bool {
|
||||
if c == nil {
|
||||
return false
|
||||
|
@ -682,6 +680,7 @@ func (v *View) openHelp(helpPage string) {
|
|||
}
|
||||
}
|
||||
|
||||
// DisplayView draws the view to the screen
|
||||
func (v *View) DisplayView() {
|
||||
if v.Buf.Settings["softwrap"].(bool) && v.leftCol != 0 {
|
||||
v.leftCol = 0
|
||||
|
|
Loading…
Reference in a new issue