Closed aharoldk closed 6 months ago
which background are u using ?
This is what you use to search for projects, make sure you have your projects correctly
local function getProjectRootPath()
local projects = o.get().project
local path = vim.fn.expand("%:p")
for project_path, _ in pairs(projects) do
path_full = vim.fs.normalize(project_path)
if string.find(path, path_full) == 1 then
current_proyect = projects[project_path]
current_proyect["path"] = project_path
return current_proyect
end
end
end
could we make it like vscode? we put the configuration file inside the project (.vscode) so every time we run the project it will refer to that file first.
Hi, @CRAG666, I think there is a problem with projects that contain -
(potentially other special characters as well).
I think this might be this offending line: https://github.com/CRAG666/code_runner.nvim/blob/0c701cae3265c79b4fdfd4b35a4f3d7c5986d46c/lua/code_runner/commands.lua#L44
Tested in command mode with prefix of lua
:
print(string.find("path-WithMinus", "path-With")) -- nil
print(string.find("pathWithout", "path")) -- 1 4
This also makes me wonder if this would make it impossible to define a project /path/to/foo
without also matching /path/to/foobar
as string.find("/path/to/foobar/shell", "/path/to/foo")
would return 1 12
thus matching. Appending a /
to the project pattern does not work as it will be stripped by vim.fs.normalize
.
Potential fix for the foobar match could be string.find(path, path_full .. "/")
but the -
problem remains.
@aharoldk, could you confirm that code_runner works as expected with the other two projects (demo and example) you defined?
Looking at https://github.com/CRAG666/code_runner.nvim/commit/701807c4f181cd00d4fad0280bbc821324cbe3c1#diff-247ceb4910166218fe8b1e16bd14726ababae11faaa9f247bb4be8122822fd46L45, it looks like the pattern matching is the reason that -
break the match.
This would work:
print(string.find("path-WithMinus", "path-With", 1, true)) -- 1 9
It makes no sense to enable pattern matching here if the "pattern" is the normalized path of the file. I see two options:
string.find(path, path_full, 1, true)
to only match without pattern.string.find(path_full, path)
to project
(not sure if that is possible like it is with filetype
)I just realised that this is wrong and I thought path_full
is the file and path
is the pattern/project.
The names confused me.
hi, i tried to run spring boot using code_runner project_path but got error when using project_path. could you help me to use the project_path?
this is my coderunner-project.json