coc-autark
SoftmotionsAutark build-script completion for coc.nvim
Published Package Summary
coc-autark
CoC completion for
Autark build scripts (Autark and *.autark).
The extension is context-aware: it recognises the Autark rule bag structure and only offers what is meaningful at the cursor.
| Cursor position | Completion |
|---|---|
| top level / rule bodies | directives (set, cc, run, include, check, ...) |
set / let / library first word | parent, root, _ |
cc / cxx / host-cc / host-cxx | objects, consumes, modules |
run / run-on-install | exec, shell, consumes, produces, always, host |
if / and / or | conditions defined, eq, prefix, contains, in, and, or and their ! forms |
meta | name, version, license, ... |
toolchain | id, system, arch, bits, endian, cc, host-cc, runner, ... |
echo | init, setup, build |
check | check scripts from .autark/ plus the standard Autark scripts; file paths for changelog_gnu.sh / changelog_md.sh |
call | macros declared in the buffer |
install / install-sources | exact, then project files |
include / configure | project files |
${...} | built-in variables, set/let/library/env/option/macro/foreach/meta declarations of the current buffer, objects { ... } names, check-script result variables and variables of the included scripts / build cache |
S{...}, SS{...}, C{...}, CC{...}, %{...} | paths relative to the project root, the script directory, the project cache or the unit cache |
@{...}, @@{...}, ^{...}, &{...} | nothing (commands and expressions) |
Paths, check-script arguments and variables are completed with their documentation; every item is annotated with a short description in the preview window.
Requirements
- CoC
0.0.82or newer: the extension is an ES module and is loaded through CoC's ESM extension loader, which needs Node started with--experimental-vm-modules(CoC passes that flag by default); - Node.js 18 or newer;
- a buffer with filetype
autark. This repository ships theftdetect/autark.vimruntime file (Autark,*.autark), so installing the grammar as a Vim/Neovim plugin is enough; - for path and variable completion the file has to be saved inside a project,
i.e. below a directory containing the root
Autarkscript.
Installation
:CocInstall coc-autark
coc-autark lives in editors/coc of the
Softmotions/tree-sitter-autark
repository and is published to the npm registry from that directory
(npm publish).
Install from a checkout (development)
CoC only installs from the npm registry or from a GitHub repository whose root
package.json is the extension, so a local checkout is wired in manually:
cd editors/coc
ln -sfn "$PWD" ~/.config/coc/extensions/node_modules/coc-autark
and add the package to the dependencies of
~/.config/coc/extensions/package.json:
{
"dependencies": {
"coc-autark": "*"
}
}
Restart Neovim/Vim afterwards. Extension updates must be pulled manually because CoC skips symbolic links.
Variable inference
Autark evaluates many variables lazily, so the extension infers names from every
available source instead of only the current buffer. For ${...} completion the
candidates are, in this order:
- well-known variables (
AUTARK_*,INSTALL_*,CC,CFLAGS,SYSTEM_*,META_*,CHANGELOG_*, ...); - declarations of the buffer:
set/let/library(includingparent { ... }androot { ... }scopes),env,option,macro,foreach,metaandobjects { NAME }ofcc/cxx/host-cc/host-cxx; - result variables of check scripts whose last argument is the variable name
(
test_header.sh,test_symbol.sh,test_blocks.sh,fetch_resource.sh); - declarations of the whole project: the root
Autarkscript (the parent scope of every child) and every script reachable throughinclude, with the defining file and line in the item detail; - variables recorded by previous builds in the cache:
*.envfiles (name and current value, e.g. check results) and thee/senvironment entries of*.depsfiles. This scan is bounded (depth 3, 300 files) and cached for a few seconds.
The last two sources explain why a variable may be suggested even though it is not declared in the current script.
Notes and limitations
- Completion only: no diagnostics, no build invocation.
- Variables that come only from
-Dcommand line options or the environment (BUILD_TYPE,ENABLE_ASAN, ...) cannot be inferred statically; the common conventions are part of the built-in list. - Autark tokens may contain
-and/, which Vim does not consider keyword characters. The extension replaces the whole typed token, so completion keeps working for names such asrun-on-installand for paths. C{}/CC{}complete existing directories only; run a build to populateautark-cachebefore completing generated files.- Cache-derived variables reflect the last build: stale names of removed check scripts can still be suggested until the cache is cleaned.
Development
The extension is plain ES module JavaScript ("type": "module") without a build
step. Only lib/index.js imports coc.nvim; lib/provider.js receives the
API as an argument, so registration and configuration are testable with a fake
API, and the completion core (scan.js, paths.js, data.js,
completion.js) has no coc dependency at all.
node test/run.js
test/run.js documents the expectations of the scanner, the completion core
and the extension wiring.
- Autark build-script completion for coc.nvim
- onLanguage:autark
Want to build, test, or contribute to coc.nvim extensions? Explore our official SDK and testing toolkits.
Open Developer GuideVersion History
This published npm package does not include a history.md or changelog.md file. Browse its npm versions or repository releases for available release information.
Contributed Commands
All contributes.commands entries from the published package manifest for coc-autark@0.1.0.
This package does not declare any contributed commands.
Configuration Schema
All contributes.configuration entries from the published package manifest, including each raw property schema for coc-settings.json.
Raw JSON Schema
{
"type": "boolean",
"scope": "application",
"default": true,
"description": "Enable coc-autark completion"
}Raw JSON Schema
{
"type": "string",
"scope": "application",
"default": "autark-cache",
"description": "Project cache directory used by C{...}/CC{...} completion (relative to the project root)"
}Raw JSON Schema
{
"type": "array",
"scope": "application",
"default": [
"autark"
],
"description": "Filetypes where Autark completion is enabled"
}Raw JSON Schema
{
"type": "boolean",
"scope": "application",
"default": true,
"description": "Complete file paths for S{}, SS{}, C{}, CC{}, include, configure and install"
}Raw JSON Schema
{
"type": "array",
"scope": "application",
"default": [
".autark",
"autark"
],
"description": "Directories scanned for check scripts, searched in the current and parent script directories"
}