Giter Club home page Giter Club logo

code_runner.nvim's People

Contributors

akatheduelist avatar azinsharaf avatar borwe avatar burgr033 avatar crag666 avatar dead-1ine avatar dorrajmachai avatar indianboy42 avatar nex-s avatar pandademic avatar registergen avatar saccarosium avatar sam-hobson avatar sigmasd avatar songlinlife avatar syphdias avatar zzlinus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

code_runner.nvim's Issues

markdown

filetype = {
markdown = "MarkdownPreview",
},

zsh:1: command not found: MarkdownPreview

Python focus

How would I go about setting up the .json file to run in python3, but to start on insert so I can use the terminal interactively? Also, the -U doesn't seem to work in python3

problen with the spaces in an file/folder name

for example i have the file named program one
code runner will execute
g++ program
g++ one
givin an error becose none of these files exist
i tried to fix it with the other threath about this but only works for the directory

Mode for specific project is broken after recent update

I've update to the latest commit and my configuration for project specific mode is broken.

require('code_runner').setup({
    startinsert = true,
    filetype = {
        c = "gcc --std=c11 -g -Wall $file && $dir/a.out",
        cpp = "g++ --std=c++14 -g -Wall $file && $dir/a.out",
        ruby = "ruby $file",
        python = "python3 $fileName",
    },
    project = {
        ["~/Repos/github.com/saccarosium/pel_json_parser"] = {
            name = "json parser",
            command = "make && ./build/json",
            mode = "tab"
        },
    }
})

Stuck when using exteral storage

OS: MacOs 13.2.1
Neovim: 0.8.3
Exteral storage: Samsung T7

It works on my local storage.
Oterh coderunner plugins able to run on exteral storage (spinrun).
Both file file format APFS and ExFAT have same issue.
All lagnuage have same situation (Java, python, typescript etc....)

The issue is:
when I type cmd :RunCode, the whole termainl freeze and cpu useage goes 99%. Need to reboot everything.

Config:
https://github.com/NateCC0902/nvim/blob/main/after/plugin/coderunner.lua

code_runner.nvim is not working in neovim-v0.8.0-dev-1063-g2f385d17a0

Runcode is not working
Runfile seems still working

my config file

use { 'CRAG666/code_runner.nvim',
            requires = 'nvim-lua/plenary.nvim',
            cmd = { 'RunFile', 'RunCode' },
            config = [[
                require "code_runner".setup {
                    mode = "float",
                    startinsert = true,
                    close_key = '<ESC>',
                    float = {
                        border = "single",
                        blend = 20,
                    },
                    filetype = {
                        python = "time python3 -u",
                        c = "cd $dir && gcc $fileName -std=gnu2x -I ./ -g -o ./bin/$fileNameWithoutExt -Wall && printf '\\n' && time ./bin/$fileNameWithoutExt",
                        php = "time php $fileName",
                        sh = "time sh $fileName",
                        html = function ()
                            local file = vim.fn.expand("%:t")
                            vim.fn.system("google-chrome-stable "..file)
                        end,
                        lua = "lua $fileName",
                        http = require "rest-nvim".run,
                        vim = function ()
                            vim.cmd "w | source $MYVIMRC | source %"
                        end,
                        markdown = function ()
                            vim.cmd "MarkdownPreviewToggle"
                        end,
                    },
                }
            ]]
        }

attempt to call a nil value

while trying to run project I got this error, runing a single file is fine.
Error executing Lua callback: ...e/pack/packer/start/code_runner.nvim/lua/code_runner.lua:75: attempt to call a nil va lue stack traceback: ...e/pack/packer/start/code_runner.nvim/lua/code_runner.lua:75: in function <...e/pack/packer/start/code_runne r.nvim/lua/code_runner.lua:75>
below is my setup for code_runner,
I am using neovim-nightly and the plugin are updated to the latest. this happened recently

