diff --git a/lua/tpl/tpl.lua b/lua/tpl/tpl.lua index c3b8a15..d5365d9 100644 --- a/lua/tpl/tpl.lua +++ b/lua/tpl/tpl.lua @@ -16,11 +16,14 @@ 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') + local current_file_fullpath = debug.getinfo(1, "S").source:sub(2) + local current_file_path = current_file_fullpath:match("(.*/)") + local tpl_path = current_file_path .. '../../data/tpl/header-' .. filetype .. '.tpl' + if file_exists(tpl_path) then + local lines = get_lines_from(tpl_path) vim.api.nvim_put(lines, "l", false, true) else - print("Pas de fichier pour ce filetype") + print("Pas de fichier pour ce filetype (" .. tpl_path .. ")") end else