Skip to content

Commit

Permalink
🐛 Fix unable to create markdown file
Browse files Browse the repository at this point in the history
Template utility is only check matching file,
so not matching return error
  • Loading branch information
Nguyen-Hoang-Nam committed Dec 4, 2021
1 parent eac8e95 commit 7401217
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
9 changes: 6 additions & 3 deletions lua/languages/markdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ M.lsp = {
on_attach = lsp.on_attach,
}

M.template = [[
M.template = {
['1'] = [[
#
Expand All @@ -39,13 +40,15 @@ M.template = [[
## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Pull requests are welcome. For major changes,
please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
## License
[MIT](https://choosealicense.com/licenses/mit/)
]]
]],
}

return M
2 changes: 1 addition & 1 deletion lua/tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ local function create_node(tree, node)
local file_extension = require('utils.core').file_extension(name)
local is_template_support = templates.file_supported(file_extension)

local file_type = ''
local file_type = '1'
if file_extension == 'java' then
file_type = vim.fn.input('\nEnter file type: [1] Class, [2] Interface: ')
end
Expand Down
4 changes: 3 additions & 1 deletion lua/utils/templates.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ end

function M.generate(file_extension, filename, path, file_type)
if file_extension == 'md' and filename == 'README.md' then
return require('languages.markdown').template
return require('languages.markdown').template[file_type]
elseif file_extension == 'java' then
local template = require('languages.java').template[file_type]
local name = remove_extension(filename, file_extension)
local group = java_group(path, filename)

return string.format(template, group, name)
else
return ''
end
end

Expand Down

0 comments on commit 7401217

Please sign in to comment.