44 Commits

Author SHA1 Message Date
Cristiano De Michele
b4a57a0b4f Merge c7c99edfb7 into 3f860f2d98 2024-08-08 12:33:56 +03:00
Caleb Maclennan
3f860f2d98 Merge pull request #531 from svalaskevicius/master 2024-08-08 12:33:49 +03:00
Igor Prusov
c9b1078807 Add delimeters fof Device Tree Source (DTS) files (#535) 2024-08-08 12:33:00 +03:00
Mark Huang
7bb1f72e80 Add comment delimiters to support aptconf (#533) 2024-05-13 13:37:01 +03:00
Sarunas Valaskevicius
fea637c3c2 Fix alternative delimiter usage in alternate buffers
Copy the configuration for a file rather than capture by reference.

Due to the logic in the alternative delimiter configurator, which swaps the
delimiters when called, every second buffer the script is used swaps the
delimiter order in the original config. This leads to incorrect
delimiters being used in every second buffer.

This change makes a copy for each buffer so swapping the order will not
affect the next loaded buffer.
2024-01-14 15:27:11 +00:00
Mark Huang
e361a44230 Add delimiter for pamenv (#530) 2023-12-18 22:49:10 +03:00
zhaoyunfeng
da948e160d fix: Ensure #Setup is run in #IsCharCommented (#527) 2023-11-02 14:24:05 +03:00
jwellhofer
c52b6e731c Add delimiters for Alloy files (#526)
Co-authored-by: Johannes Wellhöfer <johannes.wellhofer@gmail.com>
2023-10-23 11:47:28 +03:00
Christian Segundo
d2e21d417f feat: Add delimiter for HCL files (#525) 2023-08-13 01:12:53 +03:00
qizidog
ab2ae4d502 docs: Fix title numbering error in chapter-4 (#524) 2023-06-26 11:21:32 +03:00
Rich Churcher
844b211a4c Add Dart to supported languages (#523) 2023-06-26 11:19:48 +03:00
Krzysztof Leśniak
b0b09ea46c Fix use on VIM 8 with proper arguments to bufnr() (#521) 2023-06-05 11:34:33 +03:00
Christian Segundo
2045211689 Add support for jq filter files (#520) 2023-05-17 20:39:52 +03:00
Yuxin Wu
277bdfc679 fix: Reference current buffer not '1' re b:NERDCommenterFirstInit (#519) 2023-05-08 14:58:24 +03:00
YuyaKoda
1fe9e1cfea style: Remove stray whitespaces & normalize format (#517) 2023-04-26 18:20:01 +03:00
YuyaKoda
e23f55e735 feat: Add vcl (Varnish Configuration Language) (#516) 2023-04-26 16:46:33 +03:00
Yuxin Wu
91499c76a7 Prevent caching of buffer commentstring (#515)
Co-authored-by: Yuxin Wu <ppwwyyxx@users.noreply.github.com>
2023-04-21 09:44:44 +03:00
Caleb Maclennan
bd1a29536d Revert "Prevent caching of buffer commentstring (#514)"
This reverts commit 457b383767.
2023-04-20 19:50:28 +03:00
林千里
c6766698d8 Recompute indxLeft after line has changed (#507) 2023-04-20 19:44:06 +03:00
Hazael Sanchez
c5b0f78820 Add support for CEL (#512) 2023-04-20 19:42:45 +03:00
Yuxin Wu
78029a0e90 Fix support for embedded lua in vimscript (#513)
Co-authored-by: Yuxin Wu <ppwwyyxx@users.noreply.github.com>
2023-04-20 19:42:14 +03:00
Yuxin Wu
457b383767 Prevent caching of buffer commentstring (#514) 2023-04-20 19:38:56 +03:00
Chris
d069f7fb56 Update starkware cairo comments to latest syntax (#511) 2023-02-05 23:14:12 +03:00
Dmitrii Mishutin
06f6166e5d feat(dosbatch): change delimiters (#508) 2023-01-27 21:30:52 +03:00
Caleb Maclennan
c406bba57d Fix comment syntax blooper from #510 2023-01-27 17:00:07 +03:00
Konstantin-Glukhov
ea6a4f76fa Fix bug for unable to uncomment indented comments in vim files (#510)
Closes https://github.com/preservim/nerdcommenter/issues/491
2023-01-27 13:01:58 +03:00
Sankhesh Jhaveri
1caf560df1 Allow hooks to change filetype and comment deilmiters (#509)
Fixes https://github.com/preservim/nerdcommenter/pull/479
2023-01-26 20:57:08 +03:00
Caleb Maclennan
98cc4a2d64 Fixup manual install instructions to be complete
Closes #506

Co-authored-by: Yuri Schaeffer <yuri@schaeffer.tk>
2022-11-09 12:45:12 +03:00
Caleb Maclennan
f575c18d05 Release 2.7.0 (for those using releases, tracking upstream master is recommended) 2022-11-05 12:34:59 +03:00
Allen Guan
fd2114b46d Update outdated example code in readme (#504) 2022-10-29 12:40:51 +03:00
Brian Wo
fe74a1b890 Add support for Justfile (#503) 2022-10-11 10:03:52 +03:00
Brian Wo
60f3a2bc2b Add support for Svelte (#502) 2022-10-07 10:43:59 +03:00
Giuliano
2a0a05ff98 Add support for TLA+ modeling and specification language (#497) 2022-09-12 09:15:28 +03:00
Christian Segundo
6d30ebcd42 Add support for Zig (#492) 2022-05-20 23:15:25 +03:00
Caleb Maclennan
f8671f783b Add alternate delimiter to SILE format to ease switching to Lua 2022-02-24 23:22:41 +03:00
Chris
ec002e8f5d Add support for Starkware cairo (#487) 2022-02-12 17:08:52 +03:00
Caleb Maclennan
f9c5f0fbda Merge pull request #482 from tomtomjhj/insert 2022-01-15 21:13:53 +03:00
Jaehwang Jerry Jung
ac512fe158 Do not break undo sequence when moving cursor 2022-01-16 00:10:51 +09:00
Jaehwang Jerry Jung
867618364f Simplify and fix NERDCommenterInsert
* Simplify comment delimiter insertion.
* Remove the code that unnecessarily touches the leading spaces/tabs.
* Fix a bug in which `<Plug>NERDCommenterInsert` inserts the comment
  delimiters in a wrong position when `col('.')==1`.
  Example: `1|234` (cursor at `|`) → `/* */1234`.
* NOTE: Should avoid `feedkey(.., 'ni')` for inserting comment
  delimiters to ensure that `NERDCommenter_after` is called after
  inserting the delimiters. `feedkey` only adds the input to the queue,
  which will be processed after exiting the script context. On the other
  hand, `:normal` and `feedkey(.., 'x')` are eagerly processed.
2022-01-16 00:10:51 +09:00
Caleb Maclennan
97317fc319 Merge pull request #486 from phlip9/master 2022-01-15 15:51:20 +03:00
Philip Hayes
37298c471e Add support for ATS and Lean 2022-01-14 16:38:49 -08:00
Caleb Maclennan
9fffd4c022 Merge pull request #485 from ftfunjth/master 2021-12-28 13:31:54 +03:00
ftfunjth
2e7a775dd2 Add SetUp call in IsLineCommented function definition 2021-12-28 18:13:13 +08:00
Cristiano De Michele
c7c99edfb7 fix for C/C++ alternative comments 2021-11-10 18:19:33 +01:00
5 changed files with 91 additions and 116 deletions

View File

@@ -1,5 +1,12 @@
# Changelog # Changelog
### 2.7.0
* Support for many more filetypes
* Sort out race condition when using utility functions directly
* Fixup undo support when commenting results in cursor moves
* Refactor comment insertion code
### 2.6.0 ### 2.6.0
* Refactor code to run as autoload plugin * Refactor code to run as autoload plugin

View File

@@ -68,10 +68,12 @@ git clone https://github.com/preservim/nerdcommenter.git
(For Neovim, change `~/.vim/` to `~/.config/nvim/`.) (For Neovim, change `~/.vim/` to `~/.config/nvim/`.)
```sh ```sh
curl -fLo ~/.vim/plugin/NERD_Commenter.vim --create-dirs \ curl -fLo ~/.vim/plugin/nerdcommenter.vim --create-dirs \
https://raw.githubusercontent.com/preservim/nerdcommenter/master/plugin/nerdcommenter.vim https://raw.githubusercontent.com/preservim/nerdcommenter/master/plugin/nerdcommenter.vim
curl -fLo ~/.vim/doc/NERD_Commenter.txt --create-dirs \ curl -fLo ~/.vim/doc/nerdcommenter.txt --create-dirs \
https://raw.githubusercontent.com/preservim/nerdcommenter/master/doc/nerdcommenter.txt https://raw.githubusercontent.com/preservim/nerdcommenter/master/doc/nerdcommenter.txt
curl -fLo ~/.vim/autoload/nerdcommenter.vim --create-dirs \
https://raw.githubusercontent.com/preservim/nerdcommenter/master/autoload/nerdcommenter.vim
``` ```
</details> </details>
@@ -201,8 +203,8 @@ Most of the following mappings are for normal/visual mode only. The **|NERDComme
While the plugin does not directly support motions, you can leverage its support for selections to do something very similar. For example, to add motions to toggle comments on the paragraph text object you could use: While the plugin does not directly support motions, you can leverage its support for selections to do something very similar. For example, to add motions to toggle comments on the paragraph text object you could use:
```vim ```vim
nnoremap <silent> <leader>c} V}:call NERDComment('x', 'toggle')<CR> nnoremap <silent> <leader>c} V}:call nerdcommenter#Comment('x', 'toggle')<CR>
nnoremap <silent> <leader>c{ V{:call NERDComment('x', 'toggle')<CR> nnoremap <silent> <leader>c{ V{:call nerdcommenter#Comment('x', 'toggle')<CR>
``` ```
## Contributions ## Contributions

View File

@@ -15,6 +15,7 @@ let s:delimiterMap = {
\ 'ada': { 'left': '--', 'leftAlt': '-- ' }, \ 'ada': { 'left': '--', 'leftAlt': '-- ' },
\ 'ahdl': { 'left': '--' }, \ 'ahdl': { 'left': '--' },
\ 'ahk': { 'left': ';', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'ahk': { 'left': ';', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'alloy': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
\ 'amiga': { 'left': ';' }, \ 'amiga': { 'left': ';' },
\ 'aml': { 'left': '/*' }, \ 'aml': { 'left': '/*' },
\ 'ampl': { 'left': '#' }, \ 'ampl': { 'left': '#' },
@@ -23,6 +24,7 @@ let s:delimiterMap = {
\ 'apachestyle': { 'left': '#' }, \ 'apachestyle': { 'left': '#' },
\ 'apdl': { 'left': '!' }, \ 'apdl': { 'left': '!' },
\ 'applescript': { 'left': '--', 'leftAlt': '(*', 'rightAlt': '*)' }, \ 'applescript': { 'left': '--', 'leftAlt': '(*', 'rightAlt': '*)' },
\ 'aptconf': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'armasm': { 'left': ';' }, \ 'armasm': { 'left': ';' },
\ 'asciidoc': { 'left': '//' }, \ 'asciidoc': { 'left': '//' },
\ 'asm': { 'left': ';', 'leftAlt': '#' }, \ 'asm': { 'left': ';', 'leftAlt': '#' },
@@ -33,6 +35,7 @@ let s:delimiterMap = {
\ 'asterisk': { 'left': ';' }, \ 'asterisk': { 'left': ';' },
\ 'asy': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'asy': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'atlas': { 'left': 'C', 'right': '$' }, \ 'atlas': { 'left': 'C', 'right': '$' },
\ 'ats': { 'left': '//', 'leftAlt': '(*', 'rightAlt': '*)' },
\ 'augeas': { 'left': '(*', 'right': '*)' }, \ 'augeas': { 'left': '(*', 'right': '*)' },
\ 'autohotkey': { 'left': ';', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'autohotkey': { 'left': ';', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'autoit': { 'left': ';' }, \ 'autoit': { 'left': ';' },
@@ -49,9 +52,11 @@ let s:delimiterMap = {
\ 'btm': { 'left': '::' }, \ 'btm': { 'left': '::' },
\ 'c': { 'left': '/*', 'right': '*/', 'leftAlt': '//' }, \ 'c': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
\ 'cabal': { 'left': '--' }, \ 'cabal': { 'left': '--' },
\ 'cairo': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'calibre': { 'left': '//' }, \ 'calibre': { 'left': '//' },
\ 'caos': { 'left': '*' }, \ 'caos': { 'left': '*' },
\ 'catalog': { 'left': '--', 'right': '--' }, \ 'catalog': { 'left': '--', 'right': '--' },
\ 'cel': { 'left': '//' },
\ 'cf': { 'left': '<!---', 'right': '--->' }, \ 'cf': { 'left': '<!---', 'right': '--->' },
\ 'cfg': { 'left': '#' }, \ 'cfg': { 'left': '#' },
\ 'cg': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'cg': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
@@ -78,6 +83,7 @@ let s:delimiterMap = {
\ 'cython': { 'left': '# ', 'leftAlt': '#' }, \ 'cython': { 'left': '# ', 'leftAlt': '#' },
\ 'd': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'd': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'dakota': { 'left': '#' }, \ 'dakota': { 'left': '#' },
\ 'dart': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'dcl': { 'left': '$!' }, \ 'dcl': { 'left': '$!' },
\ 'debcontrol': { 'left': '#' }, \ 'debcontrol': { 'left': '#' },
\ 'debsources': { 'left': '#' }, \ 'debsources': { 'left': '#' },
@@ -85,11 +91,12 @@ let s:delimiterMap = {
\ 'desktop': { 'left': '#' }, \ 'desktop': { 'left': '#' },
\ 'dhcpd': { 'left': '#' }, \ 'dhcpd': { 'left': '#' },
\ 'diff': { 'left': '#' }, \ 'diff': { 'left': '#' },
\ 'dts': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
\ 'django': { 'left': '{% comment %}', 'right': '{% endcomment %}', 'leftAlt': '{#', 'rightAlt': '#}' }, \ 'django': { 'left': '{% comment %}', 'right': '{% endcomment %}', 'leftAlt': '{#', 'rightAlt': '#}' },
\ 'dns': { 'left': ';' }, \ 'dns': { 'left': ';' },
\ 'docbk': { 'left': '<!--', 'right': '-->' }, \ 'docbk': { 'left': '<!--', 'right': '-->' },
\ 'dockerfile': { 'left': '#' }, \ 'dockerfile': { 'left': '#' },
\ 'dosbatch': { 'left': 'REM ', 'leftAlt': '::' }, \ 'dosbatch': { 'left': 'REM ', 'nested': 1, 'leftAlt': 'REM ', 'nestedAlt': 1 },
\ 'dosini': { 'left': ';' }, \ 'dosini': { 'left': ';' },
\ 'dot': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'dot': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'dracula': { 'left': ';' }, \ 'dracula': { 'left': ';' },
@@ -157,6 +164,7 @@ let s:delimiterMap = {
\ 'haxe': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'haxe': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'hb': { 'left': '#' }, \ 'hb': { 'left': '#' },
\ 'hbs': { 'left': '{{!-- ', 'right': ' --}}' }, \ 'hbs': { 'left': '{{!-- ', 'right': ' --}}' },
\ 'hcl': { 'left': '#', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'hercules': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'hercules': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'hive': { 'left': '-- ' }, \ 'hive': { 'left': '-- ' },
\ 'hocon': { 'left': '//', 'leftAlt': '#' }, \ 'hocon': { 'left': '//', 'leftAlt': '#' },
@@ -188,17 +196,20 @@ let s:delimiterMap = {
\ 'jgraph': { 'left': '(*', 'right': '*)' }, \ 'jgraph': { 'left': '(*', 'right': '*)' },
\ 'jinja': { 'left': '{#', 'right': '#}', 'leftAlt': '<!--', 'rightAlt': '-->' }, \ 'jinja': { 'left': '{#', 'right': '#}', 'leftAlt': '<!--', 'rightAlt': '-->' },
\ 'jproperties': { 'left': '#' }, \ 'jproperties': { 'left': '#' },
\ 'jq': { 'left': '#' },
\ 'json5': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'json5': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'jsonc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'jsonc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'jsonnet': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'jsonnet': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'jsp': { 'left': '<%--', 'right': '--%>' }, \ 'jsp': { 'left': '<%--', 'right': '--%>' },
\ 'julia': { 'left': '# ', 'leftAlt': '#=', 'rightAlt': '=#' }, \ 'julia': { 'left': '# ', 'leftAlt': '#=', 'rightAlt': '=#' },
\ 'just' : { 'left': '#' },
\ 'kivy': { 'left': '#' }, \ 'kivy': { 'left': '#' },
\ 'kix': { 'left': ';' }, \ 'kix': { 'left': ';' },
\ 'kscript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'kscript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'lace': { 'left': '--' }, \ 'lace': { 'left': '--' },
\ 'laravel': { 'left': '{{--', 'right': '--}}' }, \ 'laravel': { 'left': '{{--', 'right': '--}}' },
\ 'ldif': { 'left': '#' }, \ 'ldif': { 'left': '#' },
\ 'lean': { 'left': '--', 'leftAlt': '/-', 'rightAlt': '-/' },
\ 'ledger': { 'left': '#', 'leftAlt': ';' }, \ 'ledger': { 'left': '#', 'leftAlt': ';' },
\ 'less': { 'left': '/*', 'right': '*/' }, \ 'less': { 'left': '/*', 'right': '*/' },
\ 'lhaskell': { 'left': '>{-', 'right': '-}', 'leftAlt': '>-- ' }, \ 'lhaskell': { 'left': '>{-', 'right': '-}', 'leftAlt': '>-- ' },
@@ -271,6 +282,7 @@ let s:delimiterMap = {
\ 'ox': { 'left': '//' }, \ 'ox': { 'left': '//' },
\ 'paludis-use-conf': { 'left': '#' }, \ 'paludis-use-conf': { 'left': '#' },
\ 'pandoc': { 'left': '<!--', 'right': '-->' }, \ 'pandoc': { 'left': '<!--', 'right': '-->' },
\ 'pamenv': { 'left': '#' },
\ 'pascal': { 'left': '{', 'right': '}', 'leftAlt': '(*', 'rightAlt': '*)' }, \ 'pascal': { 'left': '{', 'right': '}', 'leftAlt': '(*', 'rightAlt': '*)' },
\ 'patran': { 'left': '$', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'patran': { 'left': '$', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'pcap': { 'left': '#' }, \ 'pcap': { 'left': '#' },
@@ -342,7 +354,7 @@ let s:delimiterMap = {
\ 'sh': { 'left': '#' }, \ 'sh': { 'left': '#' },
\ 'shader_test': { 'left': '#' }, \ 'shader_test': { 'left': '#' },
\ 'sicad': { 'left': '*' }, \ 'sicad': { 'left': '*' },
\ 'sile': { 'left': '%' }, \ 'sile': { 'left': '%', 'leftAlt': '--' },
\ 'simula': { 'left': '%', 'leftAlt': '--' }, \ 'simula': { 'left': '%', 'leftAlt': '--' },
\ 'sinda': { 'left': '$' }, \ 'sinda': { 'left': '$' },
\ 'skill': { 'left': ';' }, \ 'skill': { 'left': ';' },
@@ -379,6 +391,7 @@ let s:delimiterMap = {
\ 'stan': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'stan': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'stp': { 'left': '/*', 'right': '*/', 'leftAlt': '//' }, \ 'stp': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
\ 'supercollider': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'supercollider': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'svelte': { 'left': '<!--', 'right': '-->' },
\ 'swift': { 'left': '/*', 'right': '*/', 'leftAlt': '//' }, \ 'swift': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
\ 'systemverilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'systemverilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'tads': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'tads': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
@@ -393,6 +406,7 @@ let s:delimiterMap = {
\ 'texmf': { 'left': '%' }, \ 'texmf': { 'left': '%' },
\ 'tf': { 'left': '#' }, \ 'tf': { 'left': '#' },
\ 'tidy': { 'left': '#' }, \ 'tidy': { 'left': '#' },
\ 'tla': { 'left': '\\*', 'leftAlt': '(*', 'rightAlt': '*)' },
\ 'tli': { 'left': '#' }, \ 'tli': { 'left': '#' },
\ 'tmux': { 'left': '#' }, \ 'tmux': { 'left': '#' },
\ 'toml': { 'left': '#' }, \ 'toml': { 'left': '#' },
@@ -414,6 +428,7 @@ let s:delimiterMap = {
\ 'vala': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'vala': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'vasp': { 'left': '!' }, \ 'vasp': { 'left': '!' },
\ 'vb': { 'left': "'" }, \ 'vb': { 'left': "'" },
\ 'vcl': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'velocity': { 'left': '##', 'right': '', 'leftAlt': '#*', 'rightAlt': '*#' }, \ 'velocity': { 'left': '##', 'right': '', 'leftAlt': '#*', 'rightAlt': '*#' },
\ 'vera': { 'left': '/*', 'right': '*/', 'leftAlt': '//' }, \ 'vera': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
\ 'verilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'verilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
@@ -436,7 +451,8 @@ let s:delimiterMap = {
\ 'xpm2': { 'left': '!' }, \ 'xpm2': { 'left': '!' },
\ 'xquery': { 'left': '(:', 'right': ':)' }, \ 'xquery': { 'left': '(:', 'right': ':)' },
\ 'yaml': { 'left': '#' }, \ 'yaml': { 'left': '#' },
\ 'z8a': { 'left': ';' } \ 'z8a': { 'left': ';' },
\ 'zig': { 'left': '//' }
\ } \ }
let g:NERDDelimiterMap = s:delimiterMap let g:NERDDelimiterMap = s:delimiterMap
@@ -453,10 +469,6 @@ endif
" This function is responsible for setting up buffer scoped variables for the " This function is responsible for setting up buffer scoped variables for the
" current buffer. " current buffer.
function! nerdcommenter#SetUp() abort function! nerdcommenter#SetUp() abort
if exists('b:NERDCommenterDelims')
return
endif
let filetype = &filetype let filetype = &filetype
"for compound filetypes, if we don't know how to handle the full filetype "for compound filetypes, if we don't know how to handle the full filetype
@@ -474,7 +486,7 @@ function! nerdcommenter#SetUp() abort
let b:NERDSexyComMarker = '' let b:NERDSexyComMarker = ''
if has_key(s:delimiterMap, filetype) if has_key(s:delimiterMap, filetype)
let b:NERDCommenterDelims = s:delimiterMap[filetype] let b:NERDCommenterDelims = copy(s:delimiterMap[filetype])
for i in ['left', 'leftAlt', 'right', 'rightAlt'] for i in ['left', 'leftAlt', 'right', 'rightAlt']
if !has_key(b:NERDCommenterDelims, i) if !has_key(b:NERDCommenterDelims, i)
let b:NERDCommenterDelims[i] = '' let b:NERDCommenterDelims[i] = ''
@@ -486,10 +498,10 @@ function! nerdcommenter#SetUp() abort
endif endif
endfor endfor
" if g:NERD_<filetype>_alt_style is defined, use the alternate style " if g:NERD_<filetype>_alt_style is defined, use the alternate style
let b:NERDCommenterFirstInit = getbufvar(1,'NERDCommenterFirstInit') let b:NERDCommenterFirstInit = getbufvar(bufnr('%'),'NERDCommenterFirstInit')
if exists('g:NERDAltDelims_'.filetype) && eval('g:NERDAltDelims_'.filetype) && !b:NERDCommenterFirstInit if exists('g:NERDAltDelims_'.filetype) && eval('g:NERDAltDelims_'.filetype) && !b:NERDCommenterFirstInit
call nerdcommenter#SwitchToAlternativeDelimiters(0)
let b:NERDCommenterFirstInit = 1 let b:NERDCommenterFirstInit = 1
call nerdcommenter#SwitchToAlternativeDelimiters(0)
endif endif
else else
let b:NERDCommenterDelims = s:CreateDelimMapFromCms() let b:NERDCommenterDelims = s:CreateDelimMapFromCms()
@@ -527,10 +539,10 @@ endfunction
" if this function changed the delimiters or not " if this function changed the delimiters or not
" function nerdcommenter#SwitchToAlternativeDelimiters(printMsgs) " function nerdcommenter#SwitchToAlternativeDelimiters(printMsgs)
function! nerdcommenter#SwitchToAlternativeDelimiters(printMsgs) abort function! nerdcommenter#SwitchToAlternativeDelimiters(printMsgs) abort
call nerdcommenter#SetUp()
if exists('*NERDCommenter_before') if exists('*NERDCommenter_before')
exe 'call NERDCommenter_before()' exe 'call NERDCommenter_before()'
endif endif
call nerdcommenter#SetUp()
"if both of the alternative delimiters are empty then there is no "if both of the alternative delimiters are empty then there is no
"alternative comment style so bail out "alternative comment style so bail out
if b:NERDCommenterDelims['leftAlt'] ==# '' && b:NERDCommenterDelims['rightAlt'] ==# '' if b:NERDCommenterDelims['leftAlt'] ==# '' && b:NERDCommenterDelims['rightAlt'] ==# ''
@@ -653,7 +665,7 @@ function! s:CommentBlock(top, bottom, lSide, rSide, forceNested) abort
"alternative delimiters (if THEY are) as the comment will be better and more "alternative delimiters (if THEY are) as the comment will be better and more
"accurate with multipart delimiters "accurate with multipart delimiters
let switchedDelims = 0 let switchedDelims = 0
if !s:Multipart() && g:NERDAllowAnyVisualDelims && s:AltMultipart() if !s:Multipart() && !g:NERDAllowAnyVisualDelims && s:AltMultipart()
let switchedDelims = 1 let switchedDelims = 1
call nerdcommenter#SwitchToAlternativeDelimiters(0) call nerdcommenter#SwitchToAlternativeDelimiters(0)
endif endif
@@ -1070,7 +1082,7 @@ function! s:CommentRegion(topLine, topCol, bottomLine, bottomCol, forceNested) a
"switch delimiters (if we can) if the current set isn't multipart "switch delimiters (if we can) if the current set isn't multipart
let switchedDelims = 0 let switchedDelims = 0
if !s:Multipart() && s:AltMultipart() && g:NERDAllowAnyVisualDelims if !s:Multipart() && s:AltMultipart() && !g:NERDAllowAnyVisualDelims
let switchedDelims = 1 let switchedDelims = 1
call nerdcommenter#SwitchToAlternativeDelimiters(0) call nerdcommenter#SwitchToAlternativeDelimiters(0)
endif endif
@@ -1153,6 +1165,7 @@ endfunction
" -lineNo: the line number of the line to check " -lineNo: the line number of the line to check
" Return: Number, 1 if the line is a comment, 0 else " Return: Number, 1 if the line is a comment, 0 else
function! nerdcommenter#IsLineCommented(lineNo) abort function! nerdcommenter#IsLineCommented(lineNo) abort
call nerdcommenter#SetUp()
let theLine = getline(a:lineNo) let theLine = getline(a:lineNo)
return s:IsInSexyComment(a:lineNo) || s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine) return s:IsInSexyComment(a:lineNo) || s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine)
endfunction endfunction
@@ -1167,10 +1180,10 @@ endfunction
" 'Minimal', 'Toggle', 'AlignLeft', 'AlignBoth', 'Comment', " 'Minimal', 'Toggle', 'AlignLeft', 'AlignBoth', 'Comment',
" 'Nested', 'ToEOL', 'Append', 'Insert', 'Uncomment', 'Yank' " 'Nested', 'ToEOL', 'Append', 'Insert', 'Uncomment', 'Yank'
function! nerdcommenter#Comment(mode, type) range abort function! nerdcommenter#Comment(mode, type) range abort
call nerdcommenter#SetUp()
if exists('*NERDCommenter_before') if exists('*NERDCommenter_before')
exe 'call NERDCommenter_before()' exe 'call NERDCommenter_before()'
endif endif
call nerdcommenter#SetUp()
let isVisual = a:mode =~# '[vsx]' let isVisual = a:mode =~# '[vsx]'
@@ -1303,15 +1316,16 @@ endfunction
" Function: nerdcommenter#IsCharCommented(line, col) abort " Function: nerdcommenter#IsCharCommented(line, col) abort
" Check if the character at [line, col] is inside a comment " Check if the character at [line, col] is inside a comment
" Note the Comment delimeter it self is considered as part of the comment " Note the Comment delimeter it self is considered as part of the comment
" "
" Args: " Args:
" -line the line number of the character " -line the line number of the character
" -col the column number of the character " -col the column number of the character
" Return: Number, 1 if the character is inside a comment, 0 if is not " Return: Number, 1 if the character is inside a comment, 0 if is not
function! nerdcommenter#IsCharCommented(line, col) abort function! nerdcommenter#IsCharCommented(line, col) abort
call nerdcommenter#SetUp()
" Function: s:searchfor(str, line, col, direction, [maxline]) " Function: s:searchfor(str, line, col, direction, [maxline])
" search str in the buffer, including the character at [line, col] " search str in the buffer, including the character at [line, col]
" Args: " Args:
" -str: the string for search " -str: the string for search
" -line: the line number where search begins " -line: the line number where search begins
" -col: the column number where search begins " -col: the column number where search begins
@@ -1379,14 +1393,14 @@ function! nerdcommenter#IsCharCommented(line, col) abort
let leftpos = s:searchfor(a:left, a:line, a:col, 1) let leftpos = s:searchfor(a:left, a:line, a:col, 1)
if leftpos == [0, 0] if leftpos == [0, 0]
if !blockcommented | let blockcommented = 0 | endif if !blockcommented | let blockcommented = 0 | endif
else else
" call s:searchfor(a:right, a:line, a:col, 0) " call s:searchfor(a:right, a:line, a:col, 0)
let rightpos = s:searchfor(a:right, leftpos[0], leftpos[1] + strlen(a:right) + 1, 0) let rightpos = s:searchfor(a:right, leftpos[0], leftpos[1] + strlen(a:right) + 1, 0)
if rightpos != [0, 0] if rightpos != [0, 0]
if rightpos[0] < a:line if rightpos[0] < a:line
if !blockcommented | let blockcommented = 0 | endif if !blockcommented | let blockcommented = 0 | endif
elseif rightpos[0] == a:line elseif rightpos[0] == a:line
if !blockcommented if !blockcommented
let blockcommented = (rightpos[1] + strlen(a:right) > a:col) ? 1 : 0 let blockcommented = (rightpos[1] + strlen(a:right) > a:col) ? 1 : 0
endif endif
else " rightpos > a:line else " rightpos > a:line
@@ -1400,14 +1414,14 @@ function! nerdcommenter#IsCharCommented(line, col) abort
return linecommented || blockcommented return linecommented || blockcommented
endfunction endfunction
return s:checkwith( return s:checkwith(
\ b:NERDCommenterDelims['left'], \ b:NERDCommenterDelims['left'],
\ b:NERDCommenterDelims['right'], \ b:NERDCommenterDelims['right'],
\ a:line, \ a:line,
\ a:col) || \ a:col) ||
\ s:checkwith( \ s:checkwith(
\ b:NERDCommenterDelims['leftAlt'], \ b:NERDCommenterDelims['leftAlt'],
\ b:NERDCommenterDelims['rightAlt'], \ b:NERDCommenterDelims['rightAlt'],
\ a:line, \ a:line,
\ a:col) \ a:col)
endfunction endfunction
@@ -1419,46 +1433,20 @@ function! s:PlaceDelimitersAndInsBetween() abort
let left = s:Left({'space': 1}) let left = s:Left({'space': 1})
let right = s:Right({'space': 1}) let right = s:Right({'space': 1})
let theLine = getline('.') " 0. Entered insert normal mode using <C-\><C-O> (:h i_CTRL-\_CTRL-O) to
let lineHasLeadTabs = s:HasLeadingTabs(theLine) || (theLine =~# '^ *$' && !&expandtab) " maintain the cursor position (from <Plug>NERDCommenterInsert).
" 1. Enter insert mode without changing the cursor position.
"convert tabs to spaces and adjust the cursors column to take this into " If the cursor is on EOL (right of the last char), use 'a'.
"account " Otherwise, use 'i'.
let untabbedCol = s:UntabbedCol(theLine, col('.')) let insert = col('.') > strlen(getline('.')) ? 'a' : 'i'
call setline(line('.'), s:ConvertLeadingTabsToSpaces(theLine)) " 2. Insert comment delimiters.
call cursor(line('.'), untabbedCol) " 3. Move the cursor to the left of the closing delimiter, without
" breaking undo sequence.
" get the length of the right delimiter " 4. Enter insert normal mode again without changing the cursor position.
let lenRight = strlen(right) " This ensures that returning to the insert mode after finishing the
" script execution does not move the cursor.
let isDelimOnEOL = col('.') >= strlen(getline('.')) " ( 1 ) ( 2 ) ( 3 ) ( 4 )
execute 'normal!' insert . left . right . repeat("\<C-G>U\<Left>", strchars(right)) . "\<C-\>\<C-O>"
" if the cursor is in the first col then we gotta insert rather than
" append the comment delimiters here
let insOrApp = (col('.')==1 ? 'i' : 'a')
" place the delimiters down. We do it differently depending on whether
" there is a left AND right delimiter
if lenRight > 0
execute ':normal! ' . insOrApp . left . right
execute ':normal! ' . lenRight . 'h'
else
execute ':normal! ' . insOrApp . left
endif
"if needed convert spaces back to tabs and adjust the cursors col
"accordingly
if lineHasLeadTabs
let tabbedCol = s:TabbedCol(getline('.'), col('.'))
call setline(line('.'), s:ConvertLeadingSpacesToTabs(getline('.')))
call cursor(line('.'), tabbedCol)
endif
if isDelimOnEOL && lenRight ==# 0
startinsert!
else
call feedkeys('a', 'ni')
endif
endfunction endfunction
" Function: s:RemoveDelimiters(left, right, line) " Function: s:RemoveDelimiters(left, right, line)
@@ -1784,6 +1772,8 @@ function! s:UncommentLineNormal(line) abort
endif endif
let indxLeft = s:FindDelimiterIndex(s:Left(), line)
let indxLeftAlt = s:FindDelimiterIndex(s:Left({'alt': 1}), line)
let indxLeftPlace = s:FindDelimiterIndex(g:NERDLPlace, line) let indxLeftPlace = s:FindDelimiterIndex(g:NERDLPlace, line)
let indxRightPlace = s:FindDelimiterIndex(g:NERDRPlace, line) let indxRightPlace = s:FindDelimiterIndex(g:NERDRPlace, line)
@@ -2546,15 +2536,15 @@ function! s:IsDelimValid(delimiter, delIndx, line) abort
"vim comments are so fucking stupid!! Why the hell do they have comment "vim comments are so fucking stupid!! Why the hell do they have comment
"delimiters that are used elsewhere in the syntax?!?! We need to check "delimiters that are used elsewhere in the syntax?!?! We need to check
"some conditions especially for vim "some conditions especially for vim.
if &filetype ==# 'vim' "Also check &commentstring because it may be overwritten for embedded lua.
if &filetype ==# 'vim' && &commentstring[0] ==# '"'
if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, '"', "\\")) if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, '"', "\\"))
return 0 return 0
endif endif
"if the delimiter is on the very first char of the line or is the " if the delimiter is the first non-whitespace character, it is valid
"first non-tab/space char on the line then it is a valid comment delimiter if a:line =~# '^\s*"'
if a:delIndx ==# 0 || a:line =~# "^\s\\{" . a:delIndx . "\\}\".*$"
return 1 return 1
endif endif
@@ -3019,18 +3009,6 @@ function! s:SwapOuterPlaceHoldersForMultiPartDelims(line) abort
return line return line
endfunction endfunction
" Function: s:TabbedCol(line, col)
" Gets the col number for given line and existing col number. The new col
" number is the col number when all leading spaces are converted to tabs
" Args:
" -line:the line to get the rel col for
" -col: the abs col
function! s:TabbedCol(line, col) abort
let lineTruncated = strpart(a:line, 0, a:col)
let lineSpacesToTabs = substitute(lineTruncated, s:TabSpace(), '\t', 'g')
return strlen(lineSpacesToTabs)
endfunction
"FUNCTION: s:TabSpace() "FUNCTION: s:TabSpace()
"returns a string of spaces equal in length to &tabstop "returns a string of spaces equal in length to &tabstop
function! s:TabSpace() abort function! s:TabSpace() abort
@@ -3051,15 +3029,3 @@ endfunction
function! s:UnEsc(str, escChar) abort function! s:UnEsc(str, escChar) abort
return substitute(a:str, a:escChar, '', 'g') return substitute(a:str, a:escChar, '', 'g')
endfunction endfunction
" Function: s:UntabbedCol(line, col)
" Takes a line and a col and returns the absolute column of col taking into
" account that a tab is worth 3 or 4 (or whatever) spaces.
" Args:
" -line:the line to get the abs col for
" -col: the col that doesn't take into account tabs
function! s:UntabbedCol(line, col) abort
let lineTruncated = strpart(a:line, 0, a:col)
let lineTabsToSpaces = substitute(lineTruncated, '\t', s:TabSpace(), 'g')
return strlen(lineTabsToSpaces)
endfunction

View File

@@ -66,7 +66,7 @@ creates a namespace so that custom commands don't interfere with Vim's
built-in shortcuts. built-in shortcuts.
The leader key can be mapped to whatever the user likes (see :help mapleader). The leader key can be mapped to whatever the user likes (see :help mapleader).
In the definition of custom commands |<Leader>| is the placeholder for the In the definition of custom commands |<Leader>| is the placeholder for the
leader key. To see the current mapping for |<Leader>| type :echo mapleader. leader key. To see the current mapping for |<Leader>| type :echo mapleader.
If it reports an undefined variable it means the leader key is set to the If it reports an undefined variable it means the leader key is set to the
default of '\'. default of '\'.
@@ -464,38 +464,38 @@ change the filetype back: >
|'NERDCustomDelimiters'| Add or override delimiters for any |'NERDCustomDelimiters'| Add or override delimiters for any
filetypes. filetypes.
|'NERDDefaultNesting'| Tells the script to use nested comments |'NERDDefaultNesting'| Tells the script to use nested comments
by default. by default.
|'NERDMenuMode'| Specifies how the NERD commenter menu |'NERDMenuMode'| Specifies how the NERD commenter menu
will appear (if at all). will appear (if at all).
|'NERDLPlace'| Specifies what to use as the left |'NERDLPlace'| Specifies what to use as the left
delimiter placeholder when nesting delimiter placeholder when nesting
comments. comments.
|'NERDUsePlaceHolders'| Specifies which filetypes may use |'NERDUsePlaceHolders'| Specifies which filetypes may use
placeholders when nesting comments. placeholders when nesting comments.
|'NERDRemoveAltComs'| Tells the script whether to remove |'NERDRemoveAltComs'| Tells the script whether to remove
alternative comment delimiters when alternative comment delimiters when
uncommenting. uncommenting.
|'NERDRemoveExtraSpaces'| Tells the script to always remove the |'NERDRemoveExtraSpaces'| Tells the script to always remove the
extra spaces when uncommenting extra spaces when uncommenting
(regardless of whether NERDSpaceDelims (regardless of whether NERDSpaceDelims
is set). is set).
|'NERDRPlace'| Specifies what to use as the right |'NERDRPlace'| Specifies what to use as the right
delimiter placeholder when nesting delimiter placeholder when nesting
comments. comments.
|'NERDSpaceDelims'| Specifies whether to add extra spaces |'NERDSpaceDelims'| Specifies whether to add extra spaces
around delimiters when commenting, and around delimiters when commenting, and
whether to remove them when whether to remove them when
uncommenting. uncommenting.
|'NERDTrimTrailingWhitespace'| Specifies if trailing whitespace |'NERDTrimTrailingWhitespace'| Specifies if trailing whitespace
should be deleted when uncommenting. should be deleted when uncommenting.
@@ -506,11 +506,11 @@ change the filetype back: >
one of 'none', 'left', 'start', or one of 'none', 'left', 'start', or
'both'. 'both'.
|'NERDToggleCheckAllLines'| Enable NERDCommenterToggle to check |'NERDToggleCheckAllLines'| Enable NERDCommenterToggle to check
all selected lines is commented or not. all selected lines is commented or not.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
4.3 Options details *NERDCommenterOptionsDetails* 4.2 Options details *NERDCommenterOptionsDetails*
To enable any of the below options you should put the given line in your To enable any of the below options you should put the given line in your
~/.vimrc ~/.vimrc
@@ -826,7 +826,7 @@ again.
Values: 0 or 1. Values: 0 or 1.
Default 0. Default 0.
When this option is set to 1, NERDCommenterToggle will check all selected line, When this option is set to 1, NERDCommenterToggle will check all selected line,
if there have oneline not be commented, then comment all lines. if there have oneline not be commented, then comment all lines.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
@@ -855,7 +855,7 @@ file by the following line >
< <
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3.3 Default delimiter customisation *NERDCommenterDefaultDelims* 4.3 Default delimiter customisation *NERDCommenterDefaultDelims*
If you want the NERD commenter to use the alternative delimiters for a If you want the NERD commenter to use the alternative delimiters for a
specific filetype by default then put a line of this form into your vimrc: > specific filetype by default then put a line of this form into your vimrc: >
@@ -901,15 +901,15 @@ NERDComment({mode}, {type}) *NERDComment()*
{mode}: character indicating the mode in which the comment {mode}: character indicating the mode in which the comment
is requested: is requested:
'n' for Normal mode, 'x' for Visual mode 'n' for Normal mode, 'x' for Visual mode
{type}: the type of commenting requested. Can be 'Sexy', {type}: the type of commenting requested. Can be 'Sexy',
'Invert', 'Minimal', 'Toggle', 'AlignLeft', 'Invert', 'Minimal', 'Toggle', 'AlignLeft',
'AlignBoth', 'Comment', 'Nested', 'ToEOL', 'Append', 'AlignBoth', 'Comment', 'Nested', 'ToEOL', 'Append',
'Insert', 'Uncomment', 'Yank' 'Insert', 'Uncomment', 'Yank'
NERDCommentIsCharCommented({line}, {col}) *NERDCommentIsCharCommented()* NERDCommentIsCharCommented({line}, {col}) *NERDCommentIsCharCommented()*
Check if the character at [{line}, {col}] is inside a comment Check if the character at [{line}, {col}] is inside a comment
Note the Comment delimeter it self is considered as part of the Note the Comment delimeter it self is considered as part of the
comment comment
Args: Args:

View File

@@ -125,7 +125,7 @@ function! NERDCommentIsCharCommented(line, col)
return nerdcommenter#IsCharCommented(a:line, a:col) return nerdcommenter#IsCharCommented(a:line, a:col)
endfunction endfunction
inoremap <silent> <Plug>NERDCommenterInsert <Space><BS><Esc>:call nerdcommenter#Comment('i', "insert")<CR> inoremap <silent> <Plug>NERDCommenterInsert <C-\><C-O>:call nerdcommenter#Comment('i', "Insert")<CR>
" switch to/from alternative delimiters (does not use wrapper function) " switch to/from alternative delimiters (does not use wrapper function)
nnoremap <Plug>NERDCommenterAltDelims :call nerdcommenter#SwitchToAlternativeDelimiters(1)<CR> nnoremap <Plug>NERDCommenterAltDelims :call nerdcommenter#SwitchToAlternativeDelimiters(1)<CR>