use({ "CRAG666/code_runner.nvim", requires = "nvim-lua/plenary.nvim", config = function() require("code_runner").setup({ term = { position = "vert", size = 15 }, mode = "toggleterm", filetype = { java = "cd $dir && javac $fileName && java $fileNameWithoutExt", python = "python ", lua = "lua ", rust = "cd $dir && mkdir -p .bin && rustc -g $fileName -o .bin/$fileNameWithoutExt && .bin/$fileNameWithoutExt", cpp = "cd $dir && mkdir -p .bin && g++ -g $fileName -o .bin/$fileNameWithoutExt && .bin/$fileNameWithoutExt", c = "cd $dir && mkdir -p .bin && gcc -g $fileName -o .bin/$fileNameWithoutExt && .bin/$fileNameWithoutExt", }, project = { ["~/playground/c++/open-gl"] = { name = "open gl learning", description = "repo to learn open gl", file_name = "main.cpp", command = "make -C build run", }, ["~/playground/c++/dict_cpp"] = { name = "My Dictionary app", description = "compile dict", command = "make run", }, }, }) end, })

nice plugin :-)

Hi, i'm here kinda on technological watch as sniprun's developper and I found you through the similar interactions an user (z0xyz) had on both our repos. Since you had that mention on your readme about not having found suitable projects then, I wondered if that was just a matter of timing (sniprun wasn't half as good/popular in feb 2021) or if it didn't make the cut for some other reason.

Also, looks like we both were jealous of VSCode's code runner and decided to create our own plugin ahah ! Your approach is very similar to the original thing though !
We don't do exactly the same thing, but feel free to steal features take inspiration from sniprun and I won't hesitate to do the same.

Code-writingly yours,
Michael

[feat]: support accept function as filetype value

Sometimes it will be helpful to dynamically generate runner commands for different case

I think it should accept a function that returns a string as a runner command

maybe it also can accept some args like project name or etc...

<ESC> will cause some problem in code_runner.nvim

my code_runner 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",
                        lua = "lua $fileName",
                    },
                }

after floating windows popup and press <ESC>

E5108: Error executing lua [string ":lua"]:1: Expected Lua number
stack traceback:
        [C]: in function 'nvim_win_close'
        [string ":lua"]:1: in main chunk
Press ENTER or type command to continue

How to run Lua code in buf/tab/etc

Hello, thank you for your great plugin.
I have a question: when I run my python code I can see output in tab/buf/toggleterm etc
but when I run Lua code it's just this
image

my config looks like this (I use Packer):

{
    "CRAG666/code_runner.nvim",
    config = function()
        require("code_runner").setup({
            -- put here the commands by filetype
            startinsert = false,
            filetype = {
                java = "cd $dir && javac $fileName && java $fileNameWithoutExt",
                lua = "lua",
                python = "python3 -u",
                typescript = "deno run",
                rust = "cd $dir && rustc $fileName && $dir/$fileNameWithoutExt",
                javascript = "node",
                shellscript = "bash",
            },
        })
    end,
}

How to run Lua code in buf/tab not in this notification kinda looking window?

Error 471

Good morning, after the last commit the plugin stopped working in my neovim, when I try to run it, it returns an E471 as shown in the image below:

image

I wonder if there is any way to solve it?

Error when executing

Good evening, I have always used this plugin to be able to run my python codes, and I have to congratulate the creator because his plugin is just perfect.

Earlier today I could run my code normally through your plugin, but I tried to run it again and it is showing this error in the image below:

Captura de tela de 2022-08-04 17-57-10

Picture of my configuration:

Captura de tela de 2022-08-04 17-59-45

Is there a solution to this error?

Code_runners doesn't seem to work on lunarvim

Alright I'm gonna be honest, I'm a new lunarvim user, so I might be doing something wrong, but I attempted to install the plugin by adding it to the config.lua file under the "additional plugins" section of the config. While it did appear to install (the files are where they should be at least), I cannot seem to use any of the commands. Is this an issue with lunar vim? Am I missing something?

Windows

Complains about json_path being nil in windows.

nevim freezes after `:RunClose`

