More changes

This commit is contained in:
2025-11-09 23:03:51 +00:00
parent 529cfa79c8
commit a21a1a3386
4 changed files with 76 additions and 32 deletions

View File

@@ -62,7 +62,7 @@ vim.keymap.set({ 'n', 'v', 'c', 'i' }, '<C-S-P>', function()
hidden = true,
}
end, { desc = 'Find all files' })
vim.keymap.set({ 'n', 'v', 'c', 'i' }, '<C-F>', function()
vim.keymap.set({ 'n', 'v', 'c', 'i' }, '<C-f>', function()
require('telescope.builtin').live_grep {
hidden = true,
}

View File

@@ -12,7 +12,8 @@ return { -- Autoformat
desc = '[F]ormat buffer',
},
},
opts = {
config = function()
require('conform').setup({
notify_on_error = false,
format_on_save = function(bufnr)
-- Disable "format_on_save lsp_fallback" for languages that don't
@@ -30,11 +31,14 @@ return { -- Autoformat
end,
formatters_by_ft = {
lua = { 'stylua' },
php = { 'pint' },
-- Conform can also run multiple formatters sequentially
-- python = { "isort", "black" },
--
-- You can use 'stop_after_first' to run the first available formatter from the list
-- javascript = { "prettierd", "prettier", stop_after_first = true },
},
},
log_level = vim.log.levels.DEBUG
})
end
}

View File

@@ -15,23 +15,55 @@ end
-- Keys are folder names (last segment of your cwd).
local PROJECTS = {
-- Example: a repo folder
['runcats'] = function()
['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',
'<leader>psl',
':cexpr system("cd server && vendor/bin/phpstan analyse --no-progress --error-format=raw --memory-limit=2G -vv") <CR>',
{ desc = 'Run lint' }
)
map('<leader>pcl', ':cexpr system("cd client && tsc --allowJs --removeComments --noEmit") <CR>', { desc = 'Run lint' })
map('<leader>db', function()
helpers.open_term { cmd = 'lazysql mysql://root@localhost:3306/runcats' }
end, { desc = 'Open database manager' })
map('<leader>E', ':e .env', { desc = 'Edit .env file' })
map('s ', '!cd server && ', { desc = 'Run command in server directory' }, 'c')
map('c ', '!cd client && ', { desc = 'Run command in client directory' }, 'c')
map('sl ', '!cd server && sail ', { desc = 'Run sail command' }, 'c')
map('sl ', '!cd server && vendor/bin/sail ', { desc = 'Run sail command' }, 'c')
map('art ', '!cd server && php artisan ', { desc = 'Run artisan command' }, 'c')
map('sart ', '!cd server && sail artisan ', { desc = 'Run artisan command with sail' }, 'c')
map('sart ', '!cd server && vendor/bin/sail artisan ', { desc = 'Run artisan command with sail' }, 'c')
map('cmp ', '!cd server && composer ', { desc = 'Run composer script' }, 'c')
map('yrn ', '!cd client && yarn ', { desc = 'Run yarn script' }, 'c')
map('ts ', '!cd server && php artisan typescript:transform --format', { desc = 'Compile typescript' }, 'c')
map('<C-S-F', ':vimgrep', { desc = 'Grep everywhere' })
require('conform').formatters.pint = {
append_args = {
'--config=' .. dir .. '/server/pint.json',
},
}
end,
default = function() end,
@@ -49,7 +81,7 @@ function M.apply(cwd)
local setup = PROJECTS[name] or PROJECTS.default
if type(setup) == 'function' then
setup()
setup(dir)
vim.notify(('Project config loaded: %s'):format(name), vim.log.levels.INFO, { title = 'projects.lua' })
end
end

View File

@@ -4,7 +4,15 @@ local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local function get_psr4_root()
local function get_psr4_root(path)
-- local dir = vim.fs.dirname(path)
-- while dir ~= '/' and dir ~= nil do
-- local composer_json_path = dir .. '/composer.json'
-- if vim.fn.filereadable(composer_json_path) == 1 then
-- break
-- end
-- dir = vim.fs.dirname(dir)
-- end
local handle = io.popen [[php -r "echo array_keys(json_decode(file_get_contents('composer.json'), true)['autoload']['psr-4'])[0];"]]
local ns_root = handle and handle:read '*a' or ''
if handle then