Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
0314283
Use CompilerSet to set the makeprg using local/global settings
nelstrom Sep 20, 2017
dbe450d
Use line continuation to break up long line
nelstrom Sep 20, 2017
7843f89
Merge pull request #122 from nelstrom/compilerset-makeprg
leafgarland Sep 22, 2017
f348d52
Update typescript.vim
srishanbhattarai Oct 13, 2017
7476042
Added Installation-Wiki Link
Oct 22, 2017
0398d7f
Merge pull request #125 from JustinMcNamara74/installation-wiki-link
leafgarland Oct 24, 2017
fbd0e9e
Merge pull request #124 from srishanbhattarai/master
leafgarland Oct 24, 2017
be2efbb
Support numeric separator (i.e. 123_456)
rhysd Jan 11, 2018
ba0d89c
add support for binary and octal literals
rhysd Jan 11, 2018
af501dd
allow typed return values. Fixes #131.
Jan 13, 2018
f8a2fdb
Merge pull request #132 from alexluecke/return-type-131
leafgarland Jan 23, 2018
04e0d82
Merge pull request #130 from rhysd/bin-oct-literals
leafgarland Jan 23, 2018
1c3cb0c
fix integer literal
rhysd Mar 7, 2018
e25636b
Merge pull request #135 from rhysd/fix-int-lit
leafgarland Mar 8, 2018
f981a41
Split StorageClass keywords from Identifiers
chaucerbao Jun 27, 2018
648629c
Highlight unknown as typescriptType
pocke Jul 31, 2018
61a386b
Fix code points notation in string literals
rhysd Aug 8, 2018
4f3376a
Merge pull request #143 from chaucerbao/feature/use-storage-class
leafgarland Aug 14, 2018
d5066f4
Merge pull request #145 from pocke/unknown
leafgarland Aug 14, 2018
460676d
Merge pull request #146 from rhysd/codepoint-in-string
leafgarland Aug 15, 2018
f35c66b
add g:typescript_ignore_browserwords not to highlight browser things
rhysd Aug 8, 2018
aaf0d3e
add a section about customizing syntax highlighting
rhysd Aug 15, 2018
db131b8
Merge pull request #147 from rhysd/ignore-browser
leafgarland Aug 15, 2018
09091e8
added a small example of compiler options specification
dt-rush Oct 15, 2018
0e9d92e
Merge pull request #153 from dt-rush/master
leafgarland Oct 17, 2018
2db69f9
Fix Typo: gackgroundPosition -> backgroundPosition
AprilArcus Apr 8, 2019
f50fed4
Merge pull request #161 from AprilArcus/patch-1
leafgarland Apr 11, 2019
c91c4fc
Adding ! as logical operator
May 3, 2019
4eabcd5
Adding JSON as global object.
May 3, 2019
6b1872b
Merge pull request #162 from louib/add_negate_operator
leafgarland May 3, 2019
7704fac
Merge pull request #163 from louib/json_global_object
leafgarland May 3, 2019
1516ae4
Add installation method for recent versions of Vim.
Geoffrey-A Jun 20, 2019
5a319ea
Merge pull request #164 from Geoffrey-A/master
leafgarland Jun 23, 2019
83ad139
Add support for new typescriptreact filetype
iwikal Nov 28, 2019
09cf6a6
Updated installation instructions to working command line for Powershell
OminousWater Dec 4, 2019
efc0c33
Make sure to overwrite vim's built-in syntax highlighting
jonsmithers Dec 15, 2019
2ca6afd
Merge pull request #172 from OminousWater/master
leafgarland Dec 17, 2019
323232d
Remove trailing whitespace
pappasam Dec 19, 2019
3d9b0e5
typesciptFuncKeyword is Keyword, not Function
pappasam Dec 19, 2019
616186f
Merge pull request #174 from pappasam/fix-typescriptFuncKeyword
leafgarland Dec 19, 2019
857d6dd
Add closing '>' to containing groups
pappasam Jan 26, 2020
bec15a2
Merge pull request #176 from pappasam/INDENT_CORRECTLY_MULTILINE_GENE…
leafgarland Feb 12, 2020
17d85d8
Merge pull request #173 from jonsmithers/master
leafgarland Feb 13, 2020
1557953
exclamation character wrong group
z0rzi Mar 4, 2020
bf5bddd
fix: support all legal regex flags
nornagon Aug 20, 2020
b5b8641
Extend global objects with js and node keywords
Sep 7, 2020
7586ba2
Merge pull request #181 from patstockwell/extend-global-objects
leafgarland Sep 9, 2020
90405bb
Merge pull request #180 from nornagon/patch-1
leafgarland Sep 9, 2020
9f247d7
Merge pull request #179 from z0rzi/patch-1
leafgarland Sep 9, 2020
e0160e7
Fix wrong link
SeungUkLee Nov 9, 2020
9a34991
Merge pull request #171 from iwikal/typescriptreact
leafgarland Dec 8, 2020
67e81e4
Merge pull request #185 from SeungUkLee/fix-link
leafgarland Dec 8, 2020
ee61b96
Add nullish coalescing operator (??)
Dec 11, 2020
e95a020
Override neovim 0.5.0 and up's typescript support
binyomen Mar 6, 2022
f37c425
Merge pull request #193 from binyomen/nvim_override
leafgarland Mar 22, 2022
52f3ca3
Merge pull request #186 from andbar-ru/nullish_coalescing_operator
leafgarland Mar 22, 2022
d099d32
Fix undo_ftplugin
thatsmydoing May 11, 2023
31ede5a
Merge pull request #202 from thatsmydoing/patch-1
leafgarland May 11, 2023
169f678
fix: prefer default links except on ancient Vim versions
wincent Oct 7, 2023
eafdcf5
Merge pull request #203 from wincent/def-links
leafgarland Oct 8, 2023
e83ccab
Include alternatives to this syntax in README
leafgarland Feb 4, 2024
122daf8
add satisfies to keywords
slmjkdbtl Apr 8, 2024
eb4d90d
Merge pull request #206 from slmjkdbtl/add-keyword-satisfies
leafgarland Apr 30, 2024
1b19693
rm status from typescriptMessage
slmjkdbtl May 21, 2024
8d169e1
Merge pull request #207 from slmjkdbtl/rm-status-keyword
leafgarland May 21, 2024
5fc0e70
Add `using` as a recognized keyword
nvie Dec 11, 2024
4740441
Merge pull request #208 from nvie/patch-1
leafgarland Jan 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 40 additions & 4 deletions README.md
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,43 @@
Typescript Syntax for Vim
An old Typescript Syntax for Vim
=========================

