Browse Source

Cant seem to get string litterals working, vim regex is bonkers

master
Brian Evans 1 year ago
parent
commit
857e32c2d9
  1. 27
      Makefile
  2. 5
      ftdetect/nimf.vim
  3. 56
      syntax/nimf.vim

27
Makefile

@ -0,0 +1,27 @@
UNAME := $(shell uname -s)
LANGNAME := nimf
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

5
ftdetect/nimf.vim

@ -1,3 +1,2 @@
au BufRead,BufNewFile *.gmi,*.gemini set filetype=gmi
" Gemini protocol syntax for text/gemini files (*.gmi)
" will also work for *.gemini files
au BufRead,BufNewFile *.nimf,*.nh,*.nf set filetype=nimf

56
syntax/nimf.vim

@ -12,34 +12,44 @@ elseif exists("b:current_syntax")
finish
endif
" Handle monospaced blocks
syn region gmiMono start=/^```/ end=/^```/
" Characters allowed in keywords
if version >= 600
setlocal iskeyword=!,@,33-35,%,$,38-64,A-Z,91-96,a-z,123-126,128-255
else
set iskeyword=!,@,33-35,%,$,38-64,A-Z,91-96,a-z,123-126,128-255
endif
" Handle comment blocks
syn region nimfComment start=/(/ end=/)/
" syn match nimfStringLiteral '\v"\[ \t\]\+\.\*\[ \t\]\+"'
" syn region nimfStringLiteral start=/\v" / skip=/\v\\./ end=/\v "/
" Handle between one and three heading levels
syn match gmiHeader /^#\{1,3}[^#].*$/
" Adds highlighting for integers
syn match nimfInt '\<-\=[0-9]*[0-9]\+\>'
" Start a link line
syn match gmiLinkStart /^=>/ nextgroup=gmiLinkUrl skipwhite
" keywords for language keywords
syn keyword nimfConditional if then else
syn keyword nimfLoop do loop
syn keyword nimfStatement var svar
syn keyword nimfOperators + - / * % /% 0= ++ -- ! @ > < = >= <=
syn match nimfWordDef '\<:m\?\s*[^ \t]\+\>'
syn keyword nimfWordDef ;
syn keyword nimfInclude inline
syn match nimfInclude /module-end/
" An extremely naive way of handling the URL portion of the link line
" This is left naive in a deliberate attempt to be unambiguous about
" what part of a link line gemini considers to be the URL, regardless
" of whether or not it is a valid URL
syn match gmiLinkUrl /\S\+/ contained nextgroup=gmiLinkTitle skipwhite
" Skipping whitespace from the URL match all text, including whitespace,
" until the end of the line
syn match gmiLinkTitle /.*$/ contained
" let b:current_syntax = "nimf"
" Handle list items
syn match gmiListItem /^\*.*$/
highlight link nimfInclude Include
highlight link nimfWordDef Identifier
highlight link nimfStatement Identifier
highlight link nimfInt Number
highlight link nimfComment Comment
let b:current_syntax = "gmi"
highlight link nimfStringLiteral String
highlight link nimfOperators Special
highlight link nimfConditional Conditional
highlight link nimfLoop Repeat
highlight link nimfMemory SpecialChar
hi def link gmiMono Special
hi def link gmiHeader Constant
hi def link gmiLinkStart Todo
hi def link gmiLinkUrl Underlined
hi def link gmiLinkTitle String
hi def link gmiListItem Identifier

Loading…
Cancel
Save