Skip to content

4542elgh/telescope-scratch-run.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Telescope Scratch Run integration

Telescope picker for running simple code via stdin to language compiler and output to message window.

How does it look?

Color scheme is Darcula made with TJ's colorbuddy plugin
drawing
Using Python as an example
drawing

Why?

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.

Installation

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')

Configuration

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
                }
            }
        }
    },
})

Usage

The extension provides the following picker:

" output available compilers
:Telescope scratch_run 

Lua equivalent:

require('telescope').extensions.scratch_run.all()

About

Telescope picker for running simple code via stdin to language compiler and output to message window.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages