local execute = vim.api.nvim_command local fn = vim.fn local fmt = string.format local pack_path = fn.stdpath("data") .. "/site/pack" -- ensure a given plugin from github.com// is cloned in the pack/packer/start directory local function ensure (user, repo) local install_path = fmt("%s/packer/start/%s", pack_path, repo) if fn.empty(fn.glob(install_path)) > 0 then execute(fmt("!git clone https://github.com/%s/%s %s", user, repo, install_path)) execute(fmt("packadd %s", repo)) end end -- ensure the plugin manager is installed ensure("wbthomason", "packer.nvim") require('packer').startup(function(use) -- install all the plugins you need here -- the plugin manager can manage itself use {'wbthomason/packer.nvim'} -- lsp config for elixir-ls support use {'neovim/nvim-lspconfig'} -- cmp framework for auto-completion support use {'hrsh7th/nvim-cmp'} -- install different completion source use {'hrsh7th/cmp-nvim-lsp'} use {'hrsh7th/cmp-buffer'} use {'hrsh7th/cmp-path'} use {'hrsh7th/cmp-cmdline'} -- you need a snippet engine for snippet support -- here I'm using vsnip which can load snippets in vscode format use {'hrsh7th/vim-vsnip'} use {'hrsh7th/cmp-vsnip'} -- treesitter for syntax highlighting and more use {'nvim-treesitter/nvim-treesitter'} end) -- `on_attach` callback will be called after a language server -- instance has been attached to an open buffer with matching filetype -- here we're setting key mappings for hover documentation, goto definitions, goto references, etc -- you may set those key mappings based on your own preference local on_attach = function(client, bufnr) local opts = { noremap=true, silent=true } vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', 'lua vim.lsp.buf.definition()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', 'lua vim.lsp.buf.references()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', 'lua vim.lsp.buf.declaration()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', 'lua vim.lsp.buf.implementation()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', '', 'lua vim.lsp.buf.signature_help()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'cr', 'lua vim.lsp.buf.rename()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ca', 'lua vim.lsp.buf.code_action()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'cf', 'lua vim.lsp.buf.formatting()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'cd', 'lua vim.diagnostic.open_float()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', '[d', 'lua vim.diagnostic.goto_prev()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', ']d', 'lua vim.diagnostic.goto_next()', opts) end -- setting up the elixir language server -- you have to manually specify the entrypoint cmd for elixir-ls require('lspconfig').elixirls.setup { cmd = { "/Users/nicolasknoebber/package/elixir-ls/language_server.sh" }, on_attach = on_attach }