Update generated neovim config
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
local M = {}
|
||||
|
||||
---Set up non-default configuration
|
||||
---@param config ts_context_commentstring.Config
|
||||
---@param config? ts_context_commentstring.Config
|
||||
function M.setup(config)
|
||||
require('ts_context_commentstring.config').update(config)
|
||||
end
|
||||
|
||||
@ -34,12 +34,14 @@ local M = {}
|
||||
---@field ChangeCommentary string | false | nil
|
||||
---@field CommentaryUndo string | false | nil
|
||||
|
||||
---@alias ts_context_commentstring.CustomCalculation fun(node: TSNode|nil, language_tree: vim.treesitter.LanguageTree|nil): string
|
||||
|
||||
---@class ts_context_commentstring.Config
|
||||
---@field enable_autocmd boolean
|
||||
---@field custom_calculation? fun(node: TSNode, language_tree: LanguageTree): string
|
||||
---@field languages ts_context_commentstring.LanguagesConfig
|
||||
---@field config ts_context_commentstring.LanguagesConfig
|
||||
---@field commentary_integration ts_context_commentstring.CommentaryConfig
|
||||
---@field enable_autocmd? boolean
|
||||
---@field custom_calculation? ts_context_commentstring.CustomCalculation
|
||||
---@field languages? ts_context_commentstring.LanguagesConfig
|
||||
---@field config? ts_context_commentstring.LanguagesConfig
|
||||
---@field commentary_integration? ts_context_commentstring.CommentaryConfig
|
||||
|
||||
---@type ts_context_commentstring.Config
|
||||
M.config = {
|
||||
@ -130,12 +132,16 @@ function M.is_autocmd_enabled()
|
||||
end
|
||||
|
||||
local enable_autocmd = M.config.enable_autocmd
|
||||
return enable_autocmd == nil and true or enable_autocmd
|
||||
if enable_autocmd == nil then
|
||||
return true
|
||||
end
|
||||
|
||||
return enable_autocmd
|
||||
end
|
||||
|
||||
---@return ts_context_commentstring.LanguagesConfig
|
||||
function M.get_languages_config()
|
||||
return vim.tbl_deep_extend('force', M.config.languages, M.config.config)
|
||||
return vim.tbl_deep_extend('force', M.config.languages or {}, M.config.config or {})
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@ -56,7 +56,7 @@ function M.calculate_commentstring(args)
|
||||
local node, language_tree =
|
||||
utils.get_node_at_cursor_start_of_line(vim.tbl_keys(config.get_languages_config()), location)
|
||||
|
||||
if not node and not language_tree then
|
||||
if not node or not language_tree then
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
@ -80,8 +80,8 @@ end
|
||||
--- where to start traversing the tree. Defaults to cursor start of line.
|
||||
--- This usually makes the most sense when commenting the whole line.
|
||||
---
|
||||
---@return table|nil node, table|nil language_tree Node and language tree for the
|
||||
--- location
|
||||
---@return TSNode|nil node, vim.treesitter.LanguageTree|nil language_tree Node
|
||||
--- and language tree for the location
|
||||
function M.get_node_at_cursor_start_of_line(only_languages, location)
|
||||
if not M.is_treesitter_active() then
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user