• Stars
    star
    157
  • Rank 229,875 (Top 5 %)
  • Language
    Lua
  • Created about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Neovim plugin for Elixir

elixir-tools.nvim

Overview

Discord GitHub Discussions

elixir-tools.nvim provides a nice experience for writing Elixir applications with Neovim.

Note
This plugin does not provide autocompletion, I recommend using nvim-cmp.

Note
This plugin does not provide syntax highlighting, I recommend using nvim-treesitter.

Features

Install

Requires 0.8

lazy.nvim

{
  "elixir-tools/elixir-tools.nvim",
  version = "*",
  event = { "BufReadPre", "BufNewFile" },
  config = function()
    local elixir = require("elixir")
    local elixirls = require("elixir.elixirls")

    elixir.setup {
      nextls = {enable = true},
      credo = {},
      elixirls = {
        enable = true,
        settings = elixirls.settings {
          dialyzerEnabled = false,
          enableTestLenses = false,
        },
        on_attach = function(client, bufnr)
          vim.keymap.set("n", "<space>fp", ":ElixirFromPipe<cr>", { buffer = true, noremap = true })
          vim.keymap.set("n", "<space>tp", ":ElixirToPipe<cr>", { buffer = true, noremap = true })
          vim.keymap.set("v", "<space>em", ":ElixirExpandMacro<cr>", { buffer = true, noremap = true })
        end,
      }
    }
  end,
  dependencies = {
    "nvim-lua/plenary.nvim",
  },
}

packer.nvim

use({ "elixir-tools/elixir-tools.nvim", tag = "stable", requires = { "nvim-lua/plenary.nvim" }})

Getting Started

Minimal Setup

The minimal setup will configure both ElixirLS and credo-language-server.

require("elixir").setup()

NextLS, ElixirLS, and credo-language-server can be enabled/disabled by setting the enable flag in the respective options table.

The defaults are shown below.

require("elixir").setup({
  nextls = {enable = false},
  credo = {enable = true},
  elixirls = {enable = true},
})

Advanced Setup

While the plugin works with a minimal setup, it is much more useful if you add some personal configuration.

Note
For ElixirLS, not specifying the repo, branch, or tag options will default to the latest release.

local elixir = require("elixir")
local elixirls = require("elixir.elixirls")

elixir.setup {
  nextls = {
    enable = false, -- defaults to false
    port = 9000, -- connect via TCP with the given port. mutually exclusive with `cmd`. defaults to nil
    cmd = "path/to/next-ls", -- path to the executable. mutually exclusive with `port`
    on_attach = function(client, bufnr)
      -- custom keybinds
    end
  },
  credo = {
    enable = true, -- defaults to true
    port = 9000, -- connect via TCP with the given port. mutually exclusive with `cmd`. defaults to nil
    cmd = "path/to/credo-language-server", -- path to the executable. mutually exclusive with `port`
    version = "0.1.0-rc.3", -- version of credo-language-server to install and use. defaults to the latest release
    on_attach = function(client, bufnr)
      -- custom keybinds
    end
  },
  elixirls = {
    -- specify a repository and branch
    repo = "mhanberg/elixir-ls", -- defaults to elixir-lsp/elixir-ls
    branch = "mh/all-workspace-symbols", -- defaults to nil, just checkouts out the default branch, mutually exclusive with the `tag` option
    tag = "v0.14.6", -- defaults to nil, mutually exclusive with the `branch` option

    -- alternatively, point to an existing elixir-ls installation (optional)
    -- not currently supported by elixirls, but can be a table if you wish to pass other args `{"path/to/elixirls", "--foo"}`
    cmd = "/usr/local/bin/elixir-ls.sh",

    -- default settings, use the `settings` function to override settings
    settings = elixirls.settings {
      dialyzerEnabled = true,
      fetchDeps = false,
      enableTestLenses = false,
      suggestSpecs = false,
    },
    on_attach = function(client, bufnr)
      vim.keymap.set("n", "<space>fp", ":ElixirFromPipe<cr>", { buffer = true, noremap = true })
      vim.keymap.set("n", "<space>tp", ":ElixirToPipe<cr>", { buffer = true, noremap = true })
      vim.keymap.set("v", "<space>em", ":ElixirExpandMacro<cr>", { buffer = true, noremap = true })
    end
  }
}

Features

Commands

:Elixir {command} [{subcommand}]

: The main elixir-tools command

  ```vim
  :Elixir nextls uninstall
  ```

Full List

Command Subcommand Description
nextls uninstall Removes the nextls executable from the default location: ~/.cache/elixir-tools/nextls/bin/nextls

Next LS

Note
Next LS is disabled by default. Once it reaches feature parity with ElixirLS, it will switch to enabled by default.

