When working with Elixir in LazyVim, having quick access to documentation is essential for maintaining a smooth development workflow. This article explores how to set up and use the elixir-extras.nvim plugin to access Elixir documentation directly within your Neovim environment.
Setting Up elixir-extras.nvim
First, you'll need to add the plugin configuration to your LazyVim setup. Create or modify your plugins configuration file with the following code:
return {
{
"emmanueltouzery/elixir-extras.nvim",
lazy = true,
ft = "elixir",
dependencies = {
"nvim-telescope/telescope.nvim",
},
keys = {
{ "<leader>ed", function() require("elixir-extras").elixir_view_docs({}) end, desc = "Elixir View Docs" },
{ "<leader>em", function() require("elixir-extras").elixir_view_docs({ include_mix_libs = true }) end, desc = "Elixir View Docs (mix libs)" },
{ "<leader>ec", function() require("elixir-extras").module_complete() end, desc = "Elixir Module Complete" },
},
config = function()
require("elixir-extras").setup_multiple_clause_gutter()
end,
},
}
Understanding the Configuration
Let's break down the key components:
-
lazy = true
: Enables lazy loading for better startup performance -
ft = "elixir"
: Activates the plugin only for Elixir files -
dependencies
: Requires Telescope for the documentation viewer -
keys
: Maps specific key combinations for different documentation features
Key Bindings
The configuration sets up three main key bindings:
-
<leader>ed
: View Elixir core documentation -
<leader>em
: View documentation including mix dependencies -
<leader>ec
: Access module completion
Documentation Examples
Here's how the documentation viewer looks in Neovim:
Core Elixir Documentation (<leader>ed
)
Mix Dependencies Documentation (<leader>em
)
Accessing Third-Party Documentation
To ensure documentation for third-party libraries is available, you need to:
- Add
ex_doc
to your project dependencies:
defp deps do
[
{:ex_doc, "~> 0.35", only: :dev, runtime: false}
]
end
- Generate the documentation:
mix deps.get
mix docs
Benefits
This configuration provides several advantages:
- Instant documentation access without leaving Neovim
- Seamless integration with LazyVim's existing features
- Quick access to both core Elixir and third-party documentation
- Improved development workflow efficiency
Conclusion
By integrating elixir-extras.nvim
with LazyVim, you can significantly enhance your Elixir development experience. The quick access to documentation helps maintain flow while coding and reduces context switching between your editor and external documentation sources.
Remember to keep your documentation up to date by running mix docs
when adding new dependencies to ensure comprehensive documentation coverage in your development environment.
Top comments (0)