implement language overrides (#1081)

Co-authored-by: Chris <chris@macbook.local>
This commit is contained in:
Christian Chiarulli 2021-07-25 00:13:35 -04:00 committed by GitHub
parent 98f8a77819
commit 1c3b80d041
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 1 deletions

View file

@ -42,6 +42,7 @@ lvim = {
signs = true,
underline = true,
},
override = {},
document_highlight = true,
popup_border = "single",
default_keybinds = true,

View file

@ -272,13 +272,46 @@ require("lv-utils").define_augroups {
},
}
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)
for index, value in ipairs(tab) do
if value == val then
return true
end
end
return false
end
function lsp_config.setup(lang)
lang_server = lvim.lang[lang].lsp
local lang_server = lvim.lang[lang].lsp
require("lsp.null-ls").setup "python"
local provider = lang_server.provider
if require("lv-utils").check_lsp_client_active(provider) then
return
end
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
require("lspconfig")[provider].setup(lang_server.setup)
require("lsp.null-ls").setup(lang)
end

View file

@ -45,6 +45,7 @@ local function setup_ls(exe, type)
end
local function setup(filetype, type)
local executables = nil
if type == "diagnostics" then
executables = lvim.lang[filetype].linters
end