Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ale's ale_completion_tsserver_autoimport inserts default when accepting autoimport suggestion for default import for typescript. #2899

Closed
dephiros opened this issue Nov 15, 2019 · 4 comments
Labels
bug LSP Any issue relating to LSP or tsserver

Comments

@dephiros
Copy link

Information

VIM version
NVIM v0.4.2
Build type: Release

Operating System: Mac 10.14.6

What went wrong

Ale's ale_completion_tsserver_autoimport inserts default when accepting autoimport suggestion for default import for typescript.

Reproducing the bug

  1. Create file abcd.ts with a default export
  2. In file b.ts, type abc, ale will pop up default v Import default 'abcd' from module "abcd.ts
  3. accept the suggestion, you will see the import statement added import abcd from "abcd" but the inserted text is default`. Note: the import takes two times to be inserted in the first example below as well

This happens for both ts and tsx files.
Nov-15-2019 13-40-10
Nov-15-2019 13-30-08

:ALEInfo

 Current Filetype: typescript
Available Linters: ['eslint', 'standard', 'tslint', 'tsserver', 'typecheck', 'xo']
  Enabled Linters: ['eslint', 'standard', 'tslint', 'tsserver', 'typecheck', 'xo']
 Suggested Fixers: 
  'eslint' - Apply eslint --fix to a file.
  'prettier' - Apply prettier to a file.
  'remove_trailing_lines' - Remove all blank lines at the end of a file.
  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
  'tslint' - Fix typescript files with tslint --fix.
  'xo' - Fix JavaScript/TypeScript files using xo --fix.
 Linter Variables:

let g:ale_typescript_standard_executable = 'standard'
let g:ale_typescript_standard_options = ''
let g:ale_typescript_standard_use_global = 0
let g:ale_typescript_tslint_config_path = ''
let g:ale_typescript_tslint_executable = 'tslint'
let g:ale_typescript_tslint_ignore_empty_files = 0
let g:ale_typescript_tslint_rules_dir = ''
let g:ale_typescript_tslint_use_global = 0
let g:ale_typescript_tsserver_config_path = ''
let g:ale_typescript_tsserver_executable = 'tsserver'

@w0rp
Copy link
Member

w0rp commented Jan 2, 2020

This might be something specific to JSX.

@eduinlight
Copy link

eduinlight commented Jun 11, 2020

Can you please tell me how I accept an autoimport? I type untill the popup has shown and with C-n C-p C-o select the import that I need, but I don't know how to select it. I try a lot of keys and combinations but nothing happend.

@w0rp
Copy link
Member

w0rp commented Aug 14, 2020

You want to select the menu item so it's highlighted, then press C-y.

I use this keybind to make it easy, by pressing Enter.

" Make pressing Enter accept a completion entry.
function! SmartEnter()
    if pumvisible()
        return "\<C-y>"
    endif

    return "\<CR>"
endfunction

inoremap <silent> <CR> <C-R>=SmartEnter()<CR>

@w0rp w0rp closed this as completed in 5a4fad6 Aug 14, 2020
@w0rp
Copy link
Member

w0rp commented Aug 14, 2020

I should have fixed this now. The format for default import completion data is weird, but you can read localName from displayParts to get the real name.

@w0rp w0rp added the LSP Any issue relating to LSP or tsserver label Aug 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug LSP Any issue relating to LSP or tsserver
Projects
None yet
Development

No branches or pull requests

3 participants