This commit is contained in:
DavidOnTop 2023-12-07 22:04:29 +00:00
parent 926ba239ce
commit ac6ba45b85
No known key found for this signature in database
GPG key ID: FAB914DDC2F180EB
8 changed files with 163 additions and 79 deletions

View file

@ -77,9 +77,12 @@ vim.api.nvim_create_user_command("Config", function ()
vim.cmd("cd $HOME/.config/nvim")
end, {})
vim.api.nvim_create_user_command("RetabFile", function ()
vim.api.nvim_create_user_command("RetabFile2Spaces", function ()
vim.cmd(":set ts=2 sts=2 noet | retab! | set ts=4 sts=4 et | retab!")
end, {})
vim.api.nvim_create_user_command("RetabFile4SpacesToTab", function ()
vim.cmd(":set ts=4 sts=4 noet | retab! | set ts=4 sts=0 noexpandtab | retab!")
end, {})
local function get_makefile_targets()
local makefile = "./Makefile"
@ -129,3 +132,45 @@ vim.api.nvim_create_user_command("Maket", function()
end
}):find()
end, {})
function get_just_targets()
local handle = io.popen("just --summary")
local res = handle:read("*a")
handle:close()
local targets = {}
-- insert space seperated targets
for target in string.gmatch(res, "%S+") do
table.insert(targets, target)
end
end
vim.api.nvim_create_user_command("Just", function(args)
local vimCmd = "TermExec cmd=\"just"
if (args["args"]) then
vimCmd = vimCmd .. " " .. args["args"]
end
vimCmd = vimCmd .. "\""
vim.cmd(vimCmd)
end, {nargs = "*", ["complete"] = function ()
return get_just_targets()
end})
vim.api.nvim_create_user_command("Justt", function()
local targets = get_makefile_targets()
pickers.new({}, {
prompt_title = "Run just target",
finder = finders.new_table {
results = targets
},
sorter = conf.generic_sorter({}),
attach_mappings = function (prompt_bufnr, map)
actions.select_default:replace(function ()
actions.close(prompt_bufnr)
local selection = action_state.get_selected_entry()
selection = selection[1]
vim.cmd(":Just " .. selection)
end)
return true
end
}):find()
end, {})