2021-07-28 23:24:05 +02:00
|
|
|
local utils = require "utils"
|
2021-07-29 01:13:07 +02:00
|
|
|
local service = require "lsp.service"
|
2021-07-29 01:16:45 +02:00
|
|
|
local lspconfig = require "lspconfig"
|
|
|
|
local null_ls = require "lsp.null-ls"
|
|
|
|
local M = {}
|
2021-07-25 03:17:11 +02:00
|
|
|
|
2021-07-29 01:16:45 +02:00
|
|
|
function M.config()
|
2021-07-28 23:13:50 +02:00
|
|
|
require("lsp.kind").setup()
|
|
|
|
require("lsp.handlers").setup()
|
|
|
|
require("lsp.signs").setup()
|
2021-07-28 23:20:25 +02:00
|
|
|
require("lsp.keybinds").setup()
|
2021-07-28 23:13:50 +02:00
|
|
|
end
|
2021-07-16 02:49:33 +02:00
|
|
|
|
2021-07-29 01:16:45 +02:00
|
|
|
function M.setup(lang)
|
2021-07-25 06:13:35 +02:00
|
|
|
local lang_server = lvim.lang[lang].lsp
|
2021-07-25 03:17:11 +02:00
|
|
|
local provider = lang_server.provider
|
2021-07-29 01:13:07 +02:00
|
|
|
if utils.check_lsp_client_active(provider) then
|
2021-07-25 03:17:11 +02:00
|
|
|
return
|
|
|
|
end
|
2021-07-25 06:13:35 +02:00
|
|
|
|
|
|
|
local overrides = lvim.lsp.override
|
|
|
|
|
2021-07-28 23:24:05 +02:00
|
|
|
if utils.is_table(overrides) then
|
|
|
|
if utils.has_value(overrides, lang) then
|
2021-07-25 06:13:35 +02:00
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-07-28 23:24:05 +02:00
|
|
|
if utils.is_string(overrides) then
|
2021-07-25 06:13:35 +02:00
|
|
|
if overrides == lang then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
2021-07-29 01:16:45 +02:00
|
|
|
local sources = null_ls.setup(lang)
|
2021-07-25 20:45:40 +02:00
|
|
|
|
|
|
|
for _, source in pairs(sources) do
|
|
|
|
local method = source.method
|
|
|
|
local format_method = "NULL_LS_FORMATTING"
|
|
|
|
|
2021-07-28 23:24:05 +02:00
|
|
|
if utils.is_table(method) then
|
|
|
|
if utils.has_value(method, format_method) then
|
2021-07-29 01:13:07 +02:00
|
|
|
lang_server.setup.on_attach = service.no_formatter_on_attach
|
2021-07-25 20:45:40 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-07-28 23:24:05 +02:00
|
|
|
if utils.is_string(method) then
|
2021-07-25 20:45:40 +02:00
|
|
|
if method == format_method then
|
2021-07-29 01:13:07 +02:00
|
|
|
lang_server.setup.on_attach = service.no_formatter_on_attach
|
2021-07-25 20:45:40 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-07-25 06:13:35 +02:00
|
|
|
|
2021-07-26 20:32:29 +02:00
|
|
|
if provider == "" or provider == nil then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2021-07-29 01:16:45 +02:00
|
|
|
lspconfig[provider].setup(lang_server.setup)
|
2021-07-25 03:17:11 +02:00
|
|
|
end
|
|
|
|
|
2021-07-29 01:16:45 +02:00
|
|
|
return M
|