Commits

Josh VanderLinden committed 02cac2e

Adding an Arduino syntax file and a scratch plugin

Comments (0)

Files changed (4)

 syntax:glob
 *.swp
+*.swo
 *.pyc
 .vim/view/
 .vim/.netrwhist

.vim/plugin/scratch.vim

+" File: scratch.vim
+" Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
+" Version: 1.0
+" Last Modified: June 3, 2003
+"
+" Overview
+" --------
+" You can use the scratch plugin to create a temporary scratch buffer to store
+" and edit text that will be discarded when you quit/exit vim. The contents
+" of the scratch buffer are not saved/stored in a file.
+"
+" Installation
+" ------------
+" 1. Copy the scratch.vim plugin to the $HOME/.vim/plugin directory. Refer to
+"    the following Vim help topics for more information about Vim plugins:
+"
+"       :help add-plugin
+"       :help add-global-plugin
+"       :help runtimepath
+"
+" 2. Restart Vim.
+"
+" Usage
+" -----
+" You can use the following command to open/edit the scratch buffer:
+"
+"       :Scratch
+"
+" To open the scratch buffer in a new split window, use the following command:
+"
+"       :Sscratch
+"
+" When you close the scratch buffer window, the buffer will retain the
+" contents. You can again edit the scratch buffer by openeing it using one of
+" the above commands. There is no need to save the scatch buffer.
+"
+" When you quit/exit Vim, the contents of the scratch buffer will be lost.
+" You will not be prompted to save the contents of the modified scratch
+" buffer.
+"
+" You can have only one scratch buffer open in a single Vim instance. If the
+" current buffer has unsaved modifications, then the scratch buffer will be
+" opened in a new window
+"
+" ****************** Do not modify after this line ************************
+if exists('loaded_scratch') || &cp
+    finish
+endif
+let loaded_scratch=1
+
+" Scratch buffer name
+let ScratchBufferName = "__Scratch__"
+
+" ScratchBufferOpen
+" Open the scratch buffer
+function! s:ScratchBufferOpen(new_win)
+    let split_win = a:new_win
+
+    " If the current buffer is modified then open the scratch buffer in a new
+    " window
+    if !split_win && &modified
+        let split_win = 1
+    endif
+
+    " Check whether the scratch buffer is already created
+    let scr_bufnum = bufnr(g:ScratchBufferName)
+    if scr_bufnum == -1
+        " open a new scratch buffer
+        if split_win
+            exe "new " . g:ScratchBufferName
+        else
+            exe "edit " . g:ScratchBufferName
+        endif
+    else
+        " Scratch buffer is already created. Check whether it is open
+        " in one of the windows
+        let scr_winnum = bufwinnr(scr_bufnum)
+        if scr_winnum != -1
+            " Jump to the window which has the scratch buffer if we are not
+            " already in that window
+            if winnr() != scr_winnum
+                exe scr_winnum . "wincmd w"
+            endif
+        else
+            " Create a new scratch buffer
+            if split_win
+                exe "split +buffer" . scr_bufnum
+            else
+                exe "buffer " . scr_bufnum
+            endif
+        endif
+    endif
+endfunction
+
+" ScratchMarkBuffer
+" Mark a buffer as scratch
+function! s:ScratchMarkBuffer()
+    setlocal buftype=nofile
+    setlocal bufhidden=hide
+    setlocal noswapfile
+    setlocal buflisted
+endfunction
+
+autocmd BufNewFile __Scratch__ call s:ScratchMarkBuffer()
+
+" Command to edit the scratch buffer in the current window
+command! -nargs=0 Scratch call s:ScratchBufferOpen(0)
+" Command to open the scratch buffer in a new split window
+command! -nargs=0 Sscratch call s:ScratchBufferOpen(1)
+

.vim/syntax/arduino.vim

