dmmulroy / tsc.nvim

A Neovim plugin for seamless, asynchronous project-wide TypeScript type-checking using the TypeScript compiler (tsc)
MIT License
403 stars 21 forks source link

Ability to init with raw command instead of flags #45

Open AkisArou opened 8 months ago

AkisArou commented 8 months ago

I have a monorepo where I use ts project references. I want to start the tsc from the nvim cwd (repo root dir), by executing "tsc --build /home/user/my-repo/tsconfig.json --watch".

I investigated the code, and I could not figure out a way to do this (specifically to define the path of tsconfig). Project references build command cannot be invoked with --project. I tried to trick it with bin_path option, but you check whether is executable. Via the flags you prepend double-dash.

Maybe you can provide a way to directly specify the command instead of the various options-flags? I think this may be the only way, because project references --build and rest args, should be placed in a specific order. (--build first, then tsconfig, then rest args).

Thanks! Nice plugin btw :)

dmmulroy commented 7 months ago

If the plugin respected the order of the flags in the config would that resolve this?

AkisArou commented 7 months ago

I do not think so because you prepend -- at flags and in the command for ts project references, the arg for project tsconfig has none. I find it difficult to abstract away flags-options and args to cover all cases. That's why I proposed a raw command

dmmulroy commented 7 months ago

Yeah okay I see what you're saying - I'm going to be pretty busy for the next few weeks w/ some tight deadlines. If you want to take a shot at implementing I'm happy to iterate async with you. Appreciate you raising the issue!

AkisArou commented 7 months ago

Ok I'll try to find time to implement it! Thanks

benfc1993 commented 7 months ago

Is the main issue that you want to run the TSC usrcmd and specify the path to the dir to use? If so would adding an option to specify a dir when running the TSC command work for you? Just thinking providing an option to hard code it in the package config would mean editing your nvim config whenever you change what you are working on.

The other option would maybe be the ability to provide a function which resolves to a string which can be run to set the location of the config when TSC is called?

AkisArou commented 7 months ago

Yes I think this will resolve it! This will contradict the project flag. Setting project = false so no default flag is used, will be needed.