lsp-java icon indicating copy to clipboard operation
lsp-java copied to clipboard

oorg-mode babel - how to set up code blocks?

Open ghost opened this issue 4 years ago • 4 comments

I'm sorry if this is the wrong spot to post this.

How do I set up org-mode babel code blocks to evaluate java code blocks with lsp-java? More specifically, to highlight warnings and errors, and sync class codeblocks to a workspace I believe I need to set org-babel-execute to the proper command on lsp-java This functionality appears to have been present in emacs-eclim, so I think it should be possible to set it up. But it is not a common use case

relevant documentation https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-java.html

ghost avatar Aug 19 '21 19:08 ghost

This might be a dumb question

setting (org-babel-do-load-languages 'org-babel-load-languages '((java . t)))

allows the command (C-c C-c) to work, but no IDE is present in the code block, and it returns "Can't compile java block without classname" (but there is a class present. Will research more now)

ghost avatar Aug 19 '21 19:08 ghost

OK, so the solution is defining a classname in the block metadata as per https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-java.html#orgb7540b8. so far it runs fine, but it doesnt have any of the annotating power of lsp-server. So I'm wondering how to get org-mode to enable lsp-server (perhaps there is a hook or mode) within code blocks, and then how to get that code block to be linked to the right workspace

ghost avatar Aug 19 '21 20:08 ghost

have you checked https://github.com/emacs-lsp/lsp-mode/issues/2842#issuecomment-870807018

yyoncho avatar Aug 22 '21 18:08 yyoncho

Thanks mate I'll try this

ghost avatar Aug 22 '21 18:08 ghost