clojure.vim 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. " Vim filetype plugin file
  2. " Language: Clojure
  3. " Maintainer: Alex Vear <alex@vear.uk>
  4. " Former Maintainers: Sung Pae <self@sungpae.com>
  5. " Meikel Brandmeyer <mb@kotka.de>
  6. " URL: https://github.com/clojure-vim/clojure.vim
  7. " License: Vim (see :h license)
  8. " Last Change: 2022-03-24
  9. if exists("b:did_ftplugin")
  10. finish
  11. endif
  12. let b:did_ftplugin = 1
  13. let s:cpo_save = &cpo
  14. set cpo&vim
  15. let b:undo_ftplugin = 'setlocal iskeyword< define< formatoptions< comments< commentstring< lispwords<'
  16. setlocal iskeyword+=?,-,*,!,+,/,=,<,>,.,:,$,%,&,\|
  17. " There will be false positives, but this is better than missing the whole set
  18. " of user-defined def* definitions.
  19. setlocal define=\\v[(/]def(ault)@!\\S*
  20. " Remove 't' from 'formatoptions' to avoid auto-wrapping code.
  21. setlocal formatoptions-=t
  22. " Lisp comments are routinely nested (e.g. ;;; SECTION HEADING)
  23. setlocal comments=n:;
  24. setlocal commentstring=;\ %s
  25. " Specially indented symbols from clojure.core and clojure.test.
  26. "
  27. " Clojure symbols are indented in the defn style when they:
  28. "
  29. " * Define vars and anonymous functions
  30. " * Create new lexical scopes or scopes with altered environments
  31. " * Create conditional branches from a predicate function or value
  32. "
  33. " The arglists for these functions are generally in the form of [x & body];
  34. " Functions that accept a flat list of forms do not treat the first argument
  35. " specially and hence are not indented specially.
  36. "
  37. " -*- LISPWORDS -*-
  38. " Generated from https://github.com/clojure-vim/clojure.vim/blob/fd280e33e84c88e97860930557dba3ff80b1a82d/clj/src/vim_clojure_static/generate.clj
  39. setlocal lispwords=as->,binding,bound-fn,case,catch,cond->,cond->>,condp,def,definline,definterface,defmacro,defmethod,defmulti,defn,defn-,defonce,defprotocol,defrecord,defstruct,deftest,deftest-,deftype,doseq,dotimes,doto,extend,extend-protocol,extend-type,fn,for,if,if-let,if-not,if-some,let,letfn,locking,loop,ns,proxy,reify,set-test,testing,when,when-first,when-let,when-not,when-some,while,with-bindings,with-in-str,with-local-vars,with-open,with-precision,with-redefs,with-redefs-fn,with-test
  40. " Provide insert mode completions for special forms and clojure.core. As
  41. " 'omnifunc' is set by popular Clojure REPL client plugins, we also set
  42. " 'completefunc' so that the user has some form of completion available when
  43. " 'omnifunc' is set and no REPL connection exists.
  44. for s:setting in ['omnifunc', 'completefunc']
  45. if exists('&' . s:setting) && empty(eval('&' . s:setting))
  46. execute 'setlocal ' . s:setting . '=clojurecomplete#Complete'
  47. let b:undo_ftplugin .= ' | setlocal ' . s:setting . '<'
  48. endif
  49. endfor
  50. " Skip brackets in ignored syntax regions when using the % command
  51. if exists('loaded_matchit')
  52. let b:match_words = &matchpairs
  53. let b:match_skip = 's:comment\|string\|regex\|character'
  54. let b:undo_ftplugin .= ' | unlet! b:match_words b:match_skip'
  55. endif
  56. " Filter files in the browse dialog
  57. if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
  58. let b:browsefilter = "All Files\t*\n" .
  59. \ "Clojure Files\t*.clj;*.cljc;*.cljs;*.cljx\n" .
  60. \ "EDN Files\t*.edn\n" .
  61. \ "Java Files\t*.java\n"
  62. let b:undo_ftplugin .= ' | unlet! b:browsefilter'
  63. endif
  64. let &cpo = s:cpo_save
  65. unlet! s:cpo_save s:setting s:dir
  66. " vim:sts=8:sw=8:ts=8:noet