+" Vim syntax file
+" Language:    Arduino
+" Maintainer:  Johannes Hoff <johannes@johanneshoff.com>
+" Last Change: 06 June 2011
+" License:     VIM license (:help license, replace vim by arduino.vim)
+
+" Syntax highlighting like in the Arduino IDE
+" Automatically generated by the script available at
+"    https://bitbucket.org/johannes/arduino-vim-syntax
+" Using keywords from <arduino>/build/shared/lib/keywords.txt
+" From version: ARDUINO 0022 - 2010.12.24
+
+" Thanks to Rik, Erik Nomitch, Adam Obeng and Graeme Cross for helpful feedback!
+
+" For version 5.x: Clear all syntax items
+" For version 6.x: Quit when a syntax file was already loaded
+if version < 600
+  syntax clear
+elseif exists("b:current_syntax")
+  finish
+endif
+
+" Read the C syntax to start with
+if version < 600
+  so <sfile>:p:h/cpp.vim
+else
+  runtime! syntax/cpp.vim
+endif
+
+syn keyword arduinoConstant  BIN BYTE CHANGE DEC DEFAULT EXTERNAL FALLING HALF_PI
+syn keyword arduinoConstant  HEX HIGH INPUT INTERNAL INTERNAL1V1 INTERNAL2V56
+syn keyword arduinoConstant  LOW LSBFIRST MSBFIRST OCT OUTPUT PI RISING TWO_PI
+
+syn keyword arduinoFunc      analogRead analogReference analogWrite
+syn keyword arduinoFunc      attachInterrupt bit bitClear bitRead bitSet
+syn keyword arduinoFunc      bitWrite delay delayMicroseconds detachInterrupt
+syn keyword arduinoFunc      digitalRead digitalWrite highByte interrupts
+syn keyword arduinoFunc      lowByte micros millis noInterrupts noTone pinMode
+syn keyword arduinoFunc      pulseIn shiftIn shiftOut tone
+
+syn keyword arduinoMethod    available begin end flush loop peek print println
+syn keyword arduinoMethod    read setup
+
+syn keyword arduinoModule    Serial Serial1 Serial2 Serial3
+
+syn keyword arduinoStdFunc   abs acos asin atan atan2 ceil constrain cos degrees
+syn keyword arduinoStdFunc   exp floor log map max min radians random randomSeed
+syn keyword arduinoStdFunc   round sin sq sqrt tan
+
+syn keyword arduinoType      boolean byte null String word
+
+hi def link arduinoType Type
+hi def link arduinoConstant Constant
+hi def link arduinoStdFunc Function
+hi def link arduinoFunc Function
+hi def link arduinoMethod Function
+hi def link arduinoModule Identifier
 " autocmd FileType html,htm exe ":silent 1,$!tidy --indent yes -q"
 
 " autocmd FocusLost *.inc,*.php,*.html,*.js,*.css :w
-autocmd BufEnter,BufRead *.inc,*.phtml,*.php setlocal shiftwidth=2 tabstop=2 syntax=php nolist
-autocmd BufEnter,BufRead *.html setlocal shiftwidth=2 tabstop=2 syntax=html nolist
-autocmd BufEnter,BufRead *.css setlocal shiftwidth=2 tabstop=2 syntax=css nolist
-autocmd BufEnter,BufRead *.js setlocal shiftwidth=2 tabstop=2 syntax=javascript nolist
+autocmd BufEnter,BufRead,BufNewFile *.inc,*.phtml,*.php setlocal shiftwidth=2 tabstop=2 syntax=php nolist
+autocmd BufEnter,BufRead,BufNewFile *.html setlocal shiftwidth=2 tabstop=2 syntax=html nolist
+autocmd BufEnter,BufRead,BufNewFile *.xml,*.rml setlocal shiftwidth=2 tabstop=2 syntax=xml nolist
+autocmd BufEnter,BufRead,BufNewFile *.css setlocal shiftwidth=2 tabstop=2 syntax=css nolist
+autocmd BufEnter,BufRead,BufNewFile *.js setlocal shiftwidth=2 tabstop=2 syntax=javascript nolist
+autocmd BufEnter,BufRead,BufNewFile *.pde setlocal shiftwidth=2 tabstop=2 syntax=c nolist ft=arduino
 
 " Highlight trailing spaces
 autocmd ColorScheme * highlight ExtraWhitespace ctermbg=darkgreen guibg=darkgreen
     if has("win32")
         set guifont=Dina:h8
     elseif has("gui_gtk2")
-        set guifont=xos4\ Terminus\ 9
-        "set guifont=Andale\ Mono\ 9
+        "set guifont=xos4\ Terminus\ 9
+        set guifont=Andale\ Mono\ 9
     endif
 
     set nomousehide
     "set background=light
     "colorscheme solarized
 
-    "set guioptions=-t
+    set guioptions=-T
+    set guioptions=-t
 
     " Maximize the window
     nnoremap <silent> <F5> :set lines=999 columns=999<CR>:cd ~/dev/G3/G3code/backend<CR>