Skip to content
/ coal Public

General-purpose, high-level, statically typed programming language

License

Notifications You must be signed in to change notification settings

drewxs/coal

Repository files navigation

Coal

A simple type-safe programming language.

Examples here.

Important

WIP; No 0.1.0 release yet, check back later!

Installation

Install using Cargo (requires nightly rust):

cargo install --git https://github.com/drewxs/coal.git

Build from source (also requires nightly rust):

git clone https://github.com/drewxs/coal.git
cd coal
make

Usage

# Start the REPL
coal

# Create a new project
coal new PROJECT_NAME

# Run the current project or a given program
coal run [PROGRAM_PATH]

# Evaluate a string
coal eval STRING

# Format all files in the current project or from a given path
coal fmt [PATH]

Run coal --help for more information.

IDE support

Neovim

Example configuration using lazy.nvim: init.lua

Filetype detection

Add anywhere that's loaded by init.lua:

vim.filetype.add({
  extension = {
    coal = "coal",
  },
})

Syntax highlighting

Add to your treesitter config:

vim.treesitter.language.register("rust", "coal")

Using Rust grammar (for now) as it's the closest thing to Coal's syntax.

Formatting

Using no plugins:

vim.api.nvim_create_autocmd("BufWritePre", {
  pattern = "*.coal",
  callback = function()
    local view = vim.fn.winsaveview()
    vim.cmd("%!coal fmt")
    vim.fn.winrestview(view)
  end,
})

This is basic and won't handle things like preserving cursor positions when formatting extra newlines. For a more robust solution, you can use a formatter plugin like conform.nvim.

Using conform.nvim:

Add the following to your conform config:

{
  formatters = {
    coal_fmt = {
      command = "coal",
      args = { "fmt" },
      stdin = true,
    },
  },
  formatters_by_ft = {
    coal = { "coal_fmt" },
  },
}

VSCode

Install the Coal language extension locally (requires Node.js):

make vsc

A marketplace release will be available with v0.1.0.

Development

Prerequisites:

Run make help to print a list of available commands:


Apache License 2.0

About

General-purpose, high-level, statically typed programming language

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages