Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pack): update typescript-all-in-one disable typescript-tools to denols #876

Merged
merged 3 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lua/astrocommunity/lsp/actions-preview-nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ return {
"nvim-telescope/telescope.nvim",
{
"AstroNvim/astrolsp",
optional = true,
---@type AstroLSPOpts
opts = {
mappings = {
Expand Down
1 change: 1 addition & 0 deletions lua/astrocommunity/pack/elixir-phoenix/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ return {
},
{
"AstroNvim/astrolsp",
optional = true,
opts = {
config = {
tailwindcss = {
Expand Down
3 changes: 3 additions & 0 deletions lua/astrocommunity/pack/elm/init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
return {
{
"nvim-treesitter/nvim-treesitter",
optional = true,
opts = function(_, opts)
if opts.ensure_installed ~= "all" then
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "elm" })
Expand All @@ -9,12 +10,14 @@ return {
},
{
"williamboman/mason-lspconfig.nvim",
optional = true,
opts = function(_, opts)
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "elmls" })
end,
},
{
"jay-babu/mason-null-ls.nvim",
optional = true,
opts = function(_, opts)
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "elm_format" })
end,
Expand Down
1 change: 1 addition & 0 deletions lua/astrocommunity/pack/fish/init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
return {
{
"nvim-treesitter/nvim-treesitter",
optional = true,
opts = function(_, opts)
if opts.ensure_installed ~= "all" then
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "fish" })
Expand Down
2 changes: 2 additions & 0 deletions lua/astrocommunity/pack/gleam/init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
return {
{
"nvim-treesitter/nvim-treesitter",
optional = true,
opts = function(_, opts)
if opts.ensure_installed ~= "all" then
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "gleam" })
Expand All @@ -9,6 +10,7 @@ return {
},
{
"AstroNvim/astrolsp",
optional = true,
opts = function(_, opts)
if vim.fn.executable "gleam" == 1 then
opts.servers = require("astrocore").list_insert_unique(opts.servers, { "gleam" })
Expand Down
1 change: 1 addition & 0 deletions lua/astrocommunity/pack/just/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ return {
},
{
"nvim-treesitter/nvim-treesitter",
optional = true,
opts = function(_, opts)
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.just = {
Expand Down
2 changes: 2 additions & 0 deletions lua/astrocommunity/pack/nim/init.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
return {
{
"williamboman/mason-lspconfig.nvim",
optional = true,
opts = function(_, opts)
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "nim_langserver" })
end,
},
{
"nvim-treesitter/nvim-treesitter",
optional = true,
opts = function(_, opts)
if opts.ensure_installed ~= "all" then
opts.ensure_installed =
Expand Down
1 change: 1 addition & 0 deletions lua/astrocommunity/pack/pkl/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ return {
dependencies = {
{
"nvim-treesitter/nvim-treesitter",
optional = true,
opts = function(_, opts)
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()

Expand Down
2 changes: 2 additions & 0 deletions lua/astrocommunity/pack/templ/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local utils = require "astronvim.utils"
return {
{
"nvim-treesitter/nvim-treesitter",
optional = true,
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table or string "all".
if opts.ensure_installed ~= "all" then
Expand All @@ -13,6 +14,7 @@ return {
},
{
"williamboman/mason-lspconfig.nvim",
optional = true,
opts = function(_, opts) opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "templ") end,
},
}
71 changes: 44 additions & 27 deletions lua/astrocommunity/pack/typescript-all-in-one/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,50 @@ return {
{ import = "astrocommunity.pack.typescript" },
{ import = "astrocommunity.pack.typescript-deno" },
{
"sigmasd/deno-nvim",
-- HACK: This disables tsserver if denols is attached.
-- A solution that only enables the required lsp should replace it.
opts = function(_, opts)
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(args)
local bufnr = args.buf
local curr_client = vim.lsp.get_client_by_id(args.data.client_id)
-- if deno attached, stop all typescript servers
if curr_client.name == "denols" then
vim.lsp.for_each_buffer_client(bufnr, function(client, client_id)
if client.name == "tsserver" then vim.lsp.stop_client(client_id, true) end
end)
-- if tsserver attached, stop it if there is a denols server attached
elseif curr_client.name == "tsserver" then
for _, client in ipairs(vim.lsp.get_clients { bufnr = bufnr }) do
if client.name == "denols" then
vim.lsp.stop_client(curr_client.id, true)
break
"AstroNvim/astrolsp",
optional = true,
opts = {
config = {
denols = {
-- adjust deno ls root directory detection
root_dir = function(...) return require("lspconfig.util").root_pattern("deno.json", "deno.jsonc")(...) end,
},
},
},
},
{
"AstroNvim/astrocore",
---@type AstroCoreOpts
opts = {
autocmds = {
-- set up autocommand to choose the correct language server
typescript_deno_switch = {
{
event = "LspAttach",
callback = function(args)
local bufnr = args.buf
local curr_client = vim.lsp.get_client_by_id(args.data.client_id)

if curr_client and curr_client.name == "denols" then
local clients = (vim.lsp.get_clients or vim.lsp.get_active_clients) {
bufnr = bufnr,
name = "typescript-tools",
}
for _, client in ipairs(clients) do
vim.lsp.stop_client(client.id, true)
end
end

-- if tsserver attached, stop it if there is a denols server attached
if curr_client and curr_client.name == "typescript-tools" then
if next((vim.lsp.get_clients or vim.lsp.get_active_clients) { bufnr = bufnr, name = "denols" }) then
vim.lsp.stop_client(curr_client.id, true)
end
end
end
end
end,
})
local astrolsp_avail, astrolsp = pcall(require, "astrolsp")
opts.server = astrolsp_avail and astrolsp.lsp_opts "denols"
opts.server.root_dir = require("lspconfig.util").root_pattern("deno.json", "deno.jsonc")
end,
end,
},
},
},
},
},
}
10 changes: 1 addition & 9 deletions lua/astrocommunity/pack/typescript-deno/init.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
return {
{
"AstroNvim/astrolsp",
optional = true,
---@type AstroLSPOpts
opts = {
---@diagnostic disable: missing-fields
handlers = { denols = false },
},
},
{ import = "astrocommunity.pack.json" },
{
"nvim-treesitter/nvim-treesitter",
Expand Down Expand Up @@ -44,6 +35,7 @@ return {
{
"sigmasd/deno-nvim",
ft = { "javascript", "typescript", "javascriptreact", "typescriptreact" },
dependencies = { { "AstroNvim/astrolsp", optional = true, opts = { handlers = { denols = false } } } },
opts = function(_, opts)
local astrolsp_avail, astrolsp = pcall(require, "astrolsp")
if astrolsp_avail then opts.server = astrolsp.lsp_opts "denols" end
Expand Down
Loading