Last active
September 19, 2024 07:46
-
-
Save TunkShif/9fff31262755f8f248c7b0b19a5594d5 to your computer and use it in GitHub Desktop.
neovim config for elixir development
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- set your leader and local leader key | |
-- make sure to set `mapleader` and `maplocalleader` before lazy so your mappings are correct | |
vim.g.mapleader = " " -- using space as leader key | |
vim.g.maplocalleader = "," -- using comma as local leader | |
-- bootstrap lazy.nvim plugin manager | |
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" | |
if not (vim.uv or vim.loop).fs_stat(lazypath) then | |
vim.fn.system({ | |
"git", | |
"clone", | |
"--filter=blob:none", | |
"https://github.com/folke/lazy.nvim.git", | |
"--branch=stable", | |
lazypath, | |
}) | |
end | |
vim.opt.rtp:prepend(lazypath) | |
require("lazy").setup({ | |
{ | |
"neovim/nvim-lspconfig", | |
config = function() | |
local lspconfig = require("lspconfig") | |
local capabilities = require("cmp_nvim_lsp").default_capabilities() | |
lspconfig.elixirls.setup({ | |
-- you need to specify the executable command mannualy for elixir-ls | |
cmd = { "elixir-ls" }, | |
capabilities = capabilities, | |
}) | |
end, | |
}, | |
{ | |
"nvim-treesitter/nvim-treesitter", | |
config = function() | |
require("nvim-treesitter.configs").setup({ | |
ensure_installed = { "elixir", "eex", "heex" }, | |
highlight = { enable = true }, | |
indent = { enable = true }, | |
}) | |
end, | |
}, | |
{ | |
"hrsh7th/nvim-cmp", | |
dependencies = { | |
-- install different completion source | |
"hrsh7th/cmp-nvim-lsp", | |
"hrsh7th/cmp-buffer", | |
"hrsh7th/cmp-path", | |
}, | |
config = function() | |
local cmp = require("cmp") | |
cmp.setup({ | |
-- add different completion source | |
sources = cmp.config.sources({ | |
{ name = "nvim_lsp" }, | |
{ name = "buffer" }, | |
{ name = "path" }, | |
}), | |
-- using default mapping preset | |
mapping = cmp.mapping.preset.insert({ | |
["<C-Space>"] = cmp.mapping.complete(), | |
["<CR>"] = cmp.mapping.confirm({ select = true }), | |
}), | |
snippet = { | |
-- you must specify a snippet engine | |
expand = function(args) | |
-- using neovim v0.10 native snippet feature | |
-- you can also use other snippet engines | |
vim.snippet.expand(args.body) | |
end, | |
}, | |
}) | |
end, | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment