Adds function for running different projects
This commit is contained in:
parent
73e528266c
commit
e538146c81
3 changed files with 12 additions and 16 deletions
6
flake.lock
generated
6
flake.lock
generated
|
|
@ -44,11 +44,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1740339700,
|
"lastModified": 1740865531,
|
||||||
"narHash": "sha256-cbrw7EgQhcdFnu6iS3vane53bEagZQy/xyIkDWpCgVE=",
|
"narHash": "sha256-h00vGIh/jxcGl8aWdfnVRD74KuLpyY3mZgMFMy7iKIc=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "04ef94c4c1582fd485bbfdb8c4a8ba250e359195",
|
"rev": "5ef6c425980847c78a80d759abc476e941a9bf42",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,12 @@
|
||||||
-- Map of file markers to their compile commands
|
-- Map of file markers to their compile commands
|
||||||
local project_types = {
|
local project_types = {
|
||||||
["main.odin"] = "odin build . -file",
|
["main.odin"] = "odin run .",
|
||||||
["package.json"] = "npm run build",
|
["package.json"] = "pnpm run dev",
|
||||||
["go.mod"] = "go build ./...",
|
|
||||||
["Cargo.toml"] = "cargo build",
|
|
||||||
["CMakeLists.txt"] = "cmake --build build",
|
|
||||||
["Makefile"] = "make",
|
["Makefile"] = "make",
|
||||||
}
|
}
|
||||||
|
|
||||||
local function find_project_type()
|
local function find_project_type()
|
||||||
-- Search for known project markers in the current directory
|
|
||||||
for marker, _ in pairs(project_types) do
|
for marker, _ in pairs(project_types) do
|
||||||
-- Use vim.fn.glob() to check if file exists in current directory
|
|
||||||
if vim.fn.glob(marker) ~= "" then
|
if vim.fn.glob(marker) ~= "" then
|
||||||
return marker
|
return marker
|
||||||
end
|
end
|
||||||
|
|
@ -19,7 +14,7 @@ local function find_project_type()
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local function compile()
|
local function run()
|
||||||
local marker = find_project_type()
|
local marker = find_project_type()
|
||||||
|
|
||||||
if not marker then
|
if not marker then
|
||||||
|
|
@ -40,5 +35,5 @@ local function compile()
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
compile,
|
run,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,8 @@ return {
|
||||||
desc = "Delete all buffers",
|
desc = "Delete all buffers",
|
||||||
mode = "n",
|
mode = "n",
|
||||||
},
|
},
|
||||||
{ "<leader>c", group = "code", mode = "n" },
|
{ "<leader>c", group = "code/compile", mode = "n" },
|
||||||
|
{ "<leader>cr", "<cmd>lua require('dnsc.compile').run()<cr>", desc = "Run current project", mode = "n" },
|
||||||
{ "<leader>ca", "<cmd>FzfLua lsp_code_actions<cr>", desc = "Code actions", mode = "n" },
|
{ "<leader>ca", "<cmd>FzfLua lsp_code_actions<cr>", desc = "Code actions", mode = "n" },
|
||||||
{ "<leader>cd", "<cmd>FzfLua diagnostics_document<cr>", desc = "Show diagnostics", mode = "n" },
|
{ "<leader>cd", "<cmd>FzfLua diagnostics_document<cr>", desc = "Show diagnostics", mode = "n" },
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue