neovim-nightly-overlay icon indicating copy to clipboard operation
neovim-nightly-overlay copied to clipboard

Could not find a valid `tsserver` executable in the workspace

Open marcelarie opened this issue 3 years ago • 3 comments

nvim LSP can't find the tsserver binary. To replicate, use this config:

{
    inputs.neovim-nightly-overlay.url = github:nix-community/neovim-nightly-overlay;
    outputs = inputs @ {
     }: let
    username = "m.manzanares";
    system = "x86_64-darwin";
    pkgs = import nixpkgs {
      inherit system;
      config = {allowUnfree = true;};
      overlays = [
        pkg-sets
        nur.overlay
        spacebar.overlay.x86_64-darwin
        neovim-nightly-overlay.overlay
      ];
    };
    configuration = {pkgs, ...}: {
      nix.package = pkgs.nixFlakes;
      services.nix-daemon.enable = true;
    };
  in {

      darwinConfigurations."bcn-marcel-manzanares" = darwin.lib.darwinSystem {
      inherit pkgs system;
      modules = [
        ./darwin-configuration.nix
        home-manager.darwinModules.home-manager
        {
          home-manager.useUserPackages = true;
          home-manager.useGlobalPkgs = true;
          home-manager.users."m.manzanares" = {
            imports = [./home-manager/home.nix];
          };
        }
      ];
    };

    # Expose the package set, including overlays, for convenience.
    darwinPackages = self.darwinConfigurations."bcn-marcel-manzanares".pkgs;
  };
}

in home.nix:

  programs.neovim = {
    enable = true;
    package = pkgs.neovim-nightly;
    viAlias = true;
    withPython3 = true;
    extraConfig = ''luafile ${homeDir}/.config/nvim/nix.init.lua'';

    extraPackages = with pkgs; [
      deno
      texlab
      stylua
      sqlite
      tree-sitter
      rust-analyzer
      sumneko-lua-language-server
      pkgs.rnix-lsp

      perlPackages.PLS
      perl534Packages.PerlTidy
      perl534Packages.PerlCritic
      nodePackages.prettier
      nodePackages.prettier_d_slim

      nodePackages.eslint_d
      nodePackages.typescript
      nodePackages.intelephense
      nodePackages.vim-language-server
      nodePackages.bash-language-server
      nodePackages.yaml-language-server
      nodePackages.typescript-language-server
      nodePackages.vscode-langservers-extracted
      nodePackages.dockerfile-language-server-nodejs
    ];
  };

The error return in nvim:

Error executing vim.schedule lua callback: ...ovim-unwrapped-master/share/nvim/runtime/lua/vim/lsp.lua:987: RPC[Error] code_name = InternalError, message = "R
equest initialize failed with message: Could not find a valid tsserver executable in the workspace or in the $PATH. Please ensure that the \"typescript\" depe
ndency is installed in either location. Exiting."
stack traceback:
        [C]: in function 'assert'
        ...ovim-unwrapped-master/share/nvim/runtime/lua/vim/lsp.lua:987: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

If I work in a repository that has tsserver installed on local via npm, the LSP works.

marcelarie avatar May 14 '22 18:05 marcelarie

I had the same issue and my workaround was to add --tsserver-path=tsserver to the launch options of the lsp settings in neovim.

require'lspconfig'.tsserver.setup{
    cmd = {"typescript-language-server", "--stdio", "--tsserver-path=tsserver" }
}

If that doesn't work try to use the absolute path of tsserver to test if it works.

fabbz avatar Jul 28 '22 15:07 fabbz

cmd = {"typescript-language-server", "--stdio", "--tsserver-path=tsserver" }

Thanks @fabbz, that worked !!

marcelarie avatar Jul 28 '22 18:07 marcelarie

Thank you @marcelarie for asking this and @fabbz for answering! Any idea what is causing this?

thomas-humi avatar Aug 04 '22 12:08 thomas-humi

Out of the scope of this repo. This repo is only meant for providing an overlay and binary cache for nightly build.

Kranzes avatar May 02 '23 14:05 Kranzes