Comments (5)
Update: it appears I am calling the pre
hook correctly, as I am able to print out a debug message when I attempt to comment a message. Here's what my mini.comment
plugin looks like:
-- lua/plugins/minicomment.lua
return {
"echasnovski/mini.comment",
dependencies = {
"nvim-treesitter/nvim-treesitter",
},
opts = {
hooks = {
pre = function()
print("Successfully calling pre hook function...")
require("ts_context_commentstring.internal").update_commentstring()
end,
},
},
}
and here is my nvim-treesitter
plugin customization:
-- lua/plugins/nvim-treesitter.lua
return {
"nvim-treesitter/nvim-treesitter",
dependencies = {
"JoosepAlviste/nvim-ts-context-commentstring",
},
opts = {
context_commentstring = {
enable = true,
enable_autocmd = false,
config = {
c = "// %s",
cpp = "// %s",
},
},
},
}
So I am inclined to think my call to require("ts_context_commentstring.internal").update_commentstring()
isn't working as intended.
from nvim-ts-context-commentstring.
Hey @krishna-bala! The configuration looks correct to me. I haven't used LazyVim though, so I'm not sure if there are any special steps that need to be taken.
update_commentstring()
does accept 1 argument with extra options, but it isn't required. I think that we should update the function docs to set it as optional. The code docs could be improved in general.
Here are some questions and things to try:
- What file type are you trying this out in?
- If you manually call
:=require('ts_context_commentstring.internal').calculate_commentstring()
, then does that output the correct commentstring?
from nvim-ts-context-commentstring.
Hi @JoosepAlviste, thanks for the reply. I'm trying this on cpp
files (*.h, *.cc
). Manually calling :=require('ts_context_commentstring.internal').calculate_commentstring()
in a *.cc
file outputs the desired commentstring, // %s
. However, when I use mini.comment
to comment out a line it still implements the "default" commentstring that comes with mini.comment
, which is /* %s */
. I suspect I don't fully understand how the plugins are loaded in LazyVim and am implementing this incorrectly.
That being said, the mini.comment
maintainer suggested a workaround for my use case (described below).
Create a file after/ftplugin/<some-filetype>.lua
inside your Neovim config (e.g. ~/.config/nvim/
) and put this line there: vim.bo.commentstring = '<some-commentstring>'
e.g.
-- ~/.config/nvim/after/ftplugin/c.lua
vim.bo.commentstring = '<some-commentstring>'
from nvim-ts-context-commentstring.
Not really sure if this is helpful for this situation, but I was having issues with mini.comment
in the past weeks as well. It changed to commentstring from tree-sitter which caused some issues with some filetypes. I opened an issue on this and I got a recommended a new way of setting up nvim-ts-context-commentstring
: echasnovski/mini.nvim#342
from nvim-ts-context-commentstring.
Thanks for letting me know, @victornswd! I've updated the integration instructions in the wiki: https://github.com/JoosepAlviste/nvim-ts-context-commentstring/wiki/Integrations#minicomment
Hopefully this solves the issue. Feel free to re-open if there are still problems with this.
from nvim-ts-context-commentstring.
Related Issues (20)
- Svelte only returns html-comment for all locations HOT 2
- Need help in debugging strange situation HOT 1
- Work-around to make this work with native comments in Neovim 0.10 HOT 4
- Incorrect commentstring for erb tags on eruby files
- Incorrect commentstring inside <?php ?> tags HOT 1
- Option 'commentstring' is empty in .swift file HOT 3
- Does this work well when nvim-treesitter 1.0 is out? HOT 4
- plugin cause j/k position incorrect HOT 6
- tsx is not properly commenting HOT 8
- Vue comment not working properly HOT 2
- This plugin doesn't set the `comments` var. HOT 2
- BREAKING CHANGES HOT 6
- Incorrent commentstring for inline markdown code blocks HOT 4
- `set ft?` return `filetype=on` and causing losing syntax highlighting HOT 5
- Commenting is slow in large Markdown files HOT 3
- context_commentstring nvim-treesitter module is deprecated HOT 2
- tsx is not properly commenting even when ts-context-commentstring works HOT 1
- Please do not create unnecessary global variables
- Vue comment js/ts using html comment tags HOT 2
- Doesn't work ootb with mini.comment / Comment.nvim (React) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nvim-ts-context-commentstring.