Add walkup for now
This commit is contained in:
+2
-2
@@ -82,13 +82,13 @@ keybinds = {
|
|||||||
-- c --
|
-- c --
|
||||||
keybinds = {
|
keybinds = {
|
||||||
["<leader>pr"] = "CRun",
|
["<leader>pr"] = "CRun",
|
||||||
["<leader>nh"] = "NewCHeaderFile",
|
["<leader>pb"] = "NewCHeaderFile",
|
||||||
}
|
}
|
||||||
|
|
||||||
-- cpp --
|
-- cpp --
|
||||||
keybinds = {
|
keybinds = {
|
||||||
["<leader>pr"] = "CppRun",
|
["<leader>pr"] = "CppRun",
|
||||||
["<leader>nh"] = "NewCppHeaderFile",
|
["<leader>pb"] = "NewCppHeaderFile",
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ M.defaults = {
|
|||||||
java = {
|
java = {
|
||||||
project_root = "~/Projects/Java",
|
project_root = "~/Projects/Java",
|
||||||
keybinds = {
|
keybinds = {
|
||||||
["<leader>pb"] = "JavaBuild",
|
|
||||||
["<leader>pr"] = "JavaRun",
|
["<leader>pr"] = "JavaRun",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -39,18 +38,16 @@ M.defaults = {
|
|||||||
c = {
|
c = {
|
||||||
project_root = "~/Projects/C",
|
project_root = "~/Projects/C",
|
||||||
keybinds = {
|
keybinds = {
|
||||||
["<leader>pb"] = "CBuild",
|
|
||||||
["<leader>pr"] = "CRun",
|
["<leader>pr"] = "CRun",
|
||||||
["<leader>nh"] = "NewCHeaderFile",
|
["<leader>pb"] = "NewCHeaderFile",
|
||||||
},
|
},
|
||||||
build_attributes = "",
|
build_attributes = "",
|
||||||
},
|
},
|
||||||
cpp = {
|
cpp = {
|
||||||
project_root = "~/Projects/Cpp",
|
project_root = "~/Projects/Cpp",
|
||||||
keybinds = {
|
keybinds = {
|
||||||
["<leader>pb"] = "CppBuild",
|
|
||||||
["<leader>pr"] = "CppRun",
|
["<leader>pr"] = "CppRun",
|
||||||
["<leader>nh"] = "NewCppHeaderFile",
|
["<leader>pb"] = "NewCppHeaderFile",
|
||||||
},
|
},
|
||||||
build_attributes = "",
|
build_attributes = "",
|
||||||
},
|
},
|
||||||
|
|||||||
+3
-14
@@ -1,20 +1,9 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local loaded_languages = {}
|
|
||||||
local function load_language_module(lang, opts)
|
|
||||||
if loaded_languages[lang] then return true end
|
|
||||||
|
|
||||||
local ok, mod = pcall(require, "Polydev.languages." .. lang)
|
|
||||||
if not ok or type(mod.setup) ~= "function" then return false end
|
|
||||||
|
|
||||||
mod.setup(opts and opts[lang] or {})
|
|
||||||
loaded_languages[lang] = mod
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
local opts = opts or {}
|
local opts = opts or {}
|
||||||
local config = require("Polydev.configs")
|
local config = require("Polydev.configs")
|
||||||
|
local ui = require("Polydev.ui")
|
||||||
config.setup(opts)
|
config.setup(opts)
|
||||||
require("Polydev.utils").setup(opts)
|
require("Polydev.utils").setup(opts)
|
||||||
for lang, user_opts in pairs(opts) do
|
for lang, user_opts in pairs(opts) do
|
||||||
@@ -22,7 +11,7 @@ function M.setup(opts)
|
|||||||
config.user_config[lang] = vim.tbl_deep_extend("force", default, user_opts)
|
config.user_config[lang] = vim.tbl_deep_extend("force", default, user_opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_create_user_command("PolydevOpen", require("Polydev.ui").open_project_manager, {})
|
vim.api.nvim_create_user_command("PolydevOpen", ui.open_project_manager, {})
|
||||||
|
|
||||||
local keys = vim.tbl_deep_extend("force", {}, config.get("globals").keybinds, opts or {})
|
local keys = vim.tbl_deep_extend("force", {}, config.get("globals").keybinds, opts or {})
|
||||||
for key, command in pairs(keys) do
|
for key, command in pairs(keys) do
|
||||||
@@ -34,7 +23,7 @@ function M.setup(opts)
|
|||||||
pattern = "*",
|
pattern = "*",
|
||||||
callback = function()
|
callback = function()
|
||||||
local filetype = vim.bo.filetype
|
local filetype = vim.bo.filetype
|
||||||
load_language_module(filetype, opts)
|
ui.load_language_module(filetype, opts)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|||||||
+14
-2
@@ -50,6 +50,18 @@ local function fuzzy_filter(list, query)
|
|||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local loaded_languages = {}
|
||||||
|
function M.load_language_module(lang, opts)
|
||||||
|
if loaded_languages[lang] then return true end
|
||||||
|
|
||||||
|
local ok, mod = pcall(require, "Polydev.languages." .. lang)
|
||||||
|
if not ok or type(mod.setup) ~= "function" then return false end
|
||||||
|
|
||||||
|
mod.setup(opts and opts[lang] or {})
|
||||||
|
loaded_languages[lang] = mod
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
function M.open_project_manager()
|
function M.open_project_manager()
|
||||||
local templates = require("Polydev.templates")
|
local templates = require("Polydev.templates")
|
||||||
local Popup = require("nui.popup")
|
local Popup = require("nui.popup")
|
||||||
@@ -277,7 +289,7 @@ function M.open_project_manager()
|
|||||||
vim.ui.input({ prompt = "Enter language for new file: " }, function(lang)
|
vim.ui.input({ prompt = "Enter language for new file: " }, function(lang)
|
||||||
if not lang or lang == "" then return print("File creation canceled.") end
|
if not lang or lang == "" then return print("File creation canceled.") end
|
||||||
|
|
||||||
if load_language_module(lang) and templates.files[lang] and templates.files[lang].run then
|
if M.load_language_module(lang) and templates.files[lang] and templates.files[lang].run then
|
||||||
vim.ui.input({ prompt = "Enter file name: " }, function(file_name)
|
vim.ui.input({ prompt = "Enter file name: " }, function(file_name)
|
||||||
if not file_name or file_name == "" then return print("File creation canceled.") end
|
if not file_name or file_name == "" then return print("File creation canceled.") end
|
||||||
popup:unmount()
|
popup:unmount()
|
||||||
@@ -297,7 +309,7 @@ function M.open_project_manager()
|
|||||||
vim.ui.input({ prompt = "Enter language for project: " }, function(lang)
|
vim.ui.input({ prompt = "Enter language for project: " }, function(lang)
|
||||||
if not lang or lang == "" then return print("Project creation canceled.") end
|
if not lang or lang == "" then return print("Project creation canceled.") end
|
||||||
opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get(lang), opts or {})
|
opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get(lang), opts or {})
|
||||||
if load_language_module(lang) and templates.projects[lang] and templates.projects[lang].run then
|
if M.load_language_module(lang) and templates.projects[lang] and templates.projects[lang].run then
|
||||||
popup:unmount()
|
popup:unmount()
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
templates.create_project(lang, opts.project_root)
|
templates.create_project(lang, opts.project_root)
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Start from the current directory
|
||||||
|
DIR="$(pwd)"
|
||||||
|
|
||||||
|
# Walk up until we find a marker or reach root
|
||||||
|
while [[ ! -f "$DIR/CMakeLists.txt" && \
|
||||||
|
! -f "$DIR/package.json" && \
|
||||||
|
! -d "$DIR/.git" && \
|
||||||
|
"$DIR" != "/" ]]; do
|
||||||
|
DIR="$(dirname "$DIR")"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Check if root was reached without finding anything
|
||||||
|
if [[ "$DIR" == "/" ]]; then
|
||||||
|
echo "❌ Project root not found."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "✅ Project root found at: $DIR"
|
||||||
|
|
||||||
Reference in New Issue
Block a user