Compare commits

16 Commits

Author SHA1 Message Date
8d1278b84a Fix pywal missing 2026-03-09 23:20:40 +00:00
e4a935de25 Use tokyo for fallback 2026-03-08 20:58:50 +00:00
d8732c5e2e Update files 2026-03-08 20:50:10 +00:00
ba41c9a054 Add pywal theme 2026-03-08 20:48:24 +00:00
894d2fcabf Update files 2026-03-06 17:06:16 +00:00
40adefb70c Update files 2026-03-06 17:05:20 +00:00
faea500177 Update files 2026-03-06 17:02:36 +00:00
6f74961fc6 Fix treesitter 2026-03-01 20:52:19 +00:00
cc7139c2ff Add keymap to reload file 2026-02-22 20:02:46 +00:00
Chris
bac22a5657 Comment out annoying snippets 2026-02-19 09:04:46 +00:00
20d080e223 Stuff 2026-02-15 21:35:09 +00:00
847c71a194 Update projects 2025-12-23 22:52:37 +00:00
Chris
78b8bf177c Merge branch 'main' of labs.scarif.space:chris/nvim 2025-12-18 09:18:41 +00:00
Chris
4f8e722f13 Snippets 2025-12-18 09:18:00 +00:00
1f58b9f136 More snippets 2025-12-17 16:52:51 +00:00
Chris
4d3aada204 Remove textobjects 2025-12-10 14:26:27 +00:00
10 changed files with 521 additions and 484 deletions

View File

