Skip to content

Update ts_ls.lua to include instructions for ember support #3851

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

Closed
wants to merge 7 commits into from

Conversation

NullVoxPopuli
Copy link
Contributor

idk if we just want instructions here? because we can do a lot better with the on_new_config hook.

Here is what I do in my own configs:

    if (serverName == 'ts_ls') then
      local filetypes = {
        'typescript',
        'javascript',
        'typescript.glimmer',
        'javascript.glimmer',
        'typescript.tsx',
        'javascript.jsx',
        'html.handlebars',
        'handlebars',
      }
      server.setup({
        -- filetypes MUST include our custom filetypes for all variants of TS that we might want to use
        -- else the server won't boot and on_new_config won't get called, so we can't conditionally
        -- configure the init_options based on our project
        filetypes = filetypes,
        root_dir = utils.is_ts_project,
        capabilities = capabilities,
        -- This allows us to switch types of TSServers based on the open file.
        -- We don't always need the @glint/tsserver-plugin -- for example, in backend projects.
        on_new_config = function(new_config, new_root_dir)
          local info = utils.read_nearest_ts_config(new_root_dir)
          local glintPlugin = new_root_dir .. "node_modules/@glint/tsserver-plugin"

          if new_config.init_options then
            new_config.init_options.tsdk = get_typescript_server_path(new_root_dir)
            new_config.init_options.requestForwardingCommand = "forwardingTsRequest"


            if (info.isGlintPlugin) then
              new_config.init_options.plugins = {
                {
                  name = "@glint/tsserver-plugin",
                  location = glintPlugin,
                  languages = filetypes,
                  enableForWorkspaceTypeScriptVersions = true,
                  configNamespace = "typescript"
                }
              }
              print(glintPlugin)
            end
          end
        end,
        init_options = {
          tsserver = { logVerbosity = 'verbose', trace = "verbose" },
          preferences = {
            disableAutomaticTypingAcquisition = true,
            importModuleSpecifierPreference = "relative",
            importModuleSpecifierEnding = "minimal",
          },
          plugins = {}
        },
        settings = mySettings[serverName],
        on_attach = function(client, bufnr)
          keymap(bufnr)
          conditional_features(client, bufnr)
        end
      })

this allows automatic swapping of the tsplugins based on package.json, tsconfig.json, and/or node_modules contents

@justinmk
Copy link
Member

from the lint ci :

lint.sh: Configs in lua/lspconfig/configs/* are deprecated. Add or update configs in lsp/* instead.

@justinmk
Copy link
Member

stylua lint issue

@justmejulian
Copy link
Contributor

Isn't @glint/tsserver-plugin deprecated?
https://www.npmjs.com/package/@glint/tsserver-plugin

@justinmk justinmk closed this Jun 17, 2025
@NullVoxPopuli
Copy link
Contributor Author

No, we're working on an alpha which undeprecates it.

Latest alpha was released yesterday

@NullVoxPopuli
Copy link
Contributor Author

It's been undeprecated now

@wagenet
Copy link

wagenet commented Jun 18, 2025

Note that npm still shows it as deprecated since the @latest is deprecated. The alpha version is not deprecated.

@justmejulian
Copy link
Contributor

Isn't this very specific to ember? Does it make sense to bloat the ts_ls description with something that does not effect most typescript users?
Maybe it would make more sense add it to glint.lua.
We could list it as an alternative to using the glint-language-server.

@NullVoxPopuli
Copy link
Contributor Author

Isn't this very specific to ember? Does it make sense to bloat the ts_ls description with something that does not effect most typescript users?

No moreso than the already existing vue/volar docs in here.

In reality, i'd like a way in these configs to automatically configure ts_ls plugins based on detected project config. That way, vue/volar, ember/glint, can 'just work', and not require additional config, unless for customization, like full LSes.

glint.lua

Maybe, the hope is to declare this as legacy support when we release all our v2 LS/tsserver-plugin stuff

@NullVoxPopuli
Copy link
Contributor Author

@justmejulian -- would you be willing to receive a PR that adjusts the configs to automatically apply the configs listed here in the docs based on detected packages / config files? that way, we don't need a massive documentation block for every variation.

The main thing I'd bring over from my own dotfiles, is a function like this that does the branching logic / boolean creating: https://github.com/NullVoxPopuli/dotfiles/blob/main/home/.config/nvim/lua/plugin-config/lsp/utils.lua#L44

@justmejulian
Copy link
Contributor

I don’t think I have any say in the matter 🙆
I only came across the PR while setting up Glint in my personal config. After seeing that @glint/tsserver-plugin was deprecated, I ended up using the @glint/core LSP server instead.

My personal opinion would be to keep the configs as simple as possible, and split out things like Glint/Vue into their own configs, so only the people who need them are affected. Not sure how doable that is with plugins that rely on ts_ls, though.

Long story long: if you think it would be beneficial, go ahead and open a PR! From what I’ve seen in this repo, contributions are always appreciated.

PS: Thanks for all your work in the Ember community!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants