aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/alpha/laravel/actions.lua55
-rw-r--r--lua/alpha/laravel/artisan_config.lua29
-rw-r--r--lua/alpha/laravel/init.lua42
-rw-r--r--lua/alpha/laravel/make_command_directory_map.lua26
-rw-r--r--lua/alpha/laravel/telescope.lua73
-rw-r--r--lua/alpha/laravel/utils.lua8
6 files changed, 0 insertions, 233 deletions
diff --git a/lua/alpha/laravel/actions.lua b/lua/alpha/laravel/actions.lua
deleted file mode 100644
index b7eca6f..0000000
--- a/lua/alpha/laravel/actions.lua
+++ /dev/null
@@ -1,55 +0,0 @@
-local artisan_config = require("alpha.laravel.artisan_config")
-local make_command_directory_map = require("alpha.laravel.make_command_directory_map")
-
-local M = {}
-M.make_command = function(command)
- -- change prompt from "name" to args
- -- parse args from help
- -- parse options from help
- -- can parse as json
- -- how to present the information
- vim.ui.input({ prompt = "Name: " }, function(name)
- vim.fn.jobstart({ artisan_config.artisan_cmd, "artisan", command, name }, {
- on_exit = function()
- local directory = make_command_directory_map[vim.split(command, ":")[2]]
- if directory == "" then
- return
- end
- local filename = string.format("%s/%s.php", directory, name)
- if vim.fn.findfile(filename) then
- local uri = vim.uri_from_fname(string.format("%s/%s", vim.fn.getcwd(), filename))
- local buffer = vim.uri_to_bufnr(uri)
- vim.api.nvim_win_set_buf(0, buffer)
- end
- end,
- })
- end)
-end
-
-M.output_command = function(command)
- vim.cmd('vertical new')
- local new_window = vim.api.nvim_get_current_win()
- vim.api.nvim_win_set_width(new_window, 125)
- local new_buffer = vim.api.nvim_create_buf(false, true)
- vim.api.nvim_win_set_buf(new_window, new_buffer)
- local channel_id = vim.api.nvim_open_term(new_buffer, {})
-
- local function handle_output(_, data)
- vim.fn.chansend(channel_id, data)
- end
-
- vim.fn.jobstart({ artisan_config.artisan_cmd, "artisan", command}, {
- stdeout_buffered = true,
- on_stdout = handle_output,
- on_exit = function ()
- vim.fn.chanclose(channel_id)
- vim.cmd("startinsert")
- end,
- pty = true,
- width = 120,
- })
-end
-
-M.output_command("route:list")
-
-return M
diff --git a/lua/alpha/laravel/artisan_config.lua b/lua/alpha/laravel/artisan_config.lua
deleted file mode 100644
index 6d804e8..0000000
--- a/lua/alpha/laravel/artisan_config.lua
+++ /dev/null
@@ -1,29 +0,0 @@
-local config = {
- has_composer = false,
- is_laravel = false,
- is_sail = false,
- artisan_cmd = nil
-}
-
-if vim.fn.findfile("composer.json") == nil then
- return config
-end
-
-config.has_composer = true;
-
-
-local composer_json = vim.fn.json_decode(vim.fn.readfile(vim.fn.getcwd() .. "/composer.json"))
-if composer_json["require"]["laravel/framework"] == nil then
- return config
-end
-config.is_laravel = true
-
-local artisan_command
-if composer_json["require-dev"]["laravel/sail"] ~= nil then
- config.is_sail = true
- config.artisan_cmd = "sail"
-else
- config.artisan_cmd = "php"
-end
-
-return config
diff --git a/lua/alpha/laravel/init.lua b/lua/alpha/laravel/init.lua
deleted file mode 100644
index c8ee711..0000000
--- a/lua/alpha/laravel/init.lua
+++ /dev/null
@@ -1,42 +0,0 @@
-vim.api.nvim_create_user_command("Artisan", function ()
- local artisan_config = require("alpha.laravel.artisan_config")
- if artisan_config.is_laravel then
- require("alpha.laravel.telescope").picker({})
- end
-end, {})
-
--- TODO
--- move it as plugin folder
--- Add setup fuction and set the global function like "Artisan" or something like that
--- add code actions to create a model
--- or create controller
--- or create any class
--- hover a class the actions could be call the make for that
--- trigger the completition
---
---
--- more searches on telescope or somthing
--- package laravel.nvim
---
--- require("laravel").setup() || initializes the global variable
-
--- uses the global variable so not to recheck the composer and more
---
--- require("laravel.artisan").run("route:list", {<args>})
--- require("laravel.artisan").make("controller", {<args>})
--- require("laravel.artisan").list() || return the list of commands, mostly to be use as telescope entries
--- require("laravel.artisan").help(<cmd>) || return the help for the command
--- require("laravel.artisan").watch_test("filename") || this will run auto cmd for php files and write.
---
--- can open a new buffer, replace the buffer on the window, delete the previous buffer, put response on the new buffer
---
--- require("laravel.sail").run("<cmd>")
---
--- require("laravel.composer").udpate("library") || optional field
--- require("laravel.composer").install()
--- require("laravel.composer").require()
--- require("laravel.composer").remove()
---
---
--- User commands
--- Could register the user commands for Artisan Sail & Composer
diff --git a/lua/alpha/laravel/make_command_directory_map.lua b/lua/alpha/laravel/make_command_directory_map.lua
deleted file mode 100644
index 683e001..0000000
--- a/lua/alpha/laravel/make_command_directory_map.lua
+++ /dev/null
@@ -1,26 +0,0 @@
-return {
- cast = "app/Casts",
- channel = "app/Broadcasting",
- command = "app/Console/Commands",
- component = "app/View/Components",
- controller = "app/Http/Controllers",
- event = "app/Events",
- exception = "app/Exceptions",
- factory = "",
- job = "app/Jobs",
- listener = "app/Listeners",
- mail = "app/Mail",
- middleware = "app/Http/Middleware",
- migration = "",
- model = "app/Models",
- notification = "app/Notifications",
- observer = "app/Observers",
- policy = "app/Policies",
- provider = "app/Providers",
- request = "app/Http/Requests",
- resource = "app/Http/Resources",
- rule = "app/Rules",
- scope = "app/Models/Scopes",
- seeder = "",
- test = "tests/Feature",
-}
diff --git a/lua/alpha/laravel/telescope.lua b/lua/alpha/laravel/telescope.lua
deleted file mode 100644
index db9cacf..0000000
--- a/lua/alpha/laravel/telescope.lua
+++ /dev/null
@@ -1,73 +0,0 @@
-local actions = require("telescope.actions")
-local action_state = require("telescope.actions.state")
-local utils = require("telescope.utils")
-local finders = require("telescope.finders")
-local pickers = require("telescope.pickers")
-local previewers = require("telescope.previewers")
-local putils = require("telescope.previewers.utils")
-local conf = require("telescope.config").values
-
-local artisan_config = require("alpha.laravel.artisan_config")
-local laravel_actions = require("alpha.laravel.actions")
-local laravel_utils = require("alpha.laravel.utils")
-
-local M = {}
-
-M.picker = function(opts)
- -- TODO check if cmd == sail check if sail is running
- opts = opts or {}
-
- local results = utils.get_os_command_output({ artisan_config.artisan_cmd, "artisan", "list", "--raw" })
- -- do I want to change from raw to json and decode it?
- -- what advantages will I get
- -- I have group by the id like "make" the command is the same
-
- pickers
- .new({}, {
- prompt_title = "Artisan commands",
- finder = finders.new_table({
- results = results,
- entry_maker = function(line)
- local artisan_cmd = vim.split(line, " ")[1]
- return {
- value = artisan_cmd,
- display = artisan_cmd,
- ordinal = artisan_cmd,
- }
- 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 = { artisan_config.artisan_cmd, "artisan", 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()
- -- check if entry.value is a make
- actions.close(prompt_bufnr)
- -- local cmd = string.format(":!%s %s ", get_artisan_command(), entry.value)
- -- vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(cmd, true, false, true), "t", true)
- if laravel_utils.is_make_command(entry.value) then
- laravel_actions.make_command(entry.value)
- else
- laravel_actions.output_command(entry.value)
- end
- end)
- return true
- end,
- })
- :find()
-end
-
-return M
diff --git a/lua/alpha/laravel/utils.lua b/lua/alpha/laravel/utils.lua
deleted file mode 100644
index d1e8885..0000000
--- a/lua/alpha/laravel/utils.lua
+++ /dev/null
@@ -1,8 +0,0 @@
-local M = {}
-M.is_make_command = function (command)
- local command_split = vim.split(command, ":")
-
- return command_split[1] == "make"
-end
-
-return M