Neovim: Add popup terminal functionality

This commit is contained in:
Riyyi
2025-04-12 12:50:02 +02:00
parent 855732f3c1
commit 935d6d999b
8 changed files with 47 additions and 35 deletions
-18
View File
@@ -1,18 +0,0 @@
local F = require("core.functions")
local create_command = function(name, command)
if not name or type(name) ~= "string" then return end
vim.api.nvim_create_user_command(name, function()
local cmd = type(command) == "function" and command() or command
F.execute_command(cmd)
end, {})
end
create_command("RunScript", "ls")
create_command("ScanScript", function()
local file_path = vim.fn.expand("%:p")
LOG(file_path)
return "ls"
end)
+2 -16
View File
@@ -1,21 +1,5 @@
local M = {}
M.execute_command = function(command)
if not command then return end
local job = require("plenary.job")
job:new({
command = command,
on_exit = function(j, _)
vim.schedule(function()
vim.api.nvim_echo({
{ table.concat(j:result(), "\n"), "Normal" }
}, false, {})
end)
end,
}):start()
end
M.is_buffer_a_file = function()
local buffer_name = vim.fn.bufname()
@@ -50,6 +34,8 @@ end
M.find_project_root = function()
local current_directory = M.get_current_directory()
if current_directory:match("^term://") then return nil, current_directory end
local directory = current_directory
while directory ~= "/" and not directory:match("^%a:[/\\]?$") do
local git_path = vim.loop.fs_stat(directory .. "/.git")