summaryrefslogtreecommitdiff
path: root/vim/bundle/slimv/ftplugin/scheme/slimv-scheme.vim
blob: 4a71954b6b0e736bf6a821e0893c0bc0bbe131ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
" slimv-scheme.vim:
"               Scheme filetype plugin for Slimv
" Version:      0.9.13
" Last Change:  04 May 2014
" Maintainer:   Tamas Kovacs <kovisoft at gmail dot com>
" License:      This file is placed in the public domain.
"               No warranty, express or implied.
"               *** ***   Use At-Your-Own-Risk!   *** ***
"
" =====================================================================
"
"  Load Once:
if exists("b:did_ftplugin") || exists("g:slimv_disable_scheme")
    finish
endif

" ---------- Begin part loaded once ----------
if !exists( 'g:slimv_scheme_loaded' )

let g:slimv_scheme_loaded = 1

" Try to autodetect Scheme executable
" Returns list [Scheme executable, Scheme implementation]
function! SlimvAutodetect( preferred )
    " Currently only MIT Scheme on Linux
    if executable( 'scheme' )
        " MIT Scheme
        return ['scheme', 'mit']
    endif

    return ['', '']
endfunction

" Try to find out the Scheme implementation
function! SlimvImplementation()
    if exists( 'g:slimv_impl' ) && g:slimv_impl != ''
        " Return Lisp implementation if defined
        return tolower( g:slimv_impl )
    endif

    return 'mit'
endfunction

" Try to autodetect SWANK and build the command to load the SWANK server
function! SlimvSwankLoader()
    if g:slimv_impl == 'mit'
        if exists( 'g:scheme_builtin_swank' ) && g:scheme_builtin_swank
            " MIT Scheme contains a built-in swank server since version 9.1.1
            return 'scheme --eval "(let loop () (start-swank) (loop))"'
        endif
        let swanks = split( globpath( &runtimepath, 'slime/contrib/swank-mit-scheme.scm'), '\n' )
        if len( swanks ) == 0
            return ''
        endif
        return '"' . g:slimv_lisp . '" --load "' . swanks[0] . '"'
    endif
    return ''
endfunction

" Filetype specific initialization for the REPL buffer
function! SlimvInitRepl()
    set filetype=scheme
endfunction

" Lookup symbol in the Hyperspec
function! SlimvHyperspecLookup( word, exact, all )
    " No Hyperspec support for Scheme at the moment
    let symbol = []
    return symbol
endfunction

" Source Slimv general part
runtime ftplugin/**/slimv.vim

endif "!exists( 'g:slimv_scheme_loaded' )
" ---------- End of part loaded once ----------

runtime ftplugin/**/lisp.vim

" The balloonexpr of MIT-Scheme is broken. Disable it.
let g:slimv_balloon = 0

" The fuzzy completion of MIT-Scheme is broken. Disable it.
let g:slimv_simple_compl = 1

" Must be called for each lisp buffer
call SlimvInitBuffer()

" Don't load another plugin for this buffer
let b:did_ftplugin = 1