clojure.vim 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. " 2024 Jan 14 by Vim Project (browsefilter)
  10. if exists("b:did_ftplugin")
  11. finish
  12. endif
  13. let b:did_ftplugin = 1
  14. let s:cpo_save = &cpo
  15. set cpo&vim
  16. let b:undo_ftplugin = 'setlocal iskeyword< define< formatoptions< comments< commentstring< lispwords<'
  17. setlocal iskeyword+=?,-,*,!,+,/,=,<,>,.,:,$,%,&,\|
  18. " There will be false positives, but this is better than missing the whole set
  19. " of user-defined def* definitions.
  20. setlocal define=\\v[(/]def(ault)@!\\S*
  21. " Remove 't' from 'formatoptions' to avoid auto-wrapping code.
  22. setlocal formatoptions-=t
  23. " Lisp comments are routinely nested (e.g. ;;; SECTION HEADING)
  24. setlocal comments=n:;
  25. setlocal commentstring=;\ %s
  26. " Specially indented symbols from clojure.core and clojure.test.
  27. "
  28. " Clojure symbols are indented in the defn style when they:
  29. "
  30. " * Define vars and anonymous functions
  31. " * Create new lexical scopes or scopes with altered environments
  32. " * Create conditional branches from a predicate function or value
  33. "
  34. " The arglists for these functions are generally in the form of [x & body];
  35. " Functions that accept a flat list of forms do not treat the first argument
  36. " specially and hence are not indented specially.
  37. "
  38. " -*- LISPWORDS -*-
  39. " Generated from https://github.com/clojure-vim/clojure.vim/blob/fd280e33e84c88e97860930557dba3ff80b1a82d/clj/src/vim_clojure_static/generate.clj
  40. 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
  41. " Provide insert mode completions for special forms and clojure.core. As
  42. " 'omnifunc' is set by popular Clojure REPL client plugins, we also set
  43. " 'completefunc' so that the user has some form of completion available when
  44. " 'omnifunc' is set and no REPL connection exists.
  45. for s:setting in ['omnifunc', 'completefunc']
  46. if exists('&' . s:setting) && empty(eval('&' . s:setting))
  47. execute 'setlocal ' . s:setting . '=clojurecomplete#Complete'
  48. let b:undo_ftplugin .= ' | setlocal ' . s:setting . '<'
  49. endif
  50. endfor
  51. " Skip brackets in ignored syntax regions when using the % command
  52. if exists('loaded_matchit')
  53. let b:match_words = &matchpairs
  54. let b:match_skip = 's:comment\|string\|regex\|character'
  55. let b:undo_ftplugin .= ' | unlet! b:match_words b:match_skip'
  56. endif
  57. " Filter files in the browse dialog
  58. if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
  59. let b:browsefilter = "Clojure Files\t*.clj;*.cljc;*.cljs;*.cljx\n" .
  60. \ "EDN Files\t*.edn\n" .
  61. \ "Java Files\t*.java\n"
  62. if has("win32")
  63. let b:browsefilter .= "All Files (*.*)\t*\n"
  64. else
  65. let b:browsefilter .= "All Files (*)\t*\n"
  66. endif
  67. let b:undo_ftplugin .= ' | unlet! b:browsefilter'
  68. endif
  69. let &cpo = s:cpo_save
  70. unlet! s:cpo_save s:setting s:dir
  71. " vim:sts=8:sw=8:ts=8:noet