Git Product home page Git Product logo

dhall-alacritty's Introduction

dhall-alacritty

Archived

This repository hasn't been updated in a long time and it's guaranteed to no longer represent the actual configuration options of Alacritty. If I ever find the time and motivation to revisit this, here are some TODOs:

  • Figure out how to maintain different versions of the configuration in one repository. Meaning one for Alacritty 4.0.0, another for 5.0.0, and so on
  • Handle platform differences in a better way. Usually there's a common set of options which is then extended for each platform. The issue on combinding unions might be relevant

Quickstart

requires dhall to be installed

Create an alacritty.dhall file...

let Alacritty = https://raw.githubusercontent.com/cideM/dhall-alacritty/master/linux.dhall

in  Alacritty.Config::{
    , window = Alacritty.Window.Schema::{
      , decorations = Alacritty.Window.Decoration.full
      , startup_mode = Alacritty.Window.Startup.Fullscreen
      , dynamic_padding = True
      }
    , shell = Some { program = "/usr/bin/fish", args = [ "-l" ] }
    }

... and run dhall-to-yaml --file alacritty.dhall --output alacritty.yml

This will create the alacritty.yml configuration file with the defaults for linux and some customziations. For windows or macos, just use a different .dhall file in the import.

If you only want to override specific keys you can easily do so using with:

let Alacritty = ~/private/dhall-alacritty/linux.dhall

in  Alacritty.Config::{
    , font = ./mono.dhall
    , shell = Some { program = "/usr/bin/fish", args = [ "-l" ] }
    , colors = ./papercolor.dhall
    , key_bindings = ./keys_common.dhall
    }
  with window.decorations = Alacritty.Window.Decoration.full
  with window.dynamic_padding = True

(Notice that I no longer need to specify the Alacritty.Window.Schema::{})

Why

I started this as a way of learning Dhall but then it escalated a bit and I ended up adding types for the entire alacritty config, including types and defaults for all platforms. The major goal here was learning about the language and implementing a maximum of type safety, not ergonomics. It should cover the entire configuration but if something is missing (be it a type or a constructor) or if I misinterpreted the comments in https://github.com/alacritty/alacritty/blob/master/alacritty.yml please let me know by creating an issue here in the repository!

Overriding Defaults

Basics

You can already see an example of how to override defaults above. The record you import from the GitHub URL has keys for each configuration segment and under those keys you can find both the schema and also all constructors you might need. Keep in mind that overriding the defauls of a schema (that's what XXX::{ foo = "bar" } does) is a shallow operation. Meaning...

Foo::{ bar = { a = 1 } }

... will replace the record at bar with a new record. If bars type is bar : { a : Natural, b : Natural } then you'll get a type error since you didn't specify b. On the upside, you won't silently delete things due to the compiler safety.

Keybindings

For keybindings there are some more steps. There are common keybindings (valid on all platforms) and keybindings specific to each platform.

let Alacritty =
      https://raw.githubusercontent.com/cideM/dhall-alacritty/master/linux.dhall

let keys =
      https://raw.githubusercontent.com/cideM/dhall-alacritty/master/keys/common.dhall

let keysLinux =
      https://raw.githubusercontent.com/cideM/dhall-alacritty/master/keys/linux.dhall

let common =
      keys.showCommonBindings
        [ keys.CommonBinding.Action
            { key = "A"
            , mods = None (List keys.Modifier)
            , mode = None keys.Mode
            , action = keys.Action.SpawnNewInstance
            }
        ]

let linuxBindings =
      keysLinux.showBindings
        [ keysLinux.KbdIn.Action
            { key = "B"
            , mods = None (List keysLinux.Modifier)
            , mode = None keysLinux.Mode
            , action = keysLinux.Action.CopySelection
            }
        ]

in  Alacritty.Config::{
    , window = Alacritty.Window.Schema::{
      , decorations = Alacritty.Window.Decoration.full
      , startup_mode = Alacritty.Window.Startup.Fullscreen
      , dynamic_padding = True
      }
    , shell = Some { program = "/usr/bin/fish", args = [ "-l" ] }
    , key_bindings = common # linuxBindings
    }

You create a set of common bindings and a set of platform bindings, then you render both of them before joining them. The reason for this is a bit more complicated and not really relevant. Basically rendering the keybinding records (with showBindings) converts them into a platform which is valid regardless of platform.

Mousebindings

The same concept as for keybindings applies. There's a set of common bindings and platform specific bindings. Render them before joining the lists.

dhall-alacritty's People

Contributors

cidem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dhall-alacritty's Issues

checksum failure.

Hi, Thank you for your great job.

I am a newbie on dhall.
I would like to migrate my configuration to dhall, but I got checksum failure:

dhall: 
↳ https://raw.githubusercontent.com/cideM/dhall-alacritty/master/macos.dhall
  ↳ https://raw.githubusercontent.com/cideM/dhall-alacritty/master/keys/macos.dhall
    ↳ https://raw.githubusercontent.com/cideM/dhall-alacritty/master/keys/common.dhall
      ↳ https://prelude.dhall-lang.org/package.dhall sha256:10db3c919c25e9046833df897a8ffe2701dc390fa0893d958c3430524be5a43e

Error: Import integrity check failed

Expected hash:

↳ 10db3c919c25e9046833df897a8ffe2701dc390fa0893d958c3430524be5a43e

Actual hash:

↳ 21754b84b493b98682e73f64d9d57b18e1ca36a118b81b33d0a243de8455814b

How can I overcome this problem?

Best,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.