PageRenderTime 46ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/bundle/vimclojure-2.2.0/ftplugin/clojure.vim

https://github.com/dzuchows/vimrc
Vim Script | 142 lines | 92 code | 34 blank | 16 comment | 12 complexity | ab811259c80d503f4f18ac8c5307d65a MD5 | raw file
  1. " Vim filetype plugin file
  2. " Language: Clojure
  3. " Maintainer: Meikel Brandmeyer <mb@kotka.de>
  4. " Only do this when not done yet for this buffer
  5. if exists("b:did_ftplugin")
  6. finish
  7. endif
  8. let b:did_ftplugin = 1
  9. let s:cpo_save = &cpo
  10. set cpo&vim
  11. let b:undo_ftplugin = "setlocal fo< com< cms< cpt< isk< def<"
  12. setlocal iskeyword+=?,-,*,!,+,/,=,<,>,.,:
  13. setlocal define=^\\s*(def\\(-\\|n\\|n-\\|macro\\|struct\\|multi\\)?
  14. " Set 'formatoptions' to break comment lines but not other lines,
  15. " and insert the comment leader when hitting <CR> or using "o".
  16. setlocal formatoptions-=t formatoptions+=croql
  17. setlocal commentstring=;%s
  18. " Set 'comments' to format dashed lists in comments.
  19. setlocal comments=sO:;\ -,mO:;\ \ ,n:;
  20. " Take all directories of the CLOJURE_SOURCE_DIRS environment variable
  21. " and add them to the path option.
  22. if has("win32") || has("win64")
  23. let s:delim = ";"
  24. else
  25. let s:delim = ":"
  26. endif
  27. for dir in split($CLOJURE_SOURCE_DIRS, s:delim)
  28. call vimclojure#AddPathToOption(dir . "/**", 'path')
  29. endfor
  30. " When the matchit plugin is loaded, this makes the % command skip parens and
  31. " braces in comments.
  32. let b:match_words = &matchpairs
  33. let b:match_skip = 's:comment\|string\|character'
  34. " Win32 can filter files in the browse dialog
  35. if has("gui_win32") && !exists("b:browsefilter")
  36. let b:browsefilter = "Clojure Source Files (*.clj)\t*.clj\n" .
  37. \ "Jave Source Files (*.java)\t*.java\n" .
  38. \ "All Files (*.*)\t*.*\n"
  39. endif
  40. for ns in [ "clojure.core", "clojure.inspector", "clojure.java.browse",
  41. \ "clojure.java.io", "clojure.java.javadoc", "clojure.java.shell",
  42. \ "clojure.main", "clojure.pprint", "clojure.repl", "clojure.set",
  43. \ "clojure.stacktrace", "clojure.string", "clojure.template",
  44. \ "clojure.test", "clojure.test.tap", "clojure.test.junit",
  45. \ "clojure.walk", "clojure.xml", "clojure.zip" ]
  46. call vimclojure#AddCompletions(ns)
  47. endfor
  48. " Define toplevel folding if desired.
  49. function! ClojureGetFoldingLevel(lineno)
  50. let closure = { 'lineno' : a:lineno }
  51. function closure.f() dict
  52. execute self.lineno
  53. if vimclojure#SynIdName() =~ 'clojureParen\d' && vimclojure#Yank('l', 'normal! "lyl') == '('
  54. return 1
  55. endif
  56. if searchpairpos('(', '', ')', 'bWr', 'vimclojure#SynIdName() !~ "clojureParen\\d"') != [0, 0]
  57. return 1
  58. endif
  59. return 0
  60. endfunction
  61. return vimclojure#WithSavedPosition(closure)
  62. endfunction
  63. " Disabled for now. Too slow (and naive).
  64. if exists("g:clj_want_folding") && g:clj_want_folding == 1 && 0 == 1
  65. setlocal foldexpr=ClojureGetFoldingLevel(v:lnum)
  66. setlocal foldmethod=expr
  67. endif
  68. try
  69. call vimclojure#InitBuffer()
  70. catch /.*/
  71. " We swallow a failure here. It means most likely that the
  72. " server is not running.
  73. echohl WarningMsg
  74. echomsg v:exception
  75. echohl None
  76. endtry
  77. call vimclojure#MapPlug("n", "aw", "AddToLispWords")
  78. call vimclojure#MapCommandPlug("n", "lw", "DocLookupWord")
  79. call vimclojure#MapCommandPlug("n", "li", "DocLookupInteractive")
  80. call vimclojure#MapCommandPlug("n", "jw", "JavadocLookupWord")
  81. call vimclojure#MapCommandPlug("n", "ji", "JavadocLookupInteractive")
  82. call vimclojure#MapCommandPlug("n", "fd", "FindDoc")
  83. call vimclojure#MapCommandPlug("n", "mw", "MetaLookupWord")
  84. call vimclojure#MapCommandPlug("n", "mi", "MetaLookupInteractive")
  85. call vimclojure#MapCommandPlug("n", "sw", "SourceLookupWord")
  86. call vimclojure#MapCommandPlug("n", "si", "SourceLookupInteractive")
  87. call vimclojure#MapCommandPlug("n", "gw", "GotoSourceWord")
  88. call vimclojure#MapCommandPlug("n", "gi", "GotoSourceInteractive")
  89. call vimclojure#MapCommandPlug("n", "rf", "RequireFile")
  90. call vimclojure#MapCommandPlug("n", "rF", "RequireFileAll")
  91. call vimclojure#MapCommandPlug("n", "rt", "RunTests")
  92. call vimclojure#MapCommandPlug("n", "me", "MacroExpand")
  93. call vimclojure#MapCommandPlug("n", "m1", "MacroExpand1")
  94. call vimclojure#MapCommandPlug("n", "ef", "EvalFile")
  95. call vimclojure#MapCommandPlug("n", "el", "EvalLine")
  96. call vimclojure#MapCommandPlug("v", "eb", "EvalBlock")
  97. call vimclojure#MapCommandPlug("n", "et", "EvalToplevel")
  98. call vimclojure#MapCommandPlug("n", "ep", "EvalParagraph")
  99. call vimclojure#MapCommandPlug("n", "sr", "StartRepl")
  100. call vimclojure#MapCommandPlug("n", "sR", "StartLocalRepl")
  101. if exists("b:vimclojure_namespace")
  102. setlocal omnifunc=vimclojure#OmniCompletion
  103. augroup VimClojure
  104. autocmd CursorMovedI <buffer> if pumvisible() == 0 | pclose | endif
  105. augroup END
  106. endif
  107. call vimclojure#MapPlug("n", "p", "CloseResultBuffer")
  108. let &cpo = s:cpo_save