neoclide / coc.nvim

Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.
Other
24.33k stars 956 forks source link

coc-tsserver doesn't find .js files #1976

Closed IhsanE closed 4 years ago

IhsanE commented 4 years ago

Result from CocInfo

1 // @flow info 1 ## versions 2 3 vim version: VIM - Vi IMproved 8.2 8020800 4 node version: v14.3.0 5 coc.nvim version: 0.0.78-05f8f7bd71 6 term: iTerm.app 7 platform: darwin 8 9 ## Output channel: watchman 10 11 12 ## Output channel: tsserver 13 14 [Info - 10:42:39 PM] Forking TSServer 15 PATH: /usr/local/opt/openssl@1.1/bin:/usr/local/opt/openssl@1.1/bin:/usr/local/opt/openssl@1.1/bin:/usr/local/opt/openssl@1.1/bin:/usr/local/opt/openssl@1.1/bin:/u 16 [Info - 10:42:39 PM] Started TSServer 17 { 18 "path": "/Users/ietwaroo/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib", 19 "_pathLabel": "", 20 "_api": { 21 "versionString": "3.8.3", 22 "version": "3.8.3" 23 } 24 } 25 26 ~ ~

Describe the bug

When running coc-definition in a react file that ends with .js the go to definition functionality doesn't work. It says Definition not found.

The installation clearly says it works with .jsx/.tsx, but i'm wondering if there's a way to modify the settings to treat .js as .jsx? My project uses .js to reference all .jsx files, which is why I think it makes sense to support this functionality.

Reproduce the bug

We will close your issue when you don't provide minimal vimrc and we can't reproduce it

" 2017-07-12

" $$\ $$\ $$$$$$\ $$\ $$\ " $$ | $$ |_$$ |$$$\ $$$ | " $$ | $$ | $$ | $$$$\ $$$$ | " \$$\ $$ | $$ | $$\$$\$$ $$ | " \$$\$$ / $$ | $$ \$$$ $$ | " \$$$ / $$ | $$ |\$ /$$ | " \$ / $$$$$$\ $$ | _/ $$ | " _/ _____|_| _| "

" REQUIREMENT: VIM-PLUG " INSTALL: " (mac/linux) " " 1) curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim " 2) Restart vim " 3) Type :PlugInstall " 4) Things should be installing if you define your plugins as below

call plug#begin('~/.vim/plugged') Plug 'ap/vim-buftabline' Plug 'acoustichero/goldenrod.vim' Plug 'tpope/vim-fugitive' Plug 'tpope/vim-commentary' Plug 'tpope/vim-sleuth' Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' Plug 'kien/rainbow_parentheses.vim' Plug 'valloric/matchtagalways' Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } Plug 'junegunn/fzf.vim' Plug 'sheerun/vim-polyglot' Plug 'duganchen/vim-soy' Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'Ivo-Donchev/vim-react-goto-definition' call plug#end()

" REQUIREMENT: RipGrep " INSTALL: " (mac) " 1. brew install ripgrep " " (linux) " 1. curl https://sh.rustup.rs -sSf | sh " 2. cargo install ripgrep if executable('rg') " Use rg over grep set grepprg=rg\ --vimgrep\ --no-heading set grepformat=%f:%l:%c:%m,%f:%l:%m endif

" COMMAND: \t " DESCRIPTION: Launches fuzzy searcher nnoremap t :FZF

" COMMAND: :Find " DESCRIPTION: RipGreps across project for search term command! -bang -nargs= Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/" --color "always" '.shellescape(), 1, 0) nnoremap :Find :cw vnoremap y:Find ":cw

colorscheme goldenrod let g:airline_theme='dark' let &t_Co=256

let g:neocomplete#enable_at_startup = 1 let g:neocomplete#enable_smart_case = 1 let g:rbpt_colorpairs = [ \ ['brown', 'RoyalBlue3'], \ ['Darkblue', 'SeaGreen3'], \ ['darkgray', 'DarkOrchid3'], \ ['darkgreen', 'firebrick3'], \ ['darkcyan', 'RoyalBlue3'], \ ['darkred', 'SeaGreen3'], \ ['darkmagenta', 'DarkOrchid3'], \ ['brown', 'firebrick3'], \ ['gray', 'RoyalBlue3'], \ ['black', 'SeaGreen3'], \ ['darkmagenta', 'DarkOrchid3'], \ ['Darkblue', 'firebrick3'], \ ['darkgreen', 'RoyalBlue3'], \ ['darkcyan', 'SeaGreen3'], \ ['darkred', 'DarkOrchid3'], \ ['red', 'firebrick3'], \ ]

au VimEnter RainbowParenthesesToggle au Syntax RainbowParenthesesLoadRound au Syntax RainbowParenthesesLoadSquare au Syntax RainbowParenthesesLoadBraces

