Skip to content

Commit

Permalink
Have :PhpFile insert simple PHP file contents using abbreviations
Browse files Browse the repository at this point in the history
  • Loading branch information
dietrichm committed Dec 29, 2024
1 parent e03a304 commit ee078af
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion nvim/.config/nvim/after/ftplugin/php.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ vim.b.delimitMate_matchpairs = '(:),[:],{:}'

vim.cmd.iabbrev('<buffer>', '<expr>', 'ns', [[substitute(tr(expand('%:p:h'), '/', '\'), '\v^.*\\\l[^\\]*\\?', '', '')]])
vim.cmd.iabbrev('<buffer>', '<expr>', 'cls', [[expand('%:t:r')]])
vim.cmd.iabbrev('<buffer>', 'strict', [[declare(strict_types=1);]])
vim.cmd.iabbrev('<buffer>', 'strict', [[declare(strict_types=1)]])

vim.keymap.set('n', '<Leader>af', [[:PhpFields<CR>]], { buffer = true })

vim.api.nvim_create_user_command('PhpFile', function()
local content = [[<?php
strict;
namespace ns;
class cls
{
}]]
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('i' .. content .. '<Esc>', true, false, true), 'm', false)
end, {})

0 comments on commit ee078af

Please sign in to comment.