2021-07-25 03:17:11 +02:00
|
|
|
local lsp_config = {}
|
|
|
|
|
2021-07-28 23:13:50 +02:00
|
|
|
function lsp_config.config()
|
|
|
|
require("lsp.kind").setup()
|
|
|
|
require("lsp.handlers").setup()
|
|
|
|
require("lsp.signs").setup()
|
2021-07-28 23:15:35 +02:00
|
|
|
require("ls.keybindings").setup()
|
2021-07-28 23:13:50 +02:00
|
|
|
end
|
2021-07-16 02:49:33 +02:00
|
|
|
|
|
|
|
-- My font didn't like this :/
|
|
|
|
-- vim.api.nvim_set_keymap(
|
|
|
|
-- "n",
|
|
|
|
-- "gl",
|
|
|
|
-- '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics({ show_header = false, border = { { "🭽", "FloatBorder" }, { "▔", "FloatBorder" }, { "🭾", "FloatBorder" }, { "▕", "FloatBorder" }, { "🭿", "FloatBorder" }, { "▁", "FloatBorder" }, { "🭼", "FloatBorder" }, { "▏", "FloatBorder" }, } })<CR>',
|
|
|
|
-- { noremap = true, silent = true }
|
|
|
|
-- )
|
|
|
|
|
2021-07-25 20:45:40 +02:00
|
|
|
local function no_formatter_on_attach(client, bufnr)
|
|
|
|
if lvim.lsp.on_attach_callback then
|
|
|
|
lvim.lsp.on_attach_callback(client, bufnr)
|
|
|
|
end
|
2021-07-28 23:13:50 +02:00
|
|
|
require("lsp.utils").lsp_highlight_document(client)
|
2021-07-25 20:45:40 +02:00
|
|
|
client.resolved_capabilities.document_formatting = false
|
|
|
|
end
|
|
|
|
|
2021-07-25 03:17:11 +02:00
|
|
|
function lsp_config.common_capabilities()
|
|
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
|
|
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|
|
|
capabilities.textDocument.completion.completionItem.resolveSupport = {
|
|
|
|
properties = {
|
|
|
|
"documentation",
|
|
|
|
"detail",
|
|
|
|
"additionalTextEdits",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
return capabilities
|
|
|
|
end
|
|
|
|
|
2021-07-25 13:55:19 +02:00
|
|
|
require("core.autocmds").define_augroups {
|
2021-07-09 14:07:25 +02:00
|
|
|
_general_lsp = {
|
|
|
|
{ "FileType", "lspinfo", "nnoremap <silent> <buffer> q :q<CR>" },
|
|
|
|
},
|
|
|
|
}
|
2021-07-01 00:45:40 +02:00
|
|
|
|
2021-07-25 06:13:35 +02:00
|
|
|
local function is_table(t)
|
|
|
|
return type(t) == "table"
|
|
|
|
end
|
|
|
|
|
|
|
|
local function is_string(t)
|
|
|
|
return type(t) == "string"
|
|
|
|
end
|
|
|
|
|
|
|
|
local function has_value(tab, val)
|
2021-07-25 13:36:22 +02:00
|
|
|
for _, value in ipairs(tab) do
|
2021-07-25 06:13:35 +02:00
|
|
|
if value == val then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2021-07-25 03:17:11 +02:00
|
|
|
function lsp_config.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-26 19:14:23 +02:00
|
|
|
if require("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
|
|
|
|
|
|
|
|
if is_table(overrides) then
|
|
|
|
if has_value(overrides, lang) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if is_string(overrides) then
|
|
|
|
if overrides == lang then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
2021-07-25 20:45:40 +02:00
|
|
|
local sources = require("lsp.null-ls").setup(lang)
|
|
|
|
|
|
|
|
for _, source in pairs(sources) do
|
|
|
|
local method = source.method
|
|
|
|
local format_method = "NULL_LS_FORMATTING"
|
|
|
|
|
|
|
|
if is_table(method) then
|
|
|
|
if has_value(method, format_method) then
|
|
|
|
lang_server.setup.on_attach = no_formatter_on_attach
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if is_string(method) then
|
|
|
|
if method == format_method then
|
|
|
|
lang_server.setup.on_attach = no_formatter_on_attach
|
|
|
|
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-25 03:17:11 +02:00
|
|
|
require("lspconfig")[provider].setup(lang_server.setup)
|
|
|
|
end
|
|
|
|
|
2021-03-18 01:32:52 +01:00
|
|
|
return lsp_config
|