From a78eb499922fd8e17270bbcdd5987af1fc746844 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Mon, 3 Dec 2012 23:34:33 +0100 Subject: misc changes Signed-off-by: Florian Pritz --- .vim/snippets/arduino.snippets | 205 ++++++++++++++++++++++++++++++++++++++++ .vim/syntax/go.vim | 208 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 413 insertions(+) create mode 100644 .vim/snippets/arduino.snippets create mode 100644 .vim/syntax/go.vim (limited to '.vim') diff --git a/.vim/snippets/arduino.snippets b/.vim/snippets/arduino.snippets new file mode 100644 index 0000000..4855a5f --- /dev/null +++ b/.vim/snippets/arduino.snippets @@ -0,0 +1,205 @@ +#################### +# Main structs # +#################### +# loop() +snippet loop + loop() + { + ${1} + } +# setup() +snippet setup + setup() + { + ${1} + } +##################### +# Digital I/O # +##################### +# pinMode() +snippet pinM + pinMode(${1:/* pin */}, ${2:OUTPUT});${3} +# digitalWrite() +snippet diW + digitalWrite(${1:/* pin */}, ${2:HIGH});${3} +# digitalRead() +snippet diR + digitalRead(${1:/* pin */});${3} + +##################### +# Analog I/O # +##################### +# analogReference() +snippet anRef + analogReference(${1:/* ref */});${2} +# analogRead() +snippet anR + analogRead(${1:/* pin */});${2} +# analogWrite() +snippet anW + analogWrite(${1:/* pin */}, ${2:/* value */});${3} + +##################### +# Advanced I/O # +##################### +# tone() +snippet tone + tone(${1:/* pin */}, ${2:/* Frequency */});${3} +# noTone() +snippet noTone + noTone(${1:/* pin */});${2} +# shiftOut() +snippet shiftO + shiftOut(${1:/* data pin */}, ${2:/* clockPin */}, ${3:/* bit order */}, ${4:/* value */});${5} +# shiftIn() +snippet shiftI + shiftIn(${1:/* data pin */}, ${2:/* clockPin */}, ${3:/* bit order */});${4} +# pulseIn() +snippet pulI + pulseIn(${1:/* pin */}, ${2:/* value */});${3} + +####################### +# Timing # +####################### +# delay() +snippet delay + delay(${1});${2} +# delayMicroseconds() +snippet delayMS + delayMicroseconds(${1});${2} + +###################### +# Bits and Bytes # +###################### +# lowByte() +snippet lowB + lowByte(${1});${2} +# highByte() +snippet highB + highByte(${1});${2} +# bitRead() +snippet bR + bitRead(${1:/* number */}, ${2:/* bit to read */});${3} +# bitWrite() +snippet bW + bitWrite(${1:/* number */}, ${2:/* bit to write */}, ${3:/* value */});${4} +# bitSet() +snippet bS + bitSet(${1:/* number */}, ${2:/* bit to set */});${3} +# bitClear() +snippet bC + bitClear(${1:/* number */}, ${2:/* bit to clear */});${3} + +####################### +# External Interrupts # +####################### +# attachInterrupt() +snippet aInter + attachInterrupt(${1:/* interrupt */}, ${2:/* function */}, ${3:/* mode */});${4} +# detachInterrupt() +snippet dInter + detachInterrupt(${1:/* interrupt */});${2} + +####################### +# C snippets # +####################### + +# Note : This part comes from the classic snipMate installation +# (c.snippets). I've just deleted the printf and fprintf snippets +# which are not useful with arduino. + +# #include <...> +snippet inc + #include <${1:stdio}.h>${2} +# #include "..." +snippet Inc + #include "${1:`Filename("$1.h")`}"${2} +# #ifndef ... #define ... #endif +snippet Def + #ifndef $1 + #define ${1:SYMBOL} ${2:value} + #endif${3} +snippet def + #define +snippet ifdef + #ifdef ${1:FOO} + ${2:#define } + #endif +snippet #if + #if ${1:FOO} + ${2} + #endif +# Header Include-Guard +# (the randomizer code is taken directly from TextMate; it could probably be +# cleaner, I don't know how to do it in vim script) +snippet once + #ifndef ${1:`toupper(Filename('', 'UNTITLED').'_'.system("/usr/bin/ruby -e 'print (rand * 2821109907455).round.to_s(36)'"))`} + + #define $1 + + ${2} + + #endif /* end of include guard: $1 */ +# If Condition +snippet if + if (${1:/* condition */}) { + ${2:/* code */} + } +snippet el + else { + ${1} + } +# Tertiary conditional +snippet t + ${1:/* condition */} ? ${2:a} : ${3:b} +# Do While Loop +snippet do + do { + ${2:/* code */} + } while (${1:/* condition */}); +# While Loop +snippet wh + while (${1:/* condition */}) { + ${2:/* code */} + } +# For Loop +snippet for + for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) { + ${4:/* code */} + } +# Custom For Loop +snippet forr + for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) { + ${5:/* code */} + } +# Function +snippet fun + ${1:void} ${2:function_name}(${3}) + { + ${4:/* code */} + } +# Function Declaration +snippet fund + ${1:void} ${2:function_name}(${3});${4} +# Typedef +snippet td + typedef ${1:int} ${2:MyCustomType};${3} +# Struct +snippet st + struct ${1:`Filename('$1_t', 'name')`} { + ${2:/* data */} + }${3: /* optional variable list */};${4} +# Typedef struct +snippet tds + typedef struct ${2:_$1 }{ + ${3:/* data */} + } ${1:`Filename('$1_t', 'name')`}; +# Typdef enum +snippet tde + typedef enum { + ${1:/* data */} + } ${2:foo}; +snippet . + [${1}]${2} +snippet un + unsigned diff --git a/.vim/syntax/go.vim b/.vim/syntax/go.vim new file mode 100644 index 0000000..26d7def --- /dev/null +++ b/.vim/syntax/go.vim @@ -0,0 +1,208 @@ +" Copyright 2009 The Go Authors. All rights reserved. +" Use of this source code is governed by a BSD-style +" license that can be found in the LICENSE file. +" +" go.vim: Vim syntax file for Go. +" +" Options: +" There are some options for customizing the highlighting; the recommended +" settings are the default values, but you can write: +" let OPTION_NAME = 0 +" in your ~/.vimrc file to disable particular options. You can also write: +" let OPTION_NAME = 1 +" to enable particular options. At present, all options default to on. +" +" - go_highlight_array_whitespace_error +" Highlights white space after "[]". +" - go_highlight_chan_whitespace_error +" Highlights white space around the communications operator that don't follow +" the standard style. +" - go_highlight_extra_types +" Highlights commonly used library types (os.Error, etc.). +" - go_highlight_space_tab_error +" Highlights instances of tabs following spaces. +" - go_highlight_trailing_whitespace_error +" Highlights trailing white space. + +" Quit when a (custom) syntax file was already loaded +if exists("b:current_syntax") + finish +endif + +if !exists("go_highlight_array_whitespace_error") + let go_highlight_array_whitespace_error = 1 +endif +if !exists("go_highlight_chan_whitespace_error") + let go_highlight_chan_whitespace_error = 1 +endif +if !exists("go_highlight_extra_types") + let go_highlight_extra_types = 1 +endif +if !exists("go_highlight_space_tab_error") + let go_highlight_space_tab_error = 1 +endif +if !exists("go_highlight_trailing_whitespace_error") + let go_highlight_trailing_whitespace_error = 1 +endif + +syn case match + +syn keyword goDirective package import +syn keyword goDeclaration var const type +syn keyword goDeclType struct interface + +hi def link goDirective Statement +hi def link goDeclaration Keyword +hi def link goDeclType Keyword + +" Keywords within functions +syn keyword goStatement defer go goto return break continue fallthrough +syn keyword goConditional if else switch select +syn keyword goLabel case default +syn keyword goRepeat for range + +hi def link goStatement Statement +hi def link goConditional Conditional +hi def link goLabel Label +hi def link goRepeat Repeat + +" Predefined types +syn keyword goType chan map bool string +syn keyword goSignedInts int int8 int16 int32 int64 +syn keyword goUnsignedInts byte uint uint8 uint16 uint32 uint64 uintptr +syn keyword goFloats float32 float64 +syn keyword goComplexes complex64 complex128 + +hi def link goType Type +hi def link goSignedInts Type +hi def link goUnsignedInts Type +hi def link goFloats Type +hi def link goComplexes Type + +" Treat func specially: it's a declaration at the start of a line, but a type +" elsewhere. Order matters here. +syn match goType /\/ +syn match goDeclaration /^func\>/ + +" Predefined functions and values +syn keyword goBuiltins append cap close complex copy imag len +syn keyword goBuiltins make new panic print println real recover +syn keyword goConstants iota true false nil + +hi def link goBuiltins Keyword +hi def link goConstants Keyword + +" Comments; their contents +syn keyword goTodo contained TODO FIXME XXX BUG +syn cluster goCommentGroup contains=goTodo +syn region goComment start="/\*" end="\*/" contains=@goCommentGroup,@Spell +syn region goComment start="//" end="$" contains=@goCommentGroup,@Spell + +hi def link goComment Comment +hi def link goTodo Todo + +" Go escapes +syn match goEscapeOctal display contained "\\[0-7]\{3}" +syn match goEscapeC display contained +\\[abfnrtv\\'"]+ +syn match goEscapeX display contained "\\x\x\{2}" +syn match goEscapeU display contained "\\u\x\{4}" +syn match goEscapeBigU display contained "\\U\x\{8}" +syn match goEscapeError display contained +\\[^0-7xuUabfnrtv\\'"]+ + +hi def link goEscapeOctal goSpecialString +hi def link goEscapeC goSpecialString +hi def link goEscapeX goSpecialString +hi def link goEscapeU goSpecialString +hi def link goEscapeBigU goSpecialString +hi def link goSpecialString Special +hi def link goEscapeError Error + +" Strings and their contents +syn cluster goStringGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU,goEscapeError +syn region goString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@goStringGroup +syn region goRawString start=+`+ end=+`+ + +hi def link goString String +hi def link goRawString String + +" Characters; their contents +syn cluster goCharacterGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU +syn region goCharacter start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=@goCharacterGroup + +hi def link goCharacter Character + +" Regions +syn region goBlock start="{" end="}" transparent fold +syn region goParen start='(' end=')' transparent + +" Integers +syn match goDecimalInt "\<\d\+\([Ee]\d\+\)\?\>" +syn match goHexadecimalInt "\<0x\x\+\>" +syn match goOctalInt "\<0\o\+\>" +syn match goOctalError "\<0\o*[89]\d*\>" + +hi def link goDecimalInt Integer +hi def link goHexadecimalInt Integer +hi def link goOctalInt Integer +hi def link Integer Number + +" Floating point +syn match goFloat "\<\d\+\.\d*\([Ee][-+]\d\+\)\?\>" +syn match goFloat "\<\.\d\+\([Ee][-+]\d\+\)\?\>" +syn match goFloat "\<\d\+[Ee][-+]\d\+\>" + +hi def link goFloat Float + +" Imaginary literals +syn match goImaginary "\<\d\+i\>" +syn match goImaginary "\<\d\+\.\d*\([Ee][-+]\d\+\)\?i\>" +syn match goImaginary "\<\.\d\+\([Ee][-+]\d\+\)\?i\>" +syn match goImaginary "\<\d\+[Ee][-+]\d\+i\>" + +hi def link goImaginary Number + +" Spaces after "[]" +if go_highlight_array_whitespace_error != 0 + syn match goSpaceError display "\(\[\]\)\@<=\s\+" +endif + +" Spacing errors around the 'chan' keyword +if go_highlight_chan_whitespace_error != 0 + " receive-only annotation on chan type + syn match goSpaceError display "\(<-\)\@<=\s\+\(chan\>\)\@=" + " send-only annotation on chan type + syn match goSpaceError display "\(\/ + syn match goExtraType /\/ + syn match goExtraType /\<\(os\.Error\)\>/ + syn match goExtraType /\/ + syn match goExtraType /\/ +endif + +" Space-tab error +if go_highlight_space_tab_error != 0 + syn match goSpaceError display " \+\t"me=e-1 +endif + +" Trailing white space error +if go_highlight_trailing_whitespace_error != 0 + syn match goSpaceError display excludenl "\s\+$" +endif + +hi def link goExtraType Type +hi def link goSpaceError Error + +" Search backwards for a global declaration to start processing the syntax. +"syn sync match goSync grouphere NONE /^\(const\|var\|type\|func\)\>/ + +" There's a bug in the implementation of grouphere. For now, use the +" following as a more expensive/less precise workaround. +syn sync minlines=500 + +let b:current_syntax = "go" -- cgit v1.2.3-24-g4f1b