2022-12-22 20:12:50 +00:00
|
|
|
|
local lspconfig = require("lspconfig")
|
2022-06-12 19:25:17 +00:00
|
|
|
|
|
|
|
|
|
|
local on_attach = function(client, bufnr)
|
2022-12-22 20:12:50 +00:00
|
|
|
|
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
2022-06-12 19:25:17 +00:00
|
|
|
|
|
2022-12-22 20:12:50 +00:00
|
|
|
|
local opts = { noremap = true, silent = true }
|
2022-06-12 19:25:17 +00:00
|
|
|
|
|
2022-12-22 20:12:50 +00:00
|
|
|
|
-- Mappings.
|
|
|
|
|
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
|
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
|
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
|
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
|
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
|
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
|
2022-06-12 19:25:17 +00:00
|
|
|
|
|
2022-12-22 20:12:50 +00:00
|
|
|
|
-- TODO(ade): Sort out space. This will conflict with the leader key
|
|
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<space>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
|
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<space>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
|
2022-06-12 19:25:17 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
2022-12-22 20:12:50 +00:00
|
|
|
|
local capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
2022-06-12 19:25:17 +00:00
|
|
|
|
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|
|
|
|
|
|
2022-12-22 20:12:50 +00:00
|
|
|
|
local servers = { "tsserver", "intelephense", "psalm", "gopls", "html", "cssls", "solargraph", "rust_analyzer" }
|
2022-06-12 19:25:17 +00:00
|
|
|
|
for _, lsp in ipairs(servers) do
|
2022-12-22 20:12:50 +00:00
|
|
|
|
lspconfig[lsp].setup({
|
|
|
|
|
|
on_attach = on_attach,
|
|
|
|
|
|
capabilities = capabilities,
|
|
|
|
|
|
init_options = {
|
|
|
|
|
|
usePlaceholders = true,
|
|
|
|
|
|
},
|
|
|
|
|
|
})
|
2022-06-12 19:25:17 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
lspconfig.emmet_ls.setup({
|
2022-12-22 20:12:50 +00:00
|
|
|
|
on_attach = on_attach,
|
|
|
|
|
|
capabilities = capabilities,
|
|
|
|
|
|
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "scss", "eruby" },
|
|
|
|
|
|
init_options = {
|
|
|
|
|
|
usePlaceholders = true,
|
|
|
|
|
|
},
|
2022-06-12 19:25:17 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
2022-12-22 20:12:50 +00:00
|
|
|
|
lspconfig.sumneko_lua.setup({
|
|
|
|
|
|
settings = {
|
|
|
|
|
|
Lua = {
|
|
|
|
|
|
runtime = {
|
|
|
|
|
|
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
|
|
|
|
|
version = "LuaJIT",
|
|
|
|
|
|
},
|
|
|
|
|
|
diagnostics = {
|
|
|
|
|
|
-- Get the language server to recognize the `vim` global
|
|
|
|
|
|
globals = { "vim" },
|
|
|
|
|
|
},
|
|
|
|
|
|
workspace = {
|
|
|
|
|
|
-- Make the server aware of Neovim runtime files
|
|
|
|
|
|
library = vim.api.nvim_get_runtime_file("", true),
|
|
|
|
|
|
},
|
|
|
|
|
|
-- Do not send telemetry data containing a randomized but unique identifier
|
|
|
|
|
|
telemetry = {
|
|
|
|
|
|
enable = false,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
})
|
2022-07-10 20:14:19 +00:00
|
|
|
|
|
2022-06-12 19:25:17 +00:00
|
|
|
|
-- Change the diagnostic signs
|
2022-12-22 20:12:50 +00:00
|
|
|
|
vim.fn.sign_define("DiagnosticSignHint", { text = "➤", texthl = "DiagnosticSignHint", numhl = "DiagnosticSignHint" })
|
|
|
|
|
|
vim.fn.sign_define("DiagnosticSignInfo", { text = "ℹ", texthl = "DiagnosticSignInfo", numhl = "DiagnosticSignInfo" })
|
|
|
|
|
|
vim.fn.sign_define("DiagnosticSignWarn", { text = "⚠", texthl = "DiagnosticSignWarn", numhl = "DiagnosticSignWarn" })
|
|
|
|
|
|
vim.fn.sign_define(
|
|
|
|
|
|
"DiagnosticSignError",
|
|
|
|
|
|
{ text = "✖", texthl = "DiagnosticSignError", numhl = "DiagnosticSignError" }
|
|
|
|
|
|
)
|