Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
603e7a2b7a | ||
|
|
ae26197a78 | ||
|
|
29f4436aa8 | ||
|
|
f9f6aea868 | ||
|
|
ffc4520ba9 | ||
|
|
bf0b652992 | ||
|
|
6e5fc4d1b4 | ||
|
|
64723103b6 | ||
|
|
a2d915bbd1 |
@@ -1,114 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "Neovim Configuration",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"system_prompt": "You are an expert Neovim configuration assistant. Help the user understand and modify their Neovim setup. Focus on clear explanations and suggest improvements when appropriate.",
|
|
||||||
"vars": {
|
|
||||||
"lua_dir": "lua"
|
|
||||||
},
|
|
||||||
"groups": [
|
|
||||||
{
|
|
||||||
"name": "Core Configuration",
|
|
||||||
"system_prompt": "These files define the core Neovim behavior including options, keymaps, and autocommands. When suggesting changes, ensure they align with Neovim best practices.",
|
|
||||||
"data": [
|
|
||||||
"core_opt",
|
|
||||||
"core_keymap",
|
|
||||||
"core_autocmd",
|
|
||||||
"core_helpers"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Plugin Management",
|
|
||||||
"system_prompt": "This file contains the plugin manager setup. Help the user understand plugin dependencies and installation patterns.",
|
|
||||||
"data": [
|
|
||||||
"lazy_init"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "LSP Configuration",
|
|
||||||
"system_prompt": "These files define the Language Server Protocol setup. Help the user configure language servers, diagnostics, and code actions.",
|
|
||||||
"data": [
|
|
||||||
"lsp_config"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Frequently Used Plugins",
|
|
||||||
"system_prompt": "These are plugins the user frequently configures. Provide detailed explanations about their options and how they interact with the rest of the configuration.",
|
|
||||||
"data": [
|
|
||||||
"plugin_codecompanion",
|
|
||||||
"plugin_edgy",
|
|
||||||
"plugin_snacks",
|
|
||||||
"plugin_mini",
|
|
||||||
"plugin_telescope"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "UI and Theme",
|
|
||||||
"system_prompt": "These files define the visual appearance of Neovim. Help the user understand how to customize colors and UI elements.",
|
|
||||||
"data": [
|
|
||||||
"plugin_colorscheme"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"data": {
|
|
||||||
"core_opt": {
|
|
||||||
"type": "file",
|
|
||||||
"path": "${lua_dir}/opt.lua",
|
|
||||||
"description": "Neovim options configuration"
|
|
||||||
},
|
|
||||||
"core_keymap": {
|
|
||||||
"type": "file",
|
|
||||||
"path": "${lua_dir}/keymap.lua",
|
|
||||||
"description": "Key mappings configuration"
|
|
||||||
},
|
|
||||||
"core_autocmd": {
|
|
||||||
"type": "file",
|
|
||||||
"path": "${lua_dir}/autocmd.lua",
|
|
||||||
"description": "Automatic commands configuration"
|
|
||||||
},
|
|
||||||
"core_helpers": {
|
|
||||||
"type": "file",
|
|
||||||
"path": "${lua_dir}/helpers.lua",
|
|
||||||
"description": "Helper functions for Neovim configuration"
|
|
||||||
},
|
|
||||||
"lazy_init": {
|
|
||||||
"type": "file",
|
|
||||||
"path": "${lua_dir}/lazy_init.lua",
|
|
||||||
"description": "Lazy plugin manager initialization"
|
|
||||||
},
|
|
||||||
"lsp_config": {
|
|
||||||
"type": "file",
|
|
||||||
"path": "${lua_dir}/plugins/lsp.lua",
|
|
||||||
"description": "LSP plugins and configuration"
|
|
||||||
},
|
|
||||||
"plugin_codecompanion": {
|
|
||||||
"type": "file",
|
|
||||||
"path": "${lua_dir}/plugins/codecompanion.lua",
|
|
||||||
"description": "CodeCompanion plugin configuration"
|
|
||||||
},
|
|
||||||
"plugin_edgy": {
|
|
||||||
"type": "file",
|
|
||||||
"path": "${lua_dir}/plugins/edgy.lua",
|
|
||||||
"description": "Edgy plugin configuration"
|
|
||||||
},
|
|
||||||
"plugin_snacks": {
|
|
||||||
"type": "file",
|
|
||||||
"path": "${lua_dir}/plugins/snacks.lua",
|
|
||||||
"description": "Snacks plugin configuration"
|
|
||||||
},
|
|
||||||
"plugin_mini": {
|
|
||||||
"type": "file",
|
|
||||||
"path": "${lua_dir}/plugins/mini.lua",
|
|
||||||
"description": "Mini plugins configuration"
|
|
||||||
},
|
|
||||||
"plugin_telescope": {
|
|
||||||
"type": "file",
|
|
||||||
"path": "${lua_dir}/plugins/telescope.lua",
|
|
||||||
"description": "Telescope fuzzy finder configuration"
|
|
||||||
},
|
|
||||||
"plugin_colorscheme": {
|
|
||||||
"type": "file",
|
|
||||||
"path": "${lua_dir}/plugins/color.lua",
|
|
||||||
"description": "Color scheme and UI appearance configuration"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -63,3 +63,4 @@ TODO: Neovim configurations I want to add:
|
|||||||
-- " - To operate on multiple lines use <c-v> to select the lines, <c-i> to go to
|
-- " - To operate on multiple lines use <c-v> to select the lines, <c-i> to go to
|
||||||
-- " insert mode, perform edit, press <esc>.
|
-- " insert mode, perform edit, press <esc>.
|
||||||
-- " - Use the command :r to paste the output of a command to the buffer.
|
-- " - Use the command :r to paste the output of a command to the buffer.
|
||||||
|
|
||||||
|
|||||||
+75
-62
@@ -4,35 +4,35 @@
|
|||||||
-- Highlight when yanking (copying) text
|
-- Highlight when yanking (copying) text
|
||||||
-- Try it with `yap` in normal mode
|
-- Try it with `yap` in normal mode
|
||||||
-- See `:help vim.highlight.on_yank()`
|
-- See `:help vim.highlight.on_yank()`
|
||||||
vim.api.nvim_create_autocmd('TextYankPost', {
|
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||||
desc = 'Highlight when yanking (copying) text',
|
desc = "Highlight when yanking (copying) text",
|
||||||
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
|
group = vim.api.nvim_create_augroup("kickstart-highlight-yank", { clear = true }),
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.highlight.on_yank()
|
vim.highlight.on_yank()
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
local autosave_group = vim.api.nvim_create_augroup('autosaving', { clear = true })
|
local autosave_group = vim.api.nvim_create_augroup("autosaving", { clear = true })
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd('FocusLost', {
|
vim.api.nvim_create_autocmd("FocusLost", {
|
||||||
group = autosave_group,
|
group = autosave_group,
|
||||||
pattern = '*',
|
pattern = "*",
|
||||||
command = 'silent! wa', -- Save all files when moving away from the window
|
command = "silent! wa", -- Save all files when moving away from the window
|
||||||
nested = true, -- Allow other autocommands to run after this one
|
nested = true, -- Allow other autocommands to run after this one
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd('BufLeave', {
|
vim.api.nvim_create_autocmd("BufLeave", {
|
||||||
group = autosave_group,
|
group = autosave_group,
|
||||||
pattern = '*',
|
pattern = "*",
|
||||||
command = 'silent! wa', -- Save all files when switching buffers
|
command = "silent! wa", -- Save all files when switching buffers
|
||||||
nested = true, -- Allow other autocommands to run after this one
|
nested = true, -- Allow other autocommands to run after this one
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd('SwapExists', {
|
vim.api.nvim_create_autocmd("SwapExists", {
|
||||||
desc = 'Always choose to delete the swap file, files are saved automatically',
|
desc = "Always choose to delete the swap file, files are saved automatically",
|
||||||
group = vim.api.nvim_create_augroup('NoSwaps', { clear = true }),
|
group = vim.api.nvim_create_augroup("NoSwaps", { clear = true }),
|
||||||
callback = function(args)
|
callback = function(args)
|
||||||
vim.cmd "let v:swapchoice = 'd'"
|
vim.cmd("let v:swapchoice = 'd'")
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -42,33 +42,33 @@ vim.api.nvim_create_autocmd('SwapExists', {
|
|||||||
-- 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)
|
||||||
@@ -94,86 +94,99 @@ vim.api.nvim_create_autocmd({ 'User' }, {
|
|||||||
-- end,
|
-- end,
|
||||||
-- })
|
-- })
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd({ 'BufWritePre' }, {
|
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
|
||||||
pattern = { '*.lua' },
|
pattern = { "*.lua" },
|
||||||
callback = function(args)
|
callback = function(args)
|
||||||
require('helpers').format_buffer('stylua', args.buf)
|
require("helpers").format_buffer("stylua", args.buf)
|
||||||
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,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Run shortcuts script when saving shortcut files
|
||||||
|
vim.api.nvim_create_autocmd("BufWritePost", {
|
||||||
|
pattern = {
|
||||||
|
os.getenv("XDG_CONFIG_HOME") .. "/shell/bm-files",
|
||||||
|
os.getenv("XDG_CONFIG_HOME") .. "/shell/bm-dirs",
|
||||||
|
},
|
||||||
|
desc = "Run shortcuts script",
|
||||||
|
callback = function()
|
||||||
|
os.execute("station-shortcuts")
|
||||||
|
vim.notify("Shortcuts updated!", vim.log.levels.INFO)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
local configs = {
|
local configs = {
|
||||||
{
|
{
|
||||||
path = os.getenv 'HOME' .. '/.config/nixos',
|
path = os.getenv("HOME") .. "/.config/nixos",
|
||||||
worktree = nil,
|
worktree = nil,
|
||||||
git_dir = nil,
|
git_dir = nil,
|
||||||
track_untracked = false,
|
track_untracked = false,
|
||||||
force_add = false,
|
force_add = false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path = os.getenv 'HOME' .. '/.config/nvim',
|
path = os.getenv("HOME") .. "/.config/nvim",
|
||||||
worktree = nil,
|
worktree = nil,
|
||||||
git_dir = nil,
|
git_dir = nil,
|
||||||
track_untracked = false,
|
track_untracked = false,
|
||||||
force_add = false,
|
force_add = false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path = os.getenv 'HOME',
|
path = os.getenv("HOME"),
|
||||||
worktree = os.getenv 'HOME',
|
worktree = os.getenv("HOME"),
|
||||||
git_dir = os.getenv 'HOME' .. '/.config/dotfiles/.git',
|
git_dir = os.getenv("HOME") .. "/.config/dotfiles/.git",
|
||||||
track_untracked = true,
|
track_untracked = true,
|
||||||
force_add = true, -- Handles ignored files in dotfiles
|
force_add = true, -- Handles ignored files in dotfiles
|
||||||
include_dirs = { '.config', '.local/bin', '.local/share' },
|
include_dirs = { ".config", ".local/bin", ".local/share" },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local function get_git_status(config)
|
local function get_git_status(config)
|
||||||
local base = 'git'
|
local base = "git"
|
||||||
if config.git_dir and config.worktree then
|
if config.git_dir and config.worktree then
|
||||||
base = string.format('git --git-dir=%s --worktree=%s', config.git_dir, config.worktree)
|
base = string.format("git --git-dir=%s --worktree=%s", config.git_dir, config.worktree)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check modified and untracked (including ignored if force_add is true)
|
-- Check modified and untracked (including ignored if force_add is true)
|
||||||
local cmd = base .. ' status --porcelain'
|
local cmd = base .. " status --porcelain"
|
||||||
if config.force_add then
|
if config.force_add then
|
||||||
cmd = cmd .. ' --ignored'
|
cmd = cmd .. " --ignored"
|
||||||
end
|
end
|
||||||
|
|
||||||
local handle = io.popen(cmd)
|
local handle = io.popen(cmd)
|
||||||
local result = handle:read '*a'
|
local result = handle:read("*a")
|
||||||
handle:close()
|
handle:close()
|
||||||
|
|
||||||
local has_changes = false
|
local has_changes = false
|
||||||
for line in result:gmatch '[^\r\n]+' do
|
for line in result:gmatch("[^\r\n]+") do
|
||||||
local status = line:sub(1, 2)
|
local status = line:sub(1, 2)
|
||||||
local file = line:sub(4)
|
local file = line:sub(4)
|
||||||
|
|
||||||
if status:match '[MAR]' then
|
if status:match("[MAR]") then
|
||||||
has_changes = true
|
has_changes = true
|
||||||
elseif (status == '??' or status == '!!') and config.track_untracked then
|
elseif (status == "??" or status == "!!") and config.track_untracked then
|
||||||
if config.include_dirs then
|
if config.include_dirs then
|
||||||
for _, dir in ipairs(config.include_dirs) do
|
for _, dir in ipairs(config.include_dirs) do
|
||||||
if file:sub(1, #dir) == dir then
|
if file:sub(1, #dir) == dir then
|
||||||
@@ -189,7 +202,7 @@ local function get_git_status(config)
|
|||||||
return has_changes, base
|
return has_changes, base
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd('VimLeavePre', {
|
vim.api.nvim_create_autocmd("VimLeavePre", {
|
||||||
callback = function()
|
callback = function()
|
||||||
local cwd = vim.fn.getcwd()
|
local cwd = vim.fn.getcwd()
|
||||||
|
|
||||||
@@ -198,17 +211,17 @@ vim.api.nvim_create_autocmd('VimLeavePre', {
|
|||||||
local has_changes, git_base = get_git_status(config)
|
local has_changes, git_base = get_git_status(config)
|
||||||
|
|
||||||
if has_changes then
|
if has_changes then
|
||||||
local confirm = vim.fn.confirm('Uncommitted changes in managed path. Commit?', '&Yes\n&No', 2)
|
local confirm = vim.fn.confirm("Uncommitted changes in managed path. Commit?", "&Yes\n&No", 2)
|
||||||
if confirm == 1 then
|
if confirm == 1 then
|
||||||
local msg = vim.fn.input('Commit message: ', 'chore: update files')
|
local msg = vim.fn.input("Commit message: ", "chore: update files")
|
||||||
if msg ~= '' then
|
if msg ~= "" then
|
||||||
msg = 'Update files'
|
msg = "Update files"
|
||||||
end
|
end
|
||||||
local add_cmd = ' add -A'
|
local add_cmd = " add -A"
|
||||||
os.execute(git_base .. add_cmd)
|
os.execute(git_base .. add_cmd)
|
||||||
os.execute(git_base .. ' commit -m ' .. vim.fn.shellescape(msg))
|
os.execute(git_base .. " commit -m " .. vim.fn.shellescape(msg))
|
||||||
os.execute(git_base .. ' push')
|
os.execute(git_base .. " push")
|
||||||
print '\nChanges committed.'
|
print("\nChanges committed.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
break
|
break
|
||||||
@@ -217,5 +230,5 @@ vim.api.nvim_create_autocmd('VimLeavePre', {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
require('helpers').edit_cf('a', '/lua/autocmd.lua')
|
require("helpers").edit_cf("a", "/lua/autocmd.lua")
|
||||||
|
|
||||||
|
|||||||
+11
-1
@@ -27,6 +27,10 @@ helpers.open_term = function(opts, buf_opts)
|
|||||||
}
|
}
|
||||||
|
|
||||||
local buf = vim.api.nvim_create_buf(false, true)
|
local buf = vim.api.nvim_create_buf(false, true)
|
||||||
|
if buf_options.name then
|
||||||
|
vim.api.nvim_buf_set_name(buf, buf_options.name)
|
||||||
|
buf_options.name = nil
|
||||||
|
end
|
||||||
for k, v in pairs(buf_options) do
|
for k, v in pairs(buf_options) do
|
||||||
vim.api.nvim_set_option_value(k, v, { buf = buf })
|
vim.api.nvim_set_option_value(k, v, { buf = buf })
|
||||||
end
|
end
|
||||||
@@ -159,5 +163,11 @@ helpers.format_buffer = function(formatter, buf, cwd)
|
|||||||
vim.api.nvim_buf_set_lines(buf, 0, -1, false, vim.split(result.stdout, '\n', { plain = true }))
|
vim.api.nvim_buf_set_lines(buf, 0, -1, false, vim.split(result.stdout, '\n', { plain = true }))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
helpers.create_bookmark = function(key, bookmark)
|
||||||
|
helpers.map('<Leader>b' .. key, function()
|
||||||
|
vim.cmd('edit ' .. bookmark)
|
||||||
|
end, { desc = 'Navigate to ' .. bookmark })
|
||||||
|
end
|
||||||
|
|
||||||
return helpers
|
return helpers
|
||||||
-- nnoremap <Leader>ev :tabedit $MYVIMRC<CR>
|
|
||||||
|
|||||||
+8
-10
@@ -236,9 +236,13 @@ end, { desc = 'Open scratchpad' })
|
|||||||
vim.keymap.set({ 'n', 'v', 'c', 'i' }, '<C-S-S>', function()
|
vim.keymap.set({ 'n', 'v', 'c', 'i' }, '<C-S-S>', function()
|
||||||
require('snacks').scratch.select()
|
require('snacks').scratch.select()
|
||||||
end, { desc = 'Open scratchpad buffers' })
|
end, { desc = 'Open scratchpad buffers' })
|
||||||
vim.keymap.set({ 'n', 'v', 'c', 'i' }, '<C-T>', function()
|
vim.keymap.set({ 'n', 'v', 'c', 'i', 't' }, '<C-T>', function()
|
||||||
require('snacks').terminal.toggle()
|
require('snacks').terminal.toggle()
|
||||||
end, { desc = 'Open terminal' })
|
end, { desc = 'Toggle terminal' })
|
||||||
|
vim.keymap.set({ 'n', 'v', 'c', 'i' }, '<C-N>', '<Esc>', { desc = 'Enter normal mode' })
|
||||||
|
vim.keymap.set({ 't' }, '<C-N>', '<C-\\><C-N>', { desc = 'Enter normal mode' })
|
||||||
|
vim.keymap.set({ 't' }, '<C-U>', '<C-\\><C-N><C-U>', { desc = 'Scroll up in terminal' })
|
||||||
|
vim.keymap.set({ 't' }, '<C-D>', '<C-\\><C-N><C-D>', { desc = 'Scroll down in terminal' })
|
||||||
|
|
||||||
-- Editing helpers
|
-- Editing helpers
|
||||||
vim.keymap.set('i', '<C-O>', '<Esc>o', { desc = 'Add line below' })
|
vim.keymap.set('i', '<C-O>', '<Esc>o', { desc = 'Add line below' })
|
||||||
@@ -407,13 +411,7 @@ vim.keymap.set('n', '<Leader>tc', function()
|
|||||||
end, { desc = 'Close test panels' })
|
end, { desc = 'Close test panels' })
|
||||||
|
|
||||||
vim.keymap.set('i', '<Tab>', function()
|
vim.keymap.set('i', '<Tab>', function()
|
||||||
local copilot = require 'copilot.suggestion'
|
if ls.jumpable(1) then
|
||||||
local ls = require 'luasnip'
|
|
||||||
if copilot.is_visible() then
|
|
||||||
vim.api.nvim_echo({ { 'Accepting copilot suggestion' } }, false, {})
|
|
||||||
copilot.accept()
|
|
||||||
copilot.dismiss()
|
|
||||||
elseif ls.jumpable(1) then
|
|
||||||
vim.api.nvim_echo({ { 'Jumping in snippet' } }, false, {})
|
vim.api.nvim_echo({ { 'Jumping in snippet' } }, false, {})
|
||||||
ls.jump()
|
ls.jump()
|
||||||
else
|
else
|
||||||
@@ -430,7 +428,7 @@ end, { desc = 'Luasnip accept copilot or jump forward' })
|
|||||||
-- directory if the file does not exist
|
-- directory if the file does not exist
|
||||||
vim.keymap.set('n', '<Leader>es', function()
|
vim.keymap.set('n', '<Leader>es', function()
|
||||||
local ft = vim.bo.filetype
|
local ft = vim.bo.filetype
|
||||||
if ft == 'vue' then
|
if ft == 'vue' or ft == 'typescript' then
|
||||||
ft = 'javascript'
|
ft = 'javascript'
|
||||||
end
|
end
|
||||||
local snippets_dir = vim.fn.stdpath 'config' .. '/lua/snippets'
|
local snippets_dir = vim.fn.stdpath 'config' .. '/lua/snippets'
|
||||||
|
|||||||
@@ -47,3 +47,4 @@ require('lazy').setup({
|
|||||||
})
|
})
|
||||||
|
|
||||||
require('helpers').edit_cf('l', '/lua/lazy_init.lua')
|
require('helpers').edit_cf('l', '/lua/lazy_init.lua')
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
return {
|
return {
|
||||||
'ricardoramirezr/blade-nav.nvim',
|
'ricardoramirezr/blade-nav.nvim',
|
||||||
dependencies = { -- totally optional
|
|
||||||
'saghen/blink.cmp', -- if using blink.cmp
|
|
||||||
},
|
|
||||||
ft = { 'blade', 'php' }, -- optional, improves startup time
|
ft = { 'blade', 'php' }, -- optional, improves startup time
|
||||||
|
config = function()
|
||||||
|
require('blade-nav').setup {
|
||||||
|
close_tag_on_complete = false,
|
||||||
|
integrations = {
|
||||||
|
cmp = false,
|
||||||
|
coq = false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,15 +56,10 @@ return {
|
|||||||
providers = {
|
providers = {
|
||||||
lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 },
|
lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 },
|
||||||
-- avante = { module = 'blink-cmp-avante', name = 'Avante', opts = {} },
|
-- avante = { module = 'blink-cmp-avante', name = 'Avante', opts = {} },
|
||||||
-- ['blade-nav'] = {
|
['blade-nav'] = {
|
||||||
-- module = 'blade-nav.blink',
|
name = 'blade-nav',
|
||||||
-- opts = {
|
module = 'blade-nav.integrations.blink',
|
||||||
-- clost_tag_on_complete = false,
|
|
||||||
-- },
|
|
||||||
-- },
|
|
||||||
},
|
},
|
||||||
per_filetype = {
|
|
||||||
codecompanion = { 'codecompanion' },
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -83,3 +78,4 @@ return {
|
|||||||
signature = { enabled = true },
|
signature = { enabled = true },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ return {
|
|||||||
config = function()
|
config = function()
|
||||||
local ls = require 'luasnip'
|
local ls = require 'luasnip'
|
||||||
ls.filetype_extend('vue', { 'javascript' })
|
ls.filetype_extend('vue', { 'javascript' })
|
||||||
|
ls.filetype_extend('typescript', { 'javascript' })
|
||||||
local snippets_dir = vim.fn.stdpath 'config' .. '/lua/snippets'
|
local snippets_dir = vim.fn.stdpath 'config' .. '/lua/snippets'
|
||||||
require('luasnip.loaders.from_lua').load {
|
require('luasnip.loaders.from_lua').load {
|
||||||
paths = { snippets_dir },
|
paths = { snippets_dir },
|
||||||
@@ -24,3 +25,4 @@ return {
|
|||||||
end,
|
end,
|
||||||
opts = {},
|
opts = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
return {
|
||||||
|
'nvim-treesitter/nvim-treesitter-textobjects',
|
||||||
|
branch = 'main',
|
||||||
|
config = function()
|
||||||
|
-- put your config here
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
+29
-298
@@ -6,314 +6,48 @@ local M = {}
|
|||||||
local helpers = require 'helpers'
|
local helpers = require 'helpers'
|
||||||
local map = helpers.map
|
local map = helpers.map
|
||||||
|
|
||||||
|
local function relevant_directory_from_cwd(cwd)
|
||||||
|
local basename = vim.fn.fnamemodify(cwd, ':t')
|
||||||
|
local nested_folder_names = { 'server', 'frontend', 'frontend2', 'client', 'backend' }
|
||||||
|
if vim.tbl_contains(nested_folder_names, basename) then
|
||||||
|
local parent = vim.fn.fnamemodify(cwd, ':h')
|
||||||
|
return relevant_directory_from_cwd(parent)
|
||||||
|
end
|
||||||
|
return cwd
|
||||||
|
end
|
||||||
|
|
||||||
-- Get the last folder name from a path
|
-- Get the last folder name from a path
|
||||||
local function project_name_from_cwd(cwd)
|
local function project_name_from_dir(dir)
|
||||||
return vim.fn.fnamemodify(cwd, ':t')
|
return vim.fn.fnamemodify(dir, ':t')
|
||||||
end
|
end
|
||||||
|
|
||||||
local function command_with_dir(dir, cmd)
|
|
||||||
if dir then
|
|
||||||
return '!cd ' .. dir .. ' && ' .. cmd
|
|
||||||
end
|
|
||||||
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*$'
|
|
||||||
local extensionSuffixes = {
|
|
||||||
php = { 'Controller', 'Repository', 'StoreRequest', 'UpdateRequest', 'Request', 'Resource', 'Test', 'Observer', 'Policy', 'Seeder', 'Factory' },
|
|
||||||
['[jt]s'] = { 'Service' },
|
|
||||||
}
|
|
||||||
for suffix_type, _ in pairs(extensionSuffixes) do
|
|
||||||
if ext:match(suffix_type) then
|
|
||||||
local suffixes = extensionSuffixes[suffix_type]
|
|
||||||
for _, suffix in ipairs(suffixes) do
|
|
||||||
local scope = base_name:match('^(%w+)' .. suffix .. '$')
|
|
||||||
if scope then
|
|
||||||
return scope
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return base_name
|
|
||||||
end
|
|
||||||
|
|
||||||
local function navigate_using_suffix(suffix)
|
|
||||||
local scope = get_scope_from_file(vim.fn.expand '%:t')
|
|
||||||
local file_name = scope .. suffix
|
|
||||||
local file_path = vim.system({ 'git', 'ls-files', file_name, '**/' .. file_name }):wait().stdout
|
|
||||||
if file_path ~= '' then
|
|
||||||
vim.cmd('edit ' .. file_path)
|
|
||||||
else
|
|
||||||
vim.notify('File ' .. file_name .. ' not found in git ls-files', vim.log.levels.ERROR)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function create_navigation_maps(maps)
|
|
||||||
for key, suffix_and_name in pairs(maps) do
|
|
||||||
map('<Leader>n' .. key, function()
|
|
||||||
navigate_using_suffix(suffix_and_name[1])
|
|
||||||
end, { desc = 'Navigate to relevant ' .. suffix_and_name[2] })
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function create_bookmark(key, bookmark)
|
|
||||||
map('<Leader>b' .. key, function()
|
|
||||||
vim.cmd('edit ' .. bookmark)
|
|
||||||
end, { desc = 'Navigate to ' .. bookmark })
|
|
||||||
end
|
|
||||||
|
|
||||||
local function create_bookmark_maps(maps)
|
|
||||||
for key, bookmark in pairs(maps) do
|
|
||||||
create_bookmark(key, bookmark)
|
|
||||||
end
|
|
||||||
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',
|
|
||||||
|
|
||||||
['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',
|
|
||||||
|
|
||||||
['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
|
|
||||||
|
|
||||||
local function laravel_keymaps(dir)
|
|
||||||
map('sl ', command_with_dir(dir, 'vendor/bin/sail '), { desc = 'Run sail command' }, 'c')
|
|
||||||
map('art ', command_with_dir(dir, 'php artisan '), { desc = 'Run artisan command' }, 'c')
|
|
||||||
map('sart ', command_with_dir(dir, 'vendor/bin/sail artisan '), { desc = 'Run artisan command with sail' }, 'c')
|
|
||||||
map('cmp ', command_with_dir(dir, 'composer '), { desc = 'Run composer script' }, 'c')
|
|
||||||
map('<Leader>pm', ':' .. command_with_dir(dir, 'vendor/bin/sail artisan migrate<CR>'))
|
|
||||||
map('<Leader>pr', ':' .. command_with_dir(dir, 'vendor/bin/sail artisan migrate:rollback<CR>'))
|
|
||||||
map('<Leader>pM', ':' .. command_with_dir(dir, 'vendor/bin/sail artisan make:'))
|
|
||||||
create_navigation_maps {
|
|
||||||
['m'] = { '.php', 'model' },
|
|
||||||
['c'] = { 'Controller.php', 'controller' },
|
|
||||||
['p'] = { 'Policy.php', 'policy' },
|
|
||||||
['R'] = { 'Resource.php', 'resource' },
|
|
||||||
['r'] = { 'Request.php', 'request' },
|
|
||||||
['t'] = { 'Test.php', 'test file' },
|
|
||||||
}
|
|
||||||
if dir == nil then
|
|
||||||
dir = ''
|
|
||||||
end
|
|
||||||
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 = {
|
|
||||||
-- Example: a repo folder
|
|
||||||
['runcats'] = function(dir)
|
|
||||||
-- local dump_buf = vim.api.nvim_create_buf(false, true)
|
|
||||||
-- vim.api.nvim_set_option_value('bufhidden', 'hide', { buf = dump_buf })
|
|
||||||
-- vim.api.nvim_set_option_value('modifiable', false, { buf = dump_buf })
|
|
||||||
--
|
|
||||||
-- vim.fn.jobstart('cd server && sail artisan dump-server', {
|
|
||||||
-- term = true,
|
|
||||||
-- })
|
|
||||||
|
|
||||||
-- map('<leader>dd', function()
|
|
||||||
-- local height = math.ceil(vim.o.lines * 0.8)
|
|
||||||
-- local width = math.ceil(vim.o.columns * 0.8)
|
|
||||||
-- vim.api.nvim_open_win(dump_buf, true, {
|
|
||||||
-- style = 'minimal',
|
|
||||||
-- relative = 'editor',
|
|
||||||
-- width = width,
|
|
||||||
-- height = height,
|
|
||||||
-- row = math.ceil((vim.o.lines - height) / 2),
|
|
||||||
-- col = math.ceil((vim.o.columns - width) / 2),
|
|
||||||
-- border = 'single',
|
|
||||||
-- })
|
|
||||||
--
|
|
||||||
-- vim.cmd.startinsert()
|
|
||||||
-- end, { desc = 'Open the dump-server window' })
|
|
||||||
|
|
||||||
map(
|
|
||||||
'<leader>pl',
|
|
||||||
':cexpr system("cd server && vendor/bin/phpstan analyse --no-progress --error-format=raw --memory-limit=2G -vv") <CR>',
|
|
||||||
{ desc = 'Run lint' }
|
|
||||||
)
|
|
||||||
map('<leader>pd', function()
|
|
||||||
helpers.open_term { cmd = 'lazysql mysql://root@localhost:3306/runcats' }
|
|
||||||
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/'
|
|
||||||
map('yrn ', '!cd client && yarn ', { desc = 'Run yarn script' }, 'c')
|
|
||||||
map('<Leader>pt', ':!cd server && php artisan typescript:transform --format<CR>', { desc = 'Compile typescript' })
|
|
||||||
vim.api.nvim_create_autocmd({ 'BufWritePre' }, {
|
|
||||||
pattern = { '*.php' },
|
|
||||||
callback = function(args)
|
|
||||||
require('helpers').format_buffer('pint', args.buf)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd({ 'BufWritePre' }, {
|
|
||||||
pattern = { '*.php' },
|
|
||||||
callback = function(args)
|
|
||||||
require('helpers').format_buffer('eslint_d', args.buf)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
create_bookmark('E', dir .. '/client/src/types/api/endpointMap.d.ts')
|
|
||||||
create_bookmark('q', dir .. '/client/quasar.config.ts')
|
|
||||||
create_bookmark('db', dir .. '/client/src/boot')
|
|
||||||
create_bookmark('ds', dir .. '/client/src/stores')
|
|
||||||
create_bookmark('dS', dir .. '/client/src/services')
|
|
||||||
end,
|
|
||||||
|
|
||||||
['hylark'] = function(dir)
|
|
||||||
map('<leader>pl', ':cexpr system("vendor/bin/phpstan analyse --no-progress --error-format=raw --memory-limit=2G -vv") <CR>', { desc = 'Run lint' })
|
|
||||||
map('<leader>pd', function()
|
|
||||||
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>')
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd({ 'BufWritePost' }, {
|
|
||||||
pattern = { '*.php', '.env', '.graphql' },
|
|
||||||
callback = function()
|
|
||||||
if not vim.fn.expand('%:p'):match(dir .. '/server/') then
|
|
||||||
vim.fn.jobstart('vendor/bin/sail artisan octane:reload', { stdout_buffered = true })
|
|
||||||
vim.fn.jobstart('vendor/bin/sail artisan horizon:terminate', { stdout_buffered = true })
|
|
||||||
end
|
|
||||||
if vim.fn.search '#\\[TypeScript\\]' ~= 0 then
|
|
||||||
vim.fn.jobstart('php artisan typescript:transform', { cwd = dir .. '/server', stdout_buffered = true })
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd({ 'BufWritePre' }, {
|
|
||||||
pattern = { '*.js', '*.ts', '*.vue' },
|
|
||||||
callback = function(args)
|
|
||||||
vim.env.ESLINT_D_PPID = vim.fn.getpid()
|
|
||||||
local cwd = vim.fn.getcwd()
|
|
||||||
if vim.fn.expand('%:p'):match(dir .. '/frontend2/') then
|
|
||||||
cwd = dir .. '/frontend2/'
|
|
||||||
end
|
|
||||||
require('helpers').format_buffer('eslint_d', args.buf, cwd)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd({ 'BufWritePre' }, {
|
|
||||||
pattern = { '*.php' },
|
|
||||||
callback = function(args)
|
|
||||||
local cwd = vim.fn.getcwd()
|
|
||||||
if vim.fn.expand('%:p'):match(dir .. '/server/') then
|
|
||||||
cwd = dir .. '/server/'
|
|
||||||
end
|
|
||||||
require('helpers').format_buffer('pint', args.buf, cwd)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd({ 'BufWritePost' }, {
|
|
||||||
pattern = { '.graphql' },
|
|
||||||
callback = function()
|
|
||||||
vim.fn.jobstart('vendor/bin/sail artisan lighthouse:clear-cache', { stdout_buffered = true })
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
|
|
||||||
default = function() end,
|
|
||||||
}
|
|
||||||
|
|
||||||
local last_applied = nil
|
local last_applied = nil
|
||||||
|
|
||||||
function M.apply(cwd)
|
function M.apply(cwd)
|
||||||
local dir = cwd or vim.fn.getcwd()
|
local dir = relevant_directory_from_cwd(cwd or vim.fn.getcwd())
|
||||||
local name = project_name_from_cwd(dir)
|
local name = project_name_from_dir(dir)
|
||||||
if last_applied == name then
|
if last_applied == name then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
last_applied = name
|
last_applied = name
|
||||||
|
|
||||||
local setup = PROJECTS[name]
|
-- Check if project lua file exists in nvim config path
|
||||||
if type(setup) == 'function' then
|
if vim.fn.filereadable(vim.fn.stdpath 'config' .. '/lua/projects/' .. name .. '.lua') == 1 then
|
||||||
|
local setup = require('projects.' .. name)
|
||||||
|
helpers.edit_cf('w', '/lua/projects/' .. name .. '.lua')
|
||||||
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)
|
-- Source the project file to apply any new settings
|
||||||
|
vim.api.nvim_create_autocmd({ 'BufWritePost' }, {
|
||||||
|
pattern = { vim.fn.stdpath 'config' .. '/lua/projects/' .. name .. '.lua' },
|
||||||
|
callback = function()
|
||||||
|
package.loaded['projects.' .. name] = nil
|
||||||
|
local setup = require('projects.' .. name)
|
||||||
|
setup(dir)
|
||||||
|
vim.notify(('Project config reloaded: %s'):format(name), vim.log.levels.INFO, { title = 'projects.lua' })
|
||||||
|
end,
|
||||||
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -343,6 +77,3 @@ vim.api.nvim_create_user_command('ProjectReload', function()
|
|||||||
M.apply()
|
M.apply()
|
||||||
end, {})
|
end, {})
|
||||||
|
|
||||||
-- Keep your helper line
|
|
||||||
require('helpers').edit_cf('w', '/lua/projects.lua')
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,184 @@
|
|||||||
|
local helpers = require 'helpers'
|
||||||
|
local map = helpers.map
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
local function command_with_dir(dir, cmd)
|
||||||
|
if dir then
|
||||||
|
return '!cd ' .. dir .. ' && ' .. cmd
|
||||||
|
end
|
||||||
|
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*$'
|
||||||
|
local extensionSuffixes = {
|
||||||
|
php = { 'Controller', 'Repository', 'StoreRequest', 'UpdateRequest', 'Request', 'Resource', 'Test', 'Observer', 'Policy', 'Seeder', 'Factory' },
|
||||||
|
['[jt]s'] = { 'Service' },
|
||||||
|
}
|
||||||
|
for suffix_type, _ in pairs(extensionSuffixes) do
|
||||||
|
if ext:match(suffix_type) then
|
||||||
|
local suffixes = extensionSuffixes[suffix_type]
|
||||||
|
for _, suffix in ipairs(suffixes) do
|
||||||
|
local scope = base_name:match('^(%w+)' .. suffix .. '$')
|
||||||
|
if scope then
|
||||||
|
return scope
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return base_name
|
||||||
|
end
|
||||||
|
|
||||||
|
local function navigate_using_suffix(suffix)
|
||||||
|
local scope = get_scope_from_file(vim.fn.expand '%:t')
|
||||||
|
local file_name = scope .. suffix
|
||||||
|
local file_path = vim.system({ 'git', 'ls-files', file_name, '**/' .. file_name }):wait().stdout
|
||||||
|
if file_path ~= '' then
|
||||||
|
vim.cmd('edit ' .. file_path)
|
||||||
|
else
|
||||||
|
vim.notify('File ' .. file_name .. ' not found in git ls-files', vim.log.levels.ERROR)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function create_navigation_maps(maps)
|
||||||
|
for key, suffix_and_name in pairs(maps) do
|
||||||
|
map('<Leader>n' .. key, function()
|
||||||
|
navigate_using_suffix(suffix_and_name[1])
|
||||||
|
end, { desc = 'Navigate to relevant ' .. suffix_and_name[2] })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function create_bookmark_maps(maps)
|
||||||
|
for key, bookmark in pairs(maps) do
|
||||||
|
helpers.create_bookmark(key, bookmark)
|
||||||
|
end
|
||||||
|
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',
|
||||||
|
|
||||||
|
['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',
|
||||||
|
|
||||||
|
['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
|
||||||
|
|
||||||
|
local function laravel_utils(dir)
|
||||||
|
map('<Leader>D', function()
|
||||||
|
helpers.open_term {
|
||||||
|
cmd = dir .. 'vendor/bin/var-dump-server',
|
||||||
|
buf_opts = {
|
||||||
|
bufhidden = 'hide',
|
||||||
|
modifiable = false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end, { desc = 'Open dump-server window' })
|
||||||
|
end
|
||||||
|
|
||||||
|
local function laravel_keymaps(dir)
|
||||||
|
map('sl ', command_with_dir(dir, 'vendor/bin/sail '), { desc = 'Run sail command' }, 'c')
|
||||||
|
map('art ', command_with_dir(dir, 'php artisan '), { desc = 'Run artisan command' }, 'c')
|
||||||
|
map('sart ', command_with_dir(dir, 'vendor/bin/sail artisan '), { desc = 'Run artisan command with sail' }, 'c')
|
||||||
|
map('cmp ', command_with_dir(dir, 'composer '), { desc = 'Run composer script' }, 'c')
|
||||||
|
map('<Leader>pm', ':' .. command_with_dir(dir, 'vendor/bin/sail artisan migrate<CR>'))
|
||||||
|
map('<Leader>pr', ':' .. command_with_dir(dir, 'vendor/bin/sail artisan migrate:rollback<CR>'))
|
||||||
|
map('<Leader>pM', ':' .. command_with_dir(dir, 'vendor/bin/sail artisan make:'))
|
||||||
|
create_navigation_maps {
|
||||||
|
['m'] = { '.php', 'model' },
|
||||||
|
['c'] = { 'Controller.php', 'controller' },
|
||||||
|
['p'] = { 'Policy.php', 'policy' },
|
||||||
|
['R'] = { 'Resource.php', 'resource' },
|
||||||
|
['r'] = { 'Request.php', 'request' },
|
||||||
|
['t'] = { 'Test.php', 'test file' },
|
||||||
|
}
|
||||||
|
if dir == nil then
|
||||||
|
dir = ''
|
||||||
|
end
|
||||||
|
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
|
||||||
|
|
||||||
|
M.laravel_keymaps = laravel_keymaps
|
||||||
|
M.laravel_makes = laravel_makes
|
||||||
|
M.laravel_utils = laravel_utils
|
||||||
|
M.laravel_bookmarks = laravel_bookmarks_with_dir
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
local laravel_utils = require 'projects.framework_utils.laravel'
|
||||||
|
local helpers = require 'helpers'
|
||||||
|
local map = helpers.map
|
||||||
|
local create_bookmark = helpers.create_bookmark
|
||||||
|
|
||||||
|
local function switch_to(dir)
|
||||||
|
if vim.fn.getcwd() == dir then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
vim.fn.chdir(dir)
|
||||||
|
vim.notify('Changed working directory to ' .. dir, vim.log.levels.INFO, { title = 'hylark.lua' })
|
||||||
|
end
|
||||||
|
|
||||||
|
return function(dir)
|
||||||
|
local function switch_to_server()
|
||||||
|
switch_to(dir .. '/server')
|
||||||
|
end
|
||||||
|
|
||||||
|
local function switch_to_frontend()
|
||||||
|
switch_to(dir .. '/frontend2')
|
||||||
|
end
|
||||||
|
|
||||||
|
local function switch_to_root()
|
||||||
|
switch_to(dir)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function compile_typescript()
|
||||||
|
vim.fn.jobstart('php artisan typescript:transform', { cwd = dir .. '/server', stdout_buffered = true })
|
||||||
|
vim.notify('Compiling typescript types', vim.log.levels.INFO, { title = 'hylark.lua' })
|
||||||
|
end
|
||||||
|
|
||||||
|
map('<leader>pl', ':cexpr system("vendor/bin/phpstan analyse --no-progress --error-format=raw --memory-limit=2G -vv") <CR>', { desc = 'Run lint' })
|
||||||
|
map('<leader>T', function()
|
||||||
|
helpers.open_term { cmd = 'lazysql pgsql://homestead:password@localhost:5432/homestead' }
|
||||||
|
end, { desc = 'Open database manager' })
|
||||||
|
map('yrn ', '!cd frontend && yarn ', { desc = 'Run yarn script' }, 'c')
|
||||||
|
map('<Leader>pm', ':vendor/bin/sail composer migrate<CR>')
|
||||||
|
map('<Leader>pcs', switch_to_server, { desc = 'Change working directory to server' })
|
||||||
|
map('<Leader>pcf', switch_to_frontend, { desc = 'Change working directory to frontend2' })
|
||||||
|
map('<Leader>pcr', switch_to_root, { desc = 'Change working directory to root' })
|
||||||
|
map('<Leader>pt', compile_typescript, { desc = 'Compile typescript' })
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ 'BufWritePost' }, {
|
||||||
|
pattern = { '*.php', '.env', '.graphql' },
|
||||||
|
callback = function()
|
||||||
|
if not vim.fn.expand('%:p'):match(dir .. '/server/') then
|
||||||
|
vim.fn.jobstart('vendor/bin/sail artisan octane:reload', { stdout_buffered = true })
|
||||||
|
vim.fn.jobstart('vendor/bin/sail artisan horizon:terminate', { stdout_buffered = true })
|
||||||
|
end
|
||||||
|
if vim.fn.search '#\\[TypeScript\\]' ~= 0 then
|
||||||
|
compile_typescript()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ 'BufWritePre' }, {
|
||||||
|
pattern = { '*.js', '*.ts', '*.vue' },
|
||||||
|
callback = function(args)
|
||||||
|
vim.env.ESLINT_D_PPID = vim.fn.getpid()
|
||||||
|
local cwd = vim.fn.getcwd()
|
||||||
|
if vim.fn.expand('%:p'):match(dir .. '/frontend2/') then
|
||||||
|
cwd = dir .. '/frontend2/'
|
||||||
|
end
|
||||||
|
require('helpers').format_buffer('eslint_d', args.buf, cwd)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ 'BufWritePre' }, {
|
||||||
|
pattern = { '*.php' },
|
||||||
|
callback = function(args)
|
||||||
|
local cwd = vim.fn.getcwd()
|
||||||
|
if vim.fn.expand('%:p'):match(dir .. '/server/') then
|
||||||
|
cwd = dir .. '/server/'
|
||||||
|
end
|
||||||
|
require('helpers').format_buffer('pint', args.buf, cwd)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ 'BufWritePost' }, {
|
||||||
|
pattern = { '.graphql' },
|
||||||
|
callback = function()
|
||||||
|
vim.fn.jobstart('vendor/bin/sail artisan lighthouse:clear-cache', { stdout_buffered = true })
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ 'BufEnter' }, {
|
||||||
|
pattern = { dir .. '**' },
|
||||||
|
callback = function()
|
||||||
|
if vim.fn.expand('%:p'):match(dir .. '/server/') then
|
||||||
|
switch_to_server()
|
||||||
|
elseif vim.fn.expand('%:p'):match(dir .. '/frontend2/') then
|
||||||
|
switch_to_frontend()
|
||||||
|
else
|
||||||
|
switch_to_root()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
laravel_utils.laravel_keymaps 'server/'
|
||||||
|
laravel_utils.laravel_makes 'server/'
|
||||||
|
laravel_utils.laravel_utils 'server/'
|
||||||
|
laravel_utils.laravel_bookmarks(dir .. '/server/')
|
||||||
|
|
||||||
|
create_bookmark('s', dir .. '/frontend2/src/types/api/server-types.d.ts')
|
||||||
|
end
|
||||||
|
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
local laravel_utils = require 'projects.framework_utils.laravel'
|
||||||
|
local helpers = require 'helpers'
|
||||||
|
local map = helpers.map
|
||||||
|
local create_bookmark = helpers.create_bookmark
|
||||||
|
|
||||||
|
return function(dir)
|
||||||
|
map(
|
||||||
|
'<leader>pl',
|
||||||
|
':cexpr system("cd server && vendor/bin/phpstan analyse --no-progress --error-format=raw --memory-limit=2G -vv") <CR>',
|
||||||
|
{ desc = 'Run lint' }
|
||||||
|
)
|
||||||
|
map('<leader>T', function()
|
||||||
|
helpers.open_term { cmd = 'lazysql mysql://root@localhost:3306/runcats' }
|
||||||
|
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')
|
||||||
|
map('yrn ', '!cd client && yarn ', { desc = 'Run yarn script' }, 'c')
|
||||||
|
map('<Leader>pt', ':!cd server && php artisan typescript:transform --format<CR>', { desc = 'Compile typescript' })
|
||||||
|
vim.api.nvim_create_autocmd({ 'BufWritePre' }, {
|
||||||
|
pattern = { '*.php' },
|
||||||
|
callback = function(args)
|
||||||
|
helpers.format_buffer('pint', args.buf)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ 'BufWritePre' }, {
|
||||||
|
pattern = { '*.js', '*.ts', '*.vue' },
|
||||||
|
callback = function(args)
|
||||||
|
helpers.format_buffer('eslint_d', args.buf)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
laravel_utils.laravel_keymaps 'server/'
|
||||||
|
laravel_utils.laravel_makes 'server/'
|
||||||
|
laravel_utils.laravel_utils 'server/'
|
||||||
|
laravel_utils.laravel_bookmarks 'server/'
|
||||||
|
|
||||||
|
create_bookmark('E', dir .. '/client/src/types/api/endpointMap.d.ts')
|
||||||
|
create_bookmark('q', dir .. '/client/quasar.config.ts')
|
||||||
|
create_bookmark('db', dir .. '/client/src/boot')
|
||||||
|
create_bookmark('ds', dir .. '/client/src/stores')
|
||||||
|
create_bookmark('dS', dir .. '/client/src/services')
|
||||||
|
end
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ return {
|
|||||||
|
|
||||||
s(etr('const ', 'const declaration'), {
|
s(etr('const ', 'const declaration'), {
|
||||||
c(1, {
|
c(1, {
|
||||||
sn(nil, fmta('const #~ = #~;', { i(1, 'variableName'), i(2, 'value') })),
|
sn(nil, fmta('const #~ = #~;', { i(1), i(2) })),
|
||||||
sn(
|
sn(
|
||||||
nil,
|
nil,
|
||||||
fmta(
|
fmta(
|
||||||
@@ -60,6 +60,38 @@ return {
|
|||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
s(etr('ref ', 'ref'), {
|
||||||
|
c(1, {
|
||||||
|
sn(nil, fmta('const #~ = ref(#~);', { i(1), i(2) })),
|
||||||
|
sn(
|
||||||
|
nil,
|
||||||
|
fmta(
|
||||||
|
[[
|
||||||
|
const #~ = ref<#~>(#~);
|
||||||
|
]],
|
||||||
|
{ i(1), i(2), i(3) }
|
||||||
|
)
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
|
||||||
|
s(etr('com ', 'computed'), {
|
||||||
|
c(1, {
|
||||||
|
sn(nil, fmta('const #~ = computed(() => #~);', { i(1), i(2) })),
|
||||||
|
sn(
|
||||||
|
nil,
|
||||||
|
fmta(
|
||||||
|
[[
|
||||||
|
const #~ = computed(() => {
|
||||||
|
#~
|
||||||
|
})
|
||||||
|
]],
|
||||||
|
{ i(1), i(2) }
|
||||||
|
)
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
|
||||||
s(
|
s(
|
||||||
etr('fn ', 'function block'),
|
etr('fn ', 'function block'),
|
||||||
fmta(
|
fmta(
|
||||||
@@ -126,3 +158,4 @@ return {
|
|||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
WRN 2026-07-03T16:02:54.215 c/nvim.57084.0 server_start:197: Failed to start server: operation not permitted: /var/folders/j3/6yv08_8s1s740ggr40_kgvrr0000gn/T/nvim.chris/esnddj/nvim.57725.0
|
WRN 2026-07-03T16:02:54.215 c/nvim.57084.0 server_start:197: Failed to start server: operation not permitted: /var/folders/j3/6yv08_8s1s740ggr40_kgvrr0000gn/T/nvim.chris/esnddj/nvim.57725.0
|
||||||
WRN 2026-07-03T16:03:18.385 c/nvim.57084.0 server_start:197: Failed to start server: operation not permitted: /var/folders/j3/6yv08_8s1s740ggr40_kgvrr0000gn/T/nvim.chris/O4WnB1/nvim.57764.0
|
WRN 2026-07-03T16:03:18.385 c/nvim.57084.0 server_start:197: Failed to start server: operation not permitted: /var/folders/j3/6yv08_8s1s740ggr40_kgvrr0000gn/T/nvim.chris/O4WnB1/nvim.57764.0
|
||||||
|
WRN 2026-07-14T11:43:01.105 c/nvim.17401.0 server_start:197: Failed to start server: operation not permitted: /var/folders/j3/6yv08_8s1s740ggr40_kgvrr0000gn/T/nvim.chris/KkEtYu/nvim.19436.0
|
||||||
|
|||||||
Reference in New Issue
Block a user