Skip to content

Commit 19b4e24

Browse files
authored
fix undo mapping commands
- only append if there's already a command - use exe to unmap mappings
1 parent d93bcd5 commit 19b4e24

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

ftplugin/svelte.vim

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
if exists("b:did_ftplugin") | finish | endif
22
let b:did_ftplugin = 1
33

4-
let b:undo_ftplugin = get(b:, 'undo_ftplugin', '')
4+
" Indent correctly with template string for vim-javascript/builtin
5+
" indentexpr
6+
let b:syng_str = '^\%(.*template\)\@!.*string\|special'
7+
let b:syng_strcom = '^\%(.*template\)\@!.*string\|comment\|regex\|special\|doc'
8+
9+
let b:undo_ftplugin = (exists('b:undo_ftplugin') ? b:undo_ftplugin . " | " : "") . "unlet b:syng_str b:syng_strcom"
510

611
if !has('nvim')
712
setlocal matchpairs+=<:>
@@ -16,24 +21,19 @@ if exists("loaded_matchit")
1621
\ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>,' .
1722
\ '{#\(if\|each\)[^}]*}:{\:else[^}]*}:{\/\(if\|each\)},' .
1823
\ '{#await[^}]*}:{\:then[^}]*}:{\/await},'
19-
let b:undo_ftplugin .= "| unlet b:match_ignorecase b:match_words"
24+
let b:undo_ftplugin .= " | unlet b:match_ignorecase b:match_words"
2025
endif
2126

22-
" Indent correctly with template string for vim-javascript/builtin
23-
" indentexpr
24-
let b:syng_str = '^\%(.*template\)\@!.*string\|special'
25-
let b:syng_strcom = '^\%(.*template\)\@!.*string\|comment\|regex\|special\|doc'
26-
let b:undo_ftplugin .= "| unlet b:syng_str b:syng_strcom"
27-
2827
if executable('npx') && !empty(globpath(&runtimepath, 'compiler/svelte-check.vim'))
2928
compiler svelte-check
30-
let b:undo_ftplugin .= "| compiler make"
29+
let b:undo_ftplugin .= " | compiler make"
3130
endif
3231
if exists(':Open') == 2
3332
" let &keywordprg = ':Open https://devdocs.io/\#q='..&filetype
3433
nnoremap <buffer> <expr> <F1> '<cmd>Open https://devdocs.io/\#q='..&filetype..' '..expand('<cword>')..'<CR>'
34+
let b:undo_ftplugin .= " | exe 'nunmap <buffer> <F1>'"
3535
if exists('*getregion')
3636
vnoremap <buffer> <expr> <F1> '<cmd>Open https://devdocs.io/\#q='..&filetype..' '..join(getregion(getpos('v'), getpos('.')))..'<CR>'
37+
let b:undo_ftplugin .= " | exe 'vunmap <buffer> <F1>'"
3738
endif
38-
let b:undo_ftplugin .= "| nunmap <buffer> <F1> | vnunmap <buffer> <F1>"
3939
endif

0 commit comments

Comments
 (0)