Telescope picker for running simple code via stdin to language compiler and output to message window.
Color scheme is Darcula made with TJ's colorbuddy plugin
Using Python as an example
This plugin was created so I do not have to create a file or go to playground to test simple code. A lot of times, I just want to see if syntax is correct or validate my logic is correct.
And this plugin does exactly that.
It is a simple plugin, it simply run :w !YOUR_LANG_COMPLIER
command.
You dont need to save anything into a file. Just open a new/scratch buffer with :new
and type out the code you need to test.
Then running this telescope plugin and it will take current buffer as standard input (stdin) and run it via your language's compiler.
Note: you need to have your language toolchain/compiler installed before running this.
If you are using packer.nvim, use this to setup scratch_run
use "4542elgh/telescope-scratch-run.nvim"
If you are using lazy.nvim, use this to setup scratch_run
"4542elgh/telescope-scratch-run.nvim"
In Telescope setup, require smb_unc module
require('telescope').load_extension('scratch_run')
For user defined command, you can use the following config structure under Telescope's setup.extensions
require("telescope").setup({
defaults = {
...
},
extensions = {
...
scratch_run = {
custom_compilers = {
lua = {
name = "lua",
cmd = ":w !jit" -- Make sure your command start with ':w !' then follow by your compiler command
}
}
}
},
})
The extension provides the following picker:
" output available compilers
:Telescope scratch_run
Lua equivalent:
require('telescope').extensions.scratch_run.all()