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

Don't work RunProject?

Open seriiserii825 opened this issue 1 year ago • 2 comments

Hi, thanks for plugin.

I am using simple neovim not with lua.

In code-runner.vim file

lua << EOF
require('code_runner').setup {
  filetype = {
    python = "python3 -u",
  },
  project_path = vim.fn.expand('~/.config/nvim/projects.json')
}

vim.keymap.set('n', '<leader>rc', ':RunCode<CR>', { noremap = true, silent = false })
vim.keymap.set('n', ',', ':RunFile float<CR>', { noremap = true, silent = false })
-- vim.keymap.set('n', '<leader>rft', ':RunFile tab<CR>', { noremap = true, silent = false })
-- vim.keymap.set('n', '<leader>rp', ':RunProject<CR>', { noremap = true, silent = false })
-- vim.keymap.set('n', '<leader>rx', ':RunClose<CR>', { noremap = true, silent = false })
-- vim.keymap.set('n', '<leader>crf', ':CRFiletype<CR>', { noremap = true, silent = false })
vim.keymap.set('n', '<leader>rp', ':CRProjects<CR>', { noremap = true, silent = false })

EOF

In ~/.config/nvim/projects.json

{
  "/home/serii/Documents/python/python-course": {
    "name": "Python Course",
    "description": "Simple python project",
    "file_name": "main.py",
    "command": "python -u"
  }
}

I changed ~ to /home/serii, but don't work too.

In python project in file main.py run :CRProjects and opened projects.json file.

But if i run :RunProject - i have an error

:( There is no project associated with this path

I don't know how to fix.

Thanks a lot for plugin.

seriiserii825 avatar Aug 31 '24 17:08 seriiserii825

Please what is the folder when execute?

CRAG666 avatar Sep 02 '24 02:09 CRAG666

 serii@archlinux  ~/Documents/python/python-course   main  ll                                                                         ✔  877  08:32:15
drwxr-xr-x   - serii  2 Sep 08:32 .git
.rw-r--r-- 526 serii 30 Aug 19:39 .gitignore
.rw-r--r-- 553 serii 31 Aug 21:29 .vimspector.json
drwxr-xr-x   - serii 31 Aug 22:00 lessons
.rw-r--r--  84 serii 31 Aug 22:00 main.py
.rw-r--r-- 706 serii 31 Aug 20:08 project.json
.rw-r--r--  17 serii 30 Aug 19:39 README.md
.rw-r--r--  91 serii 31 Aug 19:55 requirements.txt
drwxr-xr-x   - serii 30 Aug 19:39 venv

code-runner

seriiserii825 avatar Sep 02 '24 05:09 seriiserii825

@seriiserii825 pleace check. thanks

CRAG666 avatar Dec 18 '24 21:12 CRAG666

@CRAG666 The problem still exists, the problematic code is in commands.lua.

  -- Fallback to project or file type execution
  local context = get_project():run(false)
  if not context then
    get_filetype():run()
  end

and the notify_enable is always true in project.lua

function Project:run(mode, notify_enable)
  notify_enable = notify_enable ~= false -- Enable notifications by default

  self:setRootPath()
  if self.context then
    self:setCommand()
    notify.info("File execution as project", "Project")

    mode = mode or self.context.mode
    self.utils:runMode(self.context.command, self.context.name, mode)
    return true
  end

  if notify_enable then
    notify.warn(":( There is no project associated with this path", "Project")
  end
  return false
end

It should be

  -- Fallback to project or file type execution
  local context = get_project():run("toggleterm", false)
  if not context then
    get_filetype():run()
  end

EasonMo avatar Dec 20 '24 21:12 EasonMo

@seriiserii825 pleace check. thanks

Sorry, but didn't work. Insed main.py run :RunProject and have error, There is no project asscoiated with this path.

code-runner

And also, if just run :RunFile

Have errors, that can find modules. I think, need to run with python from venv, but how to do this?

Traceback (most recent call last):
  File "/home/serii/Documents/python/py-private/main.py", line 3, in 
<module>
    from modules.backups import backups
  File "/home/serii/Documents/python/py-private/modules/backups.py", 
line 3, in <module>
    from termcolor import colored
ModuleNotFoundError: No module named 'termcolor'


seriiserii825 avatar Dec 21 '24 07:12 seriiserii825

@seriiserii825 Please update the plugin. It should be fixed now.

EasonMo avatar Dec 23 '24 06:12 EasonMo