typescript-tools.nvim icon indicating copy to clipboard operation
typescript-tools.nvim copied to clipboard

feat(tsserver plugins): Allow for path in tsserver_plugins

Open Parsifa1 opened this issue 1 year ago • 12 comments

maybe closed #287

what i did

add a another way to add tsserver_plugins:

{
	name = "xxx",
	path = "xxx",
}

and can be mixed with string.

example:

local mason_path = vim.fn.stdpath "data" .. "/mason/packages/"
local ft = { "typescript", "javascript", "javascriptreact", "typescriptreact", "vue", "markdown.mdx" }

return {
    "pmizio/typescript-tools.nvim",
    ft = ft,
    dependencies = "nvim-lua/plenary.nvim",
    opts = {
        filetypes = ft,
        settings = {
            tsserver_plugins = {
                "@vue/typescript-plugin",        
                {
                    name = "@mdxjs/typescript-plugin",
                    path = mason_path .. "mdx-analyzer" .. "/node_modules/@mdx/language-server",
                },
            },
        },
    },
}

Parsifa1 avatar Jan 21 '25 11:01 Parsifa1

ci failed due to codelen not from this pr :X

Parsifa1 avatar Jan 21 '25 11:01 Parsifa1

could we get this merged? It is critical for NixOS users.

wvffle avatar Jan 23 '25 23:01 wvffle

Shouldn't there also be a way to specify specific languages/filetypes for each plugin?

Like the lspconfig docs include this to enable the vue plugins for ts_ls

  init_options = {
    plugins = {
      {
        name = "@vue/typescript-plugin",
        location = "/usr/local/lib/node_modules/@vue/typescript-plugin",
        languages = {"javascript", "typescript", "vue"},
      },
    },
  },

SafariKnight avatar Jan 24 '25 00:01 SafariKnight

you are right, this is way more better.

and i think it should be added into doc, some people like me didn't know we can even did it like this🥲

Parsifa1 avatar Jan 24 '25 04:01 Parsifa1

@Parsifa1 This PR seems to be valid, what's the reason for closing? I think that the project would benefit from it even if the same things can be configured through lspconfig.

wvffle avatar Jan 24 '25 11:01 wvffle

@wvffle I misunderstood what he meant. I thought TypeScript-tools already had the init_options function, but I realized it now. I will reopen it

Parsifa1 avatar Jan 24 '25 14:01 Parsifa1

It's been over a month, but this feature still hasn’t been merged. Just wanted to point out that this is really useful for nvm users—they wouldn’t have to depend on a specific npm version and could just install plugins anywhere (e.g., using Mason for the Vue plugin).

I’d rather not keep reinstalling global packages just for updating latest npm or change project directory.

Just wanted to share my thoughts—hope this feature available soon!

fzhnf avatar Mar 05 '25 06:03 fzhnf

I've been daily driving this PR since February and it works fine. Could we get this merged?

wvffle avatar May 02 '25 14:05 wvffle

Is there a reason this isn't getting merged? If you point out the issues, we can work on it @pmizio

Producdevity avatar May 27 '25 22:05 Producdevity

It seems like @KostkaBrukowa is responsible for maintaining this repository.

Could we get this merged?

wvffle avatar May 29 '25 23:05 wvffle

rebased with newest commit :)

Parsifa1 avatar Sep 02 '25 06:09 Parsifa1

add new filetype option:

local mason_path = vim.fn.stdpath "data" .. "/mason/packages/"
opts = {
        settings = {
            tsserver_plugins = {
                {
                    name = "@vue/typescript-plugin",
                    path = mason_path .. "vue-language-server" .. "/node_modules/@vue/language-server",
                    filetypes = { "vue", "typescript" },
                },
                {
                    name = "@mdxjs/typescript-plugin",
                    path = mason_path .. "mdx-analyzer" .. "/node_modules/@mdx/language-server",
                },
            },
        },
    },

you must set all possiable ft in the list, otherwise the lsp won't init properly. if filetype == nil, it will load everytime.

Parsifa1 avatar Sep 02 '25 08:09 Parsifa1