spacevim/bundle/neodev.nvim/lua/neodev/lsp.lua
JIe 2bb7059579
Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
init
2024-08-21 14:17:26 +08:00

98 lines
2.7 KiB
Lua

local util = require("neodev.util")
local M = {}
function M.setup()
local opts = require("neodev.config").options
local lsputil = require("lspconfig.util")
local hook = lsputil.add_hook_after
lsputil.on_setup = hook(lsputil.on_setup, function(config)
if opts.setup_jsonls and config.name == "jsonls" then
M.setup_jsonls(config)
end
if config.name == "lua_ls" then
config.on_new_config = hook(config.on_new_config, M.on_new_config)
-- config.before_init = hook(config.before_init, M.before_init)
end
end)
end
function M.setup_jsonls(config)
local schemas = config.settings.json and config.settings.json.schemas or {}
table.insert(schemas, {
name = "LuaLS Settings",
url = "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
fileMatch = { ".luarc.json", ".luarc.jsonc" },
})
config.settings = vim.tbl_deep_extend("force", config.settings, {
json = {
schemas = schemas,
validate = {
enable = true,
},
},
})
end
function M.before_init(params, config)
M.on_new_config(config, params.rootPath)
end
function M.on_new_config(config, root_dir)
-- don't do anything when old style setup was used
if config.settings.legacy then
util.warn(
"You're using the old way of setting up neodev (previously lua-dev).\nPlease check the docs at https://github.com/folke/neodev.nvim#-setup"
)
return
end
local lua_root = util.find_root()
local opts = require("neodev.config").merge()
opts.library.enabled = util.is_nvim_config()
if not opts.library.enabled and lua_root then
opts.library.enabled = true
opts.library.plugins = false
end
pcall(function()
opts = require("neoconf").get("neodev", opts, { file = root_dir })
end)
pcall(opts.override, root_dir, opts.library)
local library = config.settings
and config.settings.Lua
and config.settings.Lua.workspace
and config.settings.Lua.workspace.library
or {}
local ignoreDir = config.settings
and config.settings.Lua
and config.settings.Lua.workspace
and config.settings.Lua.workspace.ignoreDir
or {}
if opts.library.enabled then
config.settings =
vim.tbl_deep_extend("force", config.settings or {}, require("neodev.luals").setup(opts, config.settings).settings)
for _, lib in ipairs(library) do
table.insert(config.settings.Lua.workspace.library, lib)
end
if require("neodev.config").options.pathStrict and lua_root then
table.insert(config.settings.Lua.workspace.library, lua_root)
end
for _, dir in ipairs(ignoreDir) do
table.insert(config.settings.Lua.workspace.ignoreDir, dir)
end
end
end
return M