hi @CRAG666
posting this here as a separate issue since the other one (#51) is closed.
first let me thank you. I'm excited to use it since it would save my coding time.

:RunClose freezes neovim.

NeoVim version : 0.8.3

v2.mp4

`:RunClose` 'crashes' nvim

nvim: v0.7.2

When I run :RunClose the nvim will freeze and won't be back to normal, forcing me to close the editor having unsaved files.
Don't know the reason, but I've updated nvim and the plugin itself, yet to fix the problem.

To do the problem described;
Just like any file, do :RunCode, then do :RunClose which freezes the editor and no way to revert back.

Presumable bug with code segments prompting for user input and multiple terminals

Hello, i'm currently facing two "issues"
Firstly I have to press i every single time a piece of the code prompt the user for input . Like for instance if i have a python code with input function and run the whole file, then the terminal opens up but not place the cursor for input right away .
Secondly every single time i run , a new terminal windows pops up , so i constantly have to close them to have just one . Can't it be just one terminal window with the option to clear the previous output or even leave the previous output , but all within one single terminal window ?

Running code inside a folder that have spaces on its name results in "too many arguments" error (and how to fix it)

I'm using the default lazy configuration from the README

image

Problem:
The RunCode/RunFile command works well, except for when we are trying to run file inside a directory that has space(s) in its name- for example: "Chapter 03 - If"/ folder.

image

If we rename the directory to not have spaces, it will work as expected

image

I suspect it has something to do with how the "$dir" in filetype from setup returns the string. I found a quick fix by wrapping the $dir with a ' ' (colon) will work as expected.

-- before
cpp = "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt",
-- after
cpp = "cd '$dir' && g++ $fileName -o $fileNameWithoutExt && '$dir/$fileNameWithoutExt'",

C++ not configured but my main.cpp is compiling and running

I installed the plugin and configured it for java , python, Javscript and rust as shown in the example config. I also put the shortcut key for running the code. I wanted to run c++ code so i wanted to configure this plugin but i didnot configure it instead i downloaded another cmake plugin. I didnot bind the cmake plugin though just installed it. Now when i open main.cpp file and do the shortcut for coderunner it runs my c++ code. How is this possible ?

can I use this for my game engine

I'm making a game engine with both block/visual code and written code, I have the block stuff mostly sorted and I want to see if I can use this for the written code because lua is the easiest programming language I know.

Expected lua string

HI! At first, thanks a lot for the nice plugin.

When I used this plugin just now, I got an error:

E5108: Error executing lua ...cker/start/code_runner.nvim/lua/code_runner/commands.lua:89: Expected lua string
stack traceback:
        [C]: in function 'cmd'
        ...cker/start/code_runner.nvim/lua/code_runner/commands.lua:89: in function 'run_filetype'
        ...cker/start/code_runner.nvim/lua/code_runner/commands.lua:138: in function 'run_code'
        [string ":lua"]:1: in main chunk

here is my minimal init.lua about code_runner:

use { 'CRAG666/code_runner.nvim', requires = 'nvim-lua/plenary.nvim' }   in packer

require('code_runner').setup {
  term = {
    position = "belowright",
    size = 8
  },
  filetype_path = "$HOME/.config/nvim/code_runner.json",
  project_path = "$HOME/.config/nvim/projects.json"
}

and here is my coder_runner.json:

{
      "python": "python -u"
}

It seems also like this for other languages.

Why we need to do this ?

if command == no_sub_command then
command = command .. " " .. path
end

I inject my cofig like this:

require('code_runner').setup({
  mode = 'toggleterm',
  filetype = {
    c = (function()
      if vim.fn.has('win32') == 1 then
        result = ('cd %s && clang %s -o %s.exe && .\\%s.exe'):format(vim.fn.expand('%:p:h'), vim.fn.expand('%:t'), vim.fn.expand('%:t:r'), vim.fn.expand('%:t:r')):gsub('/', '\\')
        return result
      end
      return 'cd $dir && clang $fileName -o $fileNameWithoutExt && ./$fileNameWithoutExt'
    end)()
  }
})

The command I desire is:

cd C:\Users\aaba\Documents\_Documents\code-playground && clang main.c -o main.exe && .\main.exe

But it will auto append working directory path like this:

cd C:\Users\aaba\Documents\_Documents\code-playground && clang main.c -o main.exe && .\main.exe C:\Users\aaba\Documents\_Documents\code-playground

How can use map to run projetc

the command :SRunCode open json configuration but has not started anything
how can use :RunCode to start my project with this module

PDM Pep582 Support

I'm running Python scripts using "Python3", but need to run eval "$(pdm --pep582)" before I can run any code to set the environment variable. I've tried multiple "cmd" and "shell_cmd" options but cannot get it to work with my macOS Zsh setup. The auto setting of the variable is in my .zprofile and works when running the script through the integrated terminal or my external terminal iTerm2, just not code_runner. Any ideas on how to get this to work?

https://pdm.fming.dev/

[Feat] Run in Tmux

This is probably the best plugin for running code that I've seen yet, I'm currently using vimux to manually send commands to a tmux window, it does not offer as extensive configuration as this plugin. I was wondering if support for tmux could be added or maybe code runner + vimux sounds like a better idea

[FEATURE REQUEST] Ability to execute custom functions.

EG:

{
"cmake-build": "mkdir build && cd build && cmake ../ && $$findExecutableToExecute"
}

So when it reaches the $$finExecutableToExecute it will run a function that looks for an executable and returns the executable path.

How to keep terminal running after execution?

Hi, I want the terminal to keep running after the execution is finished.
And it will be nicer to make the plugin doesn't close the old tab and create new terminal every time it runs, rather just past the file type command with absolute path and run it, and keep the terminal open which let me see the previous output and compare with the old one.

In short, I want to make it function like the one in vscode.

[Bug] `RunProject <mode>` does not work for me

Description

If I use RunProject command in a project, it works well.

But if I use RunProject <mode>, it does not work, e.g. RunProject toggleterm.

Vim Version

NVIM v0.8.1
Build type: Release
LuaJIT 2.1.0-beta3

RunCode bug

Pressing tab after :RunCode now brings up an error.

image

Is executing a range from the current buffer possibe?

First of all, very useful plugin and has been satisfying so far to use. Just wondering is there a feature where I can execute a specified range (as in selected using visual mode), similar to snip run.

Tried RunCode on a range but it said no ranges allowed

Run a specific piece of code

Good afternoon, how are you?

I would like to know if it is possible to execute a specific piece of code instead of executing the whole code.

Currently I use the :RunFile command, but I would like to be able to select a piece of code in VISUAL MODE and run it.

Is it possible to do this?

Congratulations on your plugin, it is just perfect :)

