code_runner.nvim icon indicating copy to clipboard operation
code_runner.nvim copied to clipboard

Is there any ways to run nvim cmd with code_runner?

Open NEX-S opened this issue 3 years ago • 4 comments

I want to make my code_runner.nvim run MarkdownPreviewToggle in nvim cmd after i press some keys....

NEX-S avatar Jul 06 '22 16:07 NEX-S

I try to use this but seems not working...

        use { 'CRAG666/code_runner.nvim',
            requires = 'nvim-lua/plenary.nvim',
            -- cmd = { 'RunFile', 'RunCode' },
            config = [[
                require "code_runner".setup {
                    mode = "float",
                    startinsert = false,
                    float = {
                        border = "single",
                        blend = 30,
                    },
                    filetype = {
                        python = "time python3 -u",
                        c = "cd $dir && gcc $fileName -o $fileNameWithoutExt -Wall && time ./$fileNameWithoutExt && rm $fileNameWithoutExt",
                        php = "time php $fileName",
                        sh = "time sh $fileName",
                        html = "time google-chrome-stable $fileName",
                        markdown = vim.cmd "MarkdownPreviewToggle",
                        lua = vim.cmd "source $MYVIMRC",
                        http = require "rest-nvim".run(),
                    },
                }
            ]]
        }

NEX-S avatar Jul 06 '22 17:07 NEX-S

i have to use this to run mutiple code in one window :(


vim.api.nvim_create_autocmd({ "BufRead", "BufEnter", "BufNewFile", "TabEnter" }, {
    pattern = { "*.python", "*.php", "*.c", "*.html", "*.sh" },
    callback = function ()
        vim.keymap.set('n', ';r', '<CMD>RunCode<CR>', { noremap = true, silent = true })
    end
})

vim.api.nvim_create_autocmd({ "BufRead", "BufEnter", "BufNewFile", "TabEnter" }, {
    pattern = { "*.lua" },
    callback = function ()
        vim.keymap.set('n', ';r', '<CMD>source $MYVIMRC<CR>', { noremap = true, silent = true })
    end
})

vim.api.nvim_create_autocmd({ "BufRead", "BufEnter", "BufNewFile", "TabEnter" }, {
    pattern = { "*.md" },
    callback = function ()
        vim.keymap.set('n', ';r', '<CMD>MarkdownPreviewToggle<CR>', { noremap = true, silent = true })
    end
})

vim.api.nvim_create_autocmd({ "BufRead", "BufEnter", "BufNewFile", "TabEnter" }, {
    pattern = { "*.http" },
    callback = function ()
        vim.keymap.set('n', ';r', '<CMD>lua require "rest-nvim".run()<CR>', { noremap = true, silent = true })
    end
})

NEX-S avatar Jul 06 '22 17:07 NEX-S

This is not the normal behavior of code_runner, it works based on shell commands only use vim for the console or the windows, if you want to try to implement what you need, I am acept to any pr

CRAG666 avatar Jul 07 '22 13:07 CRAG666

lol im noob for github and i havent use git before, but i will try my best to implement that <3.

NEX-S avatar Jul 07 '22 18:07 NEX-S