aboutsummaryrefslogtreecommitdiffstats
path: root/lua/alpha/laravel-tinker.lua
diff options
context:
space:
mode:
authorAriel D'Alessandro <dalessandro.ariel@gmail.com>2023-01-31 09:44:13 +0100
committerAriel D'Alessandro <dalessandro.ariel@gmail.com>2023-01-31 09:44:13 +0100
commit669561e21073e6efafddda25ba3ace69fb43819e (patch)
treef94ebd60ad4cab480b5cbcb7e65dd2060696c339 /lua/alpha/laravel-tinker.lua
parent5044c70e9f62cdd06ee91e754423b07c1c18c12d (diff)
downloadnvim-conf-669561e21073e6efafddda25ba3ace69fb43819e.tar.gz
nvim-conf-669561e21073e6efafddda25ba3ace69fb43819e.zip
feat: apply stylua
Diffstat (limited to 'lua/alpha/laravel-tinker.lua')
-rw-r--r--lua/alpha/laravel-tinker.lua99
1 files changed, 48 insertions, 51 deletions
diff --git a/lua/alpha/laravel-tinker.lua b/lua/alpha/laravel-tinker.lua
index fa23346..214d958 100644
--- a/lua/alpha/laravel-tinker.lua
+++ b/lua/alpha/laravel-tinker.lua
@@ -1,67 +1,64 @@
local M = {}
+M.runCode = function()
+ local curBuff = vim.api.nvim_get_current_buf()
-M.runCode = function ()
- local curBuff = vim.api.nvim_get_current_buf()
+ local stats = vim.api.nvim_list_uis()[1]
- local stats = vim.api.nvim_list_uis()[1]
+ local width = stats.width
+ local height = stats.height
- local width = stats.width
- local height = stats.height
+ local bufh = vim.api.nvim_create_buf(false, true)
+ local winId = vim.api.nvim_open_win(bufh, true, {
+ relative = "editor",
+ width = width * 0.75,
+ height = height * 0.75,
+ col = 2,
+ row = 2,
+ style = "minimal",
+ border = "rounded",
+ })
- local bufh = vim.api.nvim_create_buf(false, true)
- local winId = vim.api.nvim_open_win(bufh, true, {
- relative = "editor",
- width = width * 0.75,
- height = height * 0.75,
- col = 2,
- row = 2,
- style = "minimal",
- border = "rounded",
- })
+ -- get the start and end lines of selection
+ local startLine = vim.api.nvim_buf_get_mark(curBuff, "<")[1] - 1
+ local endLine = vim.api.nvim_buf_get_mark(curBuff, ">")[1]
+ -- print("range: ", startLine, endLine)
- -- get the start and end lines of selection
- local startLine = vim.api.nvim_buf_get_mark(curBuff, "<")[1] -1
- local endLine = vim.api.nvim_buf_get_mark(curBuff, ">")[1]
- -- print("range: ", startLine, endLine)
+ local code = vim.api.nvim_buf_get_lines(curBuff, startLine, endLine, false)
- local code = vim.api.nvim_buf_get_lines(curBuff, startLine, endLine, false);
+ -- print (vim.inspect(code))
- -- print (vim.inspect(code))
+ local codeText = vim.fn.shellescape(table.concat(code, " "))
+ -- print(codeText)
- local codeText = vim.fn.shellescape(table.concat(code, " "))
- -- print(codeText)
+ local result = vim.fn.systemlist("php artisan tinker --execute=" .. codeText)
-
- local result = vim.fn.systemlist('php artisan tinker --execute=' .. codeText)
-
- vim.api.nvim_buf_set_text(bufh, 0, 0, 0, 0, result)
+ vim.api.nvim_buf_set_text(bufh, 0, 0, 0, 0, result)
end
-M.backTerminal = function ()
- local bufh = vim.api.nvim_create_buf(false, true)
- local term = vim.api.nvim_open_term(bufh, {})
-
- local winId = vim.api.nvim_open_win(bufh, true, {
- relative = "editor",
- width = 80,
- height = 80,
- col = 2,
- row = 2,
- style = "minimal",
- border = "rounded",
- })
-
- local jobId = vim.fn.jobstart("php artisan tinker", {
- on_stdout = function (err, data)
- print(err, vim.inspect(data))
- vim.api.nvim_chan_send(term, table.concat(data, "\n"))
- end
- })
-
- vim.api.nvim_chan_send(jobId, "$ub = UploadBatch::find(1);\n")
- vim.api.nvim_chan_send(jobId, "dump($ub);\n")
+M.backTerminal = function()
+ local bufh = vim.api.nvim_create_buf(false, true)
+ local term = vim.api.nvim_open_term(bufh, {})
+
+ local winId = vim.api.nvim_open_win(bufh, true, {
+ relative = "editor",
+ width = 80,
+ height = 80,
+ col = 2,
+ row = 2,
+ style = "minimal",
+ border = "rounded",
+ })
+
+ local jobId = vim.fn.jobstart("php artisan tinker", {
+ on_stdout = function(err, data)
+ print(err, vim.inspect(data))
+ vim.api.nvim_chan_send(term, table.concat(data, "\n"))
+ end,
+ })
+
+ vim.api.nvim_chan_send(jobId, "$ub = UploadBatch::find(1);\n")
+ vim.api.nvim_chan_send(jobId, "dump($ub);\n")
end
-
return M