Neovim BAML Syntax Highlighting
A Neovim plugin to provide syntax highlighting for .baml files.
- Traditional Vim syntax highlighting.
- Optional Tree-sitter integration for advanced highlighting.
- Filetype detection and indentation settings.
- Optional automatic formatting of BAML files on save using
baml-cli.
Using lazy.nvim
-
Add the plugin to your plugin specifications (e.g.,
~/.config/nvim/lua/plugins.lua):{ "klepp0/nvim-baml-syntax", dependencies = { "nvim-treesitter/nvim-treesitter" }, config = function() -- This ensures lua/baml_syntax/init.lua is run, -- which registers the "baml" parser and configures Tree-sitter: require("baml_syntax").setup() end, } -
Run
:Lazy syncwithin Neovim to install the plugin. -
Open a
.bamlfile to verify that syntax highlighting and Tree-sitter integration work as expected.
Using Packer.nvim
-
Add the following to your Packer configuration (e.g.,
~/.config/nvim/lua/plugins.lua):use { "klepp0/nvim-baml-syntax", requires = { "nvim-treesitter/nvim-treesitter" }, config = function() require("baml_syntax").setup() end, }
-
Run
:PackerSyncto install. -
Open a
.bamlfile and confirm that highlighting is applied.
Using vim-plug
-
Add the plugin lines to your
init.vimor~/.config/nvim/init.vim:call plug#begin('~/.local/share/nvim/plugged') Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} Plug 'klepp0/nvim-baml-syntax' call plug#end()
-
Restart Neovim and run
:PlugInstallto install. -
Optionally configure Tree-sitter highlighting in your init.vim or lua config:
lua << EOF require("baml_syntax").setup() EOF
-
Open a
.bamlfile and ensure the syntax highlighting is active.
Open any .baml file in Neovim to see syntax highlighting in action.
You can have BAML files get formatted on save by calling passing
format_on_save = true to the require("baml_syntax").setup() call when you
initialize the plugin. For example:
require("baml_syntax").setup({
format_on_save = true, -- Set to true to enable formatting on save
baml_cli_path = "/path/to/baml-cli", -- Optional path to baml-cli executable if it's not on PATH
}):BamlFormat- Format the current BAML file
Contributions are welcome! Please open an issue or submit a pull request.