Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add comment toggling #14634

Closed
wants to merge 4 commits into from
Closed

Add comment toggling #14634

wants to merge 4 commits into from

Conversation

habamax
Copy link
Contributor

@habamax habamax commented Apr 25, 2024

Refers to #14626

@chrisbra
Copy link
Member

Thanks. Can you add this:

	vim9script
	import autoload 'dist/comment.vim'
	nnoremap <silent> <expr> gc comment.Toggle()
	xnoremap <silent> <expr> gc comment.Toggle()
	nnoremap <silent> <expr> gcc comment.Toggle() .. '_'

into a new file pack/dist/opt/comment/plugin/comment.vim?

Then we can add the following to the documentation:

 Load the plugin with this command: >
    packadd comment
<
This way you can use the plugin with the default key bindings `gc` and similar for commenting (which is a well-established mapping established in the Vim community). 

To have more control over the mappings used, add the following snippet to your .vimrc (assuming vim9 script): >
	vim9script
	import autoload 'dist/comment.vim'
	nnoremap <silent> <expr> gc comment.Toggle()
	xnoremap <silent> <expr> gc comment.Toggle()
	nnoremap <silent> <expr> gcc comment.Toggle() .. '_'

Something like this?

Can you please also add yourself in the header of the autoload script as upstream author? And please also as Codeowner. We may also need to update the Filelist

@clason
Copy link
Contributor

clason commented Apr 25, 2024

Would it make sense to move the autoload to pack/dist/opt/comment as well then?

@habamax
Copy link
Contributor Author

habamax commented Apr 25, 2024

It doesn't feel right to add help entry into filetype.txt though.

@clason
Copy link
Contributor

clason commented Apr 26, 2024

It doesn't feel right to add help entry into filetype.txt though.

We put it in various.txt: https://github.com/neovim/neovim/blob/a736e845a48c5ccdcfeb4ea485aa859a04b35d59/runtime/doc/various.txt#L560-L597

@chrisbra
Copy link
Member

Thanks. I would move it to around here:

so it's close to the editorconfig and matchit install instructions.

We should also document the use of 'commentstring' option. Also that it won't do anything if this option isn't set for a particular filetype and how to set this to make gc work. The Neovim doc looks quite clear in this regard.

I am wondering, whether we should add help-tags for gc. That will certainly conflict with tpopes commentary plugin. So not sure if this is a particular good idea or not.

@clason
Copy link
Contributor

clason commented Apr 26, 2024

I am wondering, whether we should add help-tags for gc. That will certainly conflict with tpopes commentary plugin. So not sure if this is a particular good idea or not.

We did, because otherwise :h gc won't work because there are tags with a higher score. And conflicts (E154) are only triggered by duplicate tags in the same directory? @zeertzjq

@zeertzjq
Copy link
Member

zeertzjq commented Apr 26, 2024

Since this is an optional plugin, maybe mapping tags like gc should be added to runtime/pack/dist/opt/comment/doc/ instead (like matchit), so that they are only found when the plugin is loaded.

@Shane-XB-Qian
Copy link
Contributor

Shane-XB-Qian commented Apr 26, 2024 via email

@habamax
Copy link
Contributor Author

habamax commented Apr 26, 2024

We should also document the use of 'commentstring' option. Also that it won't do anything if this option isn't set for a particular filetype and how to set this to make gc work. The Neovim doc looks quite clear in this regard.

If it would wait another week or so, or anyone else would be able to add this documentation.

@chrisbra
Copy link
Member

please let the choice back to users, there lots wonderful vim plugins, it should be not possible to add them all within vim,
besides some users specifically may just like tpopes' commentary (e.g me), so that conflict may not be liked by amount of people.

It's completly optional. You will need to use packadd to use it. Or simply use your favorite other plugin. And it makes sense, to add the plugin specific documentation into the package itself.

Thanks

@Shane-XB-Qian
Copy link
Contributor

Shane-XB-Qian commented Apr 26, 2024 via email

@chrisbra chrisbra closed this in 5400a5d Apr 26, 2024
@chrisbra
Copy link
Member

Thanks all. I have included it and adjusted the documentation.

@habamax I made a simple change to the plugin, so that it doesn't error out for non-modifiable buffers:

if empty(&cms) || !&ma | return '' | endif

@ColinKennedy
Copy link
Contributor

Related: neovim/neovim#28176

@habamax
Copy link
Contributor Author

habamax commented Apr 26, 2024

Thanks, @chrisbra!

@girishji
Copy link
Contributor

Thank you, @habamax and @chrisbra :)

satorunooshie added a commit to satorunooshie/dotfiles that referenced this pull request Apr 28, 2024
thanks and bye tomtom/tcomment_vim

default added by vim/vim#14634
ychin added a commit to macvim-dev/macvim that referenced this pull request Sep 11, 2024
Updated to Vim 9.1.0727

This update mostly syncs to new upstream Vim version, along with small fixes.

Features
====================

New Vim features
--------------------

- Vim now supports the XDG Base Directory Specification. You can now put your
  vimrc and plugins in `~/.config/vim` intsead of `~/.vim` / ~/.vimrc`. See `:h
  xdg-base-dir`. v9.1.0327
- Auto completion
    - Matched text in a completion popup menu will now be highlighted v9.1.0476
    - Insert mode fuzzy completion (`:set completopt+=fuzzy`). v9.1.0463 / v9.1.0598
- New options:
    - `tabclose`: specifies tab closing behavior. v9.1.0572
    - `winfixbuf`: fixes a window to a buffer and prevent navigating away from
      it. v9.1.0147
- New functions:
    - `getregion()` / `getregionpos()`: Helps retrieve the text selected in a
      visual selection. v9.1.0120 v9.1.0142 v9.1.0394
    - `diff()`: Diff provided strings. v9.1.0071
    - `gettext()` / `bindtextdomain()`: Vim plugins can now add localized
      messages. v9.1.0509.
    - `filecopy()`: Copy a file using Vim script. v9.1.0465
- New bundled optional plugins (use `packadd` to enable them):
    - comment: toggle code comments on/off. vim/vim#14634
    - nohlsearch: simple package to automatically set `nohlsearch`. vim/vim#15042
- Highlighting for diff files are back to normal. v9.1.0016
- Vim9 script improvements.
- Miscellaneous smoothscroll, termdebug, security fixes.
- Other platforms (these don't affect MacVim and included for reference only):
    - GTK Vim GUI can now also use <D-...> to map super keys, similar to MacVim
      for its Cmd key mappings. This should allow sharing cross-platform
      configs easier. v9.1.0058
    - Vim GUI now supports Wayland in Linux. v9.1.0064

Misc
--------------------

- When resizing MacVim, the title bar's message looks a little nicer now. #1488
  by @sfsam
- Copyright disclaimer in About MacVim no longer shows a year. #1497

General
====================

- Sparkle (updater for MacVim) is now updated to 2.6.4. For legacy builds it's
  now updated to 1.27.3.  #1494

Fixes
====================

- Fixed dragging tabs to reorder them resulting in a crash. #1499

Compatibility
====================

Requires macOS 10.9 or above. (10.9 - 10.12 requires downloading a
separate legacy build)

Script interfaces have compatibility with these versions:

- Lua 5.4
- Perl 5.30
- Python2 2.7
- Python3 3.9 or above
- Ruby 3.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants