|
|
@ -1,8 +1,8 @@ |
|
|
|
local utils = require("doom.utils") |
|
|
|
local is_plugin_disabled = utils.is_plugin_disabled |
|
|
|
local lspconfig = require("lspconfig") |
|
|
|
local lspconfig_configs = require("lspconfig.configs") |
|
|
|
local lspconfig_util = require("lspconfig/util") |
|
|
|
local langs_utils = require('doom.modules.langs_utils') |
|
|
|
|
|
|
|
-- volar needs works with typescript server, needs to get the typescript server from the project's node_modules |
|
|
|
local function on_new_config(new_config, new_root_dir) |
|
|
@ -30,22 +30,17 @@ end |
|
|
|
local volar_root_dir = lspconfig_util.root_pattern("package.json") |
|
|
|
|
|
|
|
-- Runtime config with extra capabilities |
|
|
|
local config = { |
|
|
|
capabilities = utils.get_capabilities(), |
|
|
|
local config = langs_utils.lsp_ensure_client_capabilities({ |
|
|
|
on_attach = function(client) |
|
|
|
if not is_plugin_disabled("illuminate") then |
|
|
|
utils.illuminate_attach(client) |
|
|
|
end |
|
|
|
if type(doom.lua.on_attach) == "function" then |
|
|
|
doom.lua.on_attach(client) |
|
|
|
end |
|
|
|
end, |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
local volar = lspconfig.volar -- Get the volar config to set the `cmd` |
|
|
|
|
|
|
|
-- Contains base configuration necessary for volar to start |
|
|
|
local base_config = { |
|
|
|
local base_config = vim.tbl_deep_extend('keep', config, { |
|
|
|
default_config = { |
|
|
|
cmd = volar.document_config.default_config.cmd, |
|
|
|
root_dir = volar_root_dir, |
|
|
@ -56,52 +51,28 @@ local base_config = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
lspconfig_configs.volar_api = vim.tbl_deep_extend("keep", base_config, doom.vue.volar_api) |
|
|
|
lspconfig_configs.volar_doc = vim.tbl_deep_extend("keep", base_config, doom.vue.volar_doc) |
|
|
|
lspconfig_configs.volar_html = vim.tbl_deep_extend("keep", base_config, doom.vue.volar_html) |
|
|
|
|
|
|
|
-- |
|
|
|
local start_lsp = function() |
|
|
|
lspconfig.volar_api.setup(config) |
|
|
|
lspconfig.volar_doc.setup(config) |
|
|
|
lspconfig.volar_html.setup(config) |
|
|
|
end |
|
|
|
local volar_api_config = vim.tbl_deep_extend('force', {}, doom.vue.volar_api, base_config) |
|
|
|
langs_utils.use_lsp('volar', { |
|
|
|
name = 'volar_api', |
|
|
|
config = volar_api_config, |
|
|
|
}) |
|
|
|
|
|
|
|
local attach_buffers = function() |
|
|
|
local servers = { "volar_api", "volar_doc", "volar_html" } |
|
|
|
for _, server_name in ipairs(servers) do |
|
|
|
local lsp_server = require("lspconfig")[server_name] |
|
|
|
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do |
|
|
|
if lsp_server.filetypes then |
|
|
|
lsp_server.manager.try_add_wrapper(bufnr) |
|
|
|
else |
|
|
|
lsp_server.manager.try_add(bufnr) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
local volar_doc_config = vim.tbl_deep_extend('force', {}, doom.vue.volar_doc, base_config) |
|
|
|
langs_utils.use_lsp('volar', { |
|
|
|
name = 'volar_doc', |
|
|
|
config = volar_doc_config, |
|
|
|
}) |
|
|
|
|
|
|
|
local volar_html_config = vim.tbl_deep_extend('force', {}, doom.vue.volar_html, base_config) |
|
|
|
langs_utils.use_lsp('volar', { |
|
|
|
name = 'volar_html', |
|
|
|
config = volar_html_config, |
|
|
|
}) |
|
|
|
|
|
|
|
if not is_plugin_disabled("auto_install") then |
|
|
|
local lsp_installer = require("nvim-lsp-installer.servers") |
|
|
|
local server_available, server = lsp_installer.get_server("volar") |
|
|
|
if server_available then |
|
|
|
config.cmd_env = server:get_default_options().cmd_env |
|
|
|
if not server:is_installed() then |
|
|
|
vim.defer_fn(function() |
|
|
|
server:install() |
|
|
|
end, 50) |
|
|
|
end |
|
|
|
|
|
|
|
server:on_ready(function() |
|
|
|
start_lsp() |
|
|
|
attach_buffers() |
|
|
|
end) |
|
|
|
end |
|
|
|
else |
|
|
|
start_lsp() |
|
|
|
end |
|
|
|
|
|
|
|
vim.defer_fn(function() |
|
|
|
local ts_install = require("nvim-treesitter.install") |
|
|
@ -110,7 +81,6 @@ end, 0) |
|
|
|
|
|
|
|
-- Setup null-ls |
|
|
|
if doom.linter then |
|
|
|
local langs_utils = require('doom.modules.langs_utils') |
|
|
|
local null_ls = require("null-ls") |
|
|
|
|
|
|
|
langs_utils.use_null_ls_source({ |
|
|
|