Coder Social home page Coder Social logo

gleam-mode's Introduction

gleam-ts-mode: An Emacs Major Mode for Gleam

This mode uses tree-sitter (and Emacs 29's treesit package) under-the-hood for syntax highlighting and code navigation. If you're using an Emacs that's older than 29 (run M-x version to find out), or a version compiled without treesit (run M-: (treesit-available-p) to find out), you probably want gleam-mode instead.

gleam-mode.mp4

Setup

This project will eventually be hosted on MELPA. However, until that time, the best way to install this is first to clone the project:

$ git clone [email protected]:gleam-lang/gleam-mode

Then you'll need to load this from your init script (~/.emacs or ~/.config/emacs/init.el).

use-package (recommended)

(use-package gleam-ts-mode
  :load-path "~/path/to/gleam-mode")

Replace ~/path/to/gleam-mode with the path where you cloned gleam-mode.

vanilla

(add-to-list 'load-path "~/path/to/gleam-mode")
(load-library "gleam-ts-mode")

Replace ~/path/to/gleam-mode with the path where you cloned gleam-mode.

Install the Tree-Sitter Grammar

Unless you have the Gleam tree-sitter grammar installed and treesit knows where to find it, you'll want to run M-x gleam-ts-install-grammar. It should only take a moment, but does require that your OS has a C compiler available.

TODO

  • Syntax highlighting
  • Indentation
  • Imenu integration
  • Formatting
  • Completion?
  • REPL?

gleam-mode: An Alternative Emacs Major Mode for Gleam

This mode uses tree-sitter alongside tree-sitter-mode and tree-sitter-indent for syntax highlighting and code navigation.

gleam-mode.mp4

Setup

The best way to install this is first to clone the project:

$ git clone --recurse-submodules [email protected]:gleam-lang/gleam-mode

Then you'll need to load this from your init script (~/.emacs or ~/.config/emacs/init.el).

use-package (recommended)

(use-package gleam-mode
  :load-path "~/path/to/gleam-mode")

Replace ~/path/to/gleam-mode with the path where you cloned gleam-mode.

vanilla

(add-to-list 'load-path "~/path/to/gleam-mode")
(load-library "gleam-mode")

Replace ~/path/to/gleam-mode with the path where you cloned gleam-mode.

Configuration

gleam-mode ships with a gleam-format command that is not bound by default to any keybinding. To bind it:

use-package

Add :bind (:map gleam-mode-map (<binding> . gleam-format)) to your use-package declaration. e.g.

(use-package gleam-mode
  :load-path "~/path/to/gleam-mode"
  :bind (:map gleam-mode-map
              ("C-c g f" . gleam-format)))

(here "C-c g f" means Control+C followed by g followed by f)

vanilla

Add the following after the lines where you setup gleam-mode:

(define-key gleam-mode-map (kbd "C-c g f") 'gleam-format)

(here "C-c g f" means Control+C followed by g followed by f)

automatically format on save

Alternatively, add these lines to your configuration to automatically run gleam-format on save:

    (add-hook 'gleam-mode-hook
              (lambda () (add-hook 'before-save-hook 'gleam-format nil t)))

TODO

  • Syntax highlighting
  • Indentation (at least somewhat)
  • Formatting
  • Completion?
  • REPL?

License

This program is licensed under The Apache License, Version 2.0 or, at your option, under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. See LICENSE-apache for the terms of the Apache License, Version 2.0 or LICENSE-gpl for the terms of the GNU Public License, Version 3.

gleam-mode's People

Contributors

2ynn avatar benreyn avatar j3rn avatar lpil avatar mainshayne233 avatar picandocodigo avatar seubert avatar sidneymillen avatar

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.