Skip to content

Commit

Permalink
Merge pull request #1277 from alex-s168/vim-syntax
Browse files Browse the repository at this point in the history
add vim + nvim syntax highlighting
  • Loading branch information
andrew-johnson-4 authored Feb 20, 2025
2 parents a448c5c + 0c4ad7b commit 20aa45a
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ An assembler takes pieces of data and sticks them together. Assemblers don't alw

A fragment is a Key-Value Map of Strings to S-Expressions. This data structure permits more detailed manipulation of code than a typical assembler.

### IDE Support

Currently, there is only Vim and NeoVim syntax highlighting.
[instructions](./vim/README.md)
5 changes: 5 additions & 0 deletions vim/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Vim (+ NeoVim) Syntax Highlighting

Copy the sub-directories of this folder to your Vim configuration home.

For NeoVim: `cp -r syntax ~/.config/nvim && cp -r ftplugin ~/.config/nvim && cp -r ftdetect ~/.config/nvim`
2 changes: 2 additions & 0 deletions vim/ftdetect/lsts.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
au BufRead,BufNewFile *.lsts set filetype=lsts
au BufRead,BufNewFile *.lm set filetype=lsts
3 changes: 3 additions & 0 deletions vim/ftplugin/lsts.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
setlocal tabstop=3
setlocal shiftwidth=3
setlocal expandtab
30 changes: 30 additions & 0 deletions vim/syntax/lsts.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
:syntax case match

:syntax keyword lstsKeyword let interface for while if else match import type fragment macro λ as zero
:syntax keyword lstsType Bool U8 U16 U32 U64 I8 I16 I32 I64 F32 F64 Nil
:syntax keyword lstsTODO TODO contained
:syntax match lstsOperator /==\|!=\|<=\|>=\|<\|>\|=\|=>\|\:\:\|\.\|+\|-\|\*\|\/\|&\||\|\'&/
:syntax match lstsIdentifier /\'\?\.\?\<[a-zA-Z_][a-zA-Z0-9_\-]*\>/
:syntax match lstsAdvIdentifier /\$"[^"\n]*"/ contains=lstsEscape
:syntax match lstsComment /#.*$/ contains=lstsTODO
:syntax match lstsNumber /\<\d\+\(\.\d\+\)\?\(_u64\|_u32\|_u16\|_u8\|_i64\|_i32\|_i16\|_i8\|_f32\|_f64\)\?\>/
:syntax match lstsBraces /[{}()\[\]]/
:syntax match lstsEscape /\\[nrt\\"']/ contained
:syntax match lstsString /\(c\|r\)\?"[^"\n]*"/ contains=lstsEscape
:syntax match lstsPath /\<\([a-zA-Z_][a-zA-Z0-9_\-]*\/\)*[a-zA-Z_][a-zA-Z0-9_\-]*\.\(lsts\|lm\|h\)\>/
:syntax match lstsPunctuation /[,;\:]/

:highlight link lstsKeyword Keyword
:highlight link lstsType Type
:highlight link lstsOperator Operator
:highlight link lstsFunction Function
:highlight link lstsComment Comment
:highlight link lstsNumber Number
:highlight link lstsBraces Delimiter
:highlight link lstsString String
:highlight link lstsPath String
:highlight link lstsEscape SpecialChar
:highlight link lstsTODO SpecialChar
:highlight link lstsPunctuation Delimiter
:highlight link lstsIdentifier Identifier
:highlight link lstsAdvIdentifier Identifier

0 comments on commit 20aa45a

Please sign in to comment.