@@ -35,114 +35,176 @@ vim.api.nvim_create_autocmd('SwapExists', {
}) })
-- vim.api.nvim_create_autocmd('TextChanged', { -- vim.api.nvim_create_autocmd('TextChanged', {
-- group = autosave_group, -- group = autosave_group,
-- pattern = '*', -- pattern = '*',
-- command = 'silent! wa', -- Save all files when text is changed -- command = 'silent! wa', -- Save all files when text is changed
-- }) -- })
vim.api.nvim_create_autocmd('User', { vim.api.nvim_create_autocmd('User', {
pattern = 'OilActionsPost', pattern = 'OilActionsPost',
callback = function(event) callback = function(event)
if event.data.actions.type == 'move' then if event.data.actions.type == 'move' then
Snacks.rename.on_rename_file(event.data.actions.src_url, event.data.actions.dest_url) Snacks.rename.on_rename_file(event.data.actions.src_url, event.data.actions.dest_url)
end end
end, end,
}) })
local fidget_group = vim.api.nvim_create_augroup('CodeCompanionFidgetHooks', { clear = true }) local fidget_group = vim.api.nvim_create_augroup('CodeCompanionFidgetHooks', { clear = true })
vim.api.nvim_create_autocmd({ 'User' }, { vim.api.nvim_create_autocmd({ 'User' }, {
pattern = 'CodeCompanionRequestStarted', pattern = 'CodeCompanionRequestStarted',
group = fidget_group, group = fidget_group,
callback = function(event) callback = function(event)
local FidgetHelper = require 'utils.fidget_helper' local FidgetHelper = require 'utils.fidget_helper'
-- Pass event instead of request if the callback receives the full event object -- Pass event instead of request if the callback receives the full event object
local handle = FidgetHelper:create_progress_handle(event) local handle = FidgetHelper:create_progress_handle(event)
FidgetHelper:store_progress_handle(event.data.id, handle) FidgetHelper:store_progress_handle(event.data.id, handle)
end, end,
}) })
vim.api.nvim_create_autocmd({ 'User' }, { vim.api.nvim_create_autocmd({ 'User' }, {
pattern = 'CodeCompanionRequestFinished', pattern = 'CodeCompanionRequestFinished',
group = fidget_group, group = fidget_group,
callback = function(event) callback = function(event)
local FidgetHelper = require 'utils.fidget_helper' local FidgetHelper = require 'utils.fidget_helper'
local handle = FidgetHelper:pop_progress_handle(event.data.id) local handle = FidgetHelper:pop_progress_handle(event.data.id)
if handle then if handle then
FidgetHelper:report_exit_status(handle, event) FidgetHelper:report_exit_status(handle, event)
handle:finish() handle:finish()
end end
end, end,
}) })
-- vim.api.nvim_create_autocmd('BufEnter', { -- vim.api.nvim_create_autocmd('BufEnter', {
-- callback = function(event) -- callback = function(event)
-- local windows = vim.api.nvim_list_wins() -- local windows = vim.api.nvim_list_wins()
-- --
-- for _, window in ipairs(windows) do -- for _, window in ipairs(windows) do
-- local bufnr = vim.api.nvim_win_get_buf(window) -- local bufnr = vim.api.nvim_win_get_buf(window)
-- local ft = vim.api.nvim_get_option_value('filetype', { buf = bufnr }) -- local ft = vim.api.nvim_get_option_value('filetype', { buf = bufnr })
-- if vim.api.nvim_get_option_value('buflisted', { buf = bufnr }) -- if vim.api.nvim_get_option_value('buflisted', { buf = bufnr })
-- or ft == 'oil' -- or ft == 'oil'
-- or ft == 'snacks_dashboard' then -- or ft == 'snacks_dashboard' then
-- return -- return
-- end -- end
-- end -- end
-- vim.cmd 'qa' -- vim.cmd 'qa'
-- end, -- end,
-- }) -- })
local modes_group = vim.api.nvim_create_augroup('modes', { clear = true }) local modes_group = vim.api.nvim_create_augroup('modes', { clear = true })
vim.api.nvim_create_autocmd('FocusLost', { vim.api.nvim_create_autocmd('FocusLost', {
group = modes_group, group = modes_group,
pattern = '*', pattern = '*',
command = 'call feedkeys("\\<Esc>")', command = 'call feedkeys("\\<Esc>")',
}) })
vim.api.nvim_create_autocmd('BufNewFile', { vim.api.nvim_create_autocmd('BufNewFile', {
group = modes_group, group = modes_group,
pattern = '*', pattern = '*',
command = 'call feedkeys("i")', command = 'call feedkeys("i")',
}) })
-- Reload LuaSnip snippets when saving files in the snippets directory -- Reload LuaSnip snippets when saving files in the snippets directory
local snippets_dir = vim.fn.stdpath 'config' .. '/lua/snippets' local snippets_dir = vim.fn.stdpath 'config' .. '/lua/snippets'
vim.api.nvim_create_autocmd('BufWritePost', { vim.api.nvim_create_autocmd('BufWritePost', {
pattern = snippets_dir .. '/*.json', -- Adjust the path to match your snippets directory pattern = snippets_dir .. '/*.json', -- Adjust the path to match your snippets directory
desc = 'Reload LuaSnip snippets on save', desc = 'Reload LuaSnip snippets on save',
callback = function() callback = function()
require('luasnip.loaders.from_vscode').lazy_load { paths = { snippets_dir } } require('luasnip.loaders.from_vscode').lazy_load { paths = { snippets_dir } }
vim.notify('Snippets reloaded!', vim.log.levels.INFO) vim.notify('Snippets reloaded!', vim.log.levels.INFO)
end, end,
}) })
vim.api.nvim_create_autocmd('FileType', { local configs = {
pattern = { {
'bash', path = os.getenv("HOME") .. "/.config/nixos",
'c', worktree = nil,
'diff', git_dir = nil,
'html', track_untracked = false,
'lua', force_add = false
'luadoc', },
'markdown', {
'markdown_inline', path = os.getenv("HOME") .. "/.config/nvim",
'query', worktree = nil,
'vim', git_dir = nil,
'vimdoc', track_untracked = false,
'php', force_add = false
'javascript', },
'typescript', {
'json', path = os.getenv("HOME"),
}, worktree = os.getenv("HOME"),
callback = function() git_dir = os.getenv("HOME") .. "/.config/dotfiles/.git",
-- syntax highlighting, provided by Neovim track_untracked = true,
vim.treesitter.start() force_add = true, -- Handles ignored files in dotfiles
-- folds, provided by Neovim include_dirs = { ".config", ".local/bin", ".local/share" }
vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()' }
vim.wo.foldmethod = 'expr' }
-- indentation, provided by nvim-treesitter
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
end,
})
require('helpers').edit_cf('a', '/lua/autocmd.lua') 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')

View File

@@ -30,13 +30,13 @@ vim.keymap.set('n', '<Leader>c', function()
vim.treesitter.inspect_tree() vim.treesitter.inspect_tree()
end, { desc = 'Treesitter' }) end, { desc = 'Treesitter' })
-- vim.keymap.set('n', '<C-S-D>', function() vim.keymap.set('n', '<C-S-D>', function()
-- local node = vim.treesitter.get_node {} local node = vim.treesitter.get_node {}
-- local range = { vim.treesitter.get_node_range(node) } local range = { vim.treesitter.get_node_range(node) }
-- vim.api.nvim_win_set_cursor(0, { range[3] + 1, range[4] - 1 }) vim.api.nvim_win_set_cursor(0, { range[3] + 1, range[4] - 1 })
-- vim.fn.setpos("'x", { 0, range[1] + 1, range[2] + 1, 0 }) vim.fn.setpos("'x", { 0, range[1] + 1, range[2] + 1, 0 })
-- vim.cmd.normal 'v`x' vim.cmd.normal 'v`x'
-- end, { desc = 'Select surrounding treesitter node' }) end, { desc = 'Select surrounding treesitter node' })
vim.keymap.set('v', '<C-S-D>', function() vim.keymap.set('v', '<C-S-D>', function()
local start = vim.api.nvim_win_get_cursor(0) local start = vim.api.nvim_win_get_cursor(0)
@@ -257,6 +257,8 @@ 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>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', '<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', '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() local function open_test()
require('neotest').summary.open() require('neotest').summary.open()

View File

@@ -4,19 +4,24 @@ return {
-- change the command in the config to whatever the name of that colorscheme is. -- 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`. -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
'folke/tokyonight.nvim', 'AlphaTechnolog/pywal.nvim',
dependencies = {
'folke/tokyonight.nvim',
},
priority = 1000, -- Make sure to load this before all the other start plugins. priority = 1000, -- Make sure to load this before all the other start plugins.
config = function() config = function()
---@diagnostic disable-next-line: missing-fields ---@diagnostic disable-next-line: missing-fields
require('tokyonight').setup { 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'.
vim.cmd.colorscheme 'tokyonight-night' vim.cmd.colorscheme 'tokyonight-night'
-- 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
require('pywal').setup()
end
end, end,
} }

3
lua/plugins/pywal.lua Normal file
View File

@@ -0,0 +1,3 @@
return {
'AlphaTechnolog/pywal.nvim',
}

View File

@@ -1,153 +0,0 @@
-- Highlight, edit, and navigate code
return {
-- 'nvim-treesitter/nvim-treesitter-textobjects',
-- lazy = true,
-- branch = 'main',
-- dependencies = {
-- 'nvim-treesitter/nvim-treesitter',
-- },
-- config = function()
-- -- configuration
-- require('nvim-treesitter-textobjects').setup {
-- select = {
-- lookahead = true,
-- selection_modes = {
-- ['@parameter.outer'] = 'v', -- charwise
-- ['@function.outer'] = 'V', -- linewise
-- ['@class.outer'] = 'V', -- blockwise
-- },
-- include_surrounding_whitespace = false,
-- },
-- move = {
-- set_jumps = true,
-- },
-- }
-- for keys, query in
-- {
-- -- 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',
-- ['an'] = '@local.scope',
-- }
-- do
-- vim.keymap.set({ 'n', 'x', 'o' }, keys, function()
-- require('nvim-treesitter-textobjects.select').select_textobject(query, 'textobjects')
-- end)
-- end
-- for keys, query in
-- {
-- -- or you use the queries from supported languages with textobjects.scm
-- [']'] = '@function.outer',
-- ['o'] = { '@loop.inner', '@loop.outer' },
-- ['n'] = '@local.scope',
-- ['y'] = '@conditional.outer',
-- ['e'] = '@statement.outer',
-- ['/'] = '@comment.outer',
-- }
-- do
-- vim.keymap.set({ 'n', 'x', 'o' }, ']' .. keys, function()
-- require('nvim-treesitter-textobjects.move').goto_next_start(query, 'textobjects')
-- end)
-- vim.keymap.set({ 'n', 'x', 'o' }, '[' .. keys, function()
-- require('nvim-treesitter-textobjects.move').goto_previous_start(query, 'textobjects')
-- end)
-- end
-- -- require('nvim-treesitter.configs').setup {
-- -- incremental_selection = {
-- -- enable = true,
-- -- keymaps = {
-- -- -- mappings for incremental selection (visual mappings)
-- -- init_selection = '<C-S-D>', -- maps in normal mode to init the node/scope selection
-- -- node_incremental = '<C-S-D>', -- increment to the upper named parent
-- -- scope_incremental = '<C-S-U>', -- increment to the upper scope (as defined in locals.scm)
-- -- node_decremental = '<C-S-S>', -- 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,
-- opts = {},
-- -- There are additional nvim-treesitter modules that you can use to interact
-- -- with nvim-treesitter. You should go explore a few and see what interests you:
-- --
-- -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
-- -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
-- -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
}

View File

@@ -2,11 +2,10 @@
return { return {
'nvim-treesitter/nvim-treesitter', 'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate', build = ':TSUpdate',
branch = 'main', -- main = 'nvim-treesitter.configs', -- Sets main module to use for opts
-- [[ Configure Treesitter ]] See `:help nvim-treesitter` -- [[ Configure Treesitter ]] See `:help nvim-treesitter`
config = function() opts = {
require('nvim-treesitter').setup {} ensure_installed = {
require('nvim-treesitter').install {
'bash', 'bash',
'c', 'c',
'diff', 'diff',
@@ -18,13 +17,18 @@ return {
'query', 'query',
'vim', 'vim',
'vimdoc', 'vimdoc',
'php', },
'javascript', -- Autoinstall languages that are not installed
'typescript', auto_install = true,
'json', highlight = {
} enable = true,
end, -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules.
opts = {}, -- If you are experiencing weird indenting issues, add the language to
-- the list of additional_vim_regex_highlighting and disabled languages for indent.
additional_vim_regex_highlighting = { 'ruby' },
},
indent = { enable = true, disable = { 'ruby' } },
},
-- There are additional nvim-treesitter modules that you can use to interact -- There are additional nvim-treesitter modules that you can use to interact
-- with nvim-treesitter. You should go explore a few and see what interests you: -- with nvim-treesitter. You should go explore a few and see what interests you:
-- --

View File

@@ -92,39 +92,39 @@ end
local function laravel_bookmarks_with_dir(dir) local function laravel_bookmarks_with_dir(dir)
create_bookmark_maps { create_bookmark_maps {
['e'] = dir .. '/.env', ['e'] = dir .. '.env',
['l'] = dir .. '/storage/logs/laravel.log', ['l'] = dir .. 'storage/logs/laravel.log',
['w'] = dir .. '/routes/web.php', ['w'] = dir .. 'routes/web.php',
['a'] = dir .. '/routes/api.php', ['a'] = dir .. 'routes/api.php',
['m'] = dir .. '/database/migrations', ['m'] = dir .. 'database/migrations',
['dc'] = dir .. '/app/Core/', ['dc'] = dir .. 'app/Core/',
['dd'] = dir .. '/app/Data/', ['dd'] = dir .. 'app/Data/',
['dE'] = dir .. '/app/Enums/', ['dE'] = dir .. 'app/Enums/',
['de'] = dir .. '/app/Events/', ['de'] = dir .. 'app/Events/',
['dh'] = dir .. '/app/Http/', ['dh'] = dir .. 'app/Http/',
['dj'] = dir .. '/app/Jobs/', ['dj'] = dir .. 'app/Jobs/',
['dl'] = dir .. '/app/Listeners/', ['dl'] = dir .. 'app/Listeners/',
['dM'] = dir .. '/app/Mail/', ['dM'] = dir .. 'app/Mail/',
['dm'] = dir .. '/app/Models/', ['dm'] = dir .. 'app/Models/',
['dn'] = dir .. '/app/Notifications/', ['dn'] = dir .. 'app/Notifications/',
['do'] = dir .. '/app/Observers/', ['do'] = dir .. 'app/Observers/',
['dp'] = dir .. '/app/Providers/', ['dp'] = dir .. 'app/Providers/',
['pa'] = dir .. '/app/Providers/AppServiceProvider.php', ['pa'] = dir .. 'app/Providers/AppServiceProvider.php',
['pe'] = dir .. '/app/Providers/EventServiceProvider.php', ['pe'] = dir .. 'app/Providers/EventServiceProvider.php',
['cA'] = dir .. '/config/app.php', ['cA'] = dir .. 'config/app.php',
['ca'] = dir .. '/config/auth.php', ['ca'] = dir .. 'config/auth.php',
['cb'] = dir .. '/config/broadcasting.php', ['cb'] = dir .. 'config/broadcasting.php',
['cd'] = dir .. '/config/database.php', ['cd'] = dir .. 'config/database.php',
['cf'] = dir .. '/config/filesystems.php', ['cf'] = dir .. 'config/filesystems.php',
['ch'] = dir .. '/config/filesystems.php', ['ch'] = dir .. 'config/filesystems.php',
['cl'] = dir .. '/config/logging.php', ['cl'] = dir .. 'config/logging.php',
['cm'] = dir .. '/config/mail.php', ['cm'] = dir .. 'config/mail.php',
['cq'] = dir .. '/config/queue.php', ['cq'] = dir .. 'config/queue.php',
['cS'] = dir .. '/config/services.php', ['cS'] = dir .. 'config/services.php',
['cs'] = dir .. '/config/session.php', ['cs'] = dir .. 'config/session.php',
} }
end end
@@ -216,8 +216,8 @@ local PROJECTS = {
end, { desc = 'Open database manager' }) end, { desc = 'Open database manager' })
map('s ', '!cd server && ', { desc = 'Run command in server directory' }, 'c') map('s ', '!cd server && ', { desc = 'Run command in server directory' }, 'c')
map('c ', '!cd client && ', { desc = 'Run command in client directory' }, 'c') map('c ', '!cd client && ', { desc = 'Run command in client directory' }, 'c')
laravel_keymaps 'server' laravel_keymaps 'server/'
laravel_makes 'server' laravel_makes 'server/'
map('yrn ', '!cd client && yarn ', { desc = 'Run yarn script' }, 'c') map('yrn ', '!cd client && yarn ', { desc = 'Run yarn script' }, 'c')
map('<Leader>pt', ':!cd server && php artisan typescript:transform --format<CR>', { desc = 'Compile typescript' }) map('<Leader>pt', ':!cd server && php artisan typescript:transform --format<CR>', { desc = 'Compile typescript' })
require('conform').formatters.pint = { require('conform').formatters.pint = {
@@ -257,10 +257,12 @@ function M.apply(cwd)
end end
last_applied = name last_applied = name
local setup = PROJECTS[name] or PROJECTS.default local setup = PROJECTS[name]
if type(setup) == 'function' then if type(setup) == 'function' then
setup(dir) setup(dir)
vim.notify(('Project config loaded: %s'):format(name), vim.log.levels.INFO, { title = 'projects.lua' }) vim.notify(('Project config loaded: %s'):format(name), vim.log.levels.INFO, { title = 'projects.lua' })
else
PROJECTS.default(dir)
end end
end end

View File

@@ -1,45 +1,128 @@
local ls = require 'luasnip' local ls = require 'luasnip'
local s = ls.snippet 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 t = ls.text_node
local c = ls.choice_node
local i = ls.insert_node local i = ls.insert_node
local f = ls.function_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 { 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', { -- bs(atr('t ', 'this'), fmta('this.#~', { i(0) })),
t { '<template>', '' },
t { '', '</template>', '', '', '<script setup>', '' }, s(etr('return ', 'Add semicolon after return'), fmta('return #~;', { i(0) })),
i(0), s(etr('rt ', 'return alias'), fmta('return #~;', { i(0) })),
t { '', '</script>', '', '', '<style scoped>', '', '.o-share-page {', '}', '', '</style>' },
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', { s(
t 'function ', etr('fn ', 'function block'),
i(1), fmta(
t '(', [[
i(2), function #~(#~) {
t ') {', #~
t { '', ' ' }, }
i(0), ]],
t { '', '}' }, { 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', { bs(atr('afn ', 'async function block'), {
t 'async function ', c(1, {
i(1), sn(
t '(', nil,
i(2), fmta(
t ') {', [[
t { '', ' ' }, async (#~) => {
i(0), #~
t { '', '}' }, }
}), ]],
{ i(1), i(2) }
s('()', { )
t '() => {', ),
t { '', ' ' }, sn(
i(0), nil,
t { '', '}' }, fmta(
[[
async function (#~) {
#~
}
]],
{ i(1), i(2) }
)
),
}),
}), }),
} }

View File

@@ -16,6 +16,7 @@ local fmta = extend_decorator.apply(fmt, { delimiters = '#~' })
local utils = require 'snippets.snip_utils' local utils = require 'snippets.snip_utils'
local tr = utils.tr local tr = utils.tr
local etr = utils.etr local etr = utils.etr
local Etr = utils.Etr
local atr = utils.atr local atr = utils.atr
local ctr = utils.ctr local ctr = utils.ctr
local bs = utils.bs local bs = utils.bs
@@ -69,10 +70,10 @@ return {
--------------- ---------------
-- DEBUGGING -- -- DEBUGGING --
--------------- ---------------
s(etr('du ', 'Dump a variable to the dump server'), fmta('dump(#~);', { i(0) })), s(etr('du ', 'Dump a variable to the dump server', { priority = 1001 }), fmta('dump(#~);', { i(0) })),
bs(atr('du ', 'Dump a variable to the dump server'), fmta('dump(#~)', { i(0) })), bs(etr('du ', 'Dump a variable to the dump server'), fmta('dump(#~)', { i(0) })),
s(etr('r ', 'ray'), fmta('ray(#~);', { i(0) })), s(etr('r ', 'ray', { priority = 1001 }), fmta('ray(#~);', { i(0) })),
bs(atr('r ', 'ray'), 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('dt ', 'Dump PHPStan type definition'), fmta('\\PhpStan\\dumpType(#~);', { i(0) })),
s( s(
etr('ql ', 'Log all queries'), etr('ql ', 'Log all queries'),
@@ -107,6 +108,7 @@ return {
}), }),
s(etr('@v', '@var docblock'), fmta('/** @var #~ $#~ */', { i(1), i(0) })), s(etr('@v', '@var docblock'), fmta('/** @var #~ $#~ */', { i(1), i(0) })),
s(ctr('@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('* @pr', 'Class property docblock'), fmta('* @property #~ $#~', { i(1), i(0) })),
s(ctr('* @pb', 'Class boolean property docblock'), fmta('* @property bool $#~', { 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) })), 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(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) })), s(etr('rt ', 'return alias'), fmta('return #~;', { i(0) })),
bs(etr('fn ', 'Shorthand function block'), { bs(atr('fn ', 'Shorthand function block'), {
c(1, { c(1, {
sn(nil, fmta('fn (#~) => #~', { i(1), i(2) })), sn(nil, fmta('fn (#~) => #~', { i(1), i(2) })),
sn( sn(
@@ -186,7 +188,7 @@ return {
), ),
}), }),
}), }),
bs(etr('fun ', 'Shorthand function block'), { bs(atr('fun ', 'Shorthand function block'), {
c(1, { c(1, {
sn( sn(
nil, nil,
@@ -212,36 +214,36 @@ return {
), ),
}), }),
}), }),
s( -- s(
etr('con', 'Constructor function block'), -- etr('con', 'Constructor function block'),
c(1, { -- c(1, {
sn( -- sn(
nil, -- nil,
fmta( -- fmta(
[[ -- [[
public function __construct(#~) -- public function __construct(#~)
{ -- {
#~ -- #~
} -- }
]], -- ]],
{ i(1), i(2) } -- { i(1), i(2) }
) -- )
), -- ),
sn( -- sn(
nil, -- nil,
fmta( -- fmta(
[[ -- [[
public function __construct( -- public function __construct(
#~ -- #~
) { -- ) {
#~ -- #~
} -- }
]], -- ]],
{ i(1), i(2) } -- { i(1), i(2) }
) -- )
), -- ),
}) -- })
), -- ),
bs(atr('function', 'Shorthand function block'), fmta('fun', {})), bs(atr('function', 'Shorthand function block'), fmta('fun', {})),
bs(atr('s%$', 'string type parameter'), fmta('string $#~', { i(0, 'var') })), bs(atr('s%$', 'string type parameter'), fmta('string $#~', { i(0, 'var') })),
bs(atr('i%$', 'int type parameter'), fmta('int $#~', { 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'), etr('test', 'Create a test function'),
fmta( fmta(
[[ [[
test(#~ function () { test('#~', function () {
#~ #~
}) });
]],
{ i(1), i(0) }
)
),
s(
etr('it ', 'Create a test function'),
fmta(
[[
it('#~', function () {
#~
});
]], ]],
{ i(1), i(0) } { i(1), i(0) }
) )
@@ -371,7 +384,7 @@ return {
------------- -------------
s( s(
etr('bt', 'belongsTo Laravel relationship method'), etr('bt', 'belongsTo Laravel relationship method'),
c(0, { c(1, {
sn( sn(
nil, nil,
fmta( fmta(
@@ -384,7 +397,7 @@ return {
return $this->belongsTo(#~::class); return $this->belongsTo(#~::class);
} }
]], ]],
{ rep(1), i(0), i(1) } { rep(1), i(2), i(1) }
) )
), ),
sn( sn(
@@ -399,14 +412,14 @@ return {
return $this->belongsTo(#~::class, #~); return $this->belongsTo(#~::class, #~);
} }
]], ]],
{ rep(1), i(2), i(1), i(0) } { rep(1), i(2), i(1), i(3) }
) )
), ),
}) })
), ),
s( s(
etr('hm', 'hasMany Laravel relationship method'), etr('hm', 'hasMany Laravel relationship method'),
c(0, { c(1, {
sn( sn(
nil, nil,
fmta( fmta(
@@ -419,7 +432,7 @@ return {
return $this->hasOne(#~::class); return $this->hasOne(#~::class);
} }
]], ]],
{ rep(1), i(0), i(1) } { rep(1), i(2), i(1) }
) )
), ),
sn( sn(
@@ -434,14 +447,14 @@ return {
return $this->hasOne(#~::class, #~); return $this->hasOne(#~::class, #~);
} }
]], ]],
{ rep(1), i(2), i(1), i(0) } { rep(1), i(2), i(1), i(3) }
) )
), ),
}) })
), ),
s( s(
etr('ho', 'hasOne Laravel relationship method'), etr('ho', 'hasOne Laravel relationship method'),
c(0, { c(1, {
sn( sn(
nil, nil,
fmta( fmta(
@@ -454,7 +467,7 @@ return {
return $this->hasOne(#~::class); return $this->hasOne(#~::class);
} }
]], ]],
{ rep(1), i(0), i(1) } { rep(1), i(2), i(1) }
) )
), ),
sn( sn(
@@ -469,14 +482,14 @@ return {
return $this->hasOne(#~::class, #~); return $this->hasOne(#~::class, #~);
} }
]], ]],
{ rep(1), i(2), i(1), i(0) } { rep(1), i(2), i(1), i(3) }
) )
), ),
}) })
), ),
s( s(
etr('bm', 'belongsToMany Laravel relationship method'), etr('bm', 'belongsToMany Laravel relationship method'),
c(0, { c(1, {
sn( sn(
nil, nil,
fmta( fmta(
@@ -489,7 +502,7 @@ return {
return $this->belongsToMany(#~::class, #~); return $this->belongsToMany(#~::class, #~);
} }
]], ]],
{ rep(1), i(2), i(1), i(0) } { rep(1), i(2), i(1), i(3) }
) )
), ),
sn( sn(
@@ -504,97 +517,97 @@ return {
return $this->belongsToMany(#~::class, #~, #~); return $this->belongsToMany(#~::class, #~, #~);
} }
]], ]],
{ rep(1), i(2), i(1), i(3), 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('->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) }
) )
), ),
}) })
), ),
-- 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) }
-- )
-- ),
-- })
-- ),
} }

View File

@@ -11,6 +11,7 @@ local d = ls.dynamic_node
local fmt = require('luasnip.extras.fmt').fmt local fmt = require('luasnip.extras.fmt').fmt
local rep = require('luasnip.extras').rep local rep = require('luasnip.extras').rep
local line_begin = require('luasnip.extras.conditions').line_begin 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 extend_decorator = require 'luasnip.util.extend_decorator'
local fmta = extend_decorator.apply(fmt, { delimiters = '#~' }) local fmta = extend_decorator.apply(fmt, { delimiters = '#~' })
@@ -109,6 +110,21 @@ utils.atr = function(trigger, description, options)
) )
end 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 --- Create a snippet that will expand anywhere but in the middle of a word
---@param trigger any ---@param trigger any
---@param nodes any ---@param nodes any