initial commit (with much gratitude to sloum's slope syntax file)

master
mryouse 7 months ago
commit 29aa0c771b

@ -0,0 +1,27 @@
UNAME := $(shell uname -s)
LANGNAME := neb
SYN := /syntax
FT := /ftdetect
ifeq ($(OS), Windows_NT)
ROOT := $(HOME)/vimfiles
else
ifeq ($(UNAME), Haiku)
ROOT := /boot/home/config/settings/vim
else
ROOT := ~/.vim
endif
endif
.PHONY: install
install: ./syntax/${LANGNAME}.vim ./ftdetect/${LANGNAME}.vim
install -d ${ROOT}${SYN}
install -d ${ROOT}${FT}
install -m 0644 .${SYN}/${LANGNAME}.vim ${ROOT}${SYN}
install -m 0644 .${FT}/${LANGNAME}.vim ${ROOT}${FT}
.PHONY: remove
remove:
rm -rf ${ROOT}${SYN}/${LANGNAME}.vim
rm -rf ${ROOT}${FT}/${LANGNAME}.vim

@ -0,0 +1,9 @@
# neb vim syntax
Vim syntax highlighting for neb
## to install
Assuming neb is installed as `neb`:
```shell
neb vim-syntax-maker.neb >> syntax/neb.vim
make
```

@ -0,0 +1,11 @@
autocmd BufRead,BufNewFile *.neb set filetype=neb
let did_load_filetypes = 1
" finish if the filetype was detected
if did_filetype()
finish
endif
if getline(1) =~ '^#!.*neb'
setfiletype neb
endif

@ -0,0 +1,66 @@
" Vim syntax file
" Language: neb
" Maintainer: mryouse <mryouse@rawtext.club>
" with apologies to slope and ~sloum
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
let b:current_syntax = "neb"
setlocal iskeyword=33,35-39,42-58,60-90,94,95,97-122,126,_
" types
syn match nebType ":[a-zA-Z0-9\[\]]\+"
" :bool
syn match nebBool /\<#true\>/
syn match nebBool /\<#false\>/
" comments
syn keyword nebTodo TODO XXX FIXME BUG NOTE DEBUG contained
syn region nebComment start=/\;/ end=/$/ contains=nebTodo
" :string and escapes
syn region nebString start=/\v"/ skip=/\v\\./ end=/\v"/ contains=nebEscape
syn match nebEscape /\\\h\{1}/ contained
" catch errors caused by wrong parenthesis and brackets
syn cluster nebAll contains=nebRegion,nebComment,nebParenError,nebCommand,nebString,nebEscape,nebBool,nebType,nebFunc
syn region nebRegion matchgroup=Delimiter start="(" skip="|.\{-}|" matchgroup=Delimiter end=")" contains=@nebAll
syn match nebParenError ")"
" :number
syn match nebNumber /\<[0-9]\+\>/
syn match nebNumber /\<\.[0-9]\+\>/
syn match nebNumber /\<[0-9]\+\.\>/
syn match nebNumber /\<[0-9]\+\.[0-9]\+\>/
" synchronization
syn sync lines=100
" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
if version >= 508 || !exists("did_neb_syntax_inits")
if version < 508
let did_neb_syntax_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink nebComment Comment
HiLink nebString String
HiLink nebBool Boolean
HiLink nebCommand Statement
HiLink nebFunc Function
HiLink nebParenError Error
HiLink nebTodo Todo
HiLink nebEscape Character
HiLink nebType Type
HiLink nebNumber Number
delcommand HiLink
endif

@ -0,0 +1,17 @@
; vim-syntax-maker.neb
; by mryouse
;
; create a vim syntax file based on symbols available in the REPL
; all available function names, as string
(def all-funcs (map (lambda (x) (last (split x " ")))(map ->string (funcs))))
; statements get highlighted differently
(def statements (split "if and or branch def lambda func redef quote eval block use use-as type for-each for-count while assert" " "))
; everything that's not a statement
(def other (filter (lambda (x) (not (in? x statements))) all-funcs))
(print "\n\" generated by vim-syntax-maker.neb")
(print (concat "syn keyword nebCommand " (join statements " ")))
(print (concat "syn keyword nebFunc " (join other " ")))
Loading…
Cancel
Save