Skip to content

Commit

Permalink
feat: language additions and sorting
Browse files Browse the repository at this point in the history
This commit will:
- Add in comment support for:
  - `sh` files
  - `zsh` files
  - `solidity` files
  - `c` files
- Sort all languages in alphabetical order based on filetype/name
  • Loading branch information
felixnorden committed Oct 6, 2023
1 parent 7241635 commit 785fb6c
Showing 1 changed file with 20 additions and 18 deletions.
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
end

return M

0 comments on commit 785fb6c

Please sign in to comment.