108 lines
2.6 KiB
Lua
108 lines
2.6 KiB
Lua
local lsconf = require("lspconfig")
|
|
local lsp_utils = require("plugins.lsp.lsp-utils")
|
|
local capabilities = lsp_utils.capabilities()
|
|
local flags = {
|
|
allow_incremental_sync = true,
|
|
debounce_text_changes = 200,
|
|
}
|
|
|
|
local runtime_path = vim.split(package.path, ";")
|
|
table.insert(runtime_path, "lua/?.lua")
|
|
table.insert(runtime_path, "lua/?/init.lua")
|
|
local sumneko_root_path = "/mnt/wd1tb/catacombs/code/lua-language-server"
|
|
local sumneko_binary = "luals"
|
|
|
|
local handlers = {
|
|
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "single" }),
|
|
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = "single" }),
|
|
["textDocument/definition"] = lsp_utils.goto_split("split"),
|
|
}
|
|
|
|
local on_attach = function(client, bufnr)
|
|
vim.opt.signcolumn = "yes"
|
|
lsp_utils.disable_formatting(client)
|
|
lsp_utils.mappings(bufnr)
|
|
require("lsp_signature").on_attach({
|
|
bind = true,
|
|
hint_prefix = " ",
|
|
fix_pos = true,
|
|
padding = " ",
|
|
handler_opts = { border = "shadow" },
|
|
})
|
|
if client.resolved_capabilities.document_highlight then
|
|
vim.cmd([[
|
|
hi link LspReferenceRead Visual
|
|
hi link LspReferenceText Visual
|
|
hi link LspReferenceWrite Visual
|
|
augroup lsp_document_highlight
|
|
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
|
|
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
|
|
augroup END
|
|
]])
|
|
end
|
|
end
|
|
|
|
lsconf.sumneko_lua.setup({
|
|
cmd = { sumneko_binary, "-E", sumneko_root_path .. "/main.lua" },
|
|
settings = {
|
|
Lua = {
|
|
completion = {
|
|
enable = true,
|
|
keywordSnippet = "Replace",
|
|
callSnippet = "Replace",
|
|
},
|
|
runtime = {
|
|
version = "LuaJIT",
|
|
path = runtime_path,
|
|
},
|
|
diagnostics = {
|
|
globals = { "vim" },
|
|
},
|
|
workspace = {
|
|
library = {
|
|
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
|
|
[vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true,
|
|
[vim.fn.stdpath("config") .. "/lua"] = true,
|
|
},
|
|
maxPreload = 100000,
|
|
preloadFileSize = 10000,
|
|
},
|
|
telemetry = {
|
|
enable = false,
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
require("lspconfig/configs").ls_emmet = {
|
|
default_config = {
|
|
cmd = { "ls_emmet", "--stdio" },
|
|
filetypes = {
|
|
"html",
|
|
"css",
|
|
"scss",
|
|
"xml",
|
|
"xsl",
|
|
"sass",
|
|
"stylus",
|
|
"less",
|
|
"sss",
|
|
"svelte",
|
|
},
|
|
root_dir = function(fname)
|
|
return vim.loop.cwd()
|
|
end,
|
|
settings = {},
|
|
},
|
|
}
|
|
|
|
local servers = { "sumneko_lua", "ls_emmet", "html", "cssls", "tailwindcss", "vimls", "jsonls" }
|
|
for _, lsp in ipairs(servers) do
|
|
lsconf[lsp].setup({
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
handlers = handlers,
|
|
flags = flags,
|
|
})
|
|
end
|