let g:mta_filetypes = { \ 'html' : 1, \ 'xhtml' : 1, \ 'xml' : 1, \ 'jinja' : 1, \ 'js' : 1, \ 'javascript' : 1, \ 'es6' : 1, }

"act similar to mswin applications, Control+C, Control+P, etc. behave mswin

"its ok to not be vi compatibale set nocompatible

"disable swap file creation set noswapfile

"don't create ~filename backups, very annoying to leave this on and find dozens of extra files scattered about set nobackup

"enable the mouse & features set mouse=a set selectmode-=mouse "Use the mouse just like visual mode, so you can use vim commands on mouse selections, eg. 'x' to cut and 'y' to yank

set backspace=2 "backspace works in insert mode, much more user-friendly set tabstop=4 "set tab width to 4 spaces set shiftwidth=4 "set (auto)tab's to width of 4 spaces "Neither of the above actually puts spaces into a file when tabbing, they simply display 4 spaces when a \t is read set ignorecase "ignore case when searching set hlsearch "highlight searchs set smartcase "override ignorecase if any search character is uppercase set autoindent "turn on auto indent set smartindent "turn on smart indent set number "show line numbers set nowrap "don't wrap lines longer than the screen's width set foldmethod=indent "fold code based on indents set nofoldenable "makes sure the code is not folded when first opened, used zi to toggle set ruler "Show line statistics in bottom left corner set scrolloff=4 "Keep 4 lines at minimum above & below the cursor when scrolling around a file

"Upgrade the status line to give more usefull information set statusline=%F\ %m%r%w%y\ %=(%L\ loc)\ [#\%03.3b\ 0x\%02.2B]\ \ %l,%v\ \ %P set laststatus=2 "Make statusline always on

"Enable filetype's filetype on filetype indent on filetype plugin on

if has("autocmd") " Have Vim jump to the last position when reopening a file au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g'\"" | endif endif set expandtab ts=4 sw=4 ai

autocmd FileType python set wrap|set tabstop=4|set shiftwidth=4|set softtabstop=4|set expandtab|set colorcolumn=120|set nosmartindent autocmd FileType c set ts=4|set sw=4|set noexpandtab autocmd FileType java set wrap|set colorcolumn=120 autocmd FileType javascript set wrap|set tabstop=4|set shiftwidth=4|set softtabstop=4|set colorcolumn=125|set expandtab autocmd FileType html set wrap|set tabstop=2|set shiftwidth=2|set softtabstop=2|set colorcolumn=|set expandtab autocmd BufNewFile,BufRead .lib set syntax=txt autocmd BufNewFile,BufRead .feature set wrap autocmd BufNewFile,BufRead *.es6 set syntax=javascript

:imap jj

" Delete trailing white space func! DWS() exe "normal mz" %s/\s+$//e exe "normal `z" endfunc

autocmd BufWrite .c :call DWS() autocmd BufWrite .h :call DWS() autocmd BufWrite .cc :call DWS() autocmd BufWrite .py :call DWS() autocmd BufWrite .java :call DWS() autocmd BufWrite .js :call DWS() autocmd BufWrite .feature :call DWS() autocmd BufWrite .python :call DWS() autocmd BufWrite *.scss :call DWS()

" Disable arrow keys nnoremap nnoremap nnoremap nnoremap nnoremap :bnext nnoremap :bprev

" When vimrc is edited, reload it autocmd! bufwritepost .vimrc source ~/.vimrc

set clipboard=unnamed set noshowmode syntax on set background=dark

ca F find ca S sort i

" GoTo code navigation. nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) noremap D :call ReactGotoDef()

augroup filetype_jsx autocmd! autocmd FileType javascript set filetype=javascriptreact augroup END



- Start (neo)vim with command: `vim -u mini.vim`

- Operate vim.

## Screenshots (optional)

If applicable, add screenshots to help explain your problem.

<img width="403" alt="Screen Shot 2020-05-21 at 10 49 39 PM" src="https://user-images.githubusercontent.com/5881221/82635602-5f640e00-9bb5-11ea-97f2-ea621ca82b9e.png">
chemzqm commented 4 years ago

https://github.com/neoclide/coc-tsserver#troubleshooting

it's expected that tsserver not always work on javascript files, use typescript is recommended.

chemzqm commented 4 years ago

Also read https://code.visualstudio.com/docs/languages/jsconfig for file resolve.

IhsanE commented 4 years ago

I have the jsconfig.json file in my root and it still doesn't work. Is there anything else I can do to get Go to definition working?

chemzqm commented 4 years ago

Don't know it's problem of tssever, you can use typescript

youssef-lr commented 1 year ago

Having the same issue currently, but it used to work just fine before I don't when at what point did this stop working, it works fine on VSCode and it's using the same server, I also don't have a jsconfig file in my root.

Edit: adding a jsconfig.json solved this for me, I still don't know why it works fine without it on VSCode.

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es6"
  },
  "include": ["src/**/*"]
}