Add Vim syntax highlighting

This commit is contained in:
2026-04-10 11:06:06 -05:00
parent 525f4bd065
commit 042f21a9c6
3 changed files with 66 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
# Vim support for `str`
This directory provides Vim syntax highlighting and filetype detection for the `str` string manipulation language.
## Installation
### Manual Installation
Copy the `ftdetect` and `syntax` directories into your Vim or Neovim configuration directory.
**For Vim:**
```bash
cp -r editor-support/vim/ftdetect ~/.vim/
cp -r editor-support/vim/syntax ~/.vim/
```
**For Neovim:**
```bash
cp -r editor-support/vim/ftdetect ~/.config/nvim/
cp -r editor-support/vim/syntax ~/.config/nvim/
```

View File

@@ -0,0 +1 @@
au BufRead,BufNewFile *.str,.str.rc set filetype=str

View File

@@ -0,0 +1,45 @@
" Vim syntax file
" Language: str (Interactive string manipulation environment)
" Maintainer: Garrett Mills <shout@garrettmills.dev>
if exists("b:current_syntax")
finish
endif
" Keywords (commands)
syn keyword strKeyword exit paste copy infile outfile assign clear show undo redo history edit save load runfile script
syn keyword strKeyword enclose lower upper lsub rsub prefix suffix quote unquote replace rev trim indent concat
syn keyword strKeyword line word each on drop take missing lines words split chunk join sort unique zip
syn match strKeyword "\<contains\>"
syn keyword strKeyword to from set over call lipsum
" Types
syn match strType "::\s*\zs\(string\|int\|destructured\)"
" Variables
syn match strVariable "\$\w\+"
" Operators
syn match strOperator "="
syn match strOperator ";"
syn match strOperator "::"
" Delimiters
syn match strDelimiter "[()|]"
" Strings
syn region strString start="'" end="'" skip="\\'"
" Comments
syn match strComment "--.*$"
" Default highlighting
hi def link strKeyword Keyword
hi def link strType Type
hi def link strVariable Identifier
hi def link strOperator Operator
hi def link strDelimiter Delimiter
hi def link strString String
hi def link strComment Comment
let b:current_syntax = "str"