summaryrefslogtreecommitdiffstats
path: root/ftplugin
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2019-09-06 14:32:07 +0200
committerAdam Stankiewicz <sheerun@sher.pl>2019-09-06 14:32:07 +0200
commit84ec4eedcdd2892249b5369f91a6dd1d12fef2fc (patch)
tree6c9806851123656af2b71f6c6f5d89649442909c /ftplugin
parent66b769328c4511b2273f01c70de971c41f6964dd (diff)
downloadvim-polyglot-4.0.0.tar.gz
vim-polyglot-4.0.0.zip
Switch typescript provider, closes #428v4.0.0
Diffstat (limited to 'ftplugin')
-rw-r--r--ftplugin/tsx.vim15
-rw-r--r--ftplugin/typescript.vim67
2 files changed, 79 insertions, 3 deletions
diff --git a/ftplugin/tsx.vim b/ftplugin/tsx.vim
new file mode 100644
index 00000000..b6c76481
--- /dev/null
+++ b/ftplugin/tsx.vim
@@ -0,0 +1,15 @@
+if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'typescript') != -1
+ finish
+endif
+
+" modified from mxw/vim-jsx from html.vim
+if exists("loaded_matchit") && !exists('b:tsx_match_words')
+ let b:match_ignorecase = 0
+ let b:tsx_match_words = '(:),\[:\],{:},<:>,' .
+ \ '<\@<=\([^/][^ \t>]*\)[^>]*\%(/\@<!>\|$\):<\@<=/\1>'
+ let b:match_words = exists('b:match_words')
+ \ ? b:match_words . ',' . b:tsx_match_words
+ \ : b:tsx_match_words
+endif
+
+set suffixesadd+=.tsx
diff --git a/ftplugin/typescript.vim b/ftplugin/typescript.vim
index 705cb7cd..b3d4c9c4 100644
--- a/ftplugin/typescript.vim
+++ b/ftplugin/typescript.vim
@@ -2,6 +2,8 @@ if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'typescript') !=
finish
endif
+" set Vi-incompatible, compiler and commentstring
+
if exists("b:did_ftplugin")
finish
endif
@@ -17,9 +19,68 @@ setlocal commentstring=//\ %s
" " and insert the comment leader when hitting <CR> or using "o".
setlocal formatoptions-=t formatoptions+=croql
-setlocal suffixesadd+=.ts,.tsx
-
-let b:undo_ftplugin = "setl fo< ofu< com< cms<"
+" setlocal foldmethod=syntax
let &cpo = s:cpo_save
unlet s:cpo_save
+
+function! TsIncludeExpr(file)
+ if (filereadable(a:file))
+ return l:file
+ else
+ let l:file2=substitute(a:file,'$','/index.ts','g')
+ return l:file2
+ endif
+endfunction
+
+set path+=./node_modules/**,node_modules/**
+set include=import\_s.\\zs[^'\"]*\\ze
+set includeexpr=TsIncludeExpr(v:fname)
+set suffixesadd=.ts
+
+"
+" TagBar
+"
+let g:tagbar_type_typescript = {
+ \ 'ctagstype' : 'typescript',
+ \ 'kinds' : [
+ \ 'c:classes',
+ \ 'a:abstract classes',
+ \ 't:types',
+ \ 'n:modules',
+ \ 'f:functions',
+ \ 'v:variables',
+ \ 'l:varlambdas',
+ \ 'm:members',
+ \ 'i:interfaces',
+ \ 'e:enums'
+ \ ],
+ \ 'sro' : '.',
+ \ 'kind2scope' : {
+ \ 'c' : 'classes',
+ \ 'a' : 'abstract classes',
+ \ 't' : 'types',
+ \ 'f' : 'functions',
+ \ 'v' : 'variables',
+ \ 'l' : 'varlambdas',
+ \ 'm' : 'members',
+ \ 'i' : 'interfaces',
+ \ 'e' : 'enums'
+ \ },
+ \ 'scope2kind' : {
+ \ 'classes' : 'c',
+ \ 'abstract classes' : 'a',
+ \ 'types' : 't',
+ \ 'functions' : 'f',
+ \ 'variables' : 'v',
+ \ 'varlambdas' : 'l',
+ \ 'members' : 'm',
+ \ 'interfaces' : 'i',
+ \ 'enums' : 'e'
+ \ }
+\ }
+
+" In case you've updated/customized your ~/.ctags and prefer to use it.
+if get(g:, 'typescript_use_builtin_tagbar_defs', 1)
+ let g:tagbar_type_typescript.deffile = expand('<sfile>:p:h:h') . '/ctags/typescript.ctags'
+endif