Merge remote-tracking branch 'refs/remotes/zyedidia/master'

This commit is contained in:
Nicolai
2016-12-24 00:24:12 +01:00
9 changed files with 95 additions and 67 deletions

View File

@@ -44,7 +44,7 @@ func LoadColorscheme(colorschemeName string) {
TermMessage(colorschemeName, "is not a valid colorscheme")
} else {
if data, err := file.Data(); err != nil {
fmt.Println("Error loading colorscheme:", err)
TermMessage("Error loading colorscheme:", err)
} else {
colorscheme = ParseColorscheme(string(data))

View File

@@ -4,7 +4,6 @@ import (
"bytes"
"io"
"os/exec"
"strings"
)
// Jobs are the way plugins can run processes in the background
@@ -43,10 +42,7 @@ func (f *CallbackFile) Write(data []byte) (int, error) {
// JobStart starts a shell command in the background with the given callbacks
// It returns an *exec.Cmd as the job id
func JobStart(cmd string, onStdout, onStderr, onExit string, userargs ...string) *exec.Cmd {
split := strings.Split(cmd, " ")
cmdArgs := split[1:]
cmdName := split[0]
return JobSpawn(cmdName, cmdArgs, onStdout, onStderr, onExit, userargs...)
return JobSpawn("sh", []string{"-c", cmd}, onStdout, onStderr, onExit, userargs...)
}
// JobSpawn starts a process with args in the background with the given callbacks

View File

@@ -97,11 +97,16 @@ func LoadInput() []*Buffer {
if _, e := os.Stat(filename); e == nil {
// If it exists we load it into a buffer
input, err = os.Open(filename)
stat, _ := input.Stat()
defer input.Close()
if err != nil {
TermMessage(err)
continue
}
if stat.IsDir() {
TermMessage("Cannot read", filename, "because it is a directory")
continue
}
}
// If the file didn't exist, input will be empty, and we'll open an empty buffer
if input != nil {

File diff suppressed because one or more lines are too long

View File

@@ -51,6 +51,12 @@ as Go's GOOS variable, so `darwin`, `windows`, `linux`, `freebsd`...)
* `messenger`: lets you send messages to the user or create prompts
* `NewBuffer(text, path string) *Buffer`: creates a new buffer from a given reader with a given path
* `GetLeadingWhitespace() bool`: returns the leading whitespace of the given string
* `IsWordChar(str string) bool`: returns whether or not the string is a 'word character'
* `RuneStr(r rune) string`: returns a string containing the given rune
* `Loc(x, y int) Loc`: returns a new `Loc` struct
@@ -88,9 +94,11 @@ as Go's GOOS variable, so `darwin`, `windows`, `linux`, `freebsd`...)
`waitToClose` bool only applies if `interactive` is true and means that it should wait before
returning to the editor.
* `ToCharPos(loc Loc, buf *Buffer) int`: returns the character position of a given x, y location.
* `ToCharPos(loc Loc, buf *Buffer) int`: returns the character position of a given x, y location
* `ByteOffset(loc Loc, buf *Buffer) int`: exactly like `ToCharPos` except it it counts bytes instead of runes.
* `Reload`: (Re)load everything
* `ByteOffset(loc Loc, buf *Buffer) int`: exactly like `ToCharPos` except it it counts bytes instead of runes
* `JobSpawn(cmdName string, cmdArgs []string, onStdout, onStderr, onExit string, userargs ...string)`:
Starts running the given process in the background. `onStdout` `onStderr` and `onExit`
@@ -99,8 +107,8 @@ as Go's GOOS variable, so `darwin`, `windows`, `linux`, `freebsd`...)
`userargs` are the arguments which will get passed to the callback functions
* `JobStart(cmd string, onStdout, onStderr, onExit string, userargs ...string)`:
Starts running the given shell command in the background.
This function is a shorthand for `JobSpawn`.
Starts running the given shell command in the background. Note that the command execute
is first parsed by a shell when using this command. It is executed with `sh -c`.
* `JobSend(cmd *exec.Cmd, data string)`: send a string into the stdin of the job process
@@ -130,8 +138,8 @@ If you want a standard prompt, just use `messenger.Prompt(prompt, "", 0)`
# Adding help files, syntax files, or colorschemes in your plugin
You can use the `AddRuntimeFile(name, type, path string)` function to add various kinds of
files to your plugin. For example, if you'd like to add a help topic and to your plugin
called `test`, you would create the `test.md` file for example, and runt the function:
files to your plugin. For example, if you'd like to add a help topic to your plugin
called `test`, you would create a `test.md` file, and call the function:
```lua
AddRuntimeFile("test", "help", "test.md")
@@ -139,6 +147,8 @@ AddRuntimeFile("test", "help", "test.md")
Use `AddRuntimeFilesFromDirectory(name, type, dir, pattern)` to add a number of files
to the runtime.
To read the content of a runtime file use `ReadRuntimeFile(fileType, name string)`
or `ListRuntimeFiles(fileType string)` for all runtime files.
# Autocomplete command arguments

View File

@@ -19,20 +19,20 @@ function runLinter()
temp = os.getenv("TEMP")
end
if ft == "go" then
lint("gobuild", "go build -o " .. devnull, "%f:%l: %m")
lint("golint", "golint " .. CurView().Buf.Path, "%f:%l:%d+: %m")
lint("gobuild", "go", {"build", "-o", devnull}, "%f:%l: %m")
lint("golint", "golint", {CurView().Buf.Path}, "%f:%l:%d+: %m")
elseif ft == "lua" then
lint("luacheck", "luacheck --no-color " .. file, "%f:%l:%d+: %m")
lint("luacheck", "luacheck", {"--no-color", file}, "%f:%l:%d+: %m")
elseif ft == "python" then
lint("pyflakes", "pyflakes " .. file, "%f:%l:.-:? %m")
lint("pyflakes", "pyflakes", {file}, "%f:%l:.-:? %m")
elseif ft == "c" then
lint("gcc", "gcc -fsyntax-only -Wall -Wextra " .. file, "%f:%l:%d+:.+: %m")
lint("gcc", "gcc", {"-fsyntax-only", "-Wall", "-Wextra", file}, "%f:%l:%d+:.+: %m")
elseif ft == "d" then
lint("dmd", "dmd -color=off -o- -w -wi -c " .. file, "%f%(%l%):.+: %m")
lint("dmd", "dmd", {"-color=off", "-o-", "-w", "-wi", "-c", file}, "%f%(%l%):.+: %m")
elseif ft == "java" then
lint("javac", "javac -d " .. temp .. " " .. file, "%f:%l: error: %m")
lint("javac", "javac", {"-d", temp, file}, "%f:%l: error: %m")
elseif ft == "javascript" then
lint("jshint", "jshint " .. file, "%f: line %l,.+, %m")
lint("jshint", "jshint", {file}, "%f: line %l,.+, %m")
end
end
@@ -44,10 +44,10 @@ function onSave(view)
end
end
function lint(linter, cmd, errorformat)
function lint(linter, cmd, args, errorformat)
CurView():ClearGutterMessages(linter)
JobStart(cmd, "", "", "linter.onExit", linter, errorformat)
JobSpawn(cmd, args, "", "", "linter.onExit", linter, errorformat)
end
function onExit(output, linter, errorformat)

View File

@@ -1,25 +1,20 @@
syntax "ocaml" "\.mli?$"
#uid
color red "\<[A-Z][0-9a-z_]{2,}\>"
#declarations
color green "\<(let|val|method|in|and|rec|private|virtual|constraint)\>"
#structure items
color red "\<(type|open|class|module|exception|external)\>"
#patterns
color blue "\<(fun|function|functor|match|try|with)\>"
#patterns-modifiers
color yellow "\<(as|when|of)\>"
#conditions
color cyan "\<(if|then|else)\>"
#blocs
color magenta "\<(begin|end|object|struct|sig|for|while|do|done|to|downto)\>"
#constantes
color green "\<(true|false)\>"
#modules/classes
color green "\<(include|inherit|initializer)\>"
#expr modifiers
color yellow "\<(new|ref|mutable|lazy|assert|raise)\>"
#comments
color white start="\(\*" end="\*\)"
#strings (no multiline handling yet)
color brightblack ""[^\"]*""
# Numbers
## Integers
### Binary
color constant.number "-?0[bB][01][01_]*"
### Octal
color constant.number "-?0[oO][0-7][0-7_]*"
### Decimal
color constant.number "-?\d[\d_]*"
### Hexadecimal
color constant.number "-?0[xX][0-9a-fA-F][0-9a-fA-F_]*"
## Real
### Decimal
color constant.number "-?\d[\d_]*.\d[\d_]*([eE][+-]\d[\d_]*.\d[\d_]*)?"
### Hexadecimal
color constant.number "-?0[xX][0-9a-fA-F][0-9a-fA-F_]*.[0-9a-fA-F][0-9a-fA-F_]*([pP][+-][0-9a-fA-F][0-9a-fA-F_]*.[0-9a-fA-F][0-9a-fA-F_]*)?"
# Comments
color comment start="\(\*" end="\*\)"

View File

@@ -2,12 +2,6 @@ syntax "pascal" "\.pas$"
# color identifier "\b[\pL_][\pL_\pN]*\b"
color comment "//.*"
color comment start="\(\*" end="\*\)"
color comment start="({)(?:[^$])" end="}"
color special start="asm" end="end"
color type "\b(?i:(string|ansistring|widestring|shortstring|char|ansichar|widechar|boolean|byte|shortint|word|smallint|longword|cardinal|longint|integer|int64|single|currency|double|extended))\b"
color statement "\b(?i:(and|asm|array|begin|break|case|const|constructor|continue|destructor|div|do|downto|else|end|file|for|function|goto|if|implementation|in|inline|interface|label|mod|not|object|of|on|operator|or|packed|procedure|program|record|repeat|resourcestring|set|shl|shr|then|to|type|unit|until|uses|var|while|with|xor))\b"
@@ -15,10 +9,15 @@ color statement "\b(?i:(as|class|dispose|except|exit|exports|finalization|finall
color statement "\b(?i:(absolute|abstract|alias|assembler|cdecl|cppdecl|default|export|external|forward|generic|index|local|name|nostackframe|oldfpccall|override|pascal|private|protected|public|published|read|register|reintroduce|safecall|softfloat|specialize|stdcall|virtual|write))\b"
color constant "\b(?i:(false|true|nil))\b"
color constant "\$[0-9A-Fa-f]+" "\b[+-]?[0-9]+([.]?[0-9]+)?(?i:e[+-]?[0-9]+)?"
color special start="asm" end="end"
color constant.number "\$[0-9A-Fa-f]+" "\b[+-]?[0-9]+([.]?[0-9]+)?(?i:e[+-]?[0-9]+)?"
color constant.string "#[0-9]{1,}"
color constant.string "'(?:[^']+|'')*'"
color preproc start="{\$" end="}"
color preproc start="{\$" end="}"
color comment "//.*"
color comment start="\(\*" end="\*\)"
color comment start="({)(?:[^$])" end="}"

View File

@@ -11,21 +11,21 @@ color statement "\b(if|then|elseif|else|end|match|where|try|with|as|recover|obje
color statement "\b(while|do|repeat|until|for|in)\b"
color statement "(\?|=>)"
color statement "(\\||\\&|\\,|\\^)"
color statement "(\||\&|\,|\^)"
color statement "(\-|\+|\\*|/|\!|%|<<|>>)"
color statement "(\-|\+|\*|/|\!|%|<<|>>)"
color statement "(==|!=|<=|>=|<|>)"
color statement "\b(is|isnt|not|and|or|xor)\b"
color type "\b(_*[A-Z][_a-zA-Z0-9\\']*)\b"
color type "\b(_*[A-Z][_a-zA-Z0-9\']*)\b"
color constant "\b(this)\b"
color constant "\b(true|false)\b"
color constant.number "\b((0b[0-1_]*)|(0o[0-7_]*)|(0x[0-9a-fA-F_]*)|([0-9_]+(\\.[0-9_]+)?((e|E)(\\+|-)?[0-9_]+)?))\b"
color constant.string ""(\\.|[^"])*"|'(\\.|[^'])*'"
color constant.number "\b((0b[0-1_]*)|(0o[0-7_]*)|(0x[0-9a-fA-F_]*)|([0-9_]+(\.[0-9_]+)?((e|E)(\\+|-)?[0-9_]+)?))\b"
color constant.string ""(\\.|[^"])*""
color comment start=""""([^"]|$)" end="""""
color comment start=""""[^"]*" end="""""
color comment "(^|[[:space:]])//.*"
color comment start="/\*" end="\*/"
color todo "TODO:?"