This commit is contained in:
2025-12-09 10:35:51 +00:00
parent 0cce7837f2
commit 9bd219f053
5 changed files with 103 additions and 48 deletions

View File

@@ -46,14 +46,12 @@ vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper win
vim.keymap.set({ 'i' }, '<C-J>', function()
local ls = require 'luasnip'
print('jj')
if ls.choice_active() then
ls.change_choice(1)
end
end, { silent = true })
vim.keymap.set({ 'i' }, '<C-k>', function()
local ls = require 'luasnip'
print('kk')
if ls.choice_active() then
ls.change_choice(-1)
end

View File

@@ -31,7 +31,7 @@ return {
require('minuet').setup {
virtualtext = {
auto_trigger_ft = { '*' },
auto_trigger_ignore_ft = { 'help', 'TelescopePrompt', 'codecompanion' },
auto_trigger_ignore_ft = { 'help', 'TelescopePrompt', 'codecompanion', 'snacks_input' },
keymap = {
accept = '<A-A>',
accept_line = '<A-a>',

View File

@@ -18,6 +18,26 @@ local function command_with_dir(dir, cmd)
return '!' .. cmd
end
local function make_laravel_file(dir, cmd)
local cwd = vim.fn.getcwd()
if dir then
vim.fn.chdir(dir)
end
vim.ui.input({ prompt = 'Make: ' .. cmd }, function(input)
if input == nil then
vim.fn.chdir(cwd)
return
end
local output = vim.system({ 'vendor/bin/sail', 'artisan', 'make:' .. cmd, input }):wait().stdout
local new_file = output:match '%[([%w%./]+)%]'
if new_file ~= nil then
vim.cmd('edit ' .. new_file)
end
vim.fn.chdir(cwd)
end)
end
local function get_scope_from_file(filename)
local ext = filename:match '%.(%w+)$'
local base_name = filename:match '^(%w+)%.?%w*$'
@@ -130,6 +150,33 @@ local function laravel_keymaps(dir)
laravel_bookmarks_with_dir(dir)
end
local function laravel_makes(dir)
for key, name in pairs {
c = 'controller',
d = 'data',
e = 'event',
f = 'factory',
j = 'job',
l = 'listener',
ma = 'mail',
mi = 'migration',
mo = 'model',
mw = 'middleware',
n = 'notification',
o = 'observer',
pi = 'model --pivot',
po = 'policy',
pr = 'provider',
t = 'test --pest',
v = 'view',
x = 'exception',
} do
map('<Leader>m' .. key, function()
make_laravel_file(dir, name)
end, { desc = 'Make and navigate to relevant ' .. name })
end
end
-- Define per-project configuration here.
-- Keys are folder names (last segment of your cwd).
local PROJECTS = {
@@ -170,6 +217,7 @@ local PROJECTS = {
map('s ', '!cd server && ', { desc = 'Run command in server directory' }, 'c')
map('c ', '!cd client && ', { desc = 'Run command in client directory' }, 'c')
laravel_keymaps 'server'
laravel_makes 'server'
map('yrn ', '!cd client && yarn ', { desc = 'Run yarn script' }, 'c')
map('<Leader>pt', ':!cd server && php artisan typescript:transform --format<CR>', { desc = 'Compile typescript' })
require('conform').formatters.pint = {
@@ -191,6 +239,7 @@ local PROJECTS = {
helpers.open_term { cmd = 'lazysql pgsql://homestead:password@localhost:5432/homestead' }
end, { desc = 'Open database manager' })
laravel_keymaps()
laravel_makes()
map('yrn ', '!cd frontend && yarn ', { desc = 'Run yarn script' }, 'c')
map('<Leader>pm', ':vendor/bin/sail composer migrate<CR>')
end,

View File

@@ -2,6 +2,7 @@ local ls = require 'luasnip'
local s = ls.snippet
local sn = ls.snippet_node
local fn = ls.function_node
local ms = ls.multi_snippet
local t = ls.text_node
local c = ls.choice_node
local i = ls.insert_node
@@ -19,7 +20,7 @@ local atr = utils.atr
local ctr = utils.ctr
local bs = utils.bs
local function psr_namespace(_, snip)
local function psr_namespace()
local path = vim.fn.expand '%'
-- Get the directory of the path
local dir = vim.fs.dirname(path)
@@ -169,26 +170,24 @@ return {
s(etr('return ', 'Add semicolon after return'), fmta('return #~;', { i(0) })),
s(atr(' use ', 'Add use to function'), fmta(' use (#~)', { i(0) })),
s(etr('rt ', 'return alias'), fmta('return #~;', { i(0) })),
bs(
atr('fn ', 'Shorthand function block'),
c(0, {
bs(etr('fn ', 'Shorthand function block'), {
c(1, {
sn(nil, fmta('fn (#~) => #~', { i(1), i(2) })),
sn(
nil,
fmta(
[[
function (#~) {
#~
}
]],
function (#~) {
#~
}
]],
{ i(1), i(2) }
)
),
})
),
bs(
atr('fun ', 'Shorthand function block'),
c(0, {
}),
}),
bs(etr('fun ', 'Shorthand function block'), {
c(1, {
sn(
nil,
fmta(
@@ -211,11 +210,11 @@ return {
{ i(1), i(2), i(3) }
)
),
})
),
}),
}),
s(
etr('con', 'Constructor function block'),
c(0, {
c(1, {
sn(
nil,
fmta(
@@ -250,41 +249,45 @@ return {
bs(atr('a%$', 'array type parameter'), fmta('array $#~', { i(0, 'var') })),
s(atr('$ ', 'Expand $this->'), fmta('$this->#~', { i(0) })),
bs(
atr('am ', 'array_map function'),
c(0, {
sn(nil, fmta('array_map(fn (#~) => #~, #~)', { i(2), i(3), i(1) })),
sn(
nil,
fmta(
[[
etr('am ', 'array_map function'),
{
c(1, {
sn(nil, fmta('array_map(fn (#~) => #~, #~)', { i(2), i(3), i(1) })),
sn(
nil,
fmta(
[[
array_map(function (#~) {
#~
}, #~)
]],
{ i(2), i(0), i(1) }
)
),
})
{ i(2), i(0), i(1) }
)
),
}),
}
),
bs(atr('array_map', 'array_map function'), fmta('am', {})),
bs(etr('array_map', 'array_map function'), fmta('am', {})),
bs(
atr('af ', 'array_filter function'),
c(0, {
sn(nil, fmta('array_filter(#~, fn (#~) => #~)', { i(1), i(2), i(3) })),
sn(
nil,
fmta(
[[
etr('af ', 'array_filter function'),
{
c(1, {
sn(nil, fmta('array_filter(#~, fn (#~) => #~)', { i(1), i(2), i(3) })),
sn(
nil,
fmta(
[[
array_filter(#~, function (#~) {
#~
})
]],
{ i(1), i(2), i(0) }
)
),
})
{ i(1), i(2), i(0) }
)
),
}),
}
),
bs(atr('([^%w])array_filter', 'array_filter function'), fmta('af', {})),
bs(etr('array_filter', 'array_filter function'), fmta('af', {})),
s(
etr('php', 'php class'),
fmta(

View File

@@ -2,6 +2,7 @@ local ls = require 'luasnip'
local s = ls.snippet
local sn = ls.snippet_node
local fn = ls.function_node
local ms = ls.multi_snippet
local t = ls.text_node
local c = ls.choice_node
local i = ls.insert_node
@@ -114,15 +115,19 @@ end
---@param options? any
---@return table
utils.bs = function(trigger, nodes, options)
local btrigger
if type(trigger) == 'string' then
trigger = utils.atr('([^%w])' .. trigger)
btrigger = utils.atr('([^%w_-])' .. trigger)
else
trigger.trig = '([^%w])' .. trigger.trig
btrigger = vim.tbl_extend('keep', utils.atr('([^%w_-])' .. trigger.trig), trigger)
end
return s(
trigger,
return ms(
{
trigger,
btrigger,
},
vim.list_extend({ fn(function(args, snip)
return snip.captures[1]
return snip.captures[1] or ''
end) }, nodes),
options
)