|
| 1 | +*elixir-tools.nvim.txt* For NVIM v0.8.0 Last change: 2023 May 09 |
| 2 | + |
| 3 | +============================================================================== |
| 4 | +Table of Contents *elixir-tools.nvim-table-of-contents* |
| 5 | + |
| 6 | +1. Overview |elixir-tools.nvim-overview| |
| 7 | + - Features |elixir-tools.nvim-overview-features| |
| 8 | +2. Install |elixir-tools.nvim-install| |
| 9 | + - lazy.nvim |elixir-tools.nvim-install-lazy.nvim| |
| 10 | + - packer.nvim |elixir-tools.nvim-install-packer.nvim| |
| 11 | +3. Getting Started |elixir-tools.nvim-getting-started| |
| 12 | + - Minimal Setup |elixir-tools.nvim-getting-started-minimal-setup| |
| 13 | + - Advanced Setup |elixir-tools.nvim-getting-started-advanced-setup| |
| 14 | +4. Features |elixir-tools.nvim-features| |
| 15 | + - ElixirLS |elixir-tools.nvim-features-elixirls| |
| 16 | + - credo-language-server |elixir-tools.nvim-features-credo-language-server| |
| 17 | + - Mix |elixir-tools.nvim-features-mix| |
| 18 | + - Projectionist |elixir-tools.nvim-features-projectionist| |
| 19 | + |
| 20 | +============================================================================== |
| 21 | +1. Overview *elixir-tools.nvim-overview* |
| 22 | + |
| 23 | +<https://discord.gg/6XdGnxVA2A> |
| 24 | + |
| 25 | +`elixir-tools.nvim` provides a nice experience for writing Elixir applications |
| 26 | +with Neovim <https://github.com/neovim/neovim>. |
| 27 | + |
| 28 | + |
| 29 | + Note: This plugin does not provide autocompletion, I recommend using nvim-cmp |
| 30 | + <https://github.com/hrsh7th/nvim-cmp>. |
| 31 | + |
| 32 | + Note: This plugin does not provide syntax highlighting, I recommend using |
| 33 | + nvim-treesitter <https://github.com/nvim-treesitter/nvim-treesitter>. |
| 34 | + |
| 35 | +FEATURES *elixir-tools.nvim-overview-features* |
| 36 | + |
| 37 | + |
| 38 | +- ElixirLS <https://github.com/elixir-lsp/elixir-ls> installation and configuration (uses the Neovim built-in LSP client) |
| 39 | +- credo-language-server <https://github.com/elixir-tools/credo-language-server> integration. |
| 40 | +- `:Mix` command with autocomplete |
| 41 | +- vim-projectionist <https://github.com/tpope/vim-projectionist> support |
| 42 | + |
| 43 | + |
| 44 | +============================================================================== |
| 45 | +2. Install *elixir-tools.nvim-install* |
| 46 | + |
| 47 | +Requires 0.8 |
| 48 | + |
| 49 | + |
| 50 | +LAZY.NVIM *elixir-tools.nvim-install-lazy.nvim* |
| 51 | + |
| 52 | +>lua |
| 53 | + { |
| 54 | + "elixir-tools/elixir-tools.nvim", |
| 55 | + event = { "BufReadPre", "BufNewFile" }, |
| 56 | + config = function() |
| 57 | + local elixir = require("elixir") |
| 58 | + local elixirls = require("elixir.elixirls") |
| 59 | + |
| 60 | + elixir.setup { |
| 61 | + credo = {}, |
| 62 | + elixirls = { |
| 63 | + enabled = true, |
| 64 | + settings = elixirls.settings { |
| 65 | + dialyzerEnabled = false, |
| 66 | + enableTestLenses = false, |
| 67 | + }, |
| 68 | + on_attach = function(client, bufnr) |
| 69 | + vim.keymap.set("n", "<space>fp", ":ElixirFromPipe<cr>", { buffer = true, noremap = true }) |
| 70 | + vim.keymap.set("n", "<space>tp", ":ElixirToPipe<cr>", { buffer = true, noremap = true }) |
| 71 | + vim.keymap.set("v", "<space>em", ":ElixirExpandMacro<cr>", { buffer = true, noremap = true }) |
| 72 | + end, |
| 73 | + } |
| 74 | + } |
| 75 | + end, |
| 76 | + dependencies = { |
| 77 | + "nvim-lua/plenary.nvim", |
| 78 | + }, |
| 79 | + } |
| 80 | +< |
| 81 | + |
| 82 | + |
| 83 | +PACKER.NVIM *elixir-tools.nvim-install-packer.nvim* |
| 84 | + |
| 85 | +>lua |
| 86 | + use({ "elixir-tools/elixir-tools.nvim", requires = { "nvim-lua/plenary.nvim" }}) |
| 87 | +< |
| 88 | + |
| 89 | + |
| 90 | +============================================================================== |
| 91 | +3. Getting Started *elixir-tools.nvim-getting-started* |
| 92 | + |
| 93 | + |
| 94 | +MINIMAL SETUP *elixir-tools.nvim-getting-started-minimal-setup* |
| 95 | + |
| 96 | +The minimal setup will configure both ElixirLS and credo-language-server. |
| 97 | + |
| 98 | +>lua |
| 99 | + require("elixir").setup() |
| 100 | +< |
| 101 | + |
| 102 | +ElixirLS and credo-language-server can be disabled by setting the `enabled` |
| 103 | +flag in the respective options table. |
| 104 | + |
| 105 | +>lua |
| 106 | + require("elixir").setup({ |
| 107 | + credo = {enable = false}, |
| 108 | + elixirls = {enable = false}, |
| 109 | + }) |
| 110 | +< |
| 111 | + |
| 112 | + |
| 113 | +ADVANCED SETUP *elixir-tools.nvim-getting-started-advanced-setup* |
| 114 | + |
| 115 | +While the plugin works with a minimal setup, it is much more useful if you add |
| 116 | +some personal configuration. |
| 117 | + |
| 118 | +Note: For ElixirLS, not specifying the `repo`, `branch`, or `tag` options will |
| 119 | +default to the latest release. |
| 120 | + |
| 121 | +>lua |
| 122 | + local elixir = require("elixir") |
| 123 | + local elixirls = require("elixir.elixirls") |
| 124 | + |
| 125 | + elixir.setup { |
| 126 | + credo = { |
| 127 | + port = 9000, -- connect via TCP with the given port. mutually exclusive with `cmd` |
| 128 | + cmd = "path/to/credo-language-server", -- path to the executable. mutually exclusive with `port` |
| 129 | + on_attach = function(client, bufnr) |
| 130 | + -- custom keybinds |
| 131 | + end |
| 132 | + }, |
| 133 | + elixirls = { |
| 134 | + -- specify a repository and branch |
| 135 | + repo = "mhanberg/elixir-ls", -- defaults to elixir-lsp/elixir-ls |
| 136 | + branch = "mh/all-workspace-symbols", -- defaults to nil, just checkouts out the default branch, mutually exclusive with the `tag` option |
| 137 | + tag = "v0.13.0", -- defaults to nil, mutually exclusive with the `branch` option |
| 138 | + |
| 139 | + -- alternatively, point to an existing elixir-ls installation (optional) |
| 140 | + -- not currently supported by elixirls, but can be a table if you wish to pass other args `{"path/to/elixirls", "--foo"}` |
| 141 | + cmd = "/usr/local/bin/elixir-ls.sh", |
| 142 | + |
| 143 | + -- default settings, use the `settings` function to override settings |
| 144 | + settings = elixirls.settings { |
| 145 | + dialyzerEnabled = true, |
| 146 | + fetchDeps = false, |
| 147 | + enableTestLenses = false, |
| 148 | + suggestSpecs = false, |
| 149 | + }, |
| 150 | + on_attach = function(client, bufnr) |
| 151 | + vim.keymap.set("n", "<space>fp", ":ElixirFromPipe<cr>", { buffer = true, noremap = true }) |
| 152 | + vim.keymap.set("n", "<space>tp", ":ElixirToPipe<cr>", { buffer = true, noremap = true }) |
| 153 | + vim.keymap.set("v", "<space>em", ":ElixirExpandMacro<cr>", { buffer = true, noremap = true }) |
| 154 | + end |
| 155 | + } |
| 156 | + } |
| 157 | +< |
| 158 | + |
| 159 | + |
| 160 | +============================================================================== |
| 161 | +4. Features *elixir-tools.nvim-features* |
| 162 | + |
| 163 | + |
| 164 | +ELIXIRLS *elixir-tools.nvim-features-elixirls* |
| 165 | + |
| 166 | + |
| 167 | +AUTOMATIC INSTALLATION ~ |
| 168 | + |
| 169 | +When a compatible installation of ELixirLS is not found, you will be prompted |
| 170 | +to install it. The plugin will download the source code to the `.elixir_ls` |
| 171 | +directory and compile it using the Elixir and OTP versions used by your current |
| 172 | +project. |
| 173 | + |
| 174 | +Caveat: This assumes you are developing your project locally (outside of |
| 175 | +something like Docker) and they will be available. |
| 176 | + |
| 177 | +Caveat: This currently downloads the language server into the `.elixir_ls` |
| 178 | +directory in your repository, but it does install it into `~/.cache` and will |
| 179 | +re-use it when needed. |
| 180 | + |
| 181 | + |
| 182 | +ROOT PATH DETECTION ~ |
| 183 | + |
| 184 | +`elixir-tools.nvim` should be able to properly set the root directory for |
| 185 | +umbrella and non-umbrella apps. The nvim-lspconfig project’s root detection |
| 186 | +doesn’t properly account for umbrella projects. |
| 187 | + |
| 188 | + |
| 189 | +RUN TESTS ~ |
| 190 | + |
| 191 | +ElixirLS provides a codelens to identify and run your tests. If you configure |
| 192 | +`enableTestLenses = true` in the settings table, you will see the codelens as |
| 193 | +virtual text in your editor and can run them with `vim.lsp.codelens.run()`. |
| 194 | + |
| 195 | + |
| 196 | +COMMANDS ~ |
| 197 | + |
| 198 | + |
| 199 | + *elixir-tools.nvim-:ElixirFromPipe* |
| 200 | + |
| 201 | + |
| 202 | +:ElixirFromPipe Convert pipe operator to nested expressions. |
| 203 | + |
| 204 | + |
| 205 | + *elixir-tools.nvim-:ElixirToPipe* |
| 206 | + |
| 207 | + |
| 208 | +:ElixirToPipe Convert nested expressions to the pipe operator. |
| 209 | + |
| 210 | + |
| 211 | + |
| 212 | + |
| 213 | + *elixir-tools.nvim-:ElixirExpandMacro* |
| 214 | + |
| 215 | + |
| 216 | +:[range]ElixirExpandMacro For the given [range], expand any macros and display it in a floating window. |
| 217 | + |
| 218 | + |
| 219 | + |
| 220 | + |
| 221 | + *elixir-tools.nvim-:ElixirRestart* |
| 222 | + |
| 223 | + |
| 224 | +:ElixirRestart Restart ElixirLS, you must then reconnect your buffer with `:edit`. |
| 225 | + |
| 226 | + |
| 227 | + *elixir-tools.nvim-:ElixirOutputPanel* |
| 228 | + |
| 229 | + |
| 230 | +:ElixirOutputPanel Open the output panel that displays logs and compiler information from the server. |
| 231 | + |
| 232 | + |
| 233 | + |
| 234 | +>lua |
| 235 | + require("elixir").open_output_panel() |
| 236 | + require("elixir").open_output_panel({ window = "split" }) |
| 237 | + require("elixir").open_output_panel({ window = "vsplit" }) |
| 238 | + require("elixir").open_output_panel({ window = "float" }) |
| 239 | +< |
| 240 | + |
| 241 | + |
| 242 | +CREDO-LANGUAGE-SERVER *elixir-tools.nvim-features-credo-language-server* |
| 243 | + |
| 244 | + |
| 245 | + Note: The credo-language-server integration utilizes `Mix.install/2`, so you |
| 246 | + must be running Elixir >= 1.12 |
| 247 | + |
| 248 | +- Uses your project’s Credo version. |
| 249 | +- Full project diagnostics |
| 250 | +- Code Actions |
| 251 | + |
| 252 | + |
| 253 | +MIX *elixir-tools.nvim-features-mix* |
| 254 | + |
| 255 | +You can run any `mix` command in your project, complete with… autocomplete! |
| 256 | + |
| 257 | + |
| 258 | + *elixir-tools.nvim-:Mix* |
| 259 | + |
| 260 | + |
| 261 | +:Mix {args} Run any mix command. |
| 262 | + |
| 263 | + |
| 264 | + |
| 265 | + |
| 266 | +PROJECTIONIST *elixir-tools.nvim-features-projectionist* |
| 267 | + |
| 268 | +vim-projectionist <https://github.com/tpope/vim-projectionist> definitions are |
| 269 | +provided for: |
| 270 | + |
| 271 | + |
| 272 | +- Elixir files |
| 273 | +- Phoenix Views |
| 274 | +- Phoenix Controllers |
| 275 | +- Phoenix Channels |
| 276 | +- Wallaby/Hound Feature tests |
| 277 | + |
| 278 | +============================================================================== |
| 279 | +5. Links *elixir-tools.nvim-links* |
| 280 | + |
| 281 | +1. *Discord*: https://img.shields.io/badge/Discord-5865F3?style=flat&logo=discord&logoColor=white&link=https://discord.gg/nNDMwTJ8 |
| 282 | +2. *auto-install-elixirls*: https://user-images.githubusercontent.com/5523984/160333851-94d448d9-5c80-458c-aa0d-4c81528dde8f.gif |
| 283 | +3. *elixir-test-lens*: https://user-images.githubusercontent.com/5523984/159722637-ef1586d5-9d47-4e1a-b68b-6a90ad744098.gif |
| 284 | +4. *manipulate_pipes*: https://user-images.githubusercontent.com/5523984/160508641-cedb6ebf-3ec4-4229-9708-aa360b15a2d5.gif |
| 285 | +5. *expand_macro*: https://user-images.githubusercontent.com/5523984/162372669-4782baba-1889-4145-8a4f-e3bf13a6450d.gif |
| 286 | +6. *elixir-nvim-mix-demo*: https://user-images.githubusercontent.com/5523984/181859468-19d47a55-3f63-4af5-8698-4b5dd3459141.gif |
| 287 | + |
| 288 | +Generated by panvimdoc <https://github.com/kdheepak/panvimdoc> |
| 289 | + |
| 290 | +vim:tw=78:ts=8:noet:ft=help:norl: |
0 commit comments