关闭Limp中的高光功能

时间:2010-03-30 14:15:19

标签: vim lisp common-lisp

我在我的VIM中使用Limp。但是有一个问题,当光标移动到“(”或“)”时,它会突出显示该对中的代码块。我无法清楚地看到代码。有没有办法关闭或删除此功能?

最诚挚的问候,

1 个答案:

答案 0 :(得分:2)

我也在使用Limp,但我对其进行了一些修改,以便更好地满足我的口味。

在主limp文件夹中有一个vim子文件夹,打开文件limp.vim,最后你可以看到几个runtime命令,只需注释掉加载highlight.vim的命令。 {1}}档案:

"runtime ftplugin/lisp/limp/highlight.vim

我也想禁用autoclose.vim插件,我发现它很烦人。

"runtime ftplugin/lisp/limp/autoclose.vim

然后,打开文件mode.vim,在第58行附近,您可以看到函数调用以初始化突出显示模式;评论出来:

"call LimpHighlight_start()

然后在第68行附近,在功能LimpMode_stop()下,您还需要对通话进行评论以停止突出显示。

"call LimpHighlight_stop()

当然,如果您还停用了autoclose.vim插件,则还必须对来电启动/停止进行评论。

烦人的颜色

如果Limp设置的颜色开箱即用,就像他们对我一样,你可以禁用它并继续使用你的默认颜色方案;第30行:

"set t_Co=256
"if !exists("g:colors_name")
    "colorscheme desertEx
"endif

更改突出显示组以匹配您的colorscheme(使用:high可快速查看颜色组合列表)。例如,我使用“desertEx” colorscheme并更改了这两行以匹配它:

hi BracketsBlock ctermbg=235 guibg=grey22
hi StatusLine    ctermbg=black ctermfg=160

其他选项

我不喜欢Limp设置的选项集,特别是旧的Vi Lisp缩进。我也不喜欢折叠,所以我也禁用了折叠。我目前的选项如下:

syntax on
setlocal nocompatible nocursorline
setlocal lisp syntax=lisp
setlocal ls=2 bs=2 et sw=2 ts=2 "tw=0 
setlocal statusline=%<%f\ \(%{LimpBridge_connection_status()}\)\ %h%m%r%=%-14.(%l,%c%V%)\ %P
"setlocal iskeyword=&,*,+,45,/,48-57,:,<,=,>,@,A-Z,a-z,_
"setlocal cpoptions=-mp
"setlocal foldmethod=marker foldmarker=(,) foldminlines=1
setlocal foldcolumn=0

set lispwords+=defgeneric,block,catch,with-gensyms

