refactor(actions): deleted actions files for language types and fixed them
This commit is contained in:
1 parent
08967f9070
commit
ae0df7fe28
16 files changed
+240
-317
No files matched your search
@@ -166,8 +166,8 @@ M.create_file = function(opts)
|
|||||||
function_write(mod, fname)
|
function_write(mod, fname)
|
||||||
end
|
end
|
||||||
|
|
||||||
if cf and type(cf.func) == "function" and cf.allowed then
|
if cf and type(cf) == "function" then
|
||||||
cf.func(args, done)
|
cf(args, done)
|
||||||
else
|
else
|
||||||
done(args[filetype].templates.file.source)
|
done(args[filetype].templates.file.source)
|
||||||
end
|
end
|
||||||
@@ -179,7 +179,7 @@ M.run = function(opts)
|
|||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
local filetype = vim.bo.filetype
|
local filetype = vim.bo.filetype
|
||||||
|
|
||||||
local ft_ok, action = pcall(require, "vern-nvim.actions." .. filetype)
|
local ft_ok, action = pcall(require, "vern-nvim.configs." .. filetype)
|
||||||
if
|
if
|
||||||
not filetype
|
not filetype
|
||||||
or filetype == ""
|
or filetype == ""
|
||||||
@@ -191,7 +191,13 @@ M.run = function(opts)
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
action.run(opts)
|
local args = vim.tbl_deep_extend(
|
||||||
|
"force",
|
||||||
|
{},
|
||||||
|
opts,
|
||||||
|
require("vern-nvim.configs." .. filetype)
|
||||||
|
)
|
||||||
|
action.run(args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
local utils = require("vern-nvim.utils")
|
|
||||||
|
|
||||||
---@param opts? VernCConfig Takes a table for the runtime
|
|
||||||
function M.run(opts)
|
|
||||||
opts = opts or {}
|
|
||||||
|
|
||||||
local build_dir = vim.fn.fnameescape((utils.proj_root() or ".") .. "/build")
|
|
||||||
|
|
||||||
vim.system(
|
|
||||||
{ "sh", "-c", string.format("cd %s && cmake --build .", build_dir) },
|
|
||||||
{ text = true },
|
|
||||||
function(obj)
|
|
||||||
if obj.code ~= 0 then
|
|
||||||
vim.schedule(function()
|
|
||||||
local error_obj = (obj.stderr ~= "" and obj.stderr)
|
|
||||||
or obj.stdout
|
|
||||||
or ""
|
|
||||||
local error_lines = vim.list_extend(
|
|
||||||
{ "Error During compilation" },
|
|
||||||
vim.split(error_obj, "\n", { trimempty = true })
|
|
||||||
)
|
|
||||||
local buf, _ = utils.term(
|
|
||||||
{ "echo 'compilation failed'" },
|
|
||||||
opts.terminal,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
utils.term_override(buf, error_lines)
|
|
||||||
end)
|
|
||||||
else
|
|
||||||
vim.schedule(function()
|
|
||||||
local run_cmd = string.format(
|
|
||||||
"cd %s && ./%s",
|
|
||||||
build_dir,
|
|
||||||
utils.proj_name()
|
|
||||||
)
|
|
||||||
utils.term({ run_cmd }, opts.terminal, false)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
local utils = require("vern-nvim.utils")
|
|
||||||
|
|
||||||
---@param opts? VernCPPConfig Takes a table for the runtime
|
|
||||||
function M.run(opts)
|
|
||||||
opts = opts or {}
|
|
||||||
|
|
||||||
local build_dir = vim.fn.fnameescape((utils.proj_root() or ".") .. "/build")
|
|
||||||
|
|
||||||
vim.system(
|
|
||||||
{ "sh", "-c", string.format("cd %s && cmake --build .", build_dir) },
|
|
||||||
{ text = true },
|
|
||||||
function(obj)
|
|
||||||
if obj.code ~= 0 then
|
|
||||||
vim.schedule(function()
|
|
||||||
local error_obj = (obj.stderr ~= "" and obj.stderr)
|
|
||||||
or obj.stdout
|
|
||||||
or ""
|
|
||||||
local error_lines = vim.list_extend(
|
|
||||||
{ "Error During compilation" },
|
|
||||||
vim.split(error_obj, "\n", { trimempty = true })
|
|
||||||
)
|
|
||||||
local buf, _ = utils.term(
|
|
||||||
{ "echo 'compilation failed'" },
|
|
||||||
opts.terminal,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
utils.term_override(buf, error_lines)
|
|
||||||
end)
|
|
||||||
else
|
|
||||||
vim.schedule(function()
|
|
||||||
local run_cmd = string.format(
|
|
||||||
"cd %s && ./%s",
|
|
||||||
build_dir,
|
|
||||||
utils.proj_name()
|
|
||||||
)
|
|
||||||
utils.term({ run_cmd }, opts.terminal, false)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
local utils = require("vern-nvim.utils")
|
|
||||||
|
|
||||||
---@param opts VernJavaConfig Takes a table for the runtime
|
|
||||||
function M.run(opts)
|
|
||||||
opts = opts or {}
|
|
||||||
local root = utils.proj_root() or "."
|
|
||||||
local context = {
|
|
||||||
project_name = utils.proj_name(),
|
|
||||||
company_name = opts.env.author,
|
|
||||||
file_name = "",
|
|
||||||
}
|
|
||||||
|
|
||||||
local src_root = vim.fs.joinpath(
|
|
||||||
root,
|
|
||||||
utils.resolve_path(opts.java.dirs.src, opts.java.dirs, context)
|
|
||||||
)
|
|
||||||
local build_dir = root .. "/bin"
|
|
||||||
local build_cmd = string.format(
|
|
||||||
"javac -d %s -sourcepath %s $(find %s -name '*java')",
|
|
||||||
build_dir,
|
|
||||||
src_root,
|
|
||||||
src_root
|
|
||||||
)
|
|
||||||
|
|
||||||
vim.system({ "sh", "-c", build_cmd }, { text = true }, function(obj)
|
|
||||||
if obj.code ~= 0 then
|
|
||||||
vim.schedule(function()
|
|
||||||
local error_obj = (obj.stderr ~= "" and obj.stderr)
|
|
||||||
or obj.stdout
|
|
||||||
or ""
|
|
||||||
local error_lines = vim.list_extend(
|
|
||||||
{ "Error During compilation" },
|
|
||||||
vim.split(error_obj, "\n", { trimempty = true })
|
|
||||||
)
|
|
||||||
local buf, _ = utils.term(
|
|
||||||
{ "echo 'compilation failed'" },
|
|
||||||
opts.terminal,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
utils.term_override(buf, error_lines)
|
|
||||||
end)
|
|
||||||
else
|
|
||||||
vim.schedule(function()
|
|
||||||
local run_cmd = string.format(
|
|
||||||
"java -cp %s com.%s.%s.Main",
|
|
||||||
build_dir,
|
|
||||||
context.company_name,
|
|
||||||
context.project_name
|
|
||||||
)
|
|
||||||
utils.term({ run_cmd }, opts.terminal, false)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
local utils = require("vern-nvim.utils")
|
|
||||||
|
|
||||||
---@param opts VernLuaConfig Takes a table for the runtime
|
|
||||||
function M.run(opts)
|
|
||||||
opts = opts or {}
|
|
||||||
|
|
||||||
utils.term({
|
|
||||||
"lua " .. vim.fs.joinpath(
|
|
||||||
utils.proj_root(),
|
|
||||||
"lua",
|
|
||||||
utils.proj_name(),
|
|
||||||
"/init.lua"
|
|
||||||
),
|
|
||||||
}, opts.terminal or {}, false)
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
local utils = require("vern-nvim.utils")
|
|
||||||
|
|
||||||
---@param opts VernPythonConfig Takes a table for the runtime
|
|
||||||
function M.run(opts)
|
|
||||||
opts = opts or {}
|
|
||||||
local root = utils.proj_root() or "."
|
|
||||||
local context = {
|
|
||||||
project_name = utils.proj_name(),
|
|
||||||
company_name = opts.env.author,
|
|
||||||
file_name = "",
|
|
||||||
}
|
|
||||||
local bin = opts.python.templates.project.primary
|
|
||||||
|
|
||||||
local exe = vim.fs.joinpath(bin.path, bin.name)
|
|
||||||
or "src/{project_name}/main.py"
|
|
||||||
local exe_path = utils.resolve_path(exe, opts.python.dirs, context)
|
|
||||||
local full_path = vim.fs.joinpath(vim.fn.expand(root), exe_path)
|
|
||||||
|
|
||||||
utils.term({ "python3 " .. full_path }, opts.terminal or {}, false)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.pip_install()
|
|
||||||
vim.ui.input({ prompt = "Enter pip module: " }, function(mod)
|
|
||||||
mod = mod and vim.trim(mod)
|
|
||||||
if not mod or mod == "" then
|
|
||||||
vim.notify(
|
|
||||||
"Pip Cancelled",
|
|
||||||
vim.log.levels.WARN,
|
|
||||||
{ title = "Vern Python" }
|
|
||||||
)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
vim.notify(
|
|
||||||
"Installing " .. mod,
|
|
||||||
vim.log.levels.INFO,
|
|
||||||
{ title = "Vern Python" }
|
|
||||||
)
|
|
||||||
vim.system({ "pip", "install", mod }, { text = true }, function(obj)
|
|
||||||
vim.schedule(function()
|
|
||||||
if obj.code ~= 0 then
|
|
||||||
vim.notify(
|
|
||||||
"Pip failed: " .. obj.stderr,
|
|
||||||
vim.log.levels.WARN,
|
|
||||||
{ title = "Vern Python" }
|
|
||||||
)
|
|
||||||
else
|
|
||||||
vim.notify(
|
|
||||||
"Pip installed " .. mod,
|
|
||||||
vim.log.levels.INFO,
|
|
||||||
{ title = "Vern Python" }
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
local utils = require("vern-nvim.utils")
|
|
||||||
|
|
||||||
---@param opts VernRustConfig Takes a table for the runtime
|
|
||||||
function M.run(opts)
|
|
||||||
opts = opts or {}
|
|
||||||
utils.term(
|
|
||||||
{ "cd " .. utils.proj_root() .. " && cargo run" },
|
|
||||||
opts.terminal or {},
|
|
||||||
false
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
||||||
+30
-19
@@ -1,6 +1,9 @@
|
|||||||
|
local utils = require("vern-nvim.utils")
|
||||||
|
local comp = require("vern-nvim.languages.shared.compile")
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
M.attach = function() end
|
M.attach = nil
|
||||||
|
|
||||||
---@param root string
|
---@param root string
|
||||||
M.create_project = function(root)
|
M.create_project = function(root)
|
||||||
@@ -11,23 +14,31 @@ M.create_project = function(root)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@type VernCreateFile
|
---@type VernCreateFile
|
||||||
M.create_file = {
|
---@param opts VernCConfig
|
||||||
allowed = true,
|
M.create_file = function(opts, continue)
|
||||||
---@param opts VernCConfig
|
opts = opts or {}
|
||||||
func = function(opts, continue)
|
local file = vim.tbl_get(opts, "c", "templates", "file")
|
||||||
opts = opts or {}
|
local items = { "source", "header" }
|
||||||
local file = vim.tbl_get(opts, "c", "templates", "file")
|
vim.ui.select(items, {
|
||||||
local items = { "source", "header" }
|
prompt = "Select type:",
|
||||||
vim.ui.select(items, {
|
format_item = function(item) return item end,
|
||||||
prompt = "Select type:",
|
}, function(choice, _)
|
||||||
format_item = function(item) return item end,
|
if choice == items[1] then return continue(file.source) end
|
||||||
}, function(choice, _)
|
if choice == items[2] then return continue(file.header) end
|
||||||
if choice == items[1] then return continue(file.source) end
|
continue(nil)
|
||||||
if choice == items[2] then return continue(file.header) end
|
end)
|
||||||
continue(nil)
|
end
|
||||||
end)
|
|
||||||
end,
|
---@param opts? VernCConfig Takes a table for the runtime
|
||||||
}
|
M.run = function(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
|
||||||
|
local build_dir = vim.fn.fnameescape((utils.proj_root() or ".") .. "/build")
|
||||||
|
local build_cmd = string.format("cd %s && cmake --build .", build_dir)
|
||||||
|
local run_cmd = string.format("cd %s && ./%s", build_dir, utils.proj_name())
|
||||||
|
|
||||||
|
comp.compile(opts, build_cmd, run_cmd)
|
||||||
|
end
|
||||||
|
|
||||||
---@type VernLanguageConfig
|
---@type VernLanguageConfig
|
||||||
M.c = {
|
M.c = {
|
||||||
@@ -36,7 +47,7 @@ M.c = {
|
|||||||
src = "src",
|
src = "src",
|
||||||
include = "include/{project_name}",
|
include = "include/{project_name}",
|
||||||
},
|
},
|
||||||
keybinds = {},
|
keybinds = nil,
|
||||||
templates = {
|
templates = {
|
||||||
project = {
|
project = {
|
||||||
primary = {
|
primary = {
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
|
local utils = require("vern-nvim.utils")
|
||||||
|
local comp = require("vern-nvim.languages.shared.compile")
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
M.attach = function() end
|
M.attach = nil
|
||||||
|
|
||||||
---@param root string
|
---@param root string
|
||||||
M.create_project = function(root)
|
M.create_project = function(root)
|
||||||
@@ -11,23 +14,31 @@ M.create_project = function(root)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@type VernCreateFile
|
---@type VernCreateFile
|
||||||
M.create_file = {
|
---@param opts VernCPPConfig
|
||||||
allowed = true,
|
M.create_file = function(opts, continue)
|
||||||
---@param opts VernCPPConfig
|
opts = opts or {}
|
||||||
func = function(opts, continue)
|
local file = vim.tbl_get(opts, "cpp", "templates", "file")
|
||||||
opts = opts or {}
|
local items = { "source", "header" }
|
||||||
local file = vim.tbl_get(opts, "cpp", "templates", "file")
|
vim.ui.select(items, {
|
||||||
local items = { "source", "header" }
|
prompt = "Select type:",
|
||||||
vim.ui.select(items, {
|
format_item = function(item) return item end,
|
||||||
prompt = "Select type:",
|
}, function(choice, _)
|
||||||
format_item = function(item) return item end,
|
if choice == items[1] then return continue(file.source) end
|
||||||
}, function(choice, _)
|
if choice == items[2] then return continue(file.header) end
|
||||||
if choice == items[1] then return continue(file.source) end
|
continue(nil)
|
||||||
if choice == items[2] then return continue(file.header) end
|
end)
|
||||||
continue(nil)
|
end
|
||||||
end)
|
---
|
||||||
end,
|
---@param opts? VernCPPConfig Takes a table for the runtime
|
||||||
}
|
M.run = function(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
|
||||||
|
local build_dir = vim.fn.fnameescape((utils.proj_root() or ".") .. "/build")
|
||||||
|
local build_cmd = string.format("cd %s && cmake --build .", build_dir)
|
||||||
|
local run_cmd = string.format("cd %s && ./%s", build_dir, utils.proj_name())
|
||||||
|
|
||||||
|
comp.compile(opts, build_cmd, run_cmd)
|
||||||
|
end
|
||||||
|
|
||||||
---@type VernLanguageConfig
|
---@type VernLanguageConfig
|
||||||
M.cpp = {
|
M.cpp = {
|
||||||
@@ -36,7 +47,7 @@ M.cpp = {
|
|||||||
src = "src",
|
src = "src",
|
||||||
include = "include/{project_name}",
|
include = "include/{project_name}",
|
||||||
},
|
},
|
||||||
keybinds = {},
|
keybinds = nil,
|
||||||
templates = {
|
templates = {
|
||||||
project = {
|
project = {
|
||||||
primary = {
|
primary = {
|
||||||
|
|||||||
@@ -1,14 +1,45 @@
|
|||||||
|
local utils = require("vern-nvim.utils")
|
||||||
|
local comp = require("vern-nvim.languages.shared.compile")
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
M.attach = function() end
|
M.attach = nil
|
||||||
|
|
||||||
M.create_project = function() end
|
M.create_project = nil
|
||||||
|
|
||||||
---@type VernCreateFile
|
---@type VernCreateFile
|
||||||
M.create_file = {
|
M.create_file = nil
|
||||||
allowed = false,
|
|
||||||
func = function(_, _) return nil end,
|
---@param opts VernJavaConfig Takes a table for the runtime
|
||||||
}
|
M.run = function(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
local root = utils.proj_root()
|
||||||
|
local context = {
|
||||||
|
project_name = utils.proj_name(),
|
||||||
|
company_name = opts.env.author,
|
||||||
|
file_name = "",
|
||||||
|
}
|
||||||
|
|
||||||
|
local src_root = vim.fs.joinpath(
|
||||||
|
root,
|
||||||
|
utils.resolve_path(opts.java.dirs.src, opts.java.dirs, context)
|
||||||
|
)
|
||||||
|
local build_dir = root .. "/bin"
|
||||||
|
local build_cmd = string.format(
|
||||||
|
"javac -d %s -sourcepath %s $(find %s -name '*java')",
|
||||||
|
build_dir,
|
||||||
|
src_root,
|
||||||
|
src_root
|
||||||
|
)
|
||||||
|
local run_cmd = string.format(
|
||||||
|
"java -cp %s com.%s.%s.Main",
|
||||||
|
build_dir,
|
||||||
|
context.company_name,
|
||||||
|
context.project_name
|
||||||
|
)
|
||||||
|
|
||||||
|
comp.compile(opts, build_cmd, run_cmd)
|
||||||
|
end
|
||||||
|
|
||||||
---@type VernLanguageConfig
|
---@type VernLanguageConfig
|
||||||
M.java = {
|
M.java = {
|
||||||
@@ -17,7 +48,7 @@ M.java = {
|
|||||||
src = "src/com/{company_name}/{project_name}",
|
src = "src/com/{company_name}/{project_name}",
|
||||||
bin = "bin",
|
bin = "bin",
|
||||||
},
|
},
|
||||||
keybinds = {},
|
keybinds = nil,
|
||||||
templates = {
|
templates = {
|
||||||
project = {
|
project = {
|
||||||
primary = {
|
primary = {
|
||||||
@@ -41,7 +72,7 @@ M.java = {
|
|||||||
kind_path = "vern-nvim.templates.java",
|
kind_path = "vern-nvim.templates.java",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
extras = {},
|
extras = nil,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return M
|
return M
|
||||||
@@ -1,14 +1,27 @@
|
|||||||
|
local utils = require("vern-nvim.utils")
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
M.attach = function() end
|
M.attach = nil
|
||||||
|
|
||||||
M.create_project = function() end
|
M.create_project = nil
|
||||||
|
|
||||||
---@type VernCreateFile
|
---@type VernCreateFile
|
||||||
M.create_file = {
|
M.create_file = nil
|
||||||
allowed = false,
|
|
||||||
func = function(_, _) return nil end,
|
---@param opts VernLuaConfig Takes a table for the runtime
|
||||||
}
|
M.run = function(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
|
||||||
|
utils.term({
|
||||||
|
"lua " .. vim.fs.joinpath(
|
||||||
|
utils.proj_root(),
|
||||||
|
"lua",
|
||||||
|
utils.proj_name(),
|
||||||
|
"/init.lua"
|
||||||
|
),
|
||||||
|
}, opts.terminal or {}, false)
|
||||||
|
end
|
||||||
|
|
||||||
---@type VernLanguageConfig
|
---@type VernLanguageConfig
|
||||||
M.lua = {
|
M.lua = {
|
||||||
@@ -16,7 +29,7 @@ M.lua = {
|
|||||||
dirs = {
|
dirs = {
|
||||||
src = "lua/{project_name}",
|
src = "lua/{project_name}",
|
||||||
},
|
},
|
||||||
keybinds = {},
|
keybinds = nil,
|
||||||
templates = {
|
templates = {
|
||||||
project = {
|
project = {
|
||||||
primary = {
|
primary = {
|
||||||
@@ -40,7 +53,7 @@ M.lua = {
|
|||||||
kind_path = "vern-nvim.templates.lua",
|
kind_path = "vern-nvim.templates.lua",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
extras = {},
|
extras = nil,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
local utils = require("vern-nvim.utils")
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
M.attach = function()
|
M.attach = function()
|
||||||
@@ -28,10 +30,62 @@ M.create_project = function(root)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@type VernCreateFile
|
---@type VernCreateFile
|
||||||
M.create_file = {
|
M.create_file = nil
|
||||||
allowed = false,
|
|
||||||
func = function(_, _) return nil end,
|
---@param opts VernPythonConfig Takes a table for the runtime
|
||||||
}
|
M.run = function(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
local root = utils.proj_root() or "."
|
||||||
|
local context = {
|
||||||
|
project_name = utils.proj_name(),
|
||||||
|
company_name = opts.env.author,
|
||||||
|
file_name = "",
|
||||||
|
}
|
||||||
|
local bin = opts.python.templates.project.primary
|
||||||
|
|
||||||
|
local exe = vim.fs.joinpath(bin.path, bin.name)
|
||||||
|
or "src/{project_name}/main.py"
|
||||||
|
local exe_path = utils.resolve_path(exe, opts.python.dirs, context)
|
||||||
|
local full_path = vim.fs.joinpath(vim.fn.expand(root), exe_path)
|
||||||
|
|
||||||
|
utils.term({ "python3 " .. full_path }, opts.terminal or {}, false)
|
||||||
|
end
|
||||||
|
|
||||||
|
M.pip_install = function()
|
||||||
|
vim.ui.input({ prompt = "Enter pip module: " }, function(mod)
|
||||||
|
mod = mod and vim.trim(mod)
|
||||||
|
if not mod or mod == "" then
|
||||||
|
vim.notify(
|
||||||
|
"Pip Cancelled",
|
||||||
|
vim.log.levels.WARN,
|
||||||
|
{ title = "Vern Python" }
|
||||||
|
)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
vim.notify(
|
||||||
|
"Installing " .. mod,
|
||||||
|
vim.log.levels.INFO,
|
||||||
|
{ title = "Vern Python" }
|
||||||
|
)
|
||||||
|
vim.system({ "pip", "install", mod }, { text = true }, function(obj)
|
||||||
|
vim.schedule(function()
|
||||||
|
if obj.code ~= 0 then
|
||||||
|
vim.notify(
|
||||||
|
"Pip failed: " .. obj.stderr,
|
||||||
|
vim.log.levels.WARN,
|
||||||
|
{ title = "Vern Python" }
|
||||||
|
)
|
||||||
|
else
|
||||||
|
vim.notify(
|
||||||
|
"Pip installed " .. mod,
|
||||||
|
vim.log.levels.INFO,
|
||||||
|
{ title = "Vern Python" }
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
---@type VernLanguageConfig
|
---@type VernLanguageConfig
|
||||||
M.python = {
|
M.python = {
|
||||||
@@ -43,7 +97,7 @@ M.python = {
|
|||||||
["<leader>pi"] = {
|
["<leader>pi"] = {
|
||||||
user_command = "VernPythonPip",
|
user_command = "VernPythonPip",
|
||||||
desc = "Install python packages for environment",
|
desc = "Install python packages for environment",
|
||||||
action = require("vern-nvim.actions.python").pip_install,
|
action = M.pip_install,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
templates = {
|
templates = {
|
||||||
@@ -75,7 +129,7 @@ M.python = {
|
|||||||
kind_path = "vern-nvim.templates.python",
|
kind_path = "vern-nvim.templates.python",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
extras = {},
|
extras = nil,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return M
|
return M
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
|
local utils = require("vern-nvim.utils")
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
M.attach = function() end
|
M.attach = nil
|
||||||
|
|
||||||
M.create_project = function(root)
|
M.create_project = function(root)
|
||||||
local obj = vim.system({
|
local obj = vim.system({
|
||||||
@@ -17,16 +19,23 @@ M.create_project = function(root)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@type VernCreateFile
|
---@type VernCreateFile
|
||||||
M.create_file = {
|
M.create_file = nil
|
||||||
allowed = false,
|
|
||||||
func = function(_, _) return nil end,
|
---@param opts VernRustConfig Takes a table for the runtime
|
||||||
}
|
M.run = function(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
utils.term(
|
||||||
|
{ "cd " .. utils.proj_root() .. " && cargo run" },
|
||||||
|
opts.terminal or {},
|
||||||
|
false
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
---@type VernLanguageConfig
|
---@type VernLanguageConfig
|
||||||
M.rust = {
|
M.rust = {
|
||||||
root = "Rust",
|
root = "Rust",
|
||||||
dirs = nil,
|
dirs = nil,
|
||||||
keybinds = {},
|
keybinds = nil,
|
||||||
templates = {
|
templates = {
|
||||||
project = {
|
project = {
|
||||||
primary = { path = "src", name = "main.rs" },
|
primary = { path = "src", name = "main.rs" },
|
||||||
@@ -39,7 +48,7 @@ M.rust = {
|
|||||||
kind_path = "vern-nvim.templates.rust",
|
kind_path = "vern-nvim.templates.rust",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
extras = {},
|
extras = nil,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ function M.setup(user_opts)
|
|||||||
if not ok then return end
|
if not ok then return end
|
||||||
|
|
||||||
local opts = vim.tbl_deep_extend("force", {}, mod, M.opts or {})
|
local opts = vim.tbl_deep_extend("force", {}, mod, M.opts or {})
|
||||||
if opts[ft] and opts[ft].keybinds then
|
if opts[ft] and opts[ft].keybinds ~= nil then
|
||||||
for key, def in pairs(opts[ft].keybinds or {}) do
|
for key, def in pairs(opts[ft].keybinds or {}) do
|
||||||
if type(def.action) == "function" then
|
if type(def.action) == "function" then
|
||||||
vim.api.nvim_buf_create_user_command(
|
vim.api.nvim_buf_create_user_command(
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
local utils = require("vern-nvim.utils")
|
||||||
|
|
||||||
|
M.compile = function(opts, build_cmd, run_cmd)
|
||||||
|
vim.system({ "sh", "-c", build_cmd }, { text = true }, function(obj)
|
||||||
|
if obj.code ~= 0 then
|
||||||
|
vim.schedule(function()
|
||||||
|
local error_obj = (obj.stderr ~= "" and obj.stderr)
|
||||||
|
or obj.stdout
|
||||||
|
or ""
|
||||||
|
local error_lines = vim.list_extend(
|
||||||
|
{ "Error During compilation" },
|
||||||
|
vim.split(error_obj, "\n", { trimempty = true })
|
||||||
|
)
|
||||||
|
local buf, _ = utils.term(
|
||||||
|
{ "echo 'compilation failed'" },
|
||||||
|
opts.terminal,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
utils.term_override(buf, error_lines)
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
vim.schedule(
|
||||||
|
function() utils.term({ run_cmd }, opts.terminal, false) end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -3,8 +3,7 @@
|
|||||||
---@alias SplitAnchorType "right" | "bottom"
|
---@alias SplitAnchorType "right" | "bottom"
|
||||||
|
|
||||||
---@class VernCreateFile
|
---@class VernCreateFile
|
||||||
---@field allowed boolean Determines whether actions/init.lua uses the function
|
---@field func? fun(opts: any, continue: fun(mod: VernFileLayout|nil)): any?
|
||||||
---@field func fun(opts: any, continue: fun(mod: VernFileLayout|nil)): any?
|
|
||||||
|
|
||||||
---@class VernKeybindItem
|
---@class VernKeybindItem
|
||||||
---@field user_command string
|
---@field user_command string
|
||||||
@@ -57,7 +56,7 @@
|
|||||||
---@class VernLanguageConfig
|
---@class VernLanguageConfig
|
||||||
---@field root string
|
---@field root string
|
||||||
---@field dirs table<string, string>|nil
|
---@field dirs table<string, string>|nil
|
||||||
---@field keybinds table<string, VernKeybindItem>
|
---@field keybinds? table<string, VernKeybindItem>
|
||||||
---@field templates VernLanguageTemplates
|
---@field templates VernLanguageTemplates
|
||||||
|
|
||||||
---@class VernPythonConfig : VernCoreConfig
|
---@class VernPythonConfig : VernCoreConfig
|
||||||
|
|||||||
Reference in new issue
Block a user