CRAG666 / code_runner.nvim

Neovim plugin.The best code runner you could have, it is like the one in vscode but with super powers, it manages projects like in intellij but without being slow
MIT License
539 stars 38 forks source link

Is there any ways to run nvim cmd with code_runner? #28

Closed NEX-S closed 2 years ago

NEX-S commented 2 years ago

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

NEX-S commented 2 years ago

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 commented 2 years ago

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
})
CRAG666 commented 2 years ago

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

NEX-S commented 2 years ago

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