vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

forth.vim (2031B)


      1 " Vim filetype plugin
      2 " Language:	Forth
      3 " Maintainer:	Johan Kotlinski <kotlinski@gmail.com>
      4 " Last Change:	2023 Sep 15
      5 "		2024 Jan 14 by Vim Project (browsefilter)
      6 " URL:		https://github.com/jkotlinski/forth.vim
      7 
      8 if exists("b:did_ftplugin")
      9   finish
     10 endif
     11 let b:did_ftplugin = 1
     12 
     13 let s:cpo_save = &cpo
     14 set cpo&vim
     15 
     16 setlocal commentstring=\\\ %s
     17 setlocal comments=s:(,mb:\ ,e:),b:\\
     18 setlocal iskeyword=33-126,128-255
     19 
     20 let s:include_patterns =<< trim EOL
     21 
     22   \<\%(INCLUDE\|REQUIRE\)\>\s\+\zs\k\+\ze
     23   \<S"\s\+\zs[^"]*\ze"\s\+\%(INCLUDED\|REQUIRED\)\>
     24 EOL
     25 let &l:include = $'\c{ s:include_patterns[1:]->join('\|') }'
     26 
     27 let s:define_patterns =<< trim EOL
     28   :
     29   [2F]\=CONSTANT
     30   [2F]\=VALUE
     31   [2F]\=VARIABLE
     32   BEGIN-STRUCTURE
     33   BUFFER:
     34   CODE
     35   CREATE
     36   MARKER
     37   SYNONYM
     38 EOL
     39 let &l:define = $'\c\<\%({ s:define_patterns->join('\|') }\)'
     40 
     41 " assume consistent intra-project file extensions
     42 let &l:suffixesadd = "." .. expand("%:e")
     43 
     44 let b:undo_ftplugin = "setl cms< com< def< inc< isk< sua<"
     45 
     46 if exists("loaded_matchit") && !exists("b:match_words")
     47   let s:matchit_patterns =<< trim EOL
     48 
     49     \<\:\%(NONAME\)\=\>:\<EXIT\>:\<;\>
     50     \<IF\>:\<ELSE\>:\<THEN\>
     51     \<\[IF]\>:\<\[ELSE]\>:\<\[THEN]\>
     52     \<?\=DO\>:\<LEAVE\>:\<+\=LOOP\>
     53     \<CASE\>:\<ENDCASE\>
     54     \<OF\>:\<ENDOF\>
     55     \<BEGIN\>:\<WHILE\>:\<\%(AGAIN\|REPEAT\|UNTIL\)\>
     56     \<CODE\>:\<END-CODE\>
     57     \<BEGIN-STRUCTURE\>:\<END-STRUCTURE\>
     58   EOL
     59   let b:match_ignorecase = 1
     60   let b:match_words = s:matchit_patterns[1:]->join(',')
     61   let b:undo_ftplugin ..= "| unlet! b:match_ignorecase b:match_words"
     62   unlet s:matchit_patterns
     63 endif
     64 
     65 if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
     66   let b:browsefilter = "Forth Source Files (*.f, *.fs, *.ft, *.fth, *.4th)\t*.f;*.fs;*.ft;*.fth;*.4th\n"
     67   if has("win32")
     68     let b:browsefilter ..= "All Files (*.*)\t*\n"
     69   else
     70     let b:browsefilter ..= "All Files (*)\t*\n"
     71   endif
     72   let b:undo_ftplugin ..= " | unlet! b:browsefilter"
     73 endif
     74 
     75 let &cpo = s:cpo_save
     76 unlet s:cpo_save
     77 unlet s:define_patterns s:include_patterns