mirror of
https://github.com/LunarVim/LunarVim.git
synced 2024-09-20 18:45:08 +02:00
implement language overrides (#1081)
Co-authored-by: Chris <chris@macbook.local>
This commit is contained in:
parent
98f8a77819
commit
1c3b80d041
3 changed files with 36 additions and 1 deletions
|
@ -42,6 +42,7 @@ lvim = {
|
|||
signs = true,
|
||||
underline = true,
|
||||
},
|
||||
override = {},
|
||||
document_highlight = true,
|
||||
popup_border = "single",
|
||||
default_keybinds = true,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue