local status_ok_configs, nvim_treesitter_configs = pcall(require, 'nvim-treesitter.configs')
if not status_ok_configs then
return
end
local status_ok_install, nvim_treesitter_install = pcall(require, 'nvim-treesitter.install')
if not status_ok_install then
return
end
-- cc for linux, gcc for windows
nvim_treesitter_install.compilers = { "cc", "gcc" }
-- See `:help nvim-treesitter`
-- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}'
vim.defer_fn(function()
nvim_treesitter_configs.setup {
-- Add languages to be installed here that you want installed for treesitter
-- https://github.com/nvim-treesitter/nvim-treesitter?tab=readme-ov-file#supported-languages
ensure_installed = {
'tsx'
},
-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,
highlight = { enable = true },
indent = { enable = true },
incremental_selection = {
enable = true,
keymaps = {
init_selection = '<c-space>',
node_incremental = '<c-space>',
scope_incremental = '<c-s>',
node_decremental = '<M-space>',
},
},
textobjects = {
select = {
enable = true,
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
keymaps = {
-- You can use the capture groups defined in textobjects.scm
['aa'] = '@parameter.outer',
['ia'] = '@parameter.inner',
['af'] = '@function.outer',
['if'] = '@function.inner',
['ac'] = '@class.outer',
['ic'] = '@class.inner',
},
},
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
[']m'] = '@function.outer',
[']]'] = '@class.outer',
},
goto_next_end = {
[']M'] = '@function.outer',
[']['] = '@class.outer',
},
goto_previous_start = {
['[m'] = '@function.outer',
['[['] = '@class.outer',
},
goto_previous_end = {
['[M'] = '@function.outer',
['[]'] = '@class.outer',
},
},
swap = {
enable = true,
swap_next = {
['<leader>a'] = '@parameter.inner',
},
swap_previous = {
['<leader>A'] = '@parameter.inner',
},
},
},
}
end, 0)
comment.lua
local status_ok_comment, comment = pcall(require, 'Comment')
if not status_ok_comment then
return
end
local status_ok_ts_context_commentstring, ts_context_commentstring = pcall(require, 'ts_context_commentstring')
if not status_ok_ts_context_commentstring then
return
end
local status_ok_ts_context_commentstring_integration_comment, ts_context_commentstring_integration_comment = pcall(require, 'ts_context_commentstring.integrations.comment_nvim')
if not status_ok_ts_context_commentstring_integration_comment then
return
end
ts_context_commentstring.setup {
enable_autocmd = false,
}
comment.setup {
---Function to call before (un)comment
pre_hook = ts_context_commentstring_integration_comment.create_pre_hook(),
}
When I run
:lua print(require('ts_context_commentstring.internal').calculate_commentstring())
I get {/* %s */}, which means it works, but the comment applied still forward slashes
Did I make a mistake somewhere in my config, or because I'm using nvim 0.9.4 (I saw a comment that someone using nvim 0.9.4 has the issue like mine)?
Hi, I'm using Comment.nvim and its integration with nvim-ts-context-commentstring to comment in tsx files I follow the docs and here's my config
plugin.lua
nvim_treesitter.lua
comment.lua
When I run
:lua print(require('ts_context_commentstring.internal').calculate_commentstring())
I get{/* %s */}
, which means it works, but the comment applied still forward slashesDid I make a mistake somewhere in my config, or because I'm using nvim 0.9.4 (I saw a comment that someone using nvim 0.9.4 has the issue like mine)?