From 672f0d32e322b79661b5d7959887adaa9e41ad98 Mon Sep 17 00:00:00 2001 From: Daniil Rozanov Date: Fri, 29 Mar 2024 04:37:56 +0300 Subject: feat: build from current variant --- lua/cmake-explorer/telescope/test.lua | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 lua/cmake-explorer/telescope/test.lua (limited to 'lua/cmake-explorer/telescope/test.lua') diff --git a/lua/cmake-explorer/telescope/test.lua b/lua/cmake-explorer/telescope/test.lua new file mode 100644 index 0000000..7b8bb00 --- /dev/null +++ b/lua/cmake-explorer/telescope/test.lua @@ -0,0 +1,46 @@ +local pickers = require("telescope.pickers") +local finders = require("telescope.finders") +local conf = require("telescope.config").values +local actions = require("telescope.actions") +local action_state = require("telescope.actions.state") + +-- our picker function: colors +local colors = function(opts) + opts = opts or {} + pickers + .new(opts, { + prompt_title = "colors", + finder = finders.new_table({ + results = { + { "red", "#ff0000" }, + { "green", "#00ff00" }, + { "blue", "#0000ff" }, + }, + entry_maker = function(entry) + return { + value = entry, + display = entry[1], + ordinal = entry[1], + } + end, + }), + sorter = conf.generic_sorter(opts), + attach_mappings = function(prompt_bufnr, map) + map({ "i", "n" }, "", function(_prompt_bufnr) + print("You typed ") + end) + + actions.select_default:replace(function() + actions.close(prompt_bufnr) + local selection = action_state.get_selected_entry() + -- print(vim.inspect(selection)) + vim.api.nvim_put({ selection[1] }, "", false, true) + end) + return true + end, + }) + :find() +end + +-- to execute the function +colors() -- cgit v1.2.3