Add pascal mode formatter
Test Neovim config on push / build (ubuntu-20.04) (push) Failing after 28s
Details
Test Neovim config on push / build (ubuntu-20.04) (push) Failing after 28s
Details
This commit is contained in:
parent
d2c68f99ab
commit
7452ee9b06
|
@ -0,0 +1,41 @@
|
|||
-- Lua vim-dummy variable
|
||||
if vim == nil then
|
||||
local vim = {}
|
||||
end
|
||||
|
||||
-- @name setup_pascal
|
||||
-- @param
|
||||
-- @short Verify installation of pascal tools or install them.
|
||||
local function setup_pascal()
|
||||
local check_ptop = { os.execute("which ptop") }
|
||||
vim.cmd("set autoread")
|
||||
|
||||
-- if return value is 1, get ptop
|
||||
if check_ptop == 1 then
|
||||
os.execute("wget -o ~/.local/bin/ptop https://www.nickr.eu/data/ptop64")
|
||||
os.execute("chmod +x ~/.local/bin/ptop")
|
||||
end
|
||||
end
|
||||
|
||||
-- Setup and verify pascal tools when opening a pascal file
|
||||
vim.api.nvim_create_autocmd({ "BufEnter" }, {
|
||||
pattern = { "*.pas" },
|
||||
callback = setup_pascal,
|
||||
})
|
||||
|
||||
-- @name auto_format
|
||||
-- @param
|
||||
-- @short The format function for pascal.
|
||||
local function auto_format()
|
||||
local write_cmd = "ptop -c ~/.config/nvim/ptop.conf "
|
||||
.. vim.api.nvim_buf_get_name(0)
|
||||
.. " "
|
||||
.. vim.api.nvim_buf_get_name(0)
|
||||
os.execute(write_cmd)
|
||||
end
|
||||
|
||||
-- Add formatter command
|
||||
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
|
||||
pattern = { "*.pas" },
|
||||
callback = auto_format,
|
||||
})
|
Loading…
Reference in New Issue