emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* typescript from org src buffer -- tide, lsp
@ 2021-11-04  3:30 Greg Minshall
  2021-11-06 10:33 ` Tim Cross
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Minshall @ 2021-11-04  3:30 UTC (permalink / raw)
  To: emacs-orgmode

hi.

i'm wondering if anyone programming in typescript might have run into,
and solved, this "problem", of tangling into a subdirectory, and tide
[1] not being able to resolve "relative" imports.

i have a file in path /a/b/foo.org.  it includes various source blocks,
and they do things like `:tangle c/d/bar.ts`.  another source block,
tangled into in c/d/fubar.ts, say, does something like:
----
import Bar from "./bar"
----

when i open an Org Src edit buffer from fubar.ts's source block, with
tide mode [1] enabled, i get a complaint
----
Cannot find module './bar' or its corresponding type declarations. [2307]
----
tide (or, really, iiuc, tsserver) appears to be, reasonably, looking for
/a/b/bar.ts, and not finding it.  but, i haven't been able to figure out
how to talk tide into looking elsewhere.

i've done things like add "rootDirs" to `tsconfig.json`, to no avail.  i
haven't been able to get lsp-mode [2] to work for this scenario, either.

anyway, in case anyone has done exactly that, i'm asking.

cheers, Greg

[1] tide: https://github.com/ananthakumaran/tide
[2] lsp:  https://github.com/emacs-lsp/lsp-mode/


ps -- scrounging around trying to deal with this, i stumbled on
----
https://github.com/justbur/emacs-which-key
----
which i find a treat.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: typescript from org src buffer -- tide, lsp
  2021-11-04  3:30 typescript from org src buffer -- tide, lsp Greg Minshall
@ 2021-11-06 10:33 ` Tim Cross
  2021-11-06 15:29   ` Samuel Banya
  2021-11-06 16:56   ` Greg Minshall
  0 siblings, 2 replies; 4+ messages in thread
From: Tim Cross @ 2021-11-06 10:33 UTC (permalink / raw)
  To: emacs-orgmode


Greg Minshall <minshall@umich.edu> writes:

> hi.
>
> i'm wondering if anyone programming in typescript might have run into,
> and solved, this "problem", of tangling into a subdirectory, and tide
> [1] not being able to resolve "relative" imports.
>
> i have a file in path /a/b/foo.org.  it includes various source blocks,
> and they do things like `:tangle c/d/bar.ts`.  another source block,
> tangled into in c/d/fubar.ts, say, does something like:
> ----
> import Bar from "./bar"
> ----
>
> when i open an Org Src edit buffer from fubar.ts's source block, with
> tide mode [1] enabled, i get a complaint
> ----
> Cannot find module './bar' or its corresponding type declarations. [2307]
> ----
> tide (or, really, iiuc, tsserver) appears to be, reasonably, looking for
> /a/b/bar.ts, and not finding it.  but, i haven't been able to figure out
> how to talk tide into looking elsewhere.
>
> i've done things like add "rootDirs" to `tsconfig.json`, to no avail.  i
> haven't been able to get lsp-mode [2] to work for this scenario, either.
>
> anyway, in case anyone has done exactly that, i'm asking.
>

I've not tried to do this, but a complete shot in the dark....

according to the org manual, you can set a :dir value in the source
block header which will specify the working directory to be used i.e.
the directory where the code will be evaluated. Perhaps setting that to
the directory where the other block has tangled the output would work?

See the Environment of a code block node under the working with source
code node in the org manual for details.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: typescript from org src buffer -- tide, lsp
  2021-11-06 10:33 ` Tim Cross
@ 2021-11-06 15:29   ` Samuel Banya
  2021-11-06 16:56   ` Greg Minshall
  1 sibling, 0 replies; 4+ messages in thread
From: Samuel Banya @ 2021-11-06 15:29 UTC (permalink / raw)
  To: Charles Berry

[-- Attachment #1: Type: text/plain, Size: 2343 bytes --]

Cool topic, but I haven't done it myself either as most explanations are pretty big-brained in the sense that its a little hard for a beginner to figure out sometimes.

However, the power of literate programming is super cool, so here's a few links I found that you can go through that might help you out:
https://www.reddit.com/r/emacs/comments/a3rlvk/orgmode_literate_programming_and_emacs/
https://emacs-lsp.github.io/lsp-mode/manual-language-docs/lsp-org/
https://blog.thomasheartman.com/posts/configuring-emacs-with-org-mode-and-literate-programming
http://cachestocaches.com/2018/6/org-literate-programming/

Hope it helps, 

Sam

On Sat, Nov 6, 2021, at 6:33 AM, Tim Cross wrote:
> 
> Greg Minshall <minshall@umich.edu> writes:
> 
> > hi.
> >
> > i'm wondering if anyone programming in typescript might have run into,
> > and solved, this "problem", of tangling into a subdirectory, and tide
> > [1] not being able to resolve "relative" imports.
> >
> > i have a file in path /a/b/foo.org.  it includes various source blocks,
> > and they do things like `:tangle c/d/bar.ts`.  another source block,
> > tangled into in c/d/fubar.ts, say, does something like:
> > ----
> > import Bar from "./bar"
> > ----
> >
> > when i open an Org Src edit buffer from fubar.ts's source block, with
> > tide mode [1] enabled, i get a complaint
> > ----
> > Cannot find module './bar' or its corresponding type declarations. [2307]
> > ----
> > tide (or, really, iiuc, tsserver) appears to be, reasonably, looking for
> > /a/b/bar.ts, and not finding it.  but, i haven't been able to figure out
> > how to talk tide into looking elsewhere.
> >
> > i've done things like add "rootDirs" to `tsconfig.json`, to no avail.  i
> > haven't been able to get lsp-mode [2] to work for this scenario, either.
> >
> > anyway, in case anyone has done exactly that, i'm asking.
> >
> 
> I've not tried to do this, but a complete shot in the dark....
> 
> according to the org manual, you can set a :dir value in the source
> block header which will specify the working directory to be used i.e.
> the directory where the code will be evaluated. Perhaps setting that to
> the directory where the other block has tangled the output would work?
> 
> See the Environment of a code block node under the working with source
> code node in the org manual for details.
> 
> 

[-- Attachment #2: Type: text/html, Size: 3734 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: typescript from org src buffer -- tide, lsp
  2021-11-06 10:33 ` Tim Cross
  2021-11-06 15:29   ` Samuel Banya
@ 2021-11-06 16:56   ` Greg Minshall
  1 sibling, 0 replies; 4+ messages in thread
From: Greg Minshall @ 2021-11-06 16:56 UTC (permalink / raw)
  To: Tim Cross; +Cc: emacs-orgmode

Tim and Samuel, thanks.  :dir is a thought; and, links may yield
treasures.

cheers, Greg


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-06 16:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-04  3:30 typescript from org src buffer -- tide, lsp Greg Minshall
2021-11-06 10:33 ` Tim Cross
2021-11-06 15:29   ` Samuel Banya
2021-11-06 16:56   ` Greg Minshall

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).