Note
Next LS creates a .elixir-tools directory in your project root, but it's automatically ignored by git.

The language server for Elixir that just works. 😎

You can read more about it at https://www.elixir-tools.dev/next-ls.

Automatic Installation

Next LS is distributed as pre-compiled binaries, which are available from the Next LS GitHub releases page. elixir-tools.nvim will prompt you to install it if it is not found, and then will consequently download it from GitHub.

If you are using a package manager like Mason, you can set the cmd property of the nextls setup table and it will not prompt you to install and use it from there.

Commands

Next LS command are available as subcommands of the :Elixir command

Credo Language Server

Note
Credo Language Server integration utilizes Mix.install/2, so you must be running Elixir >= 1.12

Note
Credo Language Server creates a .elixir-tools directory in your project root. You'll want to add that to your gitignore.

  • Uses your project's Credo version.
  • Full project diagnostics
  • Code Actions

ElixirLS

Automatic Installation

When a compatible installation of ElixirLS is not found, you will be prompted to install it. The plugin will download the source code to the .elixir_ls directory and compile it using the Elixir and OTP versions used by your current project.

Caveat: This assumes you are developing your project locally (outside of something like Docker) and they will be available.

Caveat: This currently downloads the language server into the .elixir_ls directory in your repository, but it does install it into ~/.cache and will re-use it when needed.

auto-install-elixirls

Root Path Detection

elixir-tools.nvim should be able to properly set the root directory for umbrella and non-umbrella apps. The nvim-lspconfig project's root detection doesn't properly account for umbrella projects.

Run Tests

ElixirLS provides a codelens to identify and run your tests. If you configure enableTestLenses = true in the settings table, you will see the codelens as virtual text in your editor and can run them with vim.lsp.codelens.run().

elixir-test-lens

Commands

:ElixirFromPipe

: Convert pipe operator to nested expressions.

:ElixirToPipe

: Convert nested expressions to the pipe operator.

manipulate_pipes

:[range]ElixirExpandMacro

: For the given [range], expand any macros and display it in a floating window.

expand_macro

:ElixirRestart

: Restart ElixirLS, you must then reconnect your buffer with :edit.

:ElixirOutputPanel

: Open the output panel that displays logs and compiler information from the server.

require("elixir.elixirls").open_output_panel()
require("elixir.elixirls").open_output_panel({ window = "split" })
require("elixir.elixirls").open_output_panel({ window = "vsplit" })
require("elixir.elixirls").open_output_panel({ window = "float" })

Mix

You can run any mix command in your project, complete with... autocomplete!

:Mix {args}

: Run any mix command.

elixir-nvim-mix-demo

Projectionist

vim-projectionist integration!

:Esource {args}

: Create or edit a regular source module.

```vim
Esource my_app/accounts/team
```

:Etest {args}

: Create or edit a regular test module.

```vim
Etest my_app/accounts/team
```

:Etask {args}

: Create or edit a Mix task module.

```vim
Etask server.start
```

:Econtroller {args}

: Create or edit a Phoenix controller module.

```vim
Econtroller my_project_web/users
```

:Eview {args}

: Create or edit a Phoenix view module.

```vim
Eview my_project_web/users
```

:Ehtml {args}

: Create or edit a Phoenix HTML module.

```vim
Ehtml my_project_web/users
```

:Ejson {args}

: Create or edit a Phoenix JSON module.

```vim
Ejson my_project_web/users
```

:Ecomponent {args}

: Create or edit a Phoenix.Component module.

```vim
Ecomponent my_project_web/users
```

:Eliveview {args}

: Create or edit a Phoenix.LiveView module.

```vim
Eliveview my_project_web/users
```

:Elivecomponent {args}

: Create or edit a Phoenix.LiveComponent module.

```vim
Elivecomponent my_project_web/users
```

:Echannel {args}

: Create or edit a Phoenix channel module.

:Efeature {args}

: Create or edit a Wallaby test module.

More Repositories

1

temple

An HTML DSL for Elixir and Phoenix
Elixir
416
star
2

advent-of-code-elixir-starter

Template project for Advent of Code in Elixir.
Elixir
125
star
3

jekyll-tailwind-starter

Starter project for using Jekyll with Tailwind CSS
CSS
108
star
4

lazyasdf

Experimental TUI for asdf: a project to learn the art of the TUI.
Elixir
101
star
5

output-panel.nvim

A panel to view the logs from your LSP servers.
Lua
61
star
6

jekyll-postcss

A plugin to use PostCSS plugins like Autoprefixer or Tailwind CSS with Jekyll.
Ruby
60
star
7

schematic

πŸ“ schematic
Elixir
60
star
8

.dotfiles

My dotfiles
Lua
47
star
9

