A Neovim plugin for the Factor programming language, providing vocabulary navigation, syntax highlighting, and auto-pairing support.
- Vocabulary Navigation: Quickly navigate between Factor vocabularies and their related files (implementation, docs, tests)
- Syntax Highlighting: Full syntax highlighting for Factor code
- Auto-pairing: Smart bracket, quote, and parenthesis pairing (optional)
- File Type Detection: Automatic detection of Factor files and proper filetype setting
- Vocabulary Roots: Support for multiple vocabulary roots including custom paths
Using lazy.nvim
{
"factor/factor.nvim",
ft="factor",
config=function()
require("factor").setup({
-- Configuration options (see below)
})
end
}Using packer.nvim
use {
"factor/factor.nvim",
ft="factor",
config=function()
require("factor").setup({
-- Configuration options (see below)
})
end
}The plugin can be configured by calling the setup function:
require("factor").setup({
-- Path to your Factor installation (default: ~/factor/)resource_path=vim.fn.expand("~/factor/"),
-- Default vocabulary rootsdefault_vocab_roots= {
"resource:core",
"resource:basis", "resource:extra",
"resource:work"
},
-- Additional vocabulary roots (can also be set in ~/.factor-roots)additional_vocab_roots=nil,
-- Function to determine the root for new vocabulariesnew_vocab_root=function()
return"resource:work"end,
-- Enable smart auto-pairing of brackets, quotes, etc.enable_autopairs=false,
-- Characters to escape in glob patternsglob_escape=vim.loop.os_uname().sysname=="Windows" and"*[]?`{$" or"*[]?`{$\\"
})The plugin provides the following default key mappings:
| Key | Description |
|---|---|
<Leader>fi | Go to vocabulary implementation file |
<Leader>fd | Go to vocabulary documentation file |
<Leader>ft | Go to vocabulary tests file |
<Leader>fv | Go to a vocabulary (prompts for name) |
<Leader>fn | Create a new vocabulary (prompts for name) |
| Command | Description |
|---|---|
:FactorVocab <name> | Navigate to a vocabulary by name |
:NewFactorVocab <name> | Create a new vocabulary |
:FactorVocabImpl | Go to the implementation file of the current vocabulary |
:FactorVocabDocs | Go to the documentation file of the current vocabulary |
:FactorVocabTests | Go to the tests file of the current vocabulary |
When enable_autopairs is set to true, the plugin provides intelligent auto-pairing:
[→[]with cursor in between(→()with cursor in between{→{}with cursor in between"→""with cursor in between[+=→[=|=]for literal arrays(+Space→( -- )for stack effects- Pressing
Spaceinside brackets adds padding:[]→[ | ] - Pressing
Enterinside brackets creates a multi-line block Backspaceintelligently removes paired characters
The plugin recognizes the following Factor file conventions:
*.factor- Factor source files*-docs.factor- Documentation files*-tests.factor- Test files.factor-rc,factor-rc- Factor RC files~/.factor-roots- File containing additional vocabulary roots
The plugin searches for vocabularies in the following locations:
- Standard Factor directories (
core,basis,extra,work) under your Factor installation - Custom paths defined in
~/.factor-roots(one path per line) - Additional paths configured via the
additional_vocab_rootsoption
Vocabulary roots can be specified using:
resource:prefix - relative to Factor installation directoryvocab:prefix - search in all vocabulary roots- Absolute paths
- Neovim 0.7.0 or higher
- Factor programming language (for actual code execution)
Based on the original factor.vim Vimscript plugin.