Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

3 Commits

Repository files navigation

Neovim support for Factor

A Neovim plugin for the Factor programming language, providing vocabulary navigation, syntax highlighting, and auto-pairing support.

Features

  • 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

Installation

Using lazy.nvim

{
"factor/factor.nvim",
ft="factor",
config=function()
require("factor").setup({
-- Configuration options (see below)
})
end
}
use {
"factor/factor.nvim",
ft="factor",
config=function()
require("factor").setup({
-- Configuration options (see below)
})
end
}

Configuration

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"*[]?`{$\\"
})

Key Mappings

The plugin provides the following default key mappings:

KeyDescription
<Leader>fiGo to vocabulary implementation file
<Leader>fdGo to vocabulary documentation file
<Leader>ftGo to vocabulary tests file
<Leader>fvGo to a vocabulary (prompts for name)
<Leader>fnCreate a new vocabulary (prompts for name)

Commands

CommandDescription
:FactorVocab <name>Navigate to a vocabulary by name
:NewFactorVocab <name>Create a new vocabulary
:FactorVocabImplGo to the implementation file of the current vocabulary
:FactorVocabDocsGo to the documentation file of the current vocabulary
:FactorVocabTestsGo to the tests file of the current vocabulary

Auto-pairing

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 Space inside brackets adds padding: [][ | ]
  • Pressing Enter inside brackets creates a multi-line block
  • Backspace intelligently removes paired characters

File Structure

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

Vocabulary Roots

The plugin searches for vocabularies in the following locations:

  1. Standard Factor directories (core, basis, extra, work) under your Factor installation
  2. Custom paths defined in ~/.factor-roots (one path per line)
  3. Additional paths configured via the additional_vocab_roots option

Vocabulary roots can be specified using:

  • resource: prefix - relative to Factor installation directory
  • vocab: prefix - search in all vocabulary roots
  • Absolute paths

Requirements

  • Neovim 0.7.0 or higher
  • Factor programming language (for actual code execution)

Credits

Based on the original factor.vim Vimscript plugin.

About

Neovim plugin for the Factor programming language

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages