Compare commits
14 Commits
treesitter
...
d8732c5e2e
| Author | SHA1 | Date | |
|---|---|---|---|
| d8732c5e2e | |||
| ba41c9a054 | |||
| 894d2fcabf | |||
| 40adefb70c | |||
| faea500177 | |||
| 6f74961fc6 | |||
| cc7139c2ff | |||
|
|
bac22a5657 | ||
| 20d080e223 | |||
| 847c71a194 | |||
|
|
78b8bf177c | ||
|
|
4f8e722f13 | ||
| 1f58b9f136 | |||
|
|
4d3aada204 |
@@ -30,7 +30,7 @@ vim.api.nvim_create_autocmd('SwapExists', {
|
||||
desc = 'Always choose to delete the swap file, files are saved automatically',
|
||||
group = vim.api.nvim_create_augroup('NoSwaps', { clear = true }),
|
||||
callback = function(args)
|
||||
vim.cmd("let v:swapchoice = 'd'")
|
||||
vim.cmd "let v:swapchoice = 'd'"
|
||||
end,
|
||||
})
|
||||
|
||||
@@ -116,4 +116,95 @@ vim.api.nvim_create_autocmd('BufWritePost', {
|
||||
end,
|
||||
})
|
||||
|
||||
local configs = {
|
||||
{
|
||||
path = os.getenv("HOME") .. "/.config/nixos",
|
||||
worktree = nil,
|
||||
git_dir = nil,
|
||||
track_untracked = false,
|
||||
force_add = false
|
||||
},
|
||||
{
|
||||
path = os.getenv("HOME") .. "/.config/nvim",
|
||||
worktree = nil,
|
||||
git_dir = nil,
|
||||
track_untracked = false,
|
||||
force_add = false
|
||||
},
|
||||
{
|
||||
path = os.getenv("HOME"),
|
||||
worktree = os.getenv("HOME"),
|
||||
git_dir = os.getenv("HOME") .. "/.config/dotfiles/.git",
|
||||
track_untracked = true,
|
||||
force_add = true, -- Handles ignored files in dotfiles
|
||||
include_dirs = { ".config", ".local/bin", ".local/share" }
|
||||
}
|
||||
}
|
||||
|
||||
local function get_git_status(config)
|
||||
local base = "git"
|
||||
if config.git_dir and config.worktree then
|
||||
base = string.format("git --git-dir=%s --worktree=%s", config.git_dir, config.worktree)
|
||||
end
|
||||
|
||||
-- Check modified and untracked (including ignored if force_add is true)
|
||||
local cmd = base .. " status --porcelain"
|
||||
if config.force_add then cmd = cmd .. " --ignored" end
|
||||
|
||||
local handle = io.popen(cmd)
|
||||
local result = handle:read("*a")
|
||||
handle:close()
|
||||
|
||||
local has_changes = false
|
||||
for line in result:gmatch("[^\r\n]+") do
|
||||
local status = line:sub(1, 2)
|
||||
local file = line:sub(4)
|
||||
|
||||
if status:match("[MAR]") then
|
||||
has_changes = true
|
||||
elseif (status == "??" or status == "!!") and config.track_untracked then
|
||||
if config.include_dirs then
|
||||
for _, dir in ipairs(config.include_dirs) do
|
||||
if file:sub(1, #dir) == dir then
|
||||
has_changes = true
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
has_changes = true
|
||||
end
|
||||
end
|
||||
end
|
||||
return has_changes, base
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("VimLeavePre", {
|
||||
callback = function()
|
||||
local cwd = vim.fn.getcwd()
|
||||
|
||||
for _, config in ipairs(configs) do
|
||||
if cwd:sub(1, #config.path) == config.path then
|
||||
local has_changes, git_base = get_git_status(config)
|
||||
|
||||
if has_changes then
|
||||
local confirm = vim.fn.confirm("Uncommitted changes in managed path. Commit?", "&Yes\n&No", 2)
|
||||
if confirm == 1 then
|
||||
local msg = vim.fn.input("Commit message: ", "chore: update files")
|
||||
if msg ~= "" then
|
||||
msg = "Update files"
|
||||
end
|
||||
local add_cmd = " add -A"
|
||||
os.execute(git_base .. add_cmd)
|
||||
os.execute(git_base .. " commit -m " .. vim.fn.shellescape(msg))
|
||||
os.execute(git_base .. " push")
|
||||
print("\nChanges committed.")
|
||||
end
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
require('helpers').edit_cf('a', '/lua/autocmd.lua')
|
||||
|
||||
@@ -257,6 +257,7 @@ vim.keymap.set('n', '<Leader>sGS', '<CMD>Telescope git_stash<CR>', { desc = 'Sea
|
||||
vim.keymap.set('n', '<Leader>]', '<CMD>cnext<CR>', { desc = 'Next item in quickfix list' })
|
||||
vim.keymap.set('n', '<Leader>[', '<CMD>cprevious<CR>', { desc = 'Previous item in quickfix list' })
|
||||
vim.keymap.set('n', 'gd', '<CMD>Telescope lsp_definitions<CR>', { desc = 'Go to definition' })
|
||||
vim.keymap.set('n', '<Leader>r', '<CMD>e!<CR>', { desc = 'Reload buffer' })
|
||||
|
||||
|
||||
local function open_test()
|
||||
|
||||
@@ -4,19 +4,27 @@ return {
|
||||
-- change the command in the config to whatever the name of that colorscheme is.
|
||||
--
|
||||
-- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
|
||||
'AlphaTechnolog/pywal.nvim',
|
||||
dependencies = {
|
||||
'folke/tokyonight.nvim',
|
||||
},
|
||||
priority = 1000, -- Make sure to load this before all the other start plugins.
|
||||
config = function()
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
require('tokyonight').setup {
|
||||
styles = {
|
||||
comments = { italic = false }, -- Disable italics in comments
|
||||
},
|
||||
}
|
||||
|
||||
-- Load the colorscheme here.
|
||||
-- Like many other themes, this one has different styles, and you could load
|
||||
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
|
||||
-- Check if wal directory exists otherwise use tokyo
|
||||
local handle = io.popen('ls -d $HOME/.cache/wal 2>/dev/null')
|
||||
local result = handle:read('*a')
|
||||
handle:close()
|
||||
|
||||
if result == "" then
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
require('tokyonight').setup();
|
||||
|
||||
vim.cmd.colorscheme 'tokyonight-night'
|
||||
return
|
||||
end
|
||||
|
||||
require('pywal').setup();
|
||||
|
||||
end,
|
||||
}
|
||||
|
||||
3
lua/plugins/pywal.lua
Normal file
3
lua/plugins/pywal.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
return {
|
||||
'AlphaTechnolog/pywal.nvim',
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
return {
|
||||
'nvim-treesitter/nvim-treesitter-textobjects',
|
||||
dependencies = {
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
},
|
||||
lazy = false,
|
||||
enabled = true,
|
||||
config = function()
|
||||
require('nvim-treesitter.configs').setup {
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
-- mappings for incremental selection (visual mappings)
|
||||
init_selection = 'gnn', -- maps in normal mode to init the node/scope selection
|
||||
node_incremental = 'grn', -- increment to the upper named parent
|
||||
scope_incremental = 'grc', -- increment to the upper scope (as defined in locals.scm)
|
||||
node_decremental = 'grm', -- decrement to the previous node
|
||||
},
|
||||
},
|
||||
|
||||
textobjects = {
|
||||
-- syntax-aware textobjects
|
||||
enable = true,
|
||||
keymaps = {
|
||||
['iL'] = {
|
||||
-- you can define your own textobjects directly here
|
||||
go = '(function_definition) @function',
|
||||
},
|
||||
-- or you use the queries from supported languages with textobjects.scm
|
||||
['af'] = '@function.outer',
|
||||
['if'] = '@function.inner',
|
||||
['aC'] = '@class.outer',
|
||||
['iC'] = '@class.inner',
|
||||
['ay'] = '@conditional.outer',
|
||||
['iy'] = '@conditional.inner',
|
||||
['aj'] = '@loop.outer',
|
||||
['ij'] = '@loop.inner',
|
||||
['is'] = '@statement.inner',
|
||||
['as'] = '@statement.outer',
|
||||
['ac'] = '@comment.outer',
|
||||
['ic'] = '@comment.inner',
|
||||
['ap'] = '@comment.parameter',
|
||||
['ip'] = '@comment.parameter',
|
||||
},
|
||||
move = {
|
||||
enable = true,
|
||||
set_jumps = true, -- whether to set jumps in the jumplist
|
||||
goto_next_start = {
|
||||
[']m'] = '@function.outer',
|
||||
[']]'] = '@class.outer',
|
||||
},
|
||||
goto_next_end = {
|
||||
[']M'] = '@function.outer',
|
||||
[']['] = '@class.outer',
|
||||
},
|
||||
goto_previous_start = {
|
||||
['[m'] = '@function.outer',
|
||||
['[['] = '@class.outer',
|
||||
},
|
||||
goto_previous_end = {
|
||||
['[M'] = '@function.outer',
|
||||
['[]'] = '@class.outer',
|
||||
},
|
||||
},
|
||||
select = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
-- You can use the capture groups defined in textobjects.scm
|
||||
['af'] = '@function.outer',
|
||||
['if'] = '@function.inner',
|
||||
['ac'] = '@class.outer',
|
||||
['ic'] = '@class.inner',
|
||||
-- Or you can define your own textobjects like this
|
||||
['iF'] = {
|
||||
python = '(function_definition) @function',
|
||||
cpp = '(function_definition) @function',
|
||||
c = '(function_definition) @function',
|
||||
java = '(method_declaration) @function',
|
||||
go = '(method_declaration) @function',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
return {
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
build = ':TSUpdate',
|
||||
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
|
||||
-- main = 'nvim-treesitter.configs', -- Sets main module to use for opts
|
||||
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
|
||||
@@ -92,39 +92,39 @@ end
|
||||
|
||||
local function laravel_bookmarks_with_dir(dir)
|
||||
create_bookmark_maps {
|
||||
['e'] = dir .. '/.env',
|
||||
['l'] = dir .. '/storage/logs/laravel.log',
|
||||
['w'] = dir .. '/routes/web.php',
|
||||
['a'] = dir .. '/routes/api.php',
|
||||
['m'] = dir .. '/database/migrations',
|
||||
['e'] = dir .. '.env',
|
||||
['l'] = dir .. 'storage/logs/laravel.log',
|
||||
['w'] = dir .. 'routes/web.php',
|
||||
['a'] = dir .. 'routes/api.php',
|
||||
['m'] = dir .. 'database/migrations',
|
||||
|
||||
['dc'] = dir .. '/app/Core/',
|
||||
['dd'] = dir .. '/app/Data/',
|
||||
['dE'] = dir .. '/app/Enums/',
|
||||
['de'] = dir .. '/app/Events/',
|
||||
['dh'] = dir .. '/app/Http/',
|
||||
['dj'] = dir .. '/app/Jobs/',
|
||||
['dl'] = dir .. '/app/Listeners/',
|
||||
['dM'] = dir .. '/app/Mail/',
|
||||
['dm'] = dir .. '/app/Models/',
|
||||
['dn'] = dir .. '/app/Notifications/',
|
||||
['do'] = dir .. '/app/Observers/',
|
||||
['dp'] = dir .. '/app/Providers/',
|
||||
['dc'] = dir .. 'app/Core/',
|
||||
['dd'] = dir .. 'app/Data/',
|
||||
['dE'] = dir .. 'app/Enums/',
|
||||
['de'] = dir .. 'app/Events/',
|
||||
['dh'] = dir .. 'app/Http/',
|
||||
['dj'] = dir .. 'app/Jobs/',
|
||||
['dl'] = dir .. 'app/Listeners/',
|
||||
['dM'] = dir .. 'app/Mail/',
|
||||
['dm'] = dir .. 'app/Models/',
|
||||
['dn'] = dir .. 'app/Notifications/',
|
||||
['do'] = dir .. 'app/Observers/',
|
||||
['dp'] = dir .. 'app/Providers/',
|
||||
|
||||
['pa'] = dir .. '/app/Providers/AppServiceProvider.php',
|
||||
['pe'] = dir .. '/app/Providers/EventServiceProvider.php',
|
||||
['pa'] = dir .. 'app/Providers/AppServiceProvider.php',
|
||||
['pe'] = dir .. 'app/Providers/EventServiceProvider.php',
|
||||
|
||||
['cA'] = dir .. '/config/app.php',
|
||||
['ca'] = dir .. '/config/auth.php',
|
||||
['cb'] = dir .. '/config/broadcasting.php',
|
||||
['cd'] = dir .. '/config/database.php',
|
||||
['cf'] = dir .. '/config/filesystems.php',
|
||||
['ch'] = dir .. '/config/filesystems.php',
|
||||
['cl'] = dir .. '/config/logging.php',
|
||||
['cm'] = dir .. '/config/mail.php',
|
||||
['cq'] = dir .. '/config/queue.php',
|
||||
['cS'] = dir .. '/config/services.php',
|
||||
['cs'] = dir .. '/config/session.php',
|
||||
['cA'] = dir .. 'config/app.php',
|
||||
['ca'] = dir .. 'config/auth.php',
|
||||
['cb'] = dir .. 'config/broadcasting.php',
|
||||
['cd'] = dir .. 'config/database.php',
|
||||
['cf'] = dir .. 'config/filesystems.php',
|
||||
['ch'] = dir .. 'config/filesystems.php',
|
||||
['cl'] = dir .. 'config/logging.php',
|
||||
['cm'] = dir .. 'config/mail.php',
|
||||
['cq'] = dir .. 'config/queue.php',
|
||||
['cS'] = dir .. 'config/services.php',
|
||||
['cs'] = dir .. 'config/session.php',
|
||||
}
|
||||
end
|
||||
|
||||
@@ -216,8 +216,8 @@ local PROJECTS = {
|
||||
end, { desc = 'Open database manager' })
|
||||
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'
|
||||
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 = {
|
||||
@@ -257,10 +257,12 @@ function M.apply(cwd)
|
||||
end
|
||||
last_applied = name
|
||||
|
||||
local setup = PROJECTS[name] or PROJECTS.default
|
||||
local setup = PROJECTS[name]
|
||||
if type(setup) == 'function' then
|
||||
setup(dir)
|
||||
vim.notify(('Project config loaded: %s'):format(name), vim.log.levels.INFO, { title = 'projects.lua' })
|
||||
else
|
||||
PROJECTS.default(dir)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,45 +1,128 @@
|
||||
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
|
||||
local f = ls.function_node
|
||||
local d = ls.dynamic_node
|
||||
local fmt = require('luasnip.extras.fmt').fmt
|
||||
local rep = require('luasnip.extras').rep
|
||||
local extend_decorator = require 'luasnip.util.extend_decorator'
|
||||
local fmta = extend_decorator.apply(fmt, { delimiters = '#~' })
|
||||
|
||||
local utils = require 'snippets.snip_utils'
|
||||
local tr = utils.tr
|
||||
local etr = utils.etr
|
||||
local atr = utils.atr
|
||||
local ctr = utils.ctr
|
||||
local bs = utils.bs
|
||||
|
||||
return {
|
||||
s('du', { t 'console.log(', i(0), t ');' }),
|
||||
s(etr('du ', 'Dump a variable to the console'), fmta('console.log(#~);', { i(0) })),
|
||||
s(
|
||||
etr('vue', 'Vue Single File Component skeleton'),
|
||||
fmta(
|
||||
[[
|
||||
<template>
|
||||
</template>
|
||||
<script setup>
|
||||
#~
|
||||
</script>
|
||||
<style scoped>
|
||||
</style>
|
||||
]],
|
||||
{ i(0) }
|
||||
)
|
||||
),
|
||||
|
||||
s('vue', {
|
||||
t { '<template>', '' },
|
||||
t { '', '</template>', '', '', '<script setup>', '' },
|
||||
i(0),
|
||||
t { '', '</script>', '', '', '<style scoped>', '', '.o-share-page {', '}', '', '</style>' },
|
||||
-- bs(atr('t ', 'this'), fmta('this.#~', { i(0) })),
|
||||
|
||||
s(etr('return ', 'Add semicolon after return'), fmta('return #~;', { i(0) })),
|
||||
s(etr('rt ', 'return alias'), fmta('return #~;', { i(0) })),
|
||||
|
||||
s(etr('const', 'const declaration'), {
|
||||
c(1, {
|
||||
sn(nil, fmta('const #~ = #~;', { i(1, 'variableName'), i(2, 'value') })),
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
[[
|
||||
const #~ = (#~) => {
|
||||
#~
|
||||
}
|
||||
]],
|
||||
{ i(1), i(2), i(3) }
|
||||
)
|
||||
),
|
||||
}),
|
||||
}),
|
||||
|
||||
s('fun', {
|
||||
t 'function ',
|
||||
i(1),
|
||||
t '(',
|
||||
i(2),
|
||||
t ') {',
|
||||
t { '', ' ' },
|
||||
i(0),
|
||||
t { '', '}' },
|
||||
s(
|
||||
etr('fn ', 'function block'),
|
||||
fmta(
|
||||
[[
|
||||
function #~(#~) {
|
||||
#~
|
||||
}
|
||||
]],
|
||||
{ i(1), i(2), i(0) }
|
||||
)
|
||||
),
|
||||
|
||||
bs(atr('fn ', 'function block'), {
|
||||
c(1, {
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
[[
|
||||
(#~) => {
|
||||
#~
|
||||
}
|
||||
]],
|
||||
{ i(1), i(2) }
|
||||
)
|
||||
),
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
[[
|
||||
function (#~) {
|
||||
#~
|
||||
}
|
||||
]],
|
||||
{ i(1), i(2) }
|
||||
)
|
||||
),
|
||||
}),
|
||||
}),
|
||||
|
||||
s('afun', {
|
||||
t 'async function ',
|
||||
i(1),
|
||||
t '(',
|
||||
i(2),
|
||||
t ') {',
|
||||
t { '', ' ' },
|
||||
i(0),
|
||||
t { '', '}' },
|
||||
bs(atr('afn ', 'async function block'), {
|
||||
c(1, {
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
[[
|
||||
async (#~) => {
|
||||
#~
|
||||
}
|
||||
]],
|
||||
{ i(1), i(2) }
|
||||
)
|
||||
),
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
[[
|
||||
async function (#~) {
|
||||
#~
|
||||
}
|
||||
]],
|
||||
{ i(1), i(2) }
|
||||
)
|
||||
),
|
||||
}),
|
||||
|
||||
s('()', {
|
||||
t '() => {',
|
||||
t { '', ' ' },
|
||||
i(0),
|
||||
t { '', '}' },
|
||||
}),
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ local fmta = extend_decorator.apply(fmt, { delimiters = '#~' })
|
||||
local utils = require 'snippets.snip_utils'
|
||||
local tr = utils.tr
|
||||
local etr = utils.etr
|
||||
local Etr = utils.Etr
|
||||
local atr = utils.atr
|
||||
local ctr = utils.ctr
|
||||
local bs = utils.bs
|
||||
@@ -69,10 +70,10 @@ return {
|
||||
---------------
|
||||
-- DEBUGGING --
|
||||
---------------
|
||||
s(etr('du ', 'Dump a variable to the dump server'), fmta('dump(#~);', { i(0) })),
|
||||
bs(atr('du ', 'Dump a variable to the dump server'), fmta('dump(#~)', { i(0) })),
|
||||
s(etr('r ', 'ray'), fmta('ray(#~);', { i(0) })),
|
||||
bs(atr('r ', 'ray'), fmta('ray(#~)', { i(0) })),
|
||||
s(etr('du ', 'Dump a variable to the dump server', { priority = 1001 }), fmta('dump(#~);', { i(0) })),
|
||||
bs(etr('du ', 'Dump a variable to the dump server'), fmta('dump(#~)', { i(0) })),
|
||||
s(etr('r ', 'ray', { priority = 1001 }), fmta('ray(#~);', { i(0) })),
|
||||
bs(etr('r ', 'ray'), fmta('ray(#~)', { i(0) })),
|
||||
s(etr('dt ', 'Dump PHPStan type definition'), fmta('\\PhpStan\\dumpType(#~);', { i(0) })),
|
||||
s(
|
||||
etr('ql ', 'Log all queries'),
|
||||
@@ -107,6 +108,7 @@ return {
|
||||
}),
|
||||
s(etr('@v', '@var docblock'), fmta('/** @var #~ $#~ */', { i(1), i(0) })),
|
||||
s(ctr('@v', '@var docblock'), fmta('@var #~ $#~', { i(1), i(0) })),
|
||||
s(Etr('@pi', '@phpstan-ignore'), fmta('// @phpstan-ignore #~ (#~)', { i(1), i(0) })),
|
||||
s(ctr('* @pr', 'Class property docblock'), fmta('* @property #~ $#~', { i(1), i(0) })),
|
||||
s(ctr('* @pb', 'Class boolean property docblock'), fmta('* @property bool $#~', { i(0) })),
|
||||
s(ctr('* @pi', 'Class int property docblock'), fmta('* @property int $#~', { i(0) })),
|
||||
@@ -168,9 +170,9 @@ return {
|
||||
)
|
||||
),
|
||||
s(etr('return ', 'Add semicolon after return'), fmta('return #~;', { i(0) })),
|
||||
s(atr(' use ', 'Add use to function'), fmta(' use (#~)', { i(0) })),
|
||||
-- s(atr(' use ', 'Add use to function'), fmta(' use (#~)', { i(0) })),
|
||||
s(etr('rt ', 'return alias'), fmta('return #~;', { i(0) })),
|
||||
bs(etr('fn ', 'Shorthand function block'), {
|
||||
bs(atr('fn ', 'Shorthand function block'), {
|
||||
c(1, {
|
||||
sn(nil, fmta('fn (#~) => #~', { i(1), i(2) })),
|
||||
sn(
|
||||
@@ -186,7 +188,7 @@ return {
|
||||
),
|
||||
}),
|
||||
}),
|
||||
bs(etr('fun ', 'Shorthand function block'), {
|
||||
bs(atr('fun ', 'Shorthand function block'), {
|
||||
c(1, {
|
||||
sn(
|
||||
nil,
|
||||
@@ -212,36 +214,36 @@ return {
|
||||
),
|
||||
}),
|
||||
}),
|
||||
s(
|
||||
etr('con', 'Constructor function block'),
|
||||
c(1, {
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
[[
|
||||
public function __construct(#~)
|
||||
{
|
||||
#~
|
||||
}
|
||||
]],
|
||||
{ i(1), i(2) }
|
||||
)
|
||||
),
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
[[
|
||||
public function __construct(
|
||||
#~
|
||||
) {
|
||||
#~
|
||||
}
|
||||
]],
|
||||
{ i(1), i(2) }
|
||||
)
|
||||
),
|
||||
})
|
||||
),
|
||||
-- s(
|
||||
-- etr('con', 'Constructor function block'),
|
||||
-- c(1, {
|
||||
-- sn(
|
||||
-- nil,
|
||||
-- fmta(
|
||||
-- [[
|
||||
-- public function __construct(#~)
|
||||
-- {
|
||||
-- #~
|
||||
-- }
|
||||
-- ]],
|
||||
-- { i(1), i(2) }
|
||||
-- )
|
||||
-- ),
|
||||
-- sn(
|
||||
-- nil,
|
||||
-- fmta(
|
||||
-- [[
|
||||
-- public function __construct(
|
||||
-- #~
|
||||
-- ) {
|
||||
-- #~
|
||||
-- }
|
||||
-- ]],
|
||||
-- { i(1), i(2) }
|
||||
-- )
|
||||
-- ),
|
||||
-- })
|
||||
-- ),
|
||||
bs(atr('function', 'Shorthand function block'), fmta('fun', {})),
|
||||
bs(atr('s%$', 'string type parameter'), fmta('string $#~', { i(0, 'var') })),
|
||||
bs(atr('i%$', 'int type parameter'), fmta('int $#~', { i(0, 'var') })),
|
||||
@@ -358,9 +360,20 @@ return {
|
||||
etr('test', 'Create a test function'),
|
||||
fmta(
|
||||
[[
|
||||
test(#~ function () {
|
||||
test('#~', function () {
|
||||
#~
|
||||
})
|
||||
});
|
||||
]],
|
||||
{ i(1), i(0) }
|
||||
)
|
||||
),
|
||||
s(
|
||||
etr('it ', 'Create a test function'),
|
||||
fmta(
|
||||
[[
|
||||
it('#~', function () {
|
||||
#~
|
||||
});
|
||||
]],
|
||||
{ i(1), i(0) }
|
||||
)
|
||||
@@ -371,7 +384,7 @@ return {
|
||||
-------------
|
||||
s(
|
||||
etr('bt', 'belongsTo Laravel relationship method'),
|
||||
c(0, {
|
||||
c(1, {
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
@@ -384,7 +397,7 @@ return {
|
||||
return $this->belongsTo(#~::class);
|
||||
}
|
||||
]],
|
||||
{ rep(1), i(0), i(1) }
|
||||
{ rep(1), i(2), i(1) }
|
||||
)
|
||||
),
|
||||
sn(
|
||||
@@ -399,14 +412,14 @@ return {
|
||||
return $this->belongsTo(#~::class, #~);
|
||||
}
|
||||
]],
|
||||
{ rep(1), i(2), i(1), i(0) }
|
||||
{ rep(1), i(2), i(1), i(3) }
|
||||
)
|
||||
),
|
||||
})
|
||||
),
|
||||
s(
|
||||
etr('hm', 'hasMany Laravel relationship method'),
|
||||
c(0, {
|
||||
c(1, {
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
@@ -419,7 +432,7 @@ return {
|
||||
return $this->hasOne(#~::class);
|
||||
}
|
||||
]],
|
||||
{ rep(1), i(0), i(1) }
|
||||
{ rep(1), i(2), i(1) }
|
||||
)
|
||||
),
|
||||
sn(
|
||||
@@ -434,14 +447,14 @@ return {
|
||||
return $this->hasOne(#~::class, #~);
|
||||
}
|
||||
]],
|
||||
{ rep(1), i(2), i(1), i(0) }
|
||||
{ rep(1), i(2), i(1), i(3) }
|
||||
)
|
||||
),
|
||||
})
|
||||
),
|
||||
s(
|
||||
etr('ho', 'hasOne Laravel relationship method'),
|
||||
c(0, {
|
||||
c(1, {
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
@@ -454,7 +467,7 @@ return {
|
||||
return $this->hasOne(#~::class);
|
||||
}
|
||||
]],
|
||||
{ rep(1), i(0), i(1) }
|
||||
{ rep(1), i(2), i(1) }
|
||||
)
|
||||
),
|
||||
sn(
|
||||
@@ -469,14 +482,14 @@ return {
|
||||
return $this->hasOne(#~::class, #~);
|
||||
}
|
||||
]],
|
||||
{ rep(1), i(2), i(1), i(0) }
|
||||
{ rep(1), i(2), i(1), i(3) }
|
||||
)
|
||||
),
|
||||
})
|
||||
),
|
||||
s(
|
||||
etr('bm', 'belongsToMany Laravel relationship method'),
|
||||
c(0, {
|
||||
c(1, {
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
@@ -489,7 +502,7 @@ return {
|
||||
return $this->belongsToMany(#~::class, #~);
|
||||
}
|
||||
]],
|
||||
{ rep(1), i(2), i(1), i(0) }
|
||||
{ rep(1), i(2), i(1), i(3) }
|
||||
)
|
||||
),
|
||||
sn(
|
||||
@@ -504,97 +517,97 @@ return {
|
||||
return $this->belongsToMany(#~::class, #~, #~);
|
||||
}
|
||||
]],
|
||||
{ rep(1), i(2), i(1), i(3), i(0) }
|
||||
)
|
||||
),
|
||||
})
|
||||
),
|
||||
s(
|
||||
atr('->wr', 'Eloquent where method'),
|
||||
c(0, {
|
||||
sn(nil, fmta("->where('#~', #~)", { i(1), i(0) })),
|
||||
sn(nil, fmta('->where(fn ($query) => #~)', { i(0) })),
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
[[
|
||||
->where(function ($query) {
|
||||
#~
|
||||
})
|
||||
]],
|
||||
{ i(0) }
|
||||
)
|
||||
),
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
[[
|
||||
->where(function ($query) use (#~) {
|
||||
#~
|
||||
})
|
||||
]],
|
||||
{ i(1), i(0) }
|
||||
)
|
||||
),
|
||||
})
|
||||
),
|
||||
s(atr('->wi', 'Eloquent where in method'), fmta("->whereIn('#~', #~)", { i(1), i(0) })),
|
||||
s(atr('->wn', 'Eloquent where not in method'), fmta("->whereNotIn('#~', #~)", { i(1), i(0) })),
|
||||
s(
|
||||
atr('->wh', 'Eloquent where has method'),
|
||||
c(0, {
|
||||
sn(nil, fmta("->whereHas('#~')", { i(1) })),
|
||||
sn(nil, fmta("->whereHas('#~', fn ($query) => #~)", { i(1), i(0) })),
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
[[
|
||||
->whereHas('#~', function ($query) {
|
||||
#~
|
||||
})
|
||||
]],
|
||||
{ i(1), i(0) }
|
||||
)
|
||||
),
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
[[
|
||||
->whereHas('#~', function ($query) use (#~) {
|
||||
#~
|
||||
})
|
||||
]],
|
||||
{ i(1), i(2), i(0) }
|
||||
)
|
||||
),
|
||||
})
|
||||
),
|
||||
s(
|
||||
atr('->we', 'Eloquent where exists method'),
|
||||
c(0, {
|
||||
sn(nil, fmta('->whereExists(fn ($query) => #~)', { i(0) })),
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
[[
|
||||
->whereExists(function ($query) {
|
||||
#~
|
||||
})
|
||||
]],
|
||||
{ i(0) }
|
||||
)
|
||||
),
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
[[
|
||||
->whereExists(function ($query) use (#~) {
|
||||
#~
|
||||
})
|
||||
]],
|
||||
{ i(1), i(0) }
|
||||
{ rep(1), i(2), i(1), i(3), i(4) }
|
||||
)
|
||||
),
|
||||
})
|
||||
),
|
||||
-- s(
|
||||
-- atr('->wr', 'Eloquent where method'),
|
||||
-- c(0, {
|
||||
-- sn(nil, fmta("->where('#~', #~)", { i(1), i(0) })),
|
||||
-- sn(nil, fmta('->where(fn ($query) => #~)', { i(0) })),
|
||||
-- sn(
|
||||
-- nil,
|
||||
-- fmta(
|
||||
-- [[
|
||||
-- ->where(function ($query) {
|
||||
-- #~
|
||||
-- })
|
||||
-- ]],
|
||||
-- { i(0) }
|
||||
-- )
|
||||
-- ),
|
||||
-- sn(
|
||||
-- nil,
|
||||
-- fmta(
|
||||
-- [[
|
||||
-- ->where(function ($query) use (#~) {
|
||||
-- #~
|
||||
-- })
|
||||
-- ]],
|
||||
-- { i(1), i(0) }
|
||||
-- )
|
||||
-- ),
|
||||
-- })
|
||||
-- ),
|
||||
-- s(atr('->wi', 'Eloquent where in method'), fmta("->whereIn('#~', #~)", { i(1), i(0) })),
|
||||
-- s(atr('->wn', 'Eloquent where not in method'), fmta("->whereNotIn('#~', #~)", { i(1), i(0) })),
|
||||
-- s(
|
||||
-- atr('->wha', 'Eloquent where has method'),
|
||||
-- c(0, {
|
||||
-- sn(nil, fmta("->whereHas('#~')", { i(1) })),
|
||||
-- sn(nil, fmta("->whereHas('#~', fn ($query) => #~)", { i(1), i(0) })),
|
||||
-- sn(
|
||||
-- nil,
|
||||
-- fmta(
|
||||
-- [[
|
||||
-- ->whereHas('#~', function ($query) {
|
||||
-- #~
|
||||
-- })
|
||||
-- ]],
|
||||
-- { i(1), i(0) }
|
||||
-- )
|
||||
-- ),
|
||||
-- sn(
|
||||
-- nil,
|
||||
-- fmta(
|
||||
-- [[
|
||||
-- ->whereHas('#~', function ($query) use (#~) {
|
||||
-- #~
|
||||
-- })
|
||||
-- ]],
|
||||
-- { i(1), i(2), i(0) }
|
||||
-- )
|
||||
-- ),
|
||||
-- })
|
||||
-- ),
|
||||
-- s(
|
||||
-- atr('->we', 'Eloquent where exists method'),
|
||||
-- c(0, {
|
||||
-- sn(nil, fmta('->whereExists(fn ($query) => #~)', { i(0) })),
|
||||
-- sn(
|
||||
-- nil,
|
||||
-- fmta(
|
||||
-- [[
|
||||
-- ->whereExists(function ($query) {
|
||||
-- #~
|
||||
-- })
|
||||
-- ]],
|
||||
-- { i(0) }
|
||||
-- )
|
||||
-- ),
|
||||
-- sn(
|
||||
-- nil,
|
||||
-- fmta(
|
||||
-- [[
|
||||
-- ->whereExists(function ($query) use (#~) {
|
||||
-- #~
|
||||
-- })
|
||||
-- ]],
|
||||
-- { i(1), i(0) }
|
||||
-- )
|
||||
-- ),
|
||||
-- })
|
||||
-- ),
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ local d = ls.dynamic_node
|
||||
local fmt = require('luasnip.extras.fmt').fmt
|
||||
local rep = require('luasnip.extras').rep
|
||||
local line_begin = require('luasnip.extras.conditions').line_begin
|
||||
local line_end = require('luasnip.extras.conditions').line_end
|
||||
local extend_decorator = require 'luasnip.util.extend_decorator'
|
||||
local fmta = extend_decorator.apply(fmt, { delimiters = '#~' })
|
||||
|
||||
@@ -109,6 +110,21 @@ utils.atr = function(trigger, description, options)
|
||||
)
|
||||
end
|
||||
|
||||
--- Create a trigger for a snippet to expand at the end of a line
|
||||
---@param trigger string
|
||||
---@param description? string
|
||||
---@param options? table
|
||||
---@return table
|
||||
utils.Etr = function(trigger, description, options)
|
||||
return utils.tr(
|
||||
trigger,
|
||||
description,
|
||||
vim.tbl_extend('force', {
|
||||
condition = line_end
|
||||
}, options or {})
|
||||
)
|
||||
end
|
||||
|
||||
--- Create a snippet that will expand anywhere but in the middle of a word
|
||||
---@param trigger any
|
||||
---@param nodes any
|
||||
|
||||
Reference in New Issue
Block a user