You are looking at historical revision 11651 of this page. It may differ significantly from its current revision.
==Introduction Following are some configures used to edit scheme file with VIM.
==Coloring VIM's default syntax file for Scheme already have some stuff for Chicken Scheme, we can enable those by add following line into ~/.vim/ftplugin/scheme.vim.
But It still remain some annoying stuffs. Following code is a patch to syntax/scheme.vim, you can patch the system file directly, or you can copy system file to ~/.vim/syntax, and then patch to it. This patch add S-exp comment and Shebang support.
--- old-scheme.vim 2008-08-16 09:35:17.000000000 +0800 +++ scheme.vim 2008-08-16 09:34:38.000000000 +0800 @@ -29,6 +29,11 @@ syn match schemeError oneline ![^ \t()\[\]";]*! syn match schemeError oneline ")" +" Add TempStruc before Struc and Quoted. +" although TempStruc will be overrighted by them when do hightlighting, +" it still can be used to delimit a sexp. +syn region schemeTempStruc start="(" end=")" contained transparent contains=schemeTempStruc + " Quoted and backquoted stuff syn region schemeQuoted matchgroup=Delimiter start="['`]" end=![ \t()\[\]";]!me=e-1 contains=ALLBUT,schemeStruc,schemeSyntax,schemeFunc @@ -231,8 +236,13 @@ if exists("b:is_chicken") || exists("is_chicken") + syn match schemeChar oneline "#\\return" + syn match schemeChar oneline "#!eof" + " multiline comment syntax region schemeMultilineComment start=/#|/ end=/|#/ contains=schemeMultilineComment + syn region schemeSexpComment start="#;(" end=")" contains=schemeComment,schemeTempStruc + hi def link schemeSexpComment Comment syn match schemeOther oneline "##[-a-z!$%&*/:<=>?^_~0-9+.@#%]\+" syn match schemeExtSyntax oneline "#:[-a-z!$%&*/:<=>?^_~0-9+.@#%]\+" @@ -268,6 +278,9 @@ " suggested by Alex Queiroz syn match schemeExtSyntax oneline "#![-a-z!$%&*/:<=>?^_~0-9+.@#%]\+" syn region schemeString start=+#<#\s*\z(.*\)+ end=+^\z1$+ + + syn match schemeShebang "^#!/.*csi.*$" + hi def link schemeShebang Comment endif " Synchronization and the wrapping up...
===Completion VIM's completion manner can be configured by 'complete' option. Look through it's document and we can find something useful for our Scheme editing.
First is the k flag, we can supply a dict file to it. So now using following code to generate a dict file.
!/usr/local/bin/csi -script ;;; Create a dictionary file to be used by vim insert complete. (use data-structures extras srfi-1 srfi-4 srfi-13) (use srfi-14 srfi-69 match regex srfi-18 posix utils tcp lolevel) (call-with-output-file "~/scheme-word-list" (lambda (port) (for-each (lambda (x) (display x port) (newline port)) (sort (apropos-list (regexp ".*") #:macros? #t) (lambda (a b) (string<? (symbol->string a) (symbol->string b)))))))
Then add following line to ~/.vim/ftplugin/scheme.vim, and we will be able to complete some stuff using CTRL-P and CTRL-N.
Also when we edit c files, VIM find words in not only opened buffers, but also included files. Those were controlled by following options.
setl include=\^\(\\(use\\\|require-extension\\)\\s\\+ setl includeexpr=substitute(v:fname,'$','.scm','') setl path+=/usr/local/lib/chicken/3 setl suffixesadd=.scm
With above lines inserted into ~/.vim/ftplugin/scheme.vim, VIM will also try to find words in files which we used for use or require-extension. You my have to change the path to satisfy you situation.
===Indention VIM already indent Scheme file well, except it can't recognise some chicken keywords, We just have to add them.
setl lispwords+=let-values,condition-case,with-input-from-string setl lispwords+=with-output-to-string,handle-exceptions,call/cc,rec,receive setl lispwords+=call-with-output-file
Also, put those lines in to scheme.vim.
nmap <silent> == :call Scheme_indent_top_sexp()<cr> " Indent a toplevel sexp. fun! Scheme_indent_top_sexp() let pos = getpos('.') silent! exec "normal! 99[(=%" call setpos('.', pos) endfun
Then we can use == to indent a toplevel S-expression.
Following is a simple way to add interaction facility to VIM using screen.
It was stolen from this link. Thanks Jonathan Palardy.
Put following lines into ftplugin/scheme.vim
nmap <silent> <leader>es :call Scheme_eval_defun()<cr> nmap <silent> <leader>ef :call Scheme_send_sexp("(load \"" . expand("%:p") . "\")\n")<cr> fun! Scheme_send_sexp(sexp) let ss = escape(a:sexp, '\"') call system("screen -p csi -X stuff \"" . ss . "\n\"") endfun fun! Scheme_eval_defun() let pos = getpos('.') silent! exec "normal! 99[(yab" call Scheme_send_sexp(@") call setpos('.', pos) endfun
First we create a window in screen with the name of csi and start csi in it. Then open a scheme file, using <leader>es to evaluate a sexp and using <leader>ef to load a file.