jekyll-purgecss

A Jekyll plugin for Purgecss.
Ruby
24
star
10

gen_lsp

A behaviour for creating language servers.
Elixir
21
star
11

early_return

early_return
Elixir
20
star
12

eex_compiler_visualizer

Elixir
16
star
13

everforest-textmate

Forest Night Color Scheme for editors using `tmTheme`
11
star
14

monkey

Monkey programming language interpreter implementations from the book "Writing an Interpreter in Go"
Elixir
10
star
15

contact

Instant Messaging application
Elixir
9
star
16

advent-of-code-clojure-starter

Template project for Advent of Code in Clojure.
Clojure
8
star
17

temple_phoenix

Integrates Temple and Phoenix
Elixir
7
star
18

install_fathom

Single command install of Fathom Analytics.
Shell
7
star
19

control-panel.nvim

experimental plugin, use with caution
Lua
5
star
20

advent-of-code

My Advent of Code solutions
Elixir
5
star
21

tableau

Experimental static site generator for Elixir
Elixir
5
star
22

everforest-alfred

5
star
23

silicon.lua

re-upload of 0oAstro/silicon.lua
Shell
5
star
24

blog

Jekyll source code for mitchellhanberg.com
HTML
4
star
25

pipsqueak

A modern and artisanal url shortener, with synergy.
Elixir
4
star
26

notebooks

4
star
27

sandrabbit

sandrabbit
Elixir
3
star
28

zk.nvim

Exploratory plugin for sharing my zk+fzf configuration
Lua
3
star
29

monkey.nvim

Neovim plugin for the Monkey language
Lua
3
star
30

while

Elixir
3
star
31

loop

loop
Elixir
3
star
32

thicc_forest

My Neovim Colorscheme
Lua
3
star
33

blabber

Live-coding presentation tutorial project
Elixir
3
star
34

nextls

Experimental language server for Elixir. Not for public usage.
Elixir
2
star
35

wallaby_httpoison_test

Elixir
2
star
36

tree-sitter-elixir

Tree Sitter parser for Elixir
JavaScript
2
star
37

const

Constants for Elixir!
Elixir
2
star
38

alfred-localhost

Workflow to open localhost with any port easily
2
star
39

workspace-folders.nvim

Lua
2
star
40

tableau_demo_heex

Demo showing a Tableau site using HEEx
Elixir
2
star
41

homebrew-zk

Ruby
2
star
42

tailwindcss-sketchpalette

A TailwindCSS .sketchpalette
2
star
43

wallaby_plug_demo

Example application to demonstrate using Wallaby to test a standalone JS app
Elixir
1
star
44

temple_live_view

Elixir
1
star
45

issue-test

1
star
46

follow_through

Elixir
1
star
47

Buggy-s-TV-Guide

A program for CS408 at Purdue University
Java
1
star
48

surface_playground

Elixir
1
star
49

ziglings

Zig
1
star
50

duck

what the duck
Elixir
1
star
51

one-thing-workflow

A workflow to control One Thing
1
star
52

CatFeeder

Ruby
1
star
53

Lunch

An app to facilitate meal improvement through data collection and metric calculation
Ruby
1
star
54

maigai

Experimental, Production Grade, Framework for Synergy
Elixir
1
star
55

lsp_codegen

Codegen for GenLSP
Elixir
1
star
56

inline_svg_test

Elixir
1
star
57

homebrew-tap

My personal homebrew tap
Ruby
1
star
58

enviro

HTML
1
star
59

ascii_dox

AsciiDoc implementation in Elixir
Elixir
1
star
60

neovim-macos-builder

Builds NeoVim artifacts for macOS
1
star
61

blabber2

"Twitter" Clone built with Aino and Temple
Elixir
1
star
62

tree-sitter-monkey

Tree Sitter parser for Monkey
C
1
star
63

workflow-test

1
star
64

daily-ui

Daily UI challenges
1
star
65

YAFBC

a silly flappy bird clone
Java
1
star
66

wallaby_bug_demo

Elixir
1
star
67

diplo

Elixir
1
star
68

isBroken.js

πŸ”₯ Modern πŸš€ Fast 🎨 Artisanal
JavaScript
1
star
69

seven-langs

Scala
1
star
70

wallaby_stress_test

Elixir
1
star
71

cli

the motch cli
Shell
1
star
72

wallamox

Elixir
1
star
73

.github

1
star
74

temple_example

Elixir
1
star
75

foobar

Elixir
1
star
76

temple_heex_interop

Elixir
1
star
77

config_test

Elixir
1
star
78

reddit-deleter

A script to delete all of your Reddit posts and comments
Ruby
1
star
79

euler

Project Euler solutions
Ruby
1
star
80

elsa

Elixir
1
star