1
0
Fork 0

Initial commit

This commit is contained in:
sloum 2021-09-15 22:57:00 -07:00
commit e3efeeb43c
5 changed files with 158 additions and 0 deletions

31
Makefile Normal file
View File

@ -0,0 +1,31 @@
UNAME := $(shell uname -s)
LANGNAME := slope
SYN := /syntax
FT := /ftdetect
PLUG := /ftplugin
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 -d ${ROOT}${PLUG}
install -m 0644 .${SYN}/${LANGNAME}.vim ${ROOT}${SYN}
install -m 0644 .${FT}/${LANGNAME}.vim ${ROOT}${FT}
install -m 0644 .${PLUG}/${LANGNAME}.vim ${ROOT}${PLUG}
.PHONY: remove
remove:
rm -rf ${ROOT}${SYN}/${LANGNAME}.vim
rm -rf ${ROOT}${FT}/${LANGNAME}.vim
rm -rf ${ROOT}${PLUG}/${LANGNAME}.vim

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# slope vim syntax
Vim syntax highlighting for the [slope language](https://git.rawtext.club/slope-lang).

11
ftdetect/slope.vim Normal file
View File

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

14
ftplugin/slope.vim Normal file
View File

@ -0,0 +1,14 @@
if exists("b:did_ftplugin")
finish
endif
setlocal lisp
setlocal tabstop=2
setlocal softtabstop=2
setlocal shiftwidth=2
setlocal comments=:;,:;;,:;;;
setlocal commentstring=;%s
setlocal nocindent
setlocal expandtab
let b:did_ftplugin = 1

99
syntax/slope.vim Normal file
View File

@ -0,0 +1,99 @@
" Vim syntax file
" Language: slope
" Maintainer: sloum <sloum@rawtext.club>,
" Last Change: Tue Sep 14 20:21:40 PST 2021
" Information about slope can be found at:
" https://git.rawtext.club/slope-lang
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
let b:current_syntax = "slope"
setlocal iskeyword=33,35-39,42-58,60-90,94,95,97-122,126,_
" slope special forms
syn keyword slopeCommand quote if and or cond set! define lambda usage
syn keyword slopeCommand begin begin0 filter load load-mod load-mod-file
" slope bools
syn match slopeBool "#[tf]"
" slope comments
syn keyword slopeTodo TODO XXX FIXME BUG NOTE DEBUG contained
syn region slopeComment start=/\;/ end=/$/ contains=slopeTodo
" slope escape
syn match slopeEscape /\\\h\{1}/ contained
" slope strings
syn region slopeString start=/\v"/ skip=/\v\\./ end=/\v"/ contains=slopeEscape
" catch errors caused by wrong parenthesis and brackets
syn cluster slopeAll contains=slopeRegion,slopeDelim,slopeFunction,slopeVariable,slopeComment,slopeParenError,slopeSpecial,slopeNumber,slopeClause,slopeCommand,slopeString,slopeEscape,slopeBool
syn region slopeRegion matchgroup=Delimiter start="(" skip="|.\{-}|" matchgroup=Delimiter end=")" contains=@slopeAll
syn region slopeRegion matchgroup=Delimiter start="'(" skip="|.\{-}|" matchgroup=Delimiter end=")" contains=@slopeAll
syn region slopeRegion matchgroup=Delimiter start="\[" skip="|.\{-}|" matchgroup=Delimiter end="\]" contains=@slopeAll
syn match slopeParenError "]"
syn match slopeParenError ")"
" slope specials
syn keyword slopeSpecial PI PHI E sys-args stdin stdout stderr devnull
" supporting integer numbers
syn match slopeNumber "[-+]\=[0-9]\+\(\.[0-9]*\)\=\(e[-+]\=[0-9]\+\)\=\>"
syn match slopeNumber "[-+]\=\.[0-9]\+\(e[-+]\=[0-9]\+\)\=\>"
syn match slopeNumber "[-+]\=[0-9]\+/[0-9]\+\>"
syn match slopeNumber "\([-+]\=\([0-9]\+\(\.[0-9]*\)\=\(e[-+]\=[0-9]\+\)\=\|\.[0-9]\+\(e[-+]\=[0-9]\+\)\=\|[0-9]\+/[0-9]\+\)\)\=[-+]\([0-9]\+\(\.[0-9]*\)\=\(e[-+]\=[0-9]\+\)\=\|\.[0-9]\+\(e[-+]\=[0-9]\+\)\=\|[0-9]\+/[0-9]\+\)\=i\>"
" slope commands
syn keyword slopeFunction positive? negative? zero? abs floor ceil round + - / * min max number->string rand
syn keyword slopeFunction > >= < <= not equal? number? string? bool? symbol? pair? null? list? procedure? atom? ~bool assoc? string-buf? io-handle?
syn keyword slopeFunction length cons car cdr append list map for-each list->string list-ref list-sort reverse assoc member? list-seed
syn keyword slopeFunction substring string-append string->number string-format string->list string-trim-space string-index-of string-ref string->sha256
syn keyword slopeFunction string-upper string-lower string-make-buf string-buf-clear regex-match? regex-find regex-replace string-fields string->md5
syn keyword slopeFunction newline display display-lines write write-raw read-line read-char read-all read-all-lines close file-create file-create-temp
syn keyword slopeFunction file-open-read file-open-write file-append-to file-stat file-name exit license apply ! exception-mode-panic exception-mode-panic?
syn keyword slopeFunction exception-mode-pass exception-mode-pass? term-size term-char-mode term-raw-mode term-cooked-mode term-sane-mode signal-catch-sigint
syn keyword slopeFunction mod-path path-exists? path-is-dir? path-abs path-join path-extension path-base path-dir path-glob chmod chdir env subprocess
syn keyword slopeFunction mkdir rm mv pwd net-conn url-scheme url-host url-port url-path url-query hostname timestamp date timestamp->date date->timestamp
syn keyword slopeFunction date-format sleep date-default-format
" 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_slope_syntax_inits")
if version < 508
let did_slope_syntax_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink slopeComment Comment
HiLink slopeFunction Function
HiLink slopeClause Operator
HiLink slopeDelim Delimiter
HiLink slopeNumber Number
HiLink slopeSpecial Constant
HiLink slopeString String
HiLink slopeBool Boolean
HiLink slopeCommand Statement
HiLink slopeParenError Error
HiLink slopeBracketError Error
HiLink slopeTodo Todo
HiLink slopeEscape Character
delcommand HiLink
endif