height and width issue of a float window

I'm using float window with single border type. But it always shows the window in fullscreen no matter which height and width i use.
If I don't specify a height and width it works fine.

return {  
"CRAG666/code_runner.nvim",
 enabled = true,
 event = "VeryLazy",
 init = function() require("which-key").register({ ["<leader>r"] = { name = "Code Runner" } }, { mode = "n" }) end,
 opts = {
   mode = "float", --"toggle", "float", "tab", "toggleterm" 
   focus = true,
   term = {
     position = "bot",
     size = 25,
   },
   float = {
     border = "single",
     height = 30,
     width = 50,
   },
   filetype = {
     python = "C:\\Users\\azin\\AppData\\Local\\ESRI\\conda\\envs\\arcgispro-py3-clone\\python.exe"
   },
 },
 keys = {
   { "<leader>rr", "<cmd>RunCode<cr>",    desc = "Run Code" },
   { "<leader>rf", "<cmd>RunFile<cr>",    desc = "Run File" },
   -- { "<leader>rft", "<cmd>RunFile tab<cr>", desc = "Run File Tab" },
   { "<leader>rp", "<cmd>RunProject<cr>", desc = "Run Project" },
   { "<leader>rc", "<cmd>RunClose<cr>",   desc = "Run Close" },
   -- { "<leader>crf", "<cmd>CRFiletype<cr>", desc = "Open Json supported files" },
   -- { "<leader>crp", "<cmd>CRProject<cr>", desc = "Open Json list of projects" },
 },
}

wrong in the output

截屏2022-02-02 下午11 52 53

we can see the output and the code is not right in a line,
we donot know why it is narrow in the output line.

e492

I'm currently using a version of kickstart.nvim and when i added the plugin and set the keymap every time i try to run a file or code it says "e492: not an editor command:Run File, or run code:
Screenshot 2023-03-13 at 7 39 58 PM

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.