Compare commits
3 Commits
fac5782b20
...
2dcd24a5ef
Author | SHA1 | Date | |
---|---|---|---|
2dcd24a5ef | |||
50128c28c7 | |||
0717b586f9 |
15
data/tpl/header-css.tpl
Normal file
15
data/tpl/header-css.tpl
Normal 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
12
data/tpl/header-html.tpl
Normal 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
6
data/tpl/header-sh.tpl
Normal file
@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# exit on error
|
||||
set -e
|
||||
# no undefined variables
|
||||
set -u
|
@ -1 +0,0 @@
|
||||
|
5
lua/tpl/init.lua
Normal file
5
lua/tpl/init.lua
Normal file
@ -0,0 +1,5 @@
|
||||
local header = require('tpl.tpl')
|
||||
|
||||
return {
|
||||
header = header
|
||||
}
|
31
lua/tpl/tpl.lua
Normal file
31
lua/tpl/tpl.lua
Normal 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
|
@ -9,16 +9,18 @@ function! ReloadPlugin()
|
||||
|
||||
" Attention à ne pas mettre d'espace devant lua et EOF
|
||||
lua << EOF
|
||||
print("Reload")
|
||||
for k in pairs(package.loaded) do
|
||||
if k:match("^greetings")
|
||||
then package.loaded[k] = nil
|
||||
if k:match("^greetings") or k:match("^tpl") then
|
||||
print(k)
|
||||
package.loaded[k] = nil
|
||||
end
|
||||
end
|
||||
require("greetings")
|
||||
EOF
|
||||
endfunction
|
||||
|
||||
command! Greet lua require'greetings'.greet()
|
||||
command! Tpl lua require'tpl'.header()
|
||||
|
||||
augroup ReloadingGroup
|
||||
autocmd!
|
||||
|
Loading…
x
Reference in New Issue
Block a user