-- basic settings vim.g.mapleader = ' ' local set = vim.opt set.tabstop = 2 set.shiftwidth = 2 set.softtabstop = 2 set.expandtab = true 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'} -- colorscheme use 'marko-cerovac/material.nvim' -- treesitter for syntax highlighting and more use {'nvim-treesitter/nvim-treesitter'} -- status line -- https://github.com/nvim-lualine/lualine.nvim use { 'nvim-lualine/lualine.nvim', requires = { 'kyazdani42/nvim-web-devicons', opt = true } } 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', '', '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 local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) require('lspconfig').elixirls.setup { cmd = { "/Users/nicolasknoebber/package/elixir-ls/language_server.sh" }, on_attach = on_attach, capabilities = capabilities } local cmp = require'cmp' cmp.setup({ snippet = { expand = function(args) -- setting up snippet engine -- this is for vsnip, if you're using other -- snippet engine, please refer to the `nvim-cmp` guide vim.fn["vsnip#anonymous"](args.body) end, }, mapping = { [''] = cmp.mapping.confirm({ select = true }), }, sources = cmp.config.sources({ { name = 'nvim_lsp' }, { name = 'vsnip' }, -- For vsnip users. { name = 'buffer' } }) }) -- tree sitter require'nvim-treesitter.configs'.setup { ensure_installed = {"elixir", "heex"}, sync_install = true, auto_install = true, ignore_install = { }, highlight = { enable = true, disable = { }, additional_vim_regex_highlighting = false, }, } -- status line require('lualine').setup { options = { theme = 'material', } } -- color scheme require('material').setup({ lualine_style = 'default', }) vim.g.material_style = "palenight" vim.cmd 'colorscheme material'