javascript

This commit is contained in:
2022-05-13 18:15:19 -04:00
parent 4ddd1a099b
commit c4811368b2
7 changed files with 51 additions and 4 deletions
+38 -1
View File
@@ -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 = {}
}