3 Commits

Author SHA1 Message Date
mnikulin
a6fb2fcdf7 Merge 8608a214d1 into 66c07e4083 2024-10-22 11:09:01 -04:00
Kelvin Davis
66c07e4083 Added comments for typst (#538)
Some checks failed
Vint / vint (push) Has been cancelled
2024-10-22 16:38:52 +03:00
Maksim Nikulin
8608a214d1 toggle comment depends on previous line
like Ctrl+/ in pycharm, vscode and so on
2023-11-26 22:31:49 +03:00
2 changed files with 7 additions and 5 deletions

View File

@@ -421,6 +421,7 @@ let s:delimiterMap = {
\ 'txt2tags': { 'left': '%' },
\ 'typescript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'typescriptreact': { 'left': '//', 'leftAlt': '{/*', 'rightAlt': '*/}' },
\ 'typst': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'uc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'uc4': { 'left': '!' },
\ 'uil': { 'left': '!' },
@@ -1022,7 +1023,8 @@ function! s:CommentLinesToggle(forceNested, firstLine, lastLine) abort
let currentLine = a:firstLine
let align = g:NERDDefaultAlign
let leftAlignIndx = align ==# 'start' ? 0 : s:LeftMostIndx(a:forceNested, 0, a:firstLine, a:lastLine)
let lookBehind = align ==# 'previous' && currentLine != 1 && s:IsCommentedFromStartOfLine(s:Left(), getline(currentLine - 1))
let leftAlignIndx = align ==# 'start' ? 0 : s:LeftMostIndx(a:forceNested, 0, a:firstLine - lookBehind, a:lastLine)
let rightAlignIndx = s:RightMostIndx(a:forceNested, 0, a:firstLine, a:lastLine)
let rightAlignIndx = rightAlignIndx + strlen(s:Left({'space': 1}))
@@ -1040,7 +1042,7 @@ function! s:CommentLinesToggle(forceNested, firstLine, lastLine) abort
let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine)
endif
if align ==# 'left' || align ==# 'start' || align ==# 'both'
if align ==# 'left' || align ==# 'start' || align ==# 'both' || align ==# 'previous'
let theLine = s:AddLeftDelimAligned(s:Left({'space': 1}), theLine, leftAlignIndx)
else
let theLine = s:AddLeftDelim(s:Left({'space': 1}), theLine)

View File

@@ -503,8 +503,8 @@ change the filetype back: >
style sexy comments.
|'NERDDefaultAlign'| Specifies the default alignment to use,
one of 'none', 'left', 'start', or
'both'.
one of 'none', 'left', 'start', 'both'
or 'previous'.
|'NERDToggleCheckAllLines'| Enable NERDCommenterToggle to check
all selected lines is commented or not.
@@ -784,7 +784,7 @@ deleted when uncommenting a line.
------------------------------------------------------------------------------
*'NERDDefaultAlign'*
Values: 'none', 'left', 'start', 'both'
Values: 'none', 'left', 'start', 'both', 'previous'.
Default 'none'.
Specifies the default alignment to use when inserting comments.