mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-12 17:55:41 +08:00
Add more key bindings for tsx file (#4043)
This commit is contained in:
parent
5c74535428
commit
0b77e2279d
@ -44,12 +44,16 @@ function! SpaceVim#layers#lang#typescript#config() abort
|
||||
augroup SpaceVim_lang_typescript
|
||||
autocmd!
|
||||
autocmd FileType typescript setlocal omnifunc=tsuquyomi#complete
|
||||
" Does tsuquyomi support tsx file?
|
||||
autocmd FileType typescriptreact setlocal omnifunc=tsuquyomi#complete
|
||||
augroup END
|
||||
endif
|
||||
call SpaceVim#mapping#gd#add('typescript',
|
||||
\ function('s:go_to_def'))
|
||||
\ function('s:go_to_typescript_def'))
|
||||
call SpaceVim#mapping#gd#add('typescriptreact',
|
||||
\ function('s:go_to_typescriptreact_def'))
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('typescript',
|
||||
\ function('s:on_ft'))
|
||||
\ function('s:on_typescript_ft'))
|
||||
call SpaceVim#plugins#repl#reg('typescript', ['ts-node', '-i'])
|
||||
call SpaceVim#plugins#runner#reg_runner('typescript', {
|
||||
\ 'exe' : 'ts-node',
|
||||
@ -57,6 +61,13 @@ function! SpaceVim#layers#lang#typescript#config() abort
|
||||
\ 'opt': [],
|
||||
\ })
|
||||
let g:neomake_typescript_enabled_makers = ['eslint']
|
||||
" does eslint support tsx?
|
||||
let g:neoformat_typescriptreact_prettier = {
|
||||
\ 'exe': 'prettier',
|
||||
\ 'args': ['--stdin', '--stdin-filepath', '"%:p"', '--parser', 'typescript'],
|
||||
\ 'stdin': 1
|
||||
\ }
|
||||
let g:neoformat_enabled_typescriptreact = ['prettier']
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#lang#typescript#set_variable(var) abort
|
||||
@ -71,9 +82,10 @@ function! SpaceVim#layers#lang#typescript#set_variable(var) abort
|
||||
let g:tsuquyomi_tsserver_path = tsserver_path
|
||||
endif
|
||||
endif
|
||||
let g:jsdoc_lehre_path = get(a:var, 'lehre_path', 'lehre')
|
||||
endfunction
|
||||
|
||||
function! s:on_ft() abort
|
||||
function! s:on_typescript_ft() abort
|
||||
if SpaceVim#layers#lsp#check_filetype('typescript')
|
||||
nnoremap <silent><buffer> K :call SpaceVim#lsp#show_doc()<CR>
|
||||
|
||||
@ -136,7 +148,7 @@ function! s:on_ft() abort
|
||||
|
||||
endfunction
|
||||
|
||||
function! s:go_to_def() abort
|
||||
function! s:go_to_typescript_def() abort
|
||||
if !SpaceVim#layers#lsp#check_filetype('typescript')
|
||||
if has('nvim')
|
||||
TSDef
|
||||
@ -147,3 +159,14 @@ function! s:go_to_def() abort
|
||||
call SpaceVim#lsp#go_to_def()
|
||||
endif
|
||||
endfunction
|
||||
function! s:go_to_typescriptreact_def() abort
|
||||
if !SpaceVim#layers#lsp#check_filetype('typescriptreact')
|
||||
if has('nvim')
|
||||
TSDef
|
||||
else
|
||||
call SpaceVim#lsp#go_to_def()
|
||||
endif
|
||||
else
|
||||
call SpaceVim#lsp#go_to_def()
|
||||
endif
|
||||
endfunction
|
||||
|
@ -8,9 +8,8 @@ description: "This layer is for TypeScript development, includding code completi
|
||||
<!-- vim-markdown-toc GFM -->
|
||||
|
||||
- [Description](#description)
|
||||
- [Install](#install)
|
||||
- [Features](#features)
|
||||
- [Layer configuration](#layer-configuration)
|
||||
- [Installation](#installation)
|
||||
- [Layer options](#layer-options)
|
||||
- [Key bindings](#key-bindings)
|
||||
- [Code runner](#code-runner)
|
||||
- [Inferior REPL process](#inferior-repl-process)
|
||||
@ -19,9 +18,9 @@ description: "This layer is for TypeScript development, includding code completi
|
||||
|
||||
## Description
|
||||
|
||||
This layer is for TypeScript development, includding code completion, Syntax lint and doc generation.
|
||||
This layer is for TypeScript development, includding code completion, syntax lint and doc generation.
|
||||
|
||||
## Install
|
||||
## Installation
|
||||
|
||||
To use this configuration layer, update custom configuration file with:
|
||||
|
||||
@ -30,25 +29,16 @@ To use this configuration layer, update custom configuration file with:
|
||||
name = "lang#typescript"
|
||||
```
|
||||
|
||||
BTW, you need to install TypeScript via:
|
||||
To generate doc of typescript file, you need to install [lehre](https://www.npmjs.com/package/lehre)
|
||||
|
||||
```sh
|
||||
npm install -g typescript
|
||||
```
|
||||
yarn add -D lehre
|
||||
```
|
||||
|
||||
## Features
|
||||
## Layer options
|
||||
|
||||
- auto-completion
|
||||
- syntax checking
|
||||
- viewing documentation
|
||||
- type-signature
|
||||
- goto definition
|
||||
- refernce finder
|
||||
- lsp support
|
||||
|
||||
## Layer configuration
|
||||
|
||||
`typescript_server_path`: set the path of the tsserver.
|
||||
- `typescript_server_path`: set the path of the tsserver.
|
||||
- `lehre_path`: set the path of lehre
|
||||
|
||||
## Key bindings
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user