Vimcraft Docs / Editor API
Editor API Reference
Vimcraft provides a Neovim-compatible API for configuration and plugins.
Available APIs
- vim.opt - Editor options (number, cursorLine)
- vim.highlight() - Syntax highlighting
- vim.g/b/w/t/v - Variable scopes
vim.opt - Editor Options
Configure the editor with ergonomic option syntax.
// Line numbers vim.opt.number = true; // Cursor highlighting vim.opt.cursorLine = true;
See vim.opt for complete documentation.
vim.highlight - Syntax Highlighting
Customize syntax highlighting with the highlight function.
// Simple highlighting vim.highlight('Comment', { fg: '#6c6c6c' }); // With styling vim.highlight('Function', { fg: '#61afef', bold: true }); // Editor elements vim.highlight('CursorLine', { bg: '#2c323c' }); vim.highlight('LineNr', { fg: '#5a5a5a' });
See vim.highlight for complete documentation.
Variables and Scopes
Different variable scopes for configuration and state management.
Global Variables (vim.g)
// Leader key vim.g.mapLeader = ' '; vim.g.mapLocalLeader = ','; // Custom variables vim.g.myConfig = { theme: 'dark', fontSize: 14 };
Buffer Variables (vim.b)
// Buffer-specific settings vim.b.fileType = 'javascript'; vim.b.customFormatter = 'prettier';
Window Variables (vim.w)
// Window-specific state vim.w.statusLineActive = true;
Tab Variables (vim.t)
// Tab-specific state vim.t.tabName = 'Development';
Vim Variables (vim.v)
// Built-in Vim variables (read-only) const count = vim.v.count; const register = vim.v.register;
See Variables & Scopes for complete documentation.
Configuration Example
// ~/.config/vimcraft/init.ts // Leader key vim.g.mapLeader = ' '; // Display options vim.opt.number = true; vim.opt.cursorLine = true; // Custom theme const colors = { bg: '#1e1e1e', fg: '#d4d4d4', blue: '#61afef', green: '#98c379', red: '#e06c75', gray: '#6c6c6c' }; vim.highlight('Normal', { fg: colors.fg, bg: colors.bg }); vim.highlight('Comment', { fg: colors.gray, italic: true }); vim.highlight('String', { fg: colors.green }); vim.highlight('Function', { fg: colors.blue }); vim.highlight('CursorLine', { bg: '#2c323c' }); vim.highlight('LineNr', { fg: '#5a5a5a' }); console.log('ā Vimcraft configured!');
Related Documentation
- Configuration Guide - Learn how to configure Vimcraft
- Plugin Development - Build custom plugins
- Changelog - Track feature releases
- GitHub Repository - Source code and issues