changes
This commit is contained in:
parent
926ba239ce
commit
ac6ba45b85
8 changed files with 163 additions and 79 deletions
|
@ -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, {})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue