Personal emacs config
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1274 lines
52 KiB

  1. ;;; vimrc-mode.el --- Major mode for vimrc files
  2. ;; Copyright (C) 2013 Andrew Pennebaker
  3. ;; Copyright (C) 2011 Alpha Tan
  4. ;; Authors: Mark Oteiza
  5. ;; Andrew Pennebaker
  6. ;; Alpha Tan <alphatan.zh@gmail.com>
  7. ;; URL: https://github.com/mcandre/vimrc-mode
  8. ;; Package-Version: 20181116.1919
  9. ;; Package-Commit: 13bc150a870d5d4a95f1111e4740e2b22813c30e
  10. ;; Version: 0.3.1
  11. ;; Keywords: languages, vim
  12. ;; Package-Requires: ()
  13. ;; This file is free software; you can redistribute it and/or modify
  14. ;; it under the terms of the GNU General Public License as published by
  15. ;; the Free Software Foundation; either version 2, or (at your option)
  16. ;; any later version.
  17. ;; This file is distributed in the hope that it will be useful,
  18. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. ;; GNU General Public License for more details.
  21. ;; You should have received a copy of the GNU General Public License
  22. ;; along with GNU Emacs; see the file COPYING. If not, write to
  23. ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  24. ;; Boston, MA 02111-1307, USA.
  25. ;;; Commentary:
  26. ;; The homepage for Alpha Tan's original vimrc mode is
  27. ;; <http://vimrc-mode.sf.net>
  28. ;;; Code:
  29. (require 'font-lock)
  30. (defgroup vimrc-mode nil
  31. "Major mode for editing Vim script."
  32. :link '(url-link "https://github.com/mcandre/vimrc-mode")
  33. :group 'languages)
  34. (defcustom vimrc-mode-hook nil
  35. "Normal hook run when entering vimrc-mode."
  36. :type 'hook
  37. :group 'vimrc-mode)
  38. (defgroup vimrc-faces nil
  39. "Faces used for Vim script."
  40. :group 'faces)
  41. (defface vimrc-option
  42. '((default :inherit font-lock-variable-name-face))
  43. "Face used for Vim's configuration options.")
  44. (defface vimrc-function-builtin
  45. '((default :inherit font-lock-builtin-face))
  46. "Face used for Vim's built-in functions.")
  47. (defface vimrc-command
  48. '((default :inherit font-lock-keyword-face))
  49. "Face used for Vim Ex commands.")
  50. (defface vimrc-number
  51. '((((class color) (background light)) (:foreground "steel blue"))
  52. (((class color) (background dark)) (:foreground "sky blue"))
  53. (t nil))
  54. "Face used for Vim's numbers.")
  55. ;; Font lock linking
  56. (defvar vimrc-font-lock-keywords
  57. `(
  58. ;; Line comment
  59. ("^[\t ]*\\(\"\\)\\(.*\\)$"
  60. (1 font-lock-comment-delimiter-face)
  61. (2 font-lock-comment-face))
  62. ;; Trailing comment
  63. ("[\t ]+\\(\"\\)\\([^\"\r\n]*\\)$"
  64. (1 font-lock-comment-delimiter-face)
  65. (2 font-lock-comment-face))
  66. ;; String start:
  67. ("\\(\"[^\n\r\"]*\"\\)\\|\\('[^\n\r]*'\\)"
  68. (0 font-lock-string-face)) ;; String end;
  69. ;; Function-name start:
  70. ("^[ \t]*\\(fun\\(?:ction\\)?\\)!?[ \t]+\\([a-zA-Z0-9_:#]+\\)?"
  71. (2 font-lock-function-name-face nil t)) ;; Function-name end;
  72. ("\\(\\([a-zA-Z]*:\\)?[a-zA-Z]*\\)("
  73. (1 font-lock-function-name-face nil t)) ;; Function-name end;
  74. ;; Variables
  75. ("\\<[bwglsav]:[a-zA-Z_][a-zA-Z0-9#_]*\\>"
  76. (0 font-lock-variable-name-face))
  77. ("\\(let[ \t]+\\)\\<\\([a-zA-Z_][a-zA-Z0-9#_]*\\)\\>"
  78. (2 font-lock-variable-name-face))
  79. ;; Options which can be prefixed with `no'
  80. (,(concat "[^_]\\<\\(\\(?:no\\)?"
  81. (regexp-opt '("autochdir" "acd"
  82. "allowrevins" "ari"
  83. "altkeymap" "akm"
  84. "antialias" "anti"
  85. "arabic" "arab"
  86. "arabicshape" "arshape"
  87. "autoindent" "ai"
  88. "autoread" "ar"
  89. "autowrite" "aw"
  90. "autowriteall" "awa"
  91. "backup" "bk"
  92. "ballooneval" "beval"
  93. "binary" "bin"
  94. "bioskey" "biosk"
  95. "bomb"
  96. "buflisted" "bl"
  97. "cindent" "cin"
  98. "compatible" "cp"
  99. "confirm" "cf"
  100. "conskey" "consk"
  101. "copyindent" "ci"
  102. "cscopetag" "cst"
  103. "cscopeverbose" "csverb"
  104. "cursorbind" "crb"
  105. "cursorcolumn" "cuc"
  106. "cursorline" "cul"
  107. "delcombine" "deco"
  108. "diff"
  109. "digraph" "dg"
  110. "edcompatible" "ed"
  111. "endofline" "eol"
  112. "equalalways" "ea"
  113. "errorbells" "eb"
  114. "esckeys" "ek"
  115. "expandtab" "et"
  116. "exrc" "ex"
  117. "fkmap" "fk"
  118. "foldenable" "fen"
  119. "gdefault" "gd"
  120. "guipty"
  121. "hidden" "hid"
  122. "hkmap" "hk"
  123. "hkmapp" "hkp"
  124. "hlsearch" "hls"
  125. "icon"
  126. "ignorecase" "ic"
  127. "imcmdline" "imc"
  128. "imdisable" "imd"
  129. "incsearch" "is"
  130. "infercase" "inf"
  131. "insertmode" "im"
  132. "joinspaces" "js"
  133. "lazyredraw" "lz"
  134. "linebreak" "lbr"
  135. "lisp"
  136. "list"
  137. "loadplugins" "lpl"
  138. "macatsui"
  139. "magic"
  140. "modeline" "ml"
  141. "modifiable" "ma"
  142. "modified" "mod"
  143. "more"
  144. "mousefocus" "mousef"
  145. "mousehide" "mh"
  146. "number" "nu"
  147. "opendevice" "odev"
  148. "paste"
  149. "preserveindent" "pi"
  150. "previewwindow" "pvw"
  151. "prompt"
  152. "readonly" "ro"
  153. "relativenumber" "rnu"
  154. "remap"
  155. "restorescreen" "rs"
  156. "revins" "ri"
  157. "rightleft" "rl"
  158. "ruler" "ru"
  159. "scrollbind" "scb"
  160. "secure"
  161. "shellslash" "ssl"
  162. "shelltemp" "stmp"
  163. "shiftround" "sr"
  164. "shortname" "sn"
  165. "showcmd" "sc"
  166. "showfulltag" "sft"
  167. "showmatch" "sm"
  168. "showmode" "smd"
  169. "smartcase" "scs"
  170. "smartindent" "si"
  171. "smarttab" "sta"
  172. "spell"
  173. "splitbelow" "sb"
  174. "splitright" "spr"
  175. "startofline" "sol"
  176. "swapfile" "swf"
  177. "tagbsearch" "tbs"
  178. "tagrelative" "tr"
  179. "tagstack" "tgst"
  180. "termbidi" "tbidi"
  181. "terse"
  182. "textauto" "ta"
  183. "textmode" "tx"
  184. "tildeop" "top"
  185. "timeout" "to"
  186. "title"
  187. "ttimeout"
  188. "ttybuiltin" "tbi"
  189. "ttyfast" "tf"
  190. "visualbell" "vb"
  191. "warn"
  192. "weirdinvert" "wiv"
  193. "wildmenu" "wmnu"
  194. "winfixheight" "wfh"
  195. "winfixwidth" "wfw"
  196. "wrap"
  197. "wrapscan" "ws"
  198. "write"
  199. "writeany" "wa"
  200. "writebackup" "wb"
  201. ) t)
  202. "\\)\\>[^_]" )
  203. 1 '(face vimrc-option))
  204. ;; The rest of the options
  205. (,(concat "[^_]"
  206. (regexp-opt '("aleph" "al"
  207. "ambiwidth" "ambw"
  208. "arabicshape" "arshape"
  209. "background" "bg"
  210. "backspace" "bs"
  211. "backupcopy" "bkc"
  212. "backupdir" "bdir"
  213. "backupext" "bex"
  214. "backupskip" "bsk"
  215. "balloondelay" "bdlay"
  216. "balloonexpr" "bexpr"
  217. "breakat" "brk"
  218. "breakindent" "bri"
  219. "breakindentopt" "briopt"
  220. "browsedir" "bsdir"
  221. "bufhidden" "bh"
  222. "buftype" "bt"
  223. "casemap" "cmp"
  224. "cdpath" "cd"
  225. "cedit"
  226. "charconvert" "ccv"
  227. "cinkeys" "cink"
  228. "cinoptions" "cino"
  229. "cinwords" "cinw"
  230. "clipboard" "cb"
  231. "cmdheight" "ch"
  232. "cmdwinheight" "cwh"
  233. "colorcolumn" "cc"
  234. "columns" "co"
  235. "comments" "com"
  236. "commentstring" "cms"
  237. "complete"
  238. "completefunc" "cfu"
  239. "completeopt" "cot"
  240. "concealcursor" "cocu"
  241. "conceallevel" "cole"
  242. "cpoptions" "cpo"
  243. "cryptmethod" "cm"
  244. "cscopepathcomp" "cspc"
  245. "cscopeprg" "csprg"
  246. "cscopequickfix" "csqf"
  247. "cscopetagorder" "csto"
  248. "cscopeverbose" "csverb"
  249. "debug"
  250. "define" "def"
  251. "dictionary" "dict"
  252. "dex" "diffexpr"
  253. "dip" "diffopt"
  254. "directory" "dir"
  255. "display" "dy"
  256. "eadirection" "ead"
  257. "encoding" "enc"
  258. "equalprg" "ep"
  259. "errorfile" "ef"
  260. "errorformat" "efm"
  261. "eventignore" "ei"
  262. "fileencoding" "fenc"
  263. "fe"
  264. "fileencodings" "fencs"
  265. "fileformat" "ff"
  266. "fileformats" "ffs"
  267. "filetype" "ft"
  268. "fillchars" "fcs"
  269. "fkmap" "fk"
  270. "foldclose" "fcl"
  271. "foldcolumn" "fdc"
  272. "foldexpr" "fde"
  273. "foldignore" "fdi"
  274. "foldlevel" "fdl"
  275. "foldlevelstart" "fdls"
  276. "foldmarker" "fmr"
  277. "foldmethod" "fdm"
  278. "foldminlines" "fml"
  279. "foldnestmax" "fdn"
  280. "foldopen" "fdo"
  281. "foldtext" "fdt"
  282. "formatoptions" "fo"
  283. "formatlistpat" "flp"
  284. "formatprg" "fp"
  285. "formatexpr" "fex"
  286. "fsync" "fs"
  287. "grepformat" "gfm"
  288. "grepprg" "gp"
  289. "guicursor" "gcr"
  290. "guifont" "gfn"
  291. "guifontset" "gfs"
  292. "guifontwide" "gfw"
  293. "guiheadroom" "ghr"
  294. "guioptions" "go"
  295. "guitablabel" "gtl"
  296. "guitabtooltip" "gtt"
  297. "helpfile" "hf"
  298. "helpheight" "hh"
  299. "helplang" "hlg"
  300. "highlight" "hl"
  301. "history" "hi"
  302. "iconstring"
  303. "imactivatefunc" "imaf"
  304. "imactivatekey" "imak"
  305. "iminsert" "imi"
  306. "imsearch" "ims"
  307. "imstatusfunc" "imsf"
  308. "include" "inc"
  309. "includeexpr" "inex"
  310. "indentexpr" "inde"
  311. "indentkeys" "indk"
  312. "isfname" "isf"
  313. "isident" "isi"
  314. "iskeyword" "isk"
  315. "isprint" "isp"
  316. "key"
  317. "keymap" "kmp"
  318. "keymodel" "km"
  319. "keywordprg" "kp"
  320. "langmap" "lmap"
  321. "langmenu" "lm"
  322. "laststatus" "ls"
  323. "lines"
  324. "linespace" "lsp"
  325. "lispwords" "lw"
  326. "listchars" "lcs"
  327. "makeef" "mef"
  328. "makeprg" "mp"
  329. "matchpairs" "mps"
  330. "matchtime" "mat"
  331. "maxcombine" "mco"
  332. "maxfuncdepth" "mfd"
  333. "maxmapdepth" "mmd"
  334. "maxmem" "mm"
  335. "maxmempattern" "mmp"
  336. "maxmemtot" "mmt"
  337. "menuitems" "mis"
  338. "mkspellmem" "msm"
  339. "modelines" "mls"
  340. "mouse"
  341. "mousemodel" "mousem"
  342. "mouseshape" "mouses"
  343. "mousetime" "mouset"
  344. "mzquantum" "mzq"
  345. "nrformats" "nf"
  346. "numberwidth" "nuw"
  347. "omnifunc" "ofu"
  348. "operatorfunc" "opfunc"
  349. "osfiletype" "oft"
  350. "paragraphs" "para"
  351. "pastetoggle" "pt"
  352. "pex" "patchexpr"
  353. "patchmode" "pm"
  354. "path" "pa"
  355. "previewheight" "pvh"
  356. "printdevice" "pdev"
  357. "printencoding" "penc"
  358. "printexpr" "pexpr"
  359. "printfont" "pfn"
  360. "printheader" "pheader"
  361. "printmbcharset" "pmbcs"
  362. "printmbfont" "pmbfn"
  363. "printoptions" "popt"
  364. "pumheight" "ph"
  365. "quoteescape" "qe"
  366. "redrawtime" "rdt"
  367. "regexpengine" "re"
  368. "report"
  369. "rightleftcmd" "rlc"
  370. "rulerformat" "ruf"
  371. "runtimepath" "rtp"
  372. "scroll" "scr"
  373. "scrolljump" "sj"
  374. "scrolloff" "so"
  375. "scrollopt" "sbo"
  376. "sections" "sect"
  377. "selection" "sel"
  378. "selectmode" "slm"
  379. "sessionoptions" "ssop"
  380. "shell" "sh"
  381. "shellcmdflag" "shcf"
  382. "shellpipe" "sp"
  383. "shellquote" "shq"
  384. "shellredir" "srr"
  385. "shelltype" "st"
  386. "shellxescape" "sxe"
  387. "shellxquote" "sxq"
  388. "shiftwidth" "sw"
  389. "shortmess" "shm"
  390. "showbreak" "sbr"
  391. "showtabline" "stal"
  392. "sidescroll" "ss"
  393. "sidescrolloff" "siso"
  394. "softtabstop" "sts"
  395. "spellcapcheck" "spc"
  396. "spellfile" "spf"
  397. "spelllang" "spl"
  398. "spellsuggest" "sps"
  399. "statusline" "stl"
  400. "suffixes" "su"
  401. "suffixesadd" "sua"
  402. "swapsync" "sws"
  403. "switchbuf" "swb"
  404. "synmaxcol" "smc"
  405. "syntax" "syn"
  406. "tabline" "tal"
  407. "tabpagemax" "tpm"
  408. "tabstop" "ts"
  409. "taglength" "tl"
  410. "tags" "tag"
  411. "term"
  412. "termbidi" "tbidi"
  413. "termencoding" "tenc"
  414. "textwidth" "tw"
  415. "thesaurus" "tsr"
  416. "timeoutlen" "tm"
  417. "ttimeoutlen" "ttm"
  418. "titlelen"
  419. "titleold"
  420. "titlestring"
  421. "toolbar" "tb"
  422. "toolbariconsize" "tbis"
  423. "ttymouse" "ttym"
  424. "ttyscroll" "tsl"
  425. "ttytype" "tty"
  426. "undodir" "udir"
  427. "undolevels" "ul"
  428. "undoreload" "ur"
  429. "updatecount" "uc"
  430. "updatetime" "ut"
  431. "verbose" "vbs"
  432. "verbosefile" "vfile"
  433. "viewdir" "vdir"
  434. "viewoptions" "vop"
  435. "viminfo" "vi"
  436. "virtualedit" "ve"
  437. "whichwrap" "ww"
  438. "wildchar" "wc"
  439. "wildcharm" "wcm"
  440. "wildignore" "wig"
  441. "wildmode" "wim"
  442. "wildoptions" "wop"
  443. "winaltkeys" "wak"
  444. "window" "wi"
  445. "winheight" "wh"
  446. "winminheight" "wmh"
  447. "winminwidth" "wmw"
  448. "winwidth" "wiw"
  449. "wrapmargin" "wm"
  450. "wrapscan" "ws"
  451. "writedelay" "wd"
  452. ) 'words)
  453. "[^_]")
  454. 1 '(face vimrc-option))
  455. ;; Ex commands
  456. (,(concat "\\(^\\|[^_]\\)"
  457. (regexp-opt '("Next" "N"
  458. "Print" "P"
  459. "X"
  460. "abclear" "abc"
  461. "aboveleft" "abo"
  462. "all" "al"
  463. "am" "amenu" "an" "anoremenu"
  464. "argadd" "arga"
  465. "argdelete" "argd"
  466. "argdo"
  467. "argedit" "arge"
  468. "argglobal" "argg"
  469. "arglocal" "argl"
  470. "args" "ar"
  471. "argument" "argu"
  472. "ascii" "as"
  473. "augroup" "aug"
  474. "autocmd" "au"
  475. "bNext" "bN"
  476. "badd" "bad"
  477. "ball" "ba"
  478. "bdelete" "bd"
  479. "belowright" "bel"
  480. "bfirst" "bf"
  481. "blast" "bl"
  482. "bmodified" "bm"
  483. "bnext" "bn"
  484. "botright" "bo"
  485. "bprevious" "bp"
  486. "break" "brea"
  487. "breakadd" "breaka"
  488. "breakdel" "breakd"
  489. "breaklist" "breakl"
  490. "brewind" "br"
  491. "browse" "bro"
  492. "bufdo"
  493. "buffer" "b"
  494. "bunload" "bun"
  495. "bwipeout" "bw"
  496. "cNext" "cN"
  497. "cNfile" "cNf"
  498. "cabclear" "cabc"
  499. "caddbuffer" "caddb"
  500. "caddexpr" "cad"
  501. "caddfile" "caddf"
  502. "call" "cal"
  503. "catch" "cat"
  504. "cbuffer" "cb"
  505. "cc"
  506. "cclose" "ccl"
  507. "cd"
  508. "center" "ce"
  509. "cexpr" "cex"
  510. "cfile" "cf"
  511. "cfirst" "cfir"
  512. "cgetbuffer" "cgetb"
  513. "cgetexpr" "cgete"
  514. "cgetfile" "cg"
  515. "change" "c"
  516. "changes"
  517. "chdir" "chd"
  518. "checkpath" "ckpath"
  519. "checktime" "checkt"
  520. "clast" "cla"
  521. "clist" "cl"
  522. "close" "clo"
  523. "cm" "cmap"
  524. "cmapc" "cmapclear"
  525. "cme" "cmenu" "cnoreme" "cnoremenu"
  526. "cnewer" "cnew"
  527. "cnext" "cn"
  528. "cnfile" "cnf"
  529. "cno" "cnoremap"
  530. "colder" "col"
  531. "colo" "colorscheme"
  532. "comclear" "comc"
  533. "command" "com"
  534. "compiler" "comp"
  535. "confirm" "conf"
  536. "continue" "con"
  537. "copen" "cope"
  538. "copy" "co"
  539. "cpfile" "cpf"
  540. "cprevious" "cp"
  541. "cquit" "cq"
  542. "crewind" "cr"
  543. "cu" "cunmap"
  544. "cunabbrev" "cuna"
  545. "cwindow" "cw"
  546. "debuggreedy" "debugg"
  547. "delcommand" "delc"
  548. "delete" "d"
  549. "delfunction" "delf"
  550. "delmarks" "delm"
  551. "diffget" "diffg"
  552. "diffoff"
  553. "diffpatch"
  554. "diffput" "diffpu"
  555. "diffsplit"
  556. "diffthis"
  557. "diffupdate" "diffu"
  558. "digraphs" "dig"
  559. "display" "di"
  560. "djump" "dj"
  561. "dlist" "dl"
  562. "drop" "dr"
  563. "dsearch" "ds"
  564. "dsplit" "dsp"
  565. "earlier"
  566. "echoerr" "echoe"
  567. "echomsg" "echom"
  568. "echon"
  569. "edit" "e"
  570. "else" "el"
  571. "elseif" "elsei"
  572. "em" "emenu"
  573. "endf" "endfunction"
  574. "enew" "ene"
  575. "ex"
  576. "execute" "exe"
  577. "exit" "exi"
  578. "file" "fi" "f"
  579. "files" "buffers" "ls"
  580. "filetype" "filet"
  581. "finally" "fina"
  582. "find" "fin"
  583. "finish" "fini"
  584. "first" "fir"
  585. "fixdel" "fix"
  586. "fold" "fo"
  587. "foldclose" "foldc"
  588. "folddoclosed" "folddoc"
  589. "folddoopen" "foldd"
  590. "foldopen" "foldo"
  591. "for" "endfo" "endfor"
  592. "fu" "fun" "function"
  593. "goto" "go"
  594. "grep" "gr"
  595. "grepadd" "grepa"
  596. "hardcopy" "ha"
  597. "hide" "hid"
  598. "history" "his"
  599. "iabclear" "iabc"
  600. "if" "endif" "en"
  601. "ijump" "ij"
  602. "ilist" "il"
  603. "im" "imap"
  604. "imapc" "imapclear"
  605. "ime" "imenu" "inoreme" "inoremenu"
  606. "ino" "inoremap"
  607. "isearch" "is"
  608. "isplit" "isp"
  609. "iu" "iunmap"
  610. "iunabbrev" "iuna"
  611. "join" "j"
  612. "jumps" "ju"
  613. "k"
  614. "keepalt"
  615. "keepjumps" "keepj"
  616. "keepmarks" "kee"
  617. "lNext" "lN"
  618. "lNfile" "lNf"
  619. "laddbuffer" "laddb"
  620. "laddexpr" "lad"
  621. "laddfile" "laddf"
  622. "language" "lan"
  623. "last" "la"
  624. "later"
  625. "lbuffer" "lb"
  626. "lcd" "lc"
  627. "lchdir" "lch"
  628. "lclose" "lcl"
  629. "le" "left"
  630. "leftabove" "lefta"
  631. "let"
  632. "lexpr" "lex"
  633. "lfile" "lf"
  634. "lfirst" "lfir"
  635. "lgetbuffer" "lgetb"
  636. "lgetexpr" "lgete"
  637. "lgetfile" "lg"
  638. "lgrep" "lgr"
  639. "lgrepadd" "lgrepa"
  640. "list" "l"
  641. "ll"
  642. "llast" "lla"
  643. "llist" "lli"
  644. "lm" "lmap"
  645. "lmake" "lmak"
  646. "lmapc" "lmapclear"
  647. "ln" "lnoremap"
  648. "lnewer" "lnew"
  649. "lnext" "lne"
  650. "lnfile" "lnf"
  651. "loadview" "lo"
  652. "lockmarks" "loc"
  653. "lockvar" "lockv" "lockv"
  654. "lolder" "lol"
  655. "lopen" "lop"
  656. "lpfile" "lpf"
  657. "lprevious" "lp"
  658. "lrewind" "lr"
  659. "ltag" "lt"
  660. "lu" "lunmap"
  661. "lua" "lua"
  662. "luado" "luado"
  663. "luafile" "luafile"
  664. "lvimgrep" "lv"
  665. "lvimgrepadd" "lvimgrepa"
  666. "lwindow" "lw"
  667. "make" "mak"
  668. "map"
  669. "mapc" "mapclear"
  670. "mark" "ma"
  671. "marks"
  672. "match" "mat"
  673. "me" "menu" "noreme" "noremenu"
  674. "menutranslate" "menut"
  675. "mkexrc" "mk"
  676. "mksession" "mks"
  677. "mkspell" "mksp"
  678. "mkview" "mkvie"
  679. "mkvimrc" "mkv"
  680. "mode" "mod"
  681. "move" "m"
  682. "mzfile" "mzf"
  683. "mzscheme" "mz"
  684. "nbclose" "nbc"
  685. "nbkey" "nb"
  686. "nbstart" "nbs"
  687. "new"
  688. "next" "n"
  689. "nm" "nmap"
  690. "nmapc" "nmapclear"
  691. "nme" "nmenu" "nnoreme" "nnoremenu"
  692. "nn" "nnoremap"
  693. "no" "noremap" "nor"
  694. "nohlsearch" "noh"
  695. "nore" "norem"
  696. "number" "nu"
  697. "nun" "nunmap"
  698. "oldfiles" "ol"
  699. "om" "omap"
  700. "omapc" "omapclear"
  701. "ome" "omenu" "onoreme" "onoremenu"
  702. "only" "on"
  703. "ono" "onoremap"
  704. "open" "o"
  705. "options" "opt"
  706. "ou" "ounmap"
  707. "pclose" "pc"
  708. "pedit" "ped"
  709. "perl" "pe"
  710. "perldo" "perld"
  711. "pop" "po"
  712. "popu"
  713. "popup" "popu"
  714. "ppop" "pp"
  715. "preserve" "pre"
  716. "previous" "prev"
  717. "print" "p"
  718. "profdel" "profd"
  719. "profile" "prof"
  720. "promptfind" "promptf"
  721. "promptrepl" "promptr"
  722. "psearch" "ps"
  723. "ptNext" "ptN"
  724. "ptag" "pta"
  725. "ptfirst" "ptf"
  726. "ptjump" "ptj"
  727. "ptlast" "ptl"
  728. "ptnext" "ptn"
  729. "ptprevious" "ptp"
  730. "ptrewind" "ptr"
  731. "ptselect" "pts"
  732. "put" "pu"
  733. "pwd" "pw"
  734. "pyfile" "pyf"
  735. "python" "py"
  736. "qall" "qa"
  737. "quit" "q"
  738. "quitall" "quita"
  739. "read" "r"
  740. "recover" "rec"
  741. "redir" "redi"
  742. "redo" "red"
  743. "redraw" "redr"
  744. "redrawstatus" "redraws"
  745. "registers" "reg"
  746. "resize" "res"
  747. "retab" "ret"
  748. "return" "rn"
  749. "rewind" "rew"
  750. "right" "ri"
  751. "rightbelow" "rightb"
  752. "ruby" "rub"
  753. "rubydo" "rubyd"
  754. "rubyfile" "rubyf"
  755. "rundo"
  756. "runtime" "ru"
  757. "rviminfo" "sa"
  758. "sNext" "sN"
  759. "sall" "sal"
  760. "sandbox" "san"
  761. "sargument" "sa"
  762. "saveas" "sav"
  763. "sbNext" "sbN"
  764. "sball" "sba"
  765. "sbfirst" "sbf"
  766. "sblast" "sbl"
  767. "sbmodified" "sbm"
  768. "sbnext" "sbn"
  769. "sbprevious" "sbp"
  770. "sbrewind" "sbr"
  771. "sbuffer" "sb"
  772. "scriptencoding" "scripte"
  773. "scriptnames" "scrip"
  774. "set" "se"
  775. "setfiletype" "setf"
  776. "setglobal" "setg"
  777. "setlocal" "setl"
  778. "sfind" "sf"
  779. "sfirst" "sfir"
  780. "shell" "sh"
  781. "sign"
  782. "silent" "sil"
  783. "simalt" "sim"
  784. "slast" "sla"
  785. "sleep" "sl"
  786. "smagic" "sm"
  787. "smap" "smap"
  788. "smapc" "smapclear"
  789. "sme" "smenu" "snoreme" "snoremenu"
  790. "snext" "sn"
  791. "sniff" "sni"
  792. "snomagic" "sno"
  793. "snor" "snoremap"
  794. "sort" "sor"
  795. "source" "so"
  796. "spelldump" "spelld"
  797. "spellgood" "spe"
  798. "spellinfo" "spelli"
  799. "spellrepall" "spellr"
  800. "spellundo" "spellu"
  801. "spellwrong" "spellw"
  802. "split" "sp"
  803. "sprevious" "spr"
  804. "srewind" "sre"
  805. "stag" "sta"
  806. "startgreplace" "startg"
  807. "startinsert" "star"
  808. "startreplace" "startr"
  809. "stjump" "stj"
  810. "stop" "st"
  811. "stopinsert" "stopi"
  812. "stselect" "sts"
  813. "sunhide" "sun"
  814. "sunm" "sunmap"
  815. "suspend" "sus"
  816. "sview" "sv"
  817. "syncbind"
  818. "t"
  819. "tNext" "tN"
  820. "tab"
  821. "tabNext" "tabN"
  822. "tabclose" "tabc"
  823. "tabdo" "tabd"
  824. "tabedit" "tabe"
  825. "tabfind" "tabf"
  826. "tabfirst" "tabfir"
  827. "tablast" "tabl"
  828. "tabmove" "tabm"
  829. "tabnew"
  830. "tabnext" "tabn"
  831. "tabonly" "tabo"
  832. "tabprevious" "tabp"
  833. "tabrewind" "tabr"
  834. "tabs"
  835. "tag" "ta"
  836. "tags"
  837. "tcl" "tc"
  838. "tcldo" "tcld"
  839. "tclfile" "tclf"
  840. "tearoff" "te"
  841. "tfirst" "tf"
  842. "throw" "th"
  843. "tjump" "tj"
  844. "tlast" "tl"
  845. "tmenu" "tm"
  846. "tnext" "tn"
  847. "topleft" "to"
  848. "tprevious" "tp"
  849. "trewind" "tr"
  850. "try" "endt" "endtry"
  851. "tselect" "ts"
  852. "tunmenu" "tu"
  853. "unabbreviate" "una"
  854. "undo" "una"
  855. "undojoin" "undoj"
  856. "undolist" "undol"
  857. "unhide" "unh"
  858. "unlockvar" "unlo"
  859. "unm" "unmap"
  860. "unsilent" "uns"
  861. "update" "up"
  862. "verbose" "verb"
  863. "version" "ve"
  864. "vertical" "vert"
  865. "view" "vie"
  866. "vimgrep" "vim"
  867. "vimgrepadd" "vimgrepa"
  868. "visual" "vi"
  869. "vm" "vmap"
  870. "vmapc" "vmapclear"
  871. "vme" "vmenu" "vnoreme" "vnoremenu"
  872. "vn" "vnoremap"
  873. "vnew" "vne"
  874. "vsplit" "vs"
  875. "vu" "vunmap"
  876. "wNext" "wN"
  877. "wall" "wa"
  878. "while" "endwhile" "wh" "endw"
  879. "wincmd" "winc"
  880. "windo"
  881. "winpos" "winp"
  882. "winsize" "win"
  883. "wnext" "wn"
  884. "wprevious" "wp"
  885. "wq"
  886. "wqa" "wqall" "xa" "xall"
  887. "write" "w"
  888. "wsverb" "ws"
  889. "wundo"
  890. "wviminfo" "wv"
  891. "x" "xit"
  892. "xm" "xmap"
  893. "xmapc" "xmapclear"
  894. "xme" "xmenu" "xnoreme" "xnoremenu"
  895. "xn" "xnoremap"
  896. "xu" "xunmap"
  897. "yank" "y"
  898. ) 'words)
  899. "\\([^_]\\|$\\)")
  900. 2 '(face vimrc-command))
  901. ;; Built-in functions
  902. (,(concat "\\(^\\|[ \t]*\\)"
  903. (regexp-opt '("writefile"
  904. "winwidth"
  905. "winsaveview"
  906. "winrestview"
  907. "winrestcmd"
  908. "winnr"
  909. "winline"
  910. "winheight"
  911. "wincol"
  912. "winbufnr"
  913. "visualmode"
  914. "virtcol"
  915. "values"
  916. "undotree"
  917. "undofile"
  918. "type"
  919. "trunc"
  920. "tr"
  921. "toupper"
  922. "tolower"
  923. "tempname"
  924. "tanh"
  925. "tan"
  926. "taglist"
  927. "tagfiles"
  928. "tabpagewinnr"
  929. "tabpagenr"
  930. "tabpagebuflist"
  931. "system"
  932. "synstack"
  933. "synIDtrans"
  934. "synIDattr"
  935. "synID"
  936. "synconcealed"
  937. "substitute"
  938. "submatch"
  939. "strwidth"
  940. "strtrans"
  941. "strridx"
  942. "strpart"
  943. "strlen"
  944. "string"
  945. "stridx"
  946. "strftime"
  947. "strdisplaywidth"
  948. "strchars"
  949. "str2nr"
  950. "str2float"
  951. "sqrt"
  952. "split"
  953. "spellsuggest"
  954. "spellbadword"
  955. "soundfold"
  956. "sort"
  957. "sinh"
  958. "sin"
  959. "simplify"
  960. "shellescape"
  961. "setwinvar"
  962. "settabwinvar"
  963. "settabvar"
  964. "setreg"
  965. "setqflist"
  966. "setpos"
  967. "setmatches"
  968. "setloclist"
  969. "setline"
  970. "setcmdpos"
  971. "setbufvar"
  972. "serverlist"
  973. "server2client"
  974. "searchpos"
  975. "searchpairpos"
  976. "searchpair"
  977. "searchdecl"
  978. "search"
  979. "round"
  980. "reverse"
  981. "resolve"
  982. "repeat"
  983. "rename"
  984. "remove"
  985. "remote_send"
  986. "remote_read"
  987. "remote_peek"
  988. "remote_foreground"
  989. "remote_expr"
  990. "reltimestr"
  991. "reltime"
  992. "readfile"
  993. "range"
  994. "pumvisible"
  995. "printf"
  996. "prevnonblank"
  997. "pow"
  998. "pathshorten"
  999. "nr2char"
  1000. "nextnonblank"
  1001. "mzeval"
  1002. "mode"
  1003. "mkdir"
  1004. "min"
  1005. "max"
  1006. "matchstr"
  1007. "matchlist"
  1008. "matchend"
  1009. "matchdelete"
  1010. "matcharg"
  1011. "matchadd"
  1012. "match"
  1013. "mapcheck"
  1014. "maparg"
  1015. "map"
  1016. "log10"
  1017. "log"
  1018. "localtime"
  1019. "lispindent"
  1020. "line2byte"
  1021. "line"
  1022. "libcallnr"
  1023. "libcall"
  1024. "len"
  1025. "keys"
  1026. "join"
  1027. "items"
  1028. "islocked"
  1029. "isdirectory"
  1030. "insert"
  1031. "inputsecret"
  1032. "inputsave"
  1033. "inputrestore"
  1034. "inputlist"
  1035. "inputdialog"
  1036. "input"
  1037. "index"
  1038. "indent"
  1039. "iconv"
  1040. "hostname"
  1041. "hlID"
  1042. "hlexists"
  1043. "histnr"
  1044. "histget"
  1045. "histdel"
  1046. "histadd"
  1047. "hasmapto"
  1048. "haslocaldir"
  1049. "has_key"
  1050. "has"
  1051. "globpath"
  1052. "glob"
  1053. "getwinvar"
  1054. "getwinposy"
  1055. "getwinposx"
  1056. "gettabwinvar"
  1057. "gettabvar"
  1058. "getregtype"
  1059. "getreg"
  1060. "getqflist"
  1061. "getpos"
  1062. "getpid"
  1063. "getmatches"
  1064. "getloclist"
  1065. "getline"
  1066. "getftype"
  1067. "getftime"
  1068. "getfsize"
  1069. "getfperm"
  1070. "getfontname"
  1071. "getcwd"
  1072. "getcmdtype"
  1073. "getcmdpos"
  1074. "getcmdline"
  1075. "getcharmod"
  1076. "getchar"
  1077. "getbufvar"
  1078. "getbufline"
  1079. "get"
  1080. "garbagecollect"
  1081. "function"
  1082. "foreground"
  1083. "foldtextresult"
  1084. "foldtext"
  1085. "foldlevel"
  1086. "foldclosedend"
  1087. "foldclosed"
  1088. "fnamemodify"
  1089. "fnameescape"
  1090. "fmod"
  1091. "floor"
  1092. "float2nr"
  1093. "findfile"
  1094. "finddir"
  1095. "filter"
  1096. "filewritable"
  1097. "filereadable"
  1098. "feedkeys"
  1099. "extend"
  1100. "expr8"
  1101. "expand"
  1102. "exp"
  1103. "exists"
  1104. "eventhandler"
  1105. "eval"
  1106. "escape"
  1107. "empty"
  1108. "diff_hlID"
  1109. "diff_filler"
  1110. "did_filetype"
  1111. "delete"
  1112. "deepcopy"
  1113. "cursor"
  1114. "cscope_connection"
  1115. "count"
  1116. "cosh"
  1117. "cos"
  1118. "copy"
  1119. "contained"
  1120. "confirm"
  1121. "complete_check"
  1122. "complete_add"
  1123. "complete"
  1124. "col"
  1125. "clearmatches"
  1126. "cindent"
  1127. "char2nr"
  1128. "changenr"
  1129. "ceil"
  1130. "call"
  1131. "byteidx"
  1132. "byte2line"
  1133. "bufwinnr"
  1134. "bufnr"
  1135. "bufname"
  1136. "bufloaded"
  1137. "buflisted"
  1138. "bufexists"
  1139. "browsedir"
  1140. "browse"
  1141. "atan2"
  1142. "atan"
  1143. "asin"
  1144. "argv"
  1145. "argidx"
  1146. "argc"
  1147. "append"
  1148. "add"
  1149. "acos"
  1150. "abs"
  1151. ) 'words)
  1152. "\\([ \t]*(\\)")
  1153. 2 '(face vimrc-function-builtin))
  1154. ;; Numbers
  1155. ("\\<0[xX][[:xdigit:]]+"
  1156. (0 '(face vimrc-number)))
  1157. ("#[[:xdigit:]]\\{6\\}"
  1158. (0 '(face vimrc-number)))
  1159. (,(concat
  1160. "\\(\\<\\|-\\)[[:digit:]]+"
  1161. "\\(\\.[[:digit:]]+\\([eE][+-]?[[:digit:]]+\\)?\\)?")
  1162. 0 '(face vimrc-number))
  1163. ;;
  1164. ;; Operators start:
  1165. (,(concat "\\("
  1166. ;; word char
  1167. "\\(\\<isnot\\>\\)"
  1168. "\\|" "\\(\\<is\\>\\)"
  1169. "\\|" "\\(![=~]?[#?]?\\)"
  1170. "\\|" "\\(>[#\\\\?=]?[#?]?\\)"
  1171. "\\|" "\\(<[#\\\\?=]?[#?]?\\)"
  1172. "\\|" "\\(\\+=?\\)"
  1173. "\\|" "\\(-=?\\)"
  1174. "\\|" "\\(=[=~]?[#?]?\\)"
  1175. "\\|" "\\(||\\)"
  1176. "\\|" "\\(&&\\)"
  1177. "\\|" "\\(\\.\\)"
  1178. "\\)"
  1179. )
  1180. 1 font-lock-constant-face) ;; Operators end;
  1181. )
  1182. "Default expressions to highlight in Vimrc mode.")
  1183. ;; Support for Vim script
  1184. (defvar vimrc-imenu-generic-expression
  1185. '((nil "^\\(fun\\(?:ction\\)?\\)!?[[:blank:]]+\\([[:alnum:]_:#]+\\)?" 2)
  1186. (nil "^let[[:blank:]]+\\<\\([bwglsav]:[a-zA-Z_][[:alnum:]#_]*\\)\\>" 1)
  1187. (nil "^let[[:blank:]]+\\<\\([a-zA-Z_][[:alnum:]#_]*\\)\\>[^:]" 1))
  1188. "Value for `imenu-generic-expression' in Vimrc mode.
  1189. Create an index of the function and variable definitions in a
  1190. Vim file.")
  1191. (defun vimrc-beginning-of-defun (&optional arg)
  1192. "Move backward to the beginning of the current function.
  1193. With argument, repeat ARG times."
  1194. (interactive "p")
  1195. (re-search-backward (concat "^[ \t]*\\(fun\\(?:ction\\)?\\)\\b")
  1196. nil 'move (or arg 1)))
  1197. (defun vimrc-end-of-defun (&optional arg)
  1198. "Move forward to the next end of a function.
  1199. With argument, repeat ARG times."
  1200. (interactive "p")
  1201. (re-search-forward (concat "^[ \t]*\\(endf\\(?:unction\\)?\\)\\b")
  1202. nil 'move (or arg 1)))
  1203. (defvar vimrc-mode-syntax-table
  1204. (let ((table (make-syntax-table)))
  1205. (modify-syntax-entry ?' "\"" table)
  1206. (modify-syntax-entry ?\" "<" table)
  1207. (modify-syntax-entry ?\n ">" table)
  1208. (modify-syntax-entry ?# "_" table)
  1209. table))
  1210. ;;;###autoload (add-to-list 'auto-mode-alist '("\\.vim\\'" . vimrc-mode))
  1211. ;;;###autoload (add-to-list 'auto-mode-alist '("[._]?g?vimrc\\'" . vimrc-mode))
  1212. ;;;###autoload (add-to-list 'auto-mode-alist '("\\.exrc\\'" . vimrc-mode))
  1213. (defalias 'vimrc--parent-mode
  1214. (if (fboundp 'prog-mode) #'prog-mode #'fundamental-mode))
  1215. ;;;###autoload
  1216. (define-derived-mode vimrc-mode vimrc--parent-mode "Vimrc"
  1217. "Major mode for editing `vimrc', `xxx.vim' and `.exrc' configuration files."
  1218. :group 'vimrc-mode
  1219. :syntax-table vimrc-mode-syntax-table
  1220. (setq-local font-lock-defaults '(vimrc-font-lock-keywords))
  1221. (setq-local comment-start "\"")
  1222. (setq-local comment-end "")
  1223. ;(set (make-local-variable 'comment-start-skip) "\"\\* +")
  1224. (setq-local imenu-generic-expression vimrc-imenu-generic-expression)
  1225. (setq-local beginning-of-defun-function 'vimrc-beginning-of-defun)
  1226. (setq-local end-of-defun-function 'vimrc-end-of-defun)
  1227. (run-hooks 'vimrc-mode-hook))
  1228. (provide 'vimrc-mode)
  1229. ;;; vimrc-mode.el ends here