From bcbadda8d00df6d2149c81121c535e4bc9a064cb Mon Sep 17 00:00:00 2001 From: Jonas Ryssel Date: Thu, 19 Oct 2023 11:04:09 +0200 Subject: [PATCH] Support both html and javascript commentstrings in vue files --- init.vim | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/init.vim b/init.vim index c60ed21..bafcfae 100644 --- a/init.vim +++ b/init.vim @@ -798,6 +798,18 @@ EOF " Configure Vim-Commentary augroup CustomCommentDefinitions + function! SetCommentString() + let syntaxGroups = map(synstack(line('.'), col('.')), 'synIDattr(v:val,"name")') + " echo syntaxGroups " enable when debugging + if &ft == 'vue' + if join(syntaxGroups, ',') =~ 'html' + setlocal commentstring= + elseif join(syntaxGroups, ',') =~ 'javascript' + setlocal commentstring=\/\/\ %s + endif + endif + endfunction + autocmd! autocmd FileType matlab setlocal commentstring=%\ %s autocmd FileType julia setlocal commentstring=#\ %s @@ -808,6 +820,9 @@ augroup CustomCommentDefinitions autocmd FileType nix setlocal commentstring=#\ %s autocmd FileType dot setlocal commentstring=\/\/\ %s autocmd FileType markdown setlocal commentstring= + autocmd FileType html.epl setlocal commentstring=%#\ %s + autocmd FileType vue execute 'autocmd CustomCommentDefinitions CursorMoved :call SetCommentString()' + " autocmd CursorMoved * :call SetCommentString() augroup END " NCM2