Compare commits

...

3 Commits

Author SHA1 Message Date
2dcd24a5ef Ajout de la commande Tpl 2022-01-27 15:29:17 +01:00
50128c28c7 Ajout de template pour css, html et sh 2022-01-27 15:28:19 +01:00
0717b586f9 Remove useless file 2022-01-27 11:02:54 +01:00
7 changed files with 74 additions and 4 deletions

15
data/tpl/header-css.tpl Normal file
View File

@ -0,0 +1,15 @@
# Reset (Source: https://css-tricks.com/notes-on-josh-comeaus-custom-css-reset/)
* {
margin: 0;
padding: 0;
}
html, body {
height: 100%;
}
img, picture, video, canvas, svg {
display: block;
max-width: 100%;
}
p, h1, h2, h3, h4, h5, h6 {
overflow-wrap: break-word;
}

12
data/tpl/header-html.tpl Normal file
View File

@ -0,0 +1,12 @@
<!doctype html>
<html lang='fr'>
<head>
¦ <meta charset='utf-8'>
¦ <title>Title</title>
¦ <link rel='stylesheet' href='style.css'>
</head>
<body>
<script src='myScript.js'></script>
</body>
</html>

6
data/tpl/header-sh.tpl Normal file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env sh
# exit on error
set -e
# no undefined variables
set -u

View File

@ -1 +0,0 @@

5
lua/tpl/init.lua Normal file
View File

@ -0,0 +1,5 @@
local header = require('tpl.tpl')
return {
header = header
}

31
lua/tpl/tpl.lua Normal file
View File

@ -0,0 +1,31 @@
local function file_exists(file)
local f = io.open(file, "rb")
if f then f:close() end
return f ~= nil
end
local function get_lines_from(file)
if not file_exists(file) then return {} end
local lines = {}
for line in io.lines(file) do
lines[#lines + 1] = line
end
return lines
end
local function header()
local filetype = vim.api.nvim_buf_get_option(0, 'filetype')
if filetype ~= "" then
if file_exists('data/tpl/header-' .. filetype .. '.tpl') then
local lines = get_lines_from('data/tpl/header-' .. filetype .. '.tpl')
vim.api.nvim_put(lines, "l", false, true)
else
print("Pas de fichier pour ce filetype")
end
else
print("Pas de filetype")
end
end
return header

View File

@ -9,16 +9,18 @@ function! ReloadPlugin()
" Attention à ne pas mettre d'espace devant lua et EOF " Attention à ne pas mettre d'espace devant lua et EOF
lua << EOF lua << EOF
print("Reload")
for k in pairs(package.loaded) do for k in pairs(package.loaded) do
if k:match("^greetings") if k:match("^greetings") or k:match("^tpl") then
then package.loaded[k] = nil print(k)
package.loaded[k] = nil
end end
end end
require("greetings")
EOF EOF
endfunction endfunction
command! Greet lua require'greetings'.greet() command! Greet lua require'greetings'.greet()
command! Tpl lua require'tpl'.header()
augroup ReloadingGroup augroup ReloadingGroup
autocmd! autocmd!