mhartington / nvim-typescript

Typescript tooling for Neovim
615 stars 76 forks source link

E117: Unknown function: TSEchoMessage #235

Closed danbruegge closed 5 years ago

danbruegge commented 5 years ago

Problems summary

Open *.ts:

Error detected while processing FileType Autocommands for "typescript":                                                                                                       
E117: Unknown function: TSOnBufEnter                                                                                                                                          
Error detected while processing CursorMoved Autocommands for "*.ts":                                                                                                          
E117: Unknown function: TSCloseWindow                                                                                                                                         
Press ENTER or type command to continue 

Open *.tsx:

Error detected while processing CursorMoved Autocommands for "*.tsx":
Error detected while processing CursorHold Autocommands for "*.tsx":
E117: Unknown function: TSEchoMessage
Press ENTER or type command to continue

Expected

No error message.

Environment Information

Features: +acl +iconv +jemalloc +tui See ":help feature-compile"

system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info


## Provide a minimal vim rc with less than 50 lines (Required!)

```vim
" vim:fdm=marker
"
" =============================================================================
" vim-plug {{{
" =============================================================================

call plug#begin('~/.config/nvim/bundle')

" dependencies?!
Plug 'tomtom/tlib_vim'
Plug 'MarcWeber/vim-addon-mw-utils'

" visuals
Plug 'gruvbox-community/gruvbox'
Plug 'owickstrom/vim-colors-paramount'
Plug 'axvr/photon.vim'
Plug 'itchyny/lightline.vim'
Plug 'junegunn/goyo.vim'
Plug 'junegunn/limelight.vim'
Plug 'bounceme/poppy.vim'
Plug 'machakann/vim-highlightedyank'
Plug 'kshenoy/vim-signature'

" editor sugar
Plug 'w0rp/ale'
Plug 'vim-scripts/loremipsum'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-eunuch'
Plug 'tomtom/tcomment_vim'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'ntpeters/vim-better-whitespace'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'SirVer/ultisnips'
Plug 'mhinz/vim-startify'
Plug 'editorconfig/editorconfig-vim'
Plug 'mhinz/vim-signify'
Plug 'AaronLasseigne/yank-code'
Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] }
Plug 'manu-mannattil/vim-longlines'

" languages
Plug 'sheerun/vim-polyglot'
Plug 'carlitux/deoplete-ternjs', { 'do': 'npm -g install tern@0.21.0', 'for': ['javascript', 'javascript.jsx', 'typescript', 'typescript.jsx'] }
Plug 'mhartington/nvim-typescript', { 'do': ':!install.sh \| UpdateRemotePlugins', 'for': ['javascript', 'javascript.jsx', 'typescript', 'typescript.jsx'] }
Plug 'jparise/vim-graphql' " until this is resolved: https://github.com/sheerun/vim-polyglot/issues/387
Plug 'amadeus/vim-jsx', { 'for': ['javascript.jsx', 'typescript.jsx'] }
Plug 'amadeus/vim-xml', { 'for': ['javascript.jsx', 'typescript.jsx'] } " optional vim-jsx dependency
Plug 'mattn/emmet-vim', { 'for': ['html', 'javascript.jsx', 'typescript.jsx', 'css', 'scss'] }
Plug 'RRethy/vim-hexokinase'

call plug#end()

let g:plug_window = "enew"
let g:plug_pwindow = "vsplit new"

" }}}

" =============================================================================
" vim common {{{
" =============================================================================

    " filetype stuff
filetype on
filetype plugin on
filetype indent on

    " hide a unsaved buffer, so you can open a new buffer with :e
set hidden

    " don't update the display while executing macors
set lazyredraw

    " When the page starts to scroll, keep the cursor 8 lines from the top and
    " 8 lines from the bottom
set scrolloff=8

    " Better command-line completion
set wildignore+=*.dll,*.o,*.pyc,*.pyo,*.bak,*.exe,*.jpg,*.jpeg,*.png,*.gif
set wildignore+=*$py.class,*.class,*/*.dSYM/*,*.dylib,*.DAT,*.scssc
set wildignore+=*/node_modules/*

    " When completing by tag, show the whole tag, not just the funtion name
set showfulltag

    " move backup files to ~/.vim/sessions
set backupdir=~/.config/nvim/sessions
set dir=~/.config/nvim/sessions

set background=dark

    " theme specific settings before enable it with `colorscheme gruvbox`
let g:gruvbox_italic=1
let g:gruvbox_italicize_comments=1
let g:gruvbox_italicize_strings=1
let g:gruvbox_invert_selection=0
let g:gruvbox_contrast_dark='hard'
let g:gruvbox_contrast_light='hard'

    " fix hightlighting missspelled words:
    " https://github.com/morhetz/gruvbox/issues/175
let g:gruvbox_guisp_fallback = "fg"

colorscheme gruvbox

set completeopt=longest,menuone

    " Show partial commands in the last line of the screen
set showcmd

    " tabbing stuff
set expandtab
set shiftwidth=2
set softtabstop=2

    " indenting
set smartindent
set cindent

    " set relativenumber as default and switch if in insert mode to number
set number
set relativenumber
autocmd InsertEnter * :set norelativenumber
autocmd InsertLeave * :set relativenumber

    " set and display line ending
set ruler
set colorcolumn=80

    " a long line is just a long line
set nowrap

    " display/highlight current line
set cursorline

    " Set the command window height to 2 lines, to avoid many cases of having
    " to press <Enter> to continue"
set cmdheight=2

    " change options
set cpoptions+=$    " usefull when using `cw`. Adds a $ to the end of word

    " System default for mappings
let mapleader="\<Space>"

    " Open the help window on the Vertical Left side
autocmd FileType help wincmd L
autocmd FileType h wincmd L

    " Removes the delay after hiting <esc><S-o>
    " https://github.com/vim/vim/issues/24
    " It is related to terminal only. In gVim all is fine.
set timeout timeoutlen=3000 ttimeoutlen=100

    " disable 'ex' mode call
map Q <NOP>

    " Show invisibles
set list
set listchars=tab:»-,trail:·,eol:¬

    " set :substitute flag g to on
set gdefault

    " will open a split window with all searches of document from :substitute
set inccommand=split

" }}}

" =============================================================================
" Working with split windows {{{
" =============================================================================

    " Open a new empty vertical split and switch over to it
nnoremap <leader>n <c-w>n<c-w>L

    " Open a new empty horizontal split and switch to it
nnoremap <leader>N <c-w>n<c-w>J

    " Makes jumping between splited windows easier
nnoremap <a-h> <c-w>h
nnoremap <a-j> <c-w>j
nnoremap <a-k> <c-w>k
nnoremap <a-l> <c-w>l

" }}}

" =============================================================================
" Simple key mappings, that are time saver {{{
" =============================================================================

" vmap ------------------------------------------------------------------------
    " copy to system clipboard
vmap <leader>y "+y
    " small hack to highlight also the yanked code
xmap <Leader>Y :YankCode<CR>:call highlightedyank#highlight#add('HighlightedyankRegion', getpos("'<"), getpos("'>"), 'V', 1000)<CR>

" nmap ------------------------------------------------------------------------

nmap <leader>1 :w !wc -w<cr>

nmap [l :lprevious<cr>
nmap ]l :lnext<cr>

nmap <leader><cr> :Commands<cr>
nmap <leader>g :Goyo<cr>
nmap <leader>l :Limelight!!<cr>
nmap <leader>H :HexokinaseToggle<cr>
nmap <leader>f :BLines<cr>
nmap <leader>F :Lines<cr>

" nnoremap --------------------------------------------------------------------
    " Save file
nnoremap <leader>w :w<cr>

    " Open file
nnoremap <leader>o :Files<cr>
    " Open changed files from `git status`
nnoremap <leader>O :GFiles?<cr>

  " buffer stuff
nnoremap <leader>b :Buffers<cr>
nnoremap <c-c>c :bp\|bd #<cr>
nnoremap <c-c>a :%bd<cr>
nnoremap <Tab> :bnext<cr>
nnoremap <S-Tab> :bprevious<cr>
nnoremap <leader><leader> <c-^>

" vnoremap --------------------------------------------------------------------
    " search for visually selected text
vnoremap // y/<C-R>"<CR>

" mixed -----------------------------------------------------------------------
    " disable arrow keys
inoremap <Up> <NOP>
inoremap <Down> <NOP>
inoremap <Left> <NOP>
inoremap <Right> <NOP>
noremap <Up> <NOP>
noremap <Down> <NOP>

    " go hollow mode
let t:is_transparent = 0
function! Toggle_transparent()
    if t:is_transparent == 0
        hi Normal guibg=NONE ctermbg=NONE
        let t:is_transparent = 1
    else
        set background=dark
        let t:is_transparent = 0
    endif
endfunction
nnoremap <leader>h :call Toggle_transparent()<CR>

    " Simple sort lines
vmap <leader>s :sort<cr>
nmap <leader>si vi{:sort<cr>

" }}}

" =============================================================================
" Spellchecking {{{
" =============================================================================

nmap <silent> <f5> :set spell!<cr>

    " set default spellchecking to DE
setlocal spelllang=de_de

hi SpellBad cterm=underline

" }}}

" =============================================================================
" markdown settings {{{
" =============================================================================

autocmd FileType latex,tex,txt,md,markdown setlocal spell

map <leader>mh1 VypVr=
map <leader>mh2 VypVr-

" }}}

" =============================================================================
" Emmet settings {{{
" =============================================================================

    " enable all function in all mode.
let g:user_emmet_mode='a'

let g:user_emmet_settings = {
\  'typescript.jsx' : {
\      'extends' : 'jsx',
\  },
\  'javascript.jsx' : {
\      'extends' : 'jsx',
\  },
\  'jsx': {
\    'attribute_name': {'class': 'className'},
\  },
\}

    " quick emmet workaround to have css completion in javascript
function! ToggleJsxCssFt()
    if &filetype == 'javascript.jsx'
        set filetype=scss
    else
        set filetype=javascript.jsx
    endif
endfunction

nnoremap <leader>T :call ToggleJsxCssFt()<cr>

" }}}

" =============================================================================
" ALE stuff {{{
" =============================================================================

let g:ale_lint_on_text_changed = 0
let g:ale_linter_aliases = {'jsx': 'css'}
let g:ale_linters = {
    \ 'javascript': ['eslint'],
    \ 'javascript.jsx': ['eslint', 'stylelint'],
    \ 'typescript': ['eslint'],
    \ 'typescript.jsx': ['eslint', 'stylelint'],
\}

let g:ale_fix_on_save = 1
let g:ale_fixers = {
    \ 'javascript': ['prettier', 'eslint'],
    \ 'javascript.jsx': ['prettier', 'eslint'],
    \ 'json': ['prettier', 'eslint'],
    \ 'typescript': ['prettier', 'eslint'],
    \ 'typescript.jsx': ['prettier', 'eslint'],
    \ 'scss': ['prettier'],
    \ 'css': ['prettier'],
\}

let g:ale_javascript_prettier_use_local_config = 1

let g:ale_echo_msg_format = '%linter% says %s'

hi ALEError ctermbg=none cterm=underline
hi ALEWarning ctermbg=none cterm=underline
hi ALEInfo ctermbg=none cterm=underline

nmap <silent> gd :ALEGoToDefinition<CR>
nmap <silent> gr :ALEFindReferences<CR>
nmap <silent> gi :ALEHover<CR>

nmap <silent> <C-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-j> <Plug>(ale_next_wrap)

" }}}

" =============================================================================
" Lightline stuff {{{
" =============================================================================

set noshowmode

let g:lightline = {
    \ 'colorscheme': 'gruvbox',
    \ 'component': {
        \ 'readonly': '%{&readonly?"x":""}',
    \ },
    \ 'active': {
    \   'left': [ [ 'mode', 'paste' ],
    \             [ 'cocstatus', 'readonly', 'filename', 'modified' ] ]
    \ },
    \ 'component_function': {
        \ 'filename': 'LightLineFilename',
        \ 'cocstatus': 'coc#status'
    \ },
\ }

function! LightLineFilename()
  return expand('%')
endfunction

" }}}

" =============================================================================
" Deoplete stuff {{{
" =============================================================================

let g:deoplete#enable_at_startup = 1

let g:python3_host_prog = '/usr/bin/python3'
let g:deoplete#auto_complete_start_length = 1
let g:deoplete#enable_smart_case = 1

let g:deoplete#sources#ternjs#types = 1
let g:deoplete#sources#ternjs#expand_word_forward = 0
let g:deoplete#sources#ternjs#filetypes = [
  \ 'jsx',
  \ 'javascript',
  \ 'javascript.jsx',
  \ 'typescript',
  \ 'typescript.jsx',
\ ]

call deoplete#custom#source('_', 'matchers', ['matcher_full_fuzzy'])

" }}}

" =============================================================================
" Ripgrep stuff {{{
" =============================================================================

" search, but don't open the first result immediately
map <leader>r :Rg!<cr>

" }}}

" =============================================================================
" Startify stuff {{{
" =============================================================================

let g:startify_relative_path = 1
let g:startify_change_to_dir = 0

" }}}

" =============================================================================
" jsx stuff {{{
" =============================================================================

let g:jsx_ext_required = 0

" }}}

" =============================================================================
" css stuff {{{
" =============================================================================

augroup VimCSS3Syntax
  autocmd!

  autocmd FileType css setlocal iskeyword+=-
augroup END

" }}}

" =============================================================================
" editorconfig {{{
" =============================================================================

let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*']
let g:EditorConfig_exec_path = 'editorconfig'
let g:EditorConfig_core_mode = 'external_command'

" }}}

" =============================================================================
" goyo {{{
" =============================================================================

let g:goyo_width = 82
let g:goyo_linenr = 1

" }}}

" =============================================================================
" fzf.vim {{{
" =============================================================================

  " TODO: How can i avoid searching in filename
command! -bang -nargs=* Rg
  \ call fzf#vim#grep(
  \   'rg --column --line-number --no-heading --color=always -g="!yarn.lock" -g="!**/dist/*" '.shellescape(<q-args>), 1,
  \   <bang>0 ? fzf#vim#with_preview('up:60%')
  \           : fzf#vim#with_preview('right:50%:hidden', '?'),
  \   <bang>0)

" }}}

" =============================================================================
" poppy {{{
" =============================================================================

au! cursormoved * call PoppyInit()

" }}}

" =============================================================================
" limelight {{{
" =============================================================================

let g:limelight_conceal_ctermfg = 240

" }}}

" =============================================================================
" typescript {{{
" =============================================================================

autocmd BufNewFile,BufRead *.tsx set filetype=typescript.jsx

" }}}

" =============================================================================
" vim-gitgutter {{{
" =============================================================================

set updatetime=400

" }}}

" =============================================================================
" vim-signify {{{
" =============================================================================

let g:signify_vcs_list = [ 'git' ]

" }}}

" =============================================================================
" vim-which-key {{{
" =============================================================================

nnoremap <silent> <leader> :WhichKey '<Space>'<CR>

" }}}

" 
" Your minimal init.vim
set runtimepath+=~/path/to/nvim-typescript=============================================================================
" vim-jsx {{{
" =============================================================================

" disable vim-polyglot's jsx first to be sure it will not loaded
let g:polyglot_disabled = ['jsx']

" }}}

The reproduce ways from neovim starting

  1. open any ts/tsx file
laino commented 5 years ago

Run :UpdateRemotePlugins once, then restart vim.

That'll fix it.

danbruegge commented 5 years ago

Run :UpdateRemotePlugins once, then restart vim.

That'll fix it.

Sadly no, i tried several times with no success.

danbruegge commented 5 years ago

ok, really strange. I did run ./install.sh several times with no effect. Now it is working. Looks like the install.sh is ignored on plugin install...