Skip to content

Commit

Permalink
fix: backwards compatibility user configs + docs
Browse files Browse the repository at this point in the history
  • Loading branch information
felixnorden committed Oct 11, 2023
1 parent 7860232 commit 4e8efa2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions doc/nvim-ts-context-commentstring.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ With `nvim-treesitter` >= 1.0, use the `setup` function of this plugin:
The following examples are for `nvim-treesitter` < 1.0, but they can easily be
adapted for `nvim-treesitter` >= 1.0.

Support for more languages can be added quite easily by passing a `config` table
Support for more languages can be added quite easily by passing a `languages` (formerly the now deprecated `config`) table
when configuring the plugin:
>lua
require('nvim-treesitter.configs').setup {
context_commentstring = {
enable = true,
config = {
languages = {
css = '// %s',
},
},
Expand All @@ -88,7 +88,7 @@ when configuring the plugin:
Or with the `setup` function if using `nvim-treesitter` >= 1.0:
>lua
require('ts_context_commentstring').setup {
config = {
languages = {
css = '// %s',
},
}
Expand All @@ -107,7 +107,7 @@ like:
require('nvim-treesitter.configs').setup {
context_commentstring = {
enable = true,
config = {
languages = {
javascript = {
__default = '// %s',
jsx_element = '{/* %s */}',
Expand Down Expand Up @@ -135,7 +135,7 @@ multi-line comment styles (useful when integrating with a commenting plugin):
require('nvim-treesitter.configs').setup {
context_commentstring = {
enable = true,
config = {
languages = {
typescript = { __default = '// %s', __multiline = '/* %s */' },
},
},
Expand Down
4 changes: 2 additions & 2 deletions lua/ts_context_commentstring/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ M.config = {
},
},

---@deprecated
---@deprecated Use the languages configuration instead!
config = {},
}

Expand All @@ -119,7 +119,7 @@ end

---@return ts_context_commentstring.LanguagesConfig
function M.get_languages_config()
return vim.tbl_extend('keep', M.config.languages, M.config.config)
return vim.tbl_deep_extend('force', M.config.languages, M.config.config)
end

return M

0 comments on commit 4e8efa2

Please sign in to comment.