-- vim.lsp.config["elixir-ls"] = { -- cmd = { "elixir-ls" }, -- filetypes = { "elixir", "eelixir", "heex" }, -- root_markers = { "mix.exs", ".git" }, -- } -- vim.lsp.enable("elixir-ls") -- vim.lsp.config["deno"] = { -- cmd = { "deno", "lsp" }, -- filetypes = { "javascript", "typescript" }, -- root_markers = { "deno.json" }, -- } -- vim.lsp.enable("deno") -- vim.lsp.config["R"] = { -- cmd = { "/opt/homebrew/bin/R", "--no-echo", "-e", "languageserver::run()" }, -- filetypes = { "r" }, -- } -- vim.lsp.enable("R") -- vim.lsp.config["uiua"] = { cmd = { "uiua", "lsp" }, filetypes = { "uiua", "*.ua" }, } vim.lsp.enable("uiua") vim.lsp.config("dexter", { cmd = { "dexter", "lsp" }, root_markers = { ".dexter/dexter.db", ".dexter.db", ".git", "mix.exs" }, filetypes = { "elixir", "eelixir", "heex" }, init_options = { followDelegates = true, -- jump through defdelegate to the target function -- stdlibPath = "", -- override Elixir stdlib path (auto-detected) -- debug = false, -- verbose logging to stderr (view with :LspLog) }, }) vim.lsp.enable("dexter") -- CUSTOM LSP's vim.api.nvim_create_autocmd("FileType", { pattern = { "elixir", "typescript", "json" }, callback = function() vim.lsp.start({ name = "hhn_lsp", cmd = { vim.env.HOME .. "/git/hhn_lsp/bin/hhn_lsp" }, root_dir = vim.fs.dirname(vim.fs.find({ ".git" }, { upward = true })[1]), }) end, }) --------------------- auto-exec config local function project_root() local git_dir = vim.fs.find(".git", { upward = true, path = vim.fn.getcwd(), })[1] return git_dir and vim.fs.dirname(git_dir) or vim.fn.getcwd() end local root = project_root() local pair_ls_config = root .. "/.pair_ls.nvim.lua" if vim.uv.fs_stat(pair_ls_config) then dofile(pair_ls_config) end vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup("my.lsp", {}), callback = function(args) local client = assert(vim.lsp.get_client_by_id(args.data.client_id)) if client:supports_method("textDocument/completion") then client.server_capabilities.completionProvider.triggerCharacters = vim.tbl_keys( vim.tbl_extend( "force", vim.iter(client.server_capabilities.completionProvider.triggerCharacters or {}):fold({}, function(chars, char) chars[char] = true return chars end), vim .iter(vim.split("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.:-", "")) :fold({}, function(chars, char) chars[char] = true return chars end) ) ) vim.lsp.completion.enable(true, client.id, args.buf, { autotrigger = true }) end if client:supports_method("textDocument/formatting") then -- the most important part vim.api.nvim_create_autocmd("BufWritePre", { buffer = args.buf, callback = function() vim.lsp.buf.format({ bufnr = args.buf, id = client.id, timeout_ms = 5000 }) end, }) end end, }) if kx_custom and vim.loop.os_uname().sysname == "Linux" then vim.lsp.config["alsp"] = { cmd = { "alsp" }, filetypes = { "elixir", "heex", "elixirscript" }, root_markers = { "mix.exs", ".git" }, } vim.lsp.enable("alsp") vim.api.nvim_create_autocmd("BufEnter", { pattern = { "*.ae" }, callback = function() print("INITIALIZING LSPROXY") vim.lsp.start({ name = "zxcv", cmd = { "/home/omnissiah/git/lsproxy/transls" }, -- root_dir = vim.fs.dirname(vim.fs.find({ ".git" }, { upward = true })[1]), }) end, }) end vim.api.nvim_create_autocmd("FileType", { pattern = "elixir", callback = function(args) local root = vim.fs.root(args.buf, { "mix.exs", ".git" }) if not root then return end vim.lsp.start({ name = "exofx-lsp", cmd_env = { MIX_ENV = "test" }, cmd = { "mix", "exofx.lsp" }, root_dir = root, cmd_cwd = root, -- capabilities = vim.lsp.protocol.make_client_capabilities(), }) end, }) local function hover_all_clients() local bufnr = vim.api.nvim_get_current_buf() local clients = vim.lsp.get_clients({ bufnr = bufnr, method = "textDocument/hover", }) if #clients == 0 then return end local params = vim.lsp.util.make_position_params(0, clients[1].offset_encoding or "utf-16") vim.lsp.buf_request_all(bufnr, "textDocument/hover", params, function(results) local lines = {} for client_id, response in pairs(results) do local result = response.result local client = vim.lsp.get_client_by_id(client_id) if result and result.contents and client then local hover_lines = vim.lsp.util.convert_input_to_markdown_lines(result.contents) hover_lines = vim.lsp.util.trim_empty_lines(hover_lines) if #hover_lines > 0 then if #lines > 0 then table.insert(lines, "") table.insert(lines, "---") table.insert(lines, "") end table.insert(lines, "**" .. client.name .. "**") table.insert(lines, "") vim.list_extend(lines, hover_lines) end end end if #lines == 0 then return end vim.lsp.util.open_floating_preview(lines, "markdown", { border = "rounded", focus_id = "hover-all-clients", }) end) end vim.api.nvim_create_autocmd({ "LspAttach", "BufEnter" }, { callback = function(args) vim.schedule(function() vim.keymap.set("n", "K", hover_all_clients, { buffer = args.buf, desc = "Hover all LSP clients", }) end) end, }) vim.keymap.set("i", "", function() if vim.fn.pumvisible() == 1 then vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("", true, false, true), "n", false) end vim.schedule(function() vim.lsp.completion.get() end) end, { desc = "Force LSP completion" }) -- vim.api.nvim_create_autocmd("FileType", { -- pattern = "elixir", -- callback = function(args) -- local root = vim.fs.root(args.buf, { "mix.exs", ".git" }) -- if not root then -- return -- end -- -- vim.lsp.start({ -- name = "exoflua-lsp", -- cmd = { -- "env", -- "EXOFLUA_LUA_LANGUAGE_SERVER=/opt/homebrew/bin/lua-language-server", -- "mix", -- "exoflua.lsp", -- "--profile", -- "nvim", -- }, -- cmd_cwd = root, -- root_dir = root, -- capabilities = vim.lsp.protocol.make_client_capabilities(), -- }) -- end, -- }) -- -- vim.api.nvim_create_autocmd("FileType", { -- pattern = "elixir", -- callback = function(args) -- local root = vim.fs.root(args.buf, { "mix.exs", ".git" }) -- if not root then -- return -- end -- -- local cmd = root .. "/bin/exofc-lsp" -- if vim.fn.executable(cmd) ~= 1 then -- return -- end -- -- vim.lsp.start({ -- name = "exofc-lsp", -- cmd = { cmd }, -- cmd_cwd = root, -- root_dir = root, -- capabilities = vim.lsp.protocol.make_client_capabilities(), -- }, { -- bufnr = args.buf, -- }) -- end, -- }) return {}