Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language additions and sorting filetypes #78

Merged
merged 4 commits into from
Oct 12, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 20 additions & 18 deletions lua/ts_context_commentstring/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ local M = {}
---@class ts_context_commentstring.Config
---@field enable_autocmd boolean
---@field custom_calculation? fun(node: TSNode, language_tree: LanguageTree): string
---@field config ts_context_commentstring.LanguagesConfig
---@field languages ts_context_commentstring.LanguagesConfig
---@field commentary_integration ts_context_commentstring.CommentaryConfig

---@type ts_context_commentstring.Config
Expand All @@ -56,28 +56,30 @@ M.config = {
CommentaryUndo = 'gcu',
},

-- TODO: We should probably rename this as having a "config" key inside
-- "config" is probably confusing. Maybe "languages"?
config = {
languages = {
-- Languages that have a single comment style
typescript = { __default = '// %s', __multiline = '/* %s */' },
css = '/* %s */',
scss = { __default = '// %s', __multiline = '/* %s */' },
php = { __default = '// %s', __multiline = '/* %s */' },
html = '<!-- %s -->',
svelte = '<!-- %s -->',
vue = '<!-- %s -->',
astro = '<!-- %s -->',
handlebars = '{{! %s }}',
c = { __default = '// %s', __multiline = '/* %s */' },
css = '/* %s */',
glimmer = '{{! %s }}',
graphql = '# %s',
handlebars = '{{! %s }}',
html = '<!-- %s -->',
lua = { __default = '-- %s', __multiline = '--[[ %s ]]' },
vim = '" %s',
sql = '-- %s',
twig = '{# %s #}',
python = { __default = '# %s', __multiline = '""" %s """' },
nix = { __default = '# %s', __multiline = '/* %s */' },
php = { __default = '// %s', __multiline = '/* %s */' },
python = { __default = '# %s', __multiline = '""" %s """' },
rescript = { __default = '// %s', __multiline = '/* %s */' },
scss = { __default = '// %s', __multiline = '/* %s */' },
sh = '# %s',
solidity = { __default = '// %s', __multiline = '/* %s */' },
sql = '-- %s',
svelte = '<!-- %s -->',
twig = '{# %s #}',
typescript = { __default = '// %s', __multiline = '/* %s */' },
vim = '" %s',
vue = '<!-- %s -->',
zsh = '# %s',

-- Languages that can have multiple types of comments
tsx = {
Expand All @@ -94,7 +96,7 @@ M.config = {
},
}

M.config.config.javascript = M.config.config.tsx
M.config.languages.javascript = M.config.languages.tsx

---@param config? ts_context_commentstring.Config
function M.update(config)
Expand All @@ -113,7 +115,7 @@ end

---@return ts_context_commentstring.LanguagesConfig
function M.get_languages_config()
return M.config.config
return M.config.languages
JoosepAlviste marked this conversation as resolved.
Show resolved Hide resolved
end

return M