"-----------
"Taken from the bundled lisp.vim file in VIM
"(/usr/share/vim/vim72/ftplugin/lisp.vim)
setl comments=:;
setl define=^\\s*(def\\k*
setl formatoptions-=t
setl iskeyword+=+,-,*,/,%,<,=,>,:,$,?,!,@-@,94
setl comments^=:;;;,:;;,sr:#\|,mb:\|,ex:\|#
setl formatoptions+=croql
"-----------

" This allows gf and :find to work. Fix path to your needs
setlocal suffixesadd=.lisp,.cl path+=/home/gajon/Lisp/**

注意我已禁用tw=0,修改了statusline,禁用折叠,复制了与Vim捆绑在一起的选项(它们更好),向lispwords添加了一些符号,并向suffixesadd添加了一个缺失的点(cl扩展点缺少一个点)。

禁止移植性别。

Limp将它们的键 {} 绑定到将当前sexp转换为上一个/下一个sexp的函数。但它们不能可靠地工作,我认为当你可以在适当的地方轻松使用 dab p 时,它们是不必要的。除了默认的Vim {} 绑定对于转移到其他顶级表单非常有用。

在档案keys.vim中:

"nmap <buffer> {                    <Plug>SexpMoveBack
"nmap <buffer> }                    <Plug>SexpMoveForward

连接到正在运行的REPL

时出错

有一个错误阻止Limp重新连接到已经运行的REPL。在bridge.vim子文件夹内的文件vim中,第13行附近:

let cmd = s:Limp_location . "/bin/lisp.sh ".core_opt." -s ".styfile." -b ".name

".core_opt."-s之间缺少空格。

额外的好东西!

您应该能够弄清楚如何使用这些新映射。

在文件bridge.vim中,在第265行之后添加以下行:

nnoremap <silent> <buffer> <Plug>EvalUndefine   :call LimpBridge_send_to_lisp("(fmakunbound '".expand("<cword>").")")<CR>
nnoremap <silent> <buffer> <Plug>EvalAddWord    :let &lispwords.=',' . expand("<cword>")<cr>

nnoremap <silent> <buffer> <Plug>DebugTrace         :call LimpBridge_send_to_lisp("(trace ".expand("<cword>").")")<CR>
nnoremap <silent> <buffer> <Plug>DebugUnTrace       :call LimpBridge_send_to_lisp("(untrace ".expand("<cword>").")")<CR>
nnoremap <silent> <buffer> <Plug>DebugInspectObject :call LimpBridge_inspect_expression()<CR>
nnoremap <silent> <buffer> <Plug>DebugInspectLast   :call LimpBridge_send_to_lisp("(inspect *)")<CR>
nnoremap <silent> <buffer> <Plug>DebugDisassemble   :call LimpBridge_send_to_lisp("(disassemble #'".expand("<cword>").")")<CR>
nnoremap <silent> <buffer> <Plug>DebugMacroExpand   :call LimpBridge_macroexpand_current_form( "macroexpand" )<CR>
nnoremap <silent> <buffer> <Plug>DebugMacroExpand1  :call LimpBridge_macroexpand_current_form( "macroexpand-1" )<CR>

nnoremap <silent> <buffer> <Plug>ProfileSet      :call LimpBridge_send_to_lisp("(sb-profile:profile ".expand("<cword>").")")<CR>
nnoremap <silent> <buffer> <Plug>ProfileUnSet    :call LimpBridge_send_to_lisp("(sb-profile:unprofile ".expand("<cword>").")")<CR>
nnoremap <silent> <buffer> <Plug>ProfileShow     :call LimpBridge_send_to_lisp("(sb-profile:profile)")<CR>
nnoremap <silent> <buffer> <Plug>ProfileUnSetAll :call LimpBridge_send_to_lisp("(sb-profile:unprofile)")<CR>
nnoremap <silent> <buffer> <Plug>ProfileReport   :call LimpBridge_send_to_lisp("(sb-profile:report)")<CR>
nnoremap <silent> <buffer> <Plug>ProfileReset    :call LimpBridge_send_to_lisp("(sb-profile:reset)")<CR>

最后添加这两个功能:

function! LimpBridge_inspect_expression()
  let whatwhat = input("Inspect: ")
  call LimpBridge_send_to_lisp( "(inspect " . whatwhat . ")" )
endfun

function! LimpBridge_macroexpand_current_form(command)
  " save position
  let pos = LimpBridge_get_pos()

  " find & yank current s-exp
  normal! [(
  let sexp = LimpBridge_yank( "%" )
  call LimpBridge_send_to_lisp( "(" . a:command . " '" . sexp . ")" )
  call LimpBridge_goto_pos( pos )
endfunction

然后在文件keys.vim中添加以下映射:

" Undefine: Undefine a function or macro.
nmap <buffer> <LocalLeader>eu      <Plug>EvalUndefine

" Add Word: Append word to 'lispwords' option
nmap <buffer> <LocalLeader>ea      <Plug>EvalAddWord

" Trace: Set tracing for function.
" Untrace: Remove tracing for a function.
nmap <buffer> <LocalLeader>dt      <Plug>DebugTrace
nmap <buffer> <LocalLeader>du      <Plug>DebugUnTrace

" Inspect: Inspect object
" InspectPrev: Inspect last value evaled.
nmap <buffer> <LocalLeader>di      <Plug>DebugInspectObject
nmap <buffer> <LocalLeader>dI      <Plug>DebugInspectLast

" Disassemble:
nmap <buffer> <LocalLeader>dd      <Plug>DebugDisassemble

" Macroexpand:
" Macroexpand1:
nmap <buffer> <LocalLeader>ma      <Plug>DebugMacroExpand
nmap <buffer> <LocalLeader>m1      <Plug>DebugMacroExpand1

" Profile: Set profiling.
" Unprofile: Remove profiling.
nmap <buffer> <LocalLeader>pr      <Plug>ProfileSet
nmap <buffer> <LocalLeader>pu      <Plug>ProfileUnSet

" Show Profiling: Show profiling.
" Unprofile All: Remove all profiling.
nmap <buffer> <LocalLeader>pp      <Plug>ProfileShow
nmap <buffer> <LocalLeader>pa      <Plug>ProfileUnSetAll

" Profile Report: Show report.
" Profile Reset: Reset profile data.
nmap <buffer> <LocalLeader>ps      <Plug>ProfileReport
nmap <buffer> <LocalLeader>p-      <Plug>ProfileReset

" Sexp Close Open Parenthesis:
nmap <buffer> <LocalLeader>cp      <Plug>SexpCloseParenthesis
imap <buffer> <C-X>0               <C-O><LocalLeader>cp

然后在文件sexp.vim中添加此映射:

" Sexp Close Open Parenthesis:
nnoremap <silent> <buffer> <Plug>SexpCloseParenthesis  :call SlimvCloseForm()<CR>

和这两个功能:

"-------------------------------------------------------------------
" Close open parenthesis
" Taken from the Slimv plugin by Tamas Kovacs. Released in the
" public domain by the original author.
"-------------------------------------------------------------------

" Count the opening and closing parens or brackets to determine if they match
function! s:GetParenCount( lines )
    let paren = 0
    let inside_string = 0
    let i = 0
    while i < len( a:lines )
        let inside_comment = 0
        let j = 0
        while j < len( a:lines[i] )
            if inside_string
                " We are inside a string, skip parens, wait for closing '"'
                if a:lines[i][j] == '"'
                    let inside_string = 0
                endif
            elseif inside_comment
                " We are inside a comment, skip parens, wait for end of line
            else
                " We are outside of strings and comments, now we shall count parens
                if a:lines[i][j] == '"'
                    let inside_string = 1
                endif
                if a:lines[i][j] == ';'
                    let inside_comment = 1
                endif
                if a:lines[i][j] == '(' || a:lines[i][j] == '['
                    let paren = paren + 1
                endif
                if a:lines[i][j] == ')' || a:lines[i][j] == ']'
                    let paren = paren - 1
                    if paren < 0
                        " Oops, too many closing parens in the middle
                        return paren
                    endif
                endif
            endif
            let j = j + 1
        endwhile
        let i = i + 1
    endwhile
    return paren
endfunction

" Close current top level form by adding the missing parens
function! SlimvCloseForm()
    let l2 = line( '.' )
    normal 99[(
    let l1 = line( '.' )
    let form = []
    let l = l1
    while l <= l2
        call add( form, getline( l ) )
        let l = l + 1
    endwhile
    let paren = s:GetParenCount( form )
    if paren > 0
        " Add missing parens
        let lastline = getline( l2 )
        while paren > 0
            let lastline = lastline . ')'
            let paren = paren - 1
        endwhile
        call setline( l2, lastline )
    endif
    normal %
endfunction

希望这有助于您更好地使用Limp。