-
-
Notifications
You must be signed in to change notification settings - Fork 240
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
feat(pack): create multiple typescript packs #121
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for starting to take a look at this. I do recommend we don't rename the existing typescript
pack. This isn't a horrible name, will cause a lot of breaking changes to existing users, and you can still add the others. Also a bad habit in this community repo to effectively rename other people's contributions/"maintained" packages if you will
I have reverted the renaming commit. @ALL the project root detection is still broken which leads to tsserver being loaded when it shouldn't be.
I'll look into it but suggestions and direct help is always appreciated since I'm not the most experienced person when it comes to nvim/lsp configuration. |
@owittek just heads up, I edited your comment a bit to fix my suggestion with more detail |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned by @owittek these plugin packs don't work as intended. Marking as changes requested just in case anyone wants to pick this up to finish it. It's pretty close though!
I also want to add the dap & neo-tree configuration to |
@owittek did a bit of investigation into this. You could look into doing something like this: 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_active_clients { bufnr = bufnr }) do
if client.name == "denols" then
vim.lsp.stop_client(curr_client.id, true)
break
end
end
end
end,
}) You will still need to make sure you update the root_dir = require("lspconfig.util").root_pattern("deno.json", "deno.jsonc"), This seems to work pretty well, but it definitely feels a bit hacky. It would be much more preferable to just disable auto starting and calculate your own logic to attach the clients to buffers individually. |
lua/astrocommunity/pack/typescript-tsserver-and-denols/tsserver-and-denols.lua
Outdated
Show resolved
Hide resolved
803683b
to
ca102a7
Compare
9578b7c
to
1682851
Compare
I have yet to test the changes but I wouldn't mind getting feedback on the approach that I'm taking with the packs. |
@mehalter please review the changes & merge it if everything looks good. EDIT: For some reason the automatic installation does not work. |
did the involvement of babu in chat helped? |
I didn't get any input unfortunately, I'll see if @folke might be able to help since it might be an issue with config overriding by lazy.nvim. |
What automatic installation are you referring to? mason-null-ls? is that plugin being loaded? |
Awesome that you've responded here, I was planning to open a help request. If you look at the typescript-denols-and-tsserver.lua you can see that I'm importing both the denols & tsserver configs. Both configs override the mason-null-ls config (yep, that's a plugin that both configure) & importing both leads to wonky behavior. I can print from both functions but the config does not seem to work properly. Edit: ensure_installed is a table within |
Again, is mason-null-ls even loaded? Either way, no idea. I'm pretty sure config merging works as expected. Try adding some print statements inside the mason-null-ls thing to see the resolved config. Also remember that if you're configuring a list at two places, then lists are not going to be merged. To merge them manually, make the relevant |
just to be clear, add something like: config = function(_, opts)
vim.pretty_print(opts)
require("mason-null-ls").setup(opts)
end |
That's exactly what I'm doing, astrocommunity has a util function called list_insert_unique for that and I'm using it in both functions since they use the same base configuration |
Seems like nothing is being printed right now. A small correction on my part: |
If nothing gets printed after you add that |
Makes sense but what could be the reason for the plugin not being loaded? This is what I return to only configure {
{
import = "astrocommunity.pack.json"
},
{ "nvim-treesitter/nvim-treesitter",
opts = <function 1>
},
{ "williamboman/mason-lspconfig.nvim",
config = <function 2>,
opts = <function 3>
},
{ "jay-babu/mason-nvim-dap.nvim",
opts = <function 4>
},
{ "jay-babu/mason-null-ls.nvim",
opts = <function 5>
},
{ "jose-elias-alvarez/typescript.nvim",
ft = { "javascript", "typescript", "javascriptreact", "typescriptreact" },
init = <function 6>,
opts = <function 7>
},
{ "nvim-neo-tree/neo-tree.nvim",
opts = {
event_handlers = { {
event = "file_moved",
handler = <function 8>
}, {
event = "file_renamed",
handler = <function 8>
} }
}
},
{ "vuki656/package-info.nvim",
config = true,
event = "BufRead package.json",
requires = "MunifTanjim/nui.nvim"
},
{ "mfussenegger/nvim-dap",
config = <function 9>,
dependencies = { { "mxsdev/nvim-dap-vscode-js",
opts = {
adapters = { "pwa-node" },
debugger_cmd = { "js-debug-adapter" }
}
}, { "theHamsta/nvim-dap-virtual-text",
config = true
}, { "rcarriga/nvim-dap-ui",
config = true
} },
enabled = true,
ft = { "javascript", "typescript", "javascriptreact", "typescriptreact" }
}
} |
I assume you have |
That makes sense but AstroNvim itself configures -- I shortened the code just for demonstration
config = function(_, opts)
require("mason").setup(opts)
for _, plugin in ipairs { "mason-lspconfig", "mason-null-ls", "mason-nvim-dap" } do
pcall(require, plugin)
end
end |
Then there must be a bug in there, since it's not loaded. You can also check with |
Sorry, but this is 100% for sure user error. I'm sure you'll figure it out. I have other stuff to do. |
All good, thanks for your time! |
23f13a3
to
31e4840
Compare
b838dbb
to
176cb5e
Compare
Co-authored-by: Micah Halter <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
feat(pack): Add multiple typescript packs Co-authored-by: Micah Halter <[email protected]>
As described here I am looking to add separate packs for both tsserver, denols & tsserver + denols for TypeScript developers. This is a first attempt at doing it and the changes are yet to be tested. The reason why I already open a PR is so the original authors of the typescript pack can take a look at it and possibly extend the functionality (especially to the denols pack) to create a more mature prduct.
Personally I'd also consider adding
eslint_d
to the tsserver pack, please let me know your opinions about that.Resolves #120