ahahah thanks for saying I’m a noob , I’m definitely not an expert.
Ok so this is some of my lsp file with the keymaps and I’m registering lsp servers
(I’ve been doing a few tests that’s why there is a for loop then elixirls. etc)
local servers = {
"cssls",
"dockerls",
"elixirls",
"gopls",
"html",
"jsonls",
"lua_ls",
"svelte",
-- "tailwindcss",
"taplo",
"tsserver",
}
local server_settings = {
["lua_ls"] = {
Lua = {
runtime = { version = "LuaJIT" },
diagnostics = { globals = { "vim" } },
workspace = {
library = vim.api.nvim_get_runtime_file("", true),
},
},
},
["yamlls"] = {
yaml = {
keyOrdering = false,
},
},
}
local server_with_disabled_formatting = {
["tsserver"] = true,
["lua_ls"] = true,
["tailwindcss"] = true,
["cssls"] = true,
}
mason.setup()
mason_lsp.setup({ ensure_installed = servers })
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = cmp_lsp.default_capabilities(capabilities)
-- The biding for every servers
local on_attach = function(client, bufnr)
local bufopts = { noremap = true, silent = true, buffer = bufnr }
bufopts.desc = "Go to definition"
vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts)
bufopts.desc = "Go to type definition"
vim.keymap.set("n", "gt", vim.lsp.buf.type_definition, bufopts)
bufopts.desc = "Go to implementation"
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts)
bufopts.desc = "Show diagnostics"
vim.keymap.set("n", "gl", vim.diagnostic.open_float, bufopts)
bufopts.desc = "Go to next diagnostics"
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, bufopts)
bufopts.desc = "Go to prev diagnostics"
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, bufopts)
bufopts.desc = "Telescope diagnostics"
vim.keymap.set("n", "<leader>ld", ":Telescope diagnostics<CR>", bufopts)
bufopts.desc = "Rename"
vim.keymap.set("n", "<leader>lr", vim.lsp.buf.rename, bufopts)
bufopts.desc = "Code action"
vim.keymap.set("n", "<leader>lc", vim.lsp.buf.code_action, bufopts)
if server_with_disabled_formatting[client.name] then
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false
end
end
for _, server in pairs(servers) do
lsp[server].setup({
capabilities = capabilities,
on_attach = on_attach,
settings = server_settings[server],
})
end
lsp.elixirls.setup({
filetypes = { "elixir", "eelixir", "heex", "surface" },
capabilities = capabilities,
cmd = {
"/Users/pielov/.local/share/nvim/mason/packages/elixir-ls/language_server.sh",
},
on_attach = on_attach,
root_dir = null_ls_utils.root_pattern("mix.exs", ".git")
or vim.loop.os_homedir(),
settings = {
elixirLS = {
fetchDeps = true,
},
},
})
I can’t upload image because I’m new but LspInfo gives me
Language client log: /Users/pielov/.local/state/nvim/lsp.log
Detected filetype: elixir
1 client(s) attached to this buffer:
Client: elixirls (id: 1, bufnr: [2])
filetypes: elixir, eelixir, heex, surface
autostart: true
root directory: /Users/pielov/workspace/personal/elixir/elixirapp
cmd: /Users/pielov/.local/share/nvim/mason/packages/elixir-ls/language_server.sh
Configured servers list: elixirls, graphql, gopls, taplo, dockerls, jsonls, cssls, lua_ls, svelte, tsserver, html
I tried to download elixirls from github and cmd into it, with no luck
I tried elixirtools.nvim doesn’t work as well