javascript
This commit is contained in:
+38
-1
@@ -7,6 +7,21 @@ local coq = require('coq')
|
||||
local lspstatus = require('lsp-status')
|
||||
lspstatus.register_progress()
|
||||
|
||||
local function find_repo_root(names)
|
||||
local util = require("lspconfig.util")
|
||||
local config = names.configfiles
|
||||
for _, i in ipairs(config) do
|
||||
local gitroot = util.root_pattern('.git')(i)
|
||||
if gitroot then
|
||||
for _, file in ipairs(config) do
|
||||
if util.path.is_file(util.path.join(gitroot, file)) then
|
||||
return gitroot
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local lsp_confs = {
|
||||
sumneko_lua = {
|
||||
settings = {
|
||||
@@ -39,7 +54,29 @@ local lsp_confs = {
|
||||
ccls = {},
|
||||
pyright = {},
|
||||
gopls = {},
|
||||
dartls = {}
|
||||
dartls = {},
|
||||
tsserver = {
|
||||
root_dir = find_repo_root({
|
||||
configfiles = { "tsconfig.json", "jsconfig.json", "package.json" }
|
||||
}),
|
||||
},
|
||||
eslint = {
|
||||
root_dir = find_repo_root({
|
||||
configfiles = { ".eslintrc", ".eslintrc.js", "package.json" }
|
||||
}),
|
||||
on_new_config = function (config, new_root_dir)
|
||||
local default_config = require('lspconfig.server_configurations.eslint').default_config
|
||||
default_config.on_new_config(config, new_root_dir)
|
||||
|
||||
local util = require('lspconfig.util')
|
||||
local pnp_cjs = util.path.join(new_root_dir, '.pnp.cjs')
|
||||
local pnp_js = util.path.join(new_root_dir, '.pnp.js')
|
||||
if util.path.exists(pnp_cjs) or util.path.exists(pnp_js) then
|
||||
config.cmd = { 'yarn', 'exec', unpack(default_config.cmd) }
|
||||
end
|
||||
end
|
||||
},
|
||||
svelte = {}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user