I don't know of a plugin, but you can sorta do something kinda like the thing ish if you squint and cross your fingers...
You can perform actual in-place calculations by using the expression register. So for example:
= 2 + 2
<insert mode cursor here>
Then something like `<C-r>=eval(getline('1h')[2:])` will end up with:
= 2 + 2
4
If you regularly did so writing a more robust mapping would probably useful.
And using regular :global you could perform similar operations across a file with `:g/^= / <expression replacement>`
I think the real solution would be just to use evil-mode in emacs when you wish to use things like literate-calc-mode. I do that for org-mode because it is just so much more powerful than the basic vim plugin for org-mode files.
> Is it something very difficult in vim?
Since 8.2 was released you can use popupwin¹ to emulate something similar. I'd probably give it a go if you wrote it :P
It is a real shame you can't use a funcref(or even multiple characters) for conceal replacement, or you could simply add a conceal² for => to show the result. Such functionality would also be nice for inlining computed types in various languages too.
I've looked into this a bit and the closest thing I could find is in VimWiki, where certain plaintext patterns are dynamically replaced with other text without actually changing the buffer.
See how line 11 dynamically changes in this video based on whether his cursor is on the line:
I also second what JNRowe says about trying the new popup feature. I recently used this to run a script that calculates something based on where my cursor is currently at in the file, then show the result at the cursor using a popup:
fun! CalculateFoodCalories()
let day = GetSectionName()
let day = substitute(day, "\[", "", "g")
let day = substitute(day, "\]", "", "g")
let out = split(trim(system("food --date=" . day)), "\n")
call popup_atcursor(out, #{ title: "Today's calories", highlight: 'Statement', border: [], padding: [1,2,1,2]})
endfun
nnoremap <silent> <leader>m :call CalculateFoodCalories()<CR>
After looking into how conceal works, it doesn't look like you can use it to "annotate" a line or dynamically change the text on the screen without actually changing the contents of the buffer. It can only be used to hide some pattern of text that's already in the buffer.
I would look into using popups, a separate pane, or something like vim-notebook.