Vim syntax highlighting for BoxLang - a dynamic JVM language and runtime.
- π Table of Contents
- π Overview
- β¨ Features
- β‘ Installation
- π File Extensions
- βοΈ Manual Filetype Setting
- π¨ Syntax Highlighting Examples
- π BoxLang-Specific Features
- π¨ Customization
- π Code Folding
- π§ Troubleshooting
- π€ Contributing
- π License
- π Related Projects
This plugin provides comprehensive syntax highlighting for BoxLang script files (.bx, .bxs) and template files (.bxm). It includes support for:
- Script Syntax - Pure BoxLang script with modern language features
- Template Syntax - Markup-based BoxLang with
bx:tags and HTML - Cross-Syntax Embedding - Template islands in script files and
<bx:script>blocks in templates
- Modern Keywords:
class,interface,assert,final,package,abstract,static - Control Flow:
if,else,for,while,do,switch,case,try,catch,finally - Operators:
- Standard:
+,-,*,/,%,^,&,&&,||,! - Comparison:
==,!=,<>,>,<,>=,<= - Strict equality:
===,!== - Elvis operator:
?: - Bitwise (BoxLang-specific):
b|,b&,b^,b~,b<<,b>>,b>>>
- Standard:
- Functions:
- Arrow functions:
=> - Lambda functions:
-> - Static BIF references:
::
- Arrow functions:
- Annotations:
@name(...)with complex parameter support - String Interpolation:
#expression#within strings - Comments:
//,/* */,/** */(JavaDoc-style) - Component Islands: Triple backtick template blocks embedded in script
- Data Structures: Arrays, structs, queries
- Scopes:
variables,local,arguments,request,session,application,server, etc.
- HTML Support: Custom lightweight HTML syntax highlighting
- Multi-color support: Distinct colors for special tags (
html,head,body,script,style,link) vs standard tags DOCTYPEhighlighting- Full HTML comments support
<!-- --> - Integration within BoxLang tags
- Multi-color support: Distinct colors for special tags (
- bx: Tags: Native BoxLang component tags
- Control flow:
<bx:if>,<bx:elseif>,<bx:else>,<bx:for>,<bx:while>,<bx:switch>,<bx:case> - Output:
<bx:output> - Functions:
<bx:function>,<bx:argument>,<bx:return> - Error handling:
<bx:try>,<bx:catch>,<bx:finally>,<bx:throw>,<bx:rethrow> - Components:
<bx:component>,<bx:interface>,<bx:property> - Utility:
<bx:set>,<bx:include>,<bx:import>,<bx:param> - Advanced:
<bx:lock>,<bx:thread>,<bx:transaction>,<bx:abort>,<bx:exit>
- Control flow:
- Expression Interpolation:
#expression#in text and attributes - Template Comments:
<!--- ... ---> - Embedded Script:
<bx:script>blocks with full script syntax highlighting - Code Folding: Automatic folding for tag regions
Using lazy.nvim (Lua)
Add this to your plugin configuration (e.g., lua/plugins/boxlang.lua):
return {
{
"ortus-boxlang/vim-boxlang",
ft = { "boxlang", "boxlangTemplate" }, -- Optional: lazy load on filetype
init = function()
-- Any custom configuration here
end,
}
}Using vim-plug
Add to your .vimrc or init.vim:
Plug 'ortus-solutions/vim-boxlang'Then run:
:PlugInstallUsing Vundle
Add to your .vimrc:
Plugin 'ortus-solutions/vim-boxlang'Then run:
:PluginInstallUsing Pathogen
cd ~/.vim/bundle
git clone https://github.com/ortus-solutions/vim-boxlang.git-
Clone this repository:
git clone https://github.com/ortus-solutions/vim-boxlang.git
-
Copy the files to your vim runtime directory:
cp -r vim-boxlang/syntax ~/.vim/ cp -r vim-boxlang/ftdetect ~/.vim/
For NeoVim, use the same installation methods but replace ~/.vim with:
- Linux/macOS:
~/.config/nvim - Windows:
~/AppData/Local/nvim
The plugin automatically detects and applies syntax highlighting based on file extensions:
.bx- BoxLang script class/component files β Usesboxlangsyntax.bxs- BoxLang script files (executable) β Usesboxlangsyntax.bxm- BoxLang template/markup files β UsesboxlangTemplatesyntax
If automatic detection doesn't work, you can manually set the filetype:
" For script files
:setfiletype boxlang
" For template files
:setfiletype boxlangTemplateOr add to your file:
// For .bx/.bxs files, add at the top:
// vim: set filetype=boxlang:
<!--- For .bxm files, add at the top: --->
<!--- vim: set filetype=boxlangTemplate: --->/**
* BoxLang class example with modern syntax
*/
@Component
class UserService {
property String name;
property Number age;
public function init() {
this.name = "BoxLang";
return this;
}
/**
* Get user with arrow function
*/
public function getUser() => {
return {
name: this.name,
age: this.age,
active: true
};
}
// Lambda function
public function filter(array data) {
return data.filter((item) -> item.active === true);
}
// Bitwise operations
public function bitwiseExample() {
var flags = 5 b| 3; // Bitwise OR
return flags b& 1; // Bitwise AND
}
}
<!--- BoxLang template example --->
<bx:output>
<h1>Welcome to #variables.appName#!</h1>
<bx:if condition="user.isLoggedIn()">
<p>Hello, #user.getName()#</p>
<bx:else>
<p>Please log in</p>
</bx:if>
<bx:for array="#items#" index="i" item="item">
<div class="item-##i##">
#item.name#
</div>
</bx:for>
</bx:output>
<bx:script>
// Embedded script with full syntax highlighting
function loadData() {
var data = queryExecute("SELECT * FROM users");
return data;
}
</bx:script>This syntax file is specifically designed for BoxLang, not CFML/ColdFusion. Key differences:
- Uses
bx:prefix for tags (notcf) - Highlights
classkeyword (BoxLang native, vs CFML'scomponent) - Supports bitwise operators (
b|,b&,b^,b~,b<<,b>>,b>>>) - Strict equality operators (
===,!==) - Arrow functions (
=>) and lambda functions (->) assertstatementcastasoperator- Modern keywords:
final,package,interfaceas first-class
A separate CFML syntax file is available for ColdFusion compatibility mode.
You can customize the highlighting by adding to your .vimrc:
" Example: Change keyword color
hi boxlangKeyword ctermfg=cyan guifg=#00ffff
" Example: Change string color
hi boxlangStringSingle ctermfg=green guifg=#00ff00
hi boxlangStringDouble ctermfg=green guifg=#00ff00
" Example: Customize operator color
hi boxlangOperator ctermfg=yellow guifg=#ffff00
" Example: Make bitwise operators stand out
hi boxlangBitwiseOp ctermfg=magenta guifg=#ff00ffThe syntax files include folding support for major code blocks:
" Enable folding in your .vimrc
set foldenable
set foldmethod=syntax
set foldlevelstart=10
" Toggle fold with 'za'
" Open all folds with 'zR'
" Close all folds with 'zM'Folds are automatically created for:
- Classes and interfaces
- Functions
- Control structures (
if,for,while,switch,try) - Tag regions in templates
-
Verify filetype is set correctly:
:set filetype?
-
Check if syntax is enabled:
:syntax on
-
Reload the syntax file:
:syntax clear :edit
Ensure your color scheme supports the standard vim highlight groups. You can test with a built-in scheme:
:colorscheme desert
:colorscheme murphyContributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Test with various BoxLang files
- Submit a pull request
Apache 2.0 - See LICENSE file for details.
- BoxLang - Official BoxLang website
- BoxLang Runtime - BoxLang runtime and compiler
- VSCode BoxLang - BoxLang extension for VS Code
