diff --git a/.config/nvim/after/plugin/lsp.lua b/.config/nvim/after/plugin/lsp.lua index 8f3b1a6..ec3ba49 100644 --- a/.config/nvim/after/plugin/lsp.lua +++ b/.config/nvim/after/plugin/lsp.lua @@ -88,6 +88,45 @@ local lsp_status = require('lsp-status') lsp_status.register_progress() local lspconfig = require 'lspconfig' +local configs = require 'lspconfig.configs' + +-- Global mappings. +-- See `:help vim.diagnostic.*` for documentation on any of the below functions +vim.keymap.set('n', 'e', vim.diagnostic.open_float) +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist) + +-- Use LspAttach autocommand to only map the following keys +-- after the language server attaches to the current buffer +vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('UserLspConfig', {}), + callback = function(ev) + -- Enable completion triggered by + vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' + + -- Buffer local mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local opts = { buffer = ev.buf } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, opts) + vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, opts) + vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, opts) + vim.keymap.set('n', 'wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, opts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, opts) + vim.keymap.set({ 'n', 'v' }, 'ca', vim.lsp.buf.code_action, opts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) + vim.keymap.set('n', 'f', function() + vim.lsp.buf.format { async = true } + end, opts) + end, +}) local on_attach = function(client, bufnr) nnoremap("gd", "Lspsaga peek_definition") @@ -125,10 +164,10 @@ local function config(_config) end -- Enable the following language servers -local servers = { 'gopls', 'julials', 'rust_analyzer', 'pyright' } -for _, lsp in ipairs(servers) do - lspconfig[lsp].setup(config()) -end +-- local servers = { 'gopls', 'julials', 'rust_analyzer', 'pyright' } +-- for _, lsp in ipairs(servers) do +-- lspconfig[lsp].setup(config()) +-- end require'lspconfig'.lua_ls.setup { settings = { @@ -176,3 +215,26 @@ require('rust-tools').setup({ }, }) + +local lexical_config = { + filetypes = { "elixir", "eelixir", "heex" }, + cmd = { "/Users/halfdan/code/lexical/_build/dev/package/lexical/bin/start_lexical.sh" }, + settings = {}, +} + +if not configs.lexical then + configs.lexical = { + default_config = { + filetypes = lexical_config.filetypes, + cmd = lexical_config.cmd, + root_dir = function(fname) + return lspconfig.util.root_pattern("mix.exs", ".git")(fname) or vim.loop.os_homedir() + end, + -- optional settings + settings = lexical_config.settings, + }, + } +end + +lspconfig.lexical.setup({}) + diff --git a/.config/nvim/lua/halfdan/lazy.lua b/.config/nvim/lua/halfdan/lazy.lua index e006333..f0ca6cf 100644 --- a/.config/nvim/lua/halfdan/lazy.lua +++ b/.config/nvim/lua/halfdan/lazy.lua @@ -144,27 +144,27 @@ require("lazy").setup({ "elixir-tools/elixir-tools.nvim", version = "*", event = { "BufReadPre", "BufNewFile" }, - config = function() - local elixir = require("elixir") - local elixirls = require("elixir.elixirls") + -- config = function() + -- local elixir = require("elixir") + -- local elixirls = require("elixir.elixirls") - elixir.setup { - nextls = {enable = true}, - credo = {}, - elixirls = { - enable = false, - settings = elixirls.settings { - dialyzerEnabled = false, - enableTestLenses = false, - }, - on_attach = function(client, bufnr) - vim.keymap.set("n", "fp", ":ElixirFromPipe", { buffer = true, noremap = true }) - vim.keymap.set("n", "tp", ":ElixirToPipe", { buffer = true, noremap = true }) - vim.keymap.set("v", "em", ":ElixirExpandMacro", { buffer = true, noremap = true }) - end, - } - } - end, + -- elixir.setup { + -- nextls = {enable = true}, + -- credo = {}, + -- elixirls = { + -- enable = false, + -- settings = elixirls.settings { + -- dialyzerEnabled = false, + -- enableTestLenses = false, + -- }, + -- on_attach = function(client, bufnr) + -- vim.keymap.set("n", "fp", ":ElixirFromPipe", { buffer = true, noremap = true }) + -- vim.keymap.set("n", "tp", ":ElixirToPipe", { buffer = true, noremap = true }) + -- vim.keymap.set("v", "em", ":ElixirExpandMacro", { buffer = true, noremap = true }) + -- end, + -- } + -- } + -- end, dependencies = { "nvim-lua/plenary.nvim", },