diff options
| author | Ariel D'Alessandro <dalessandro.ariel@gmail.com> | 2022-02-13 17:53:07 +0100 |
|---|---|---|
| committer | Ariel D'Alessandro <dalessandro.ariel@gmail.com> | 2022-02-13 17:53:18 +0100 |
| commit | a9430e56a302a66d57fa3f7af80a74e6d037bd2c (patch) | |
| tree | 4bc2c2df29c555c8639882c109a85847bd794c7b /lua/alpha/telescope_laravel.lua | |
| parent | d43a4f3b7455599968b9e61c64944ef2759458d6 (diff) | |
| download | nvim-conf-a9430e56a302a66d57fa3f7af80a74e6d037bd2c.tar.gz nvim-conf-a9430e56a302a66d57fa3f7af80a74e6d037bd2c.zip | |
more refactor
Diffstat (limited to 'lua/alpha/telescope_laravel.lua')
| -rw-r--r-- | lua/alpha/telescope_laravel.lua | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/lua/alpha/telescope_laravel.lua b/lua/alpha/telescope_laravel.lua deleted file mode 100644 index fc730b6..0000000 --- a/lua/alpha/telescope_laravel.lua +++ /dev/null @@ -1,89 +0,0 @@ -local actions = require('telescope.actions') -local pickers = require "telescope.pickers" -local finders = require "telescope.finders" -local previewers = require "telescope.previewers" -local conf = require("telescope.config").values -local putils = require "telescope.previewers.utils" -local action_state = require "telescope.actions.state" -local utils = require "telescope.utils" -local laravel = {} - -function Split(s, delimiter) - local result = {}; - for match in (s..delimiter):gmatch("(.-)"..delimiter) do - table.insert(result, match); - end - return result; -end - -local lookup_keys = { - display = 1, - ordinal = 1, - value = 1, -} - -local mt_string_entry = { - __index = function(t, k) - return rawget(t, rawget(lookup_keys, k)) - end, -} - -local function getArtisanCommand(args) - local artCmdStr = vim.g.laravel_artisan - if artCmdStr == nil then - artCmdStr = "php artisan" - end - if type(args) ~= "table" then - return Split(artCmdStr .. ' ' .. args, " ") - end - local cmd = Split(artCmdStr, ' ') - for _, value in ipairs(args) do - table.insert(cmd, value) - end - - return cmd -end - -laravel.artisan = function() - - local results = utils.get_os_command_output(getArtisanCommand('--raw')) - - pickers.new({}, { - prompt_title = "Artisan commands", - finder = finders.new_table { - results = results, - entry_maker = function (line) - return setmetatable({ - Split(line, " ")[1], - }, mt_string_entry) - end - }, - previewer = previewers.new_buffer_previewer { - title = "Help", - get_buffer_by_name = function(_, entry) - return entry.value - end, - - define_preview = function(self, entry) - - local cmd = getArtisanCommand({entry.value, '-h'}) - - putils.job_maker(cmd, self.state.bufnr, { - value = entry.value, - bufname = self.state.bufname, - }) - end, - }, - sorter = conf.file_sorter(), - attach_mappings = function (_, map) - map('i', '<cr>', function(prompt_bufnr) - local entry = action_state.get_selected_entry() - actions.close(prompt_bufnr) - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(":Artisan " .. entry.value .. " ", true, false, true), "t", true) - end) - return true - end - }):find() -end - -return laravel |