---

NOTE: This Typescript syntax was created before Typescript's 1.0 release, more than a decade ago. I hope it
has been helpful but there are now other options available. Vim has included
[Typescript syntax](https://github.com/vim/vim/blob/master/runtime/syntax/typescript.vim) for some years,
which receives more frequent updates at its own [repository](https://github.com/HerringtonDarkholme/yats.vim).
Neovim can also use a [treesitter grammar](https://github.com/tree-sitter/tree-sitter-typescript) for highlighting.

---

Syntax file and other settings for [TypeScript](http://typescriptlang.org). The
syntax file is taken from this [blog
post](http://blogs.msdn.com/b/interoperability/archive/2012/10/01/sublime-text-vi-emacs-typescript-enabled.aspx).
syntax file was originally from this 2012 [blog
post](https://docs.microsoft.com/en-us/archive/blogs/interoperability/sublime-text-vi-emacs-typescript-enabled).

Checkout [Tsuquyomi](https://github.com/Quramy/tsuquyomi) for omni-completion
and other features for TypeScript editing.

Install
-------

The simplest way to install is via a Vim add-in manager such as
From Vim 8 onward, the plugin can be installed as simply as (Unix/Mac):
```
git clone https://github.com/leafgarland/typescript-vim.git ~/.vim/pack/typescript/start/typescript-vim
```

On Windows/Powershell, use the following:
```
git clone https://github.com/leafgarland/typescript-vim.git $home/vimfiles/pack/typescript/start/typescript-vim
```

For older versions of Vim, the simplest way to install is via a Vim add-in manager such as
[Plug](https://github.com/junegunn/vim-plug),
[Vundle](https://github.com/gmarik/vundle) or
[Pathogen](https://github.com/tpope/vim-pathogen/).

_See the [Installation Wiki](https://github.com/leafgarland/typescript-vim/wiki/Installation)_

### Pathogen

```
Expand DownExpand Up@@ -89,6 +111,10 @@ let g:typescript_compiler_binary = 'tsc'
let g:typescript_compiler_options = ''
```

These options will be passed to the binary as command arguments. For example,
if `g:typescript_compiler_binary = 'tsc'` and `g:typescript_compiler_options = '--lib es6'`,
`l:makeprg` will be: `tsc --lib es6 $* %`.

You can completely override this plugin's compiler settings with something like
this in your `.vimrc`, where you can set makeprg to whatever you want.

Expand All@@ -107,4 +133,14 @@ autocmd QuickFixCmdPost [^l]* nested cwindow
autocmd QuickFixCmdPost l* nested lwindow
```

Syntax highlighting
-------------------

Syntax highlighting for TypeScript can be customized by following variables.

- `g:typescript_ignore_typescriptdoc`: When this variable is defined, doccomments will not be
highlighted.
- `g:typescript_ignore_browserwords`: When this variable is set to `1`, browser API names such as
`window` or `document` will not be highlighted. (default to `0`)

![Obligatory screenshot](https://raw.github.com/leafgarland/typescript-vim/master/vimshot01.png)
12 changes: 11 additions & 1 deletion compiler/typescript.vim
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,16 @@ if exists(":CompilerSet") != 2
command! -nargs=* CompilerSet setlocal <args>
endif

let &l:makeprg = g:typescript_compiler_binary . ' ' . g:typescript_compiler_options . ' $* %'
let s:cpo_save = &cpo
set cpo-=C

execute 'CompilerSet makeprg='
\ . escape(g:typescript_compiler_binary, ' ')
\ . '\ '
\ . escape(g:typescript_compiler_options, ' ')
\ . '\ $*\ %'

CompilerSet errorformat=%+A\ %#%f\ %#(%l\\\,%c):\ %m,%C%m

let &cpo = s:cpo_save
unlet s:cpo_save
1 change: 1 addition & 0 deletions compiler/typescriptreact.vim
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
runtime! compiler/typescript.vim
4 changes: 2 additions & 2 deletions ftplugin/typescript.vim
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,9 +13,9 @@ setlocal commentstring=//\ %s
" " and insert the comment leader when hitting <CR> or using "o".
setlocal formatoptions-=t formatoptions+=croql

setlocal suffixesadd+=.ts
setlocal suffixesadd+=.ts,.tsx

let b:undo_ftplugin = "setl fo< ofu< com< cms<"
let b:undo_ftplugin = "setl cms< fo< sua<"

let &cpo = s:cpo_save
unlet s:cpo_save
1 change: 1 addition & 0 deletions ftplugin/typescriptreact.vim
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
runtime! ftplugin/typescript.vim
7 changes: 4 additions & 3 deletions indent/typescript.vim
Original file line numberDiff line numberDiff line change
Expand Up@@ -169,7 +169,7 @@ endfunction
function s:PrevCodeLine(lnum)
let l:n = prevnonblank(a:lnum)
while l:n
if getline(l:n) =~ '^\s*\/[/*]'
if getline(l:n) =~ '^\s*\/[/*]'
if (stridx(getline(l:n),'`') > 0 || getline(l:n-1)[-1:] == '\') &&
\ s:syn_at(l:n,1) =~? s:syng_str
return l:n
Expand DownExpand Up@@ -293,8 +293,9 @@ function GetTypescriptIndent()
let l:line = ''
endif

" the containing paren, bracket, or curly. Many hacks for performance
let idx = index([']',')','}'],l:line[0])
" the containing paren, bracket, curly, or closing '>'.
" Many hacks for performance
let idx = index([']',')','}','>'],l:line[0])
if b:js_cache[0] >= l:lnum && b:js_cache[0] < v:lnum &&
\ (b:js_cache[0] > l:lnum || s:Balanced(l:lnum))
call call('cursor',b:js_cache[1:])
Expand Down
1 change: 1 addition & 0 deletions indent/typescriptreact.vim
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
runtime! indent/typescript.vim
Loading