Shougo / ddc-source-lsp

lsp source for ddc.vim
Other
67 stars 22 forks source link

Not working on Typescript file. #27

Closed susiyaki closed 3 years ago

susiyaki commented 3 years ago

I tried to use this plugin with dein.vim refered your vim config files.

https://github.com/Shougo/shougo-s-github/blob/master/vim/rc/ddc.toml#L116

But not working this plugin on Typescript project(It worked lsp suggestion when I opened other vim config). Other plugins worked fine.

I checked LspInfo and it's fine.

Following code is ddc.toml file. denops.vim, context_filetype.vim, nvim-lspinstall and impatient.nvim are imported other toml file like your vim config.

[[plugins]]
repo = 'Shougo/ddc.vim'
depends = ['context_filetype.vim', 'denops.vim', 'pum.vim']
on_event = 'InsertEnter'
hook_source = '''
  call ddc#custom#patch_global(
      \ 'sources', ['eskk', 'nvim-lsp', 'file', 'around'],
      \ )

  call ddc#custom#patch_global('sourceOptions', {
      \ '_': {
      \   'ignoreCase': v:true,
      \   'matchers': ['matcher_head'],
      \   'sorters': ['sorter_rank'],
      \   'converters': ['converter_remove_overlap'],
      \ },
      \ 'around': {
      \   'mark': 'A',
      \   'matchers': ['matcher_head', 'matcher_length'],
      \ },
      \ 'nvim-lsp': {
      \   'mark': 'lsp',
      \   'forceCompletionPattern': '\.\w*|:\w*|->\w*'
      \ },
      \ 'file': {
      \   'mark': 'F',
      \   'isVolatile': v:true,
      \   'minAutoCompleteLength': 1000,
      \   'forceCompletionPattern': '\S/\S*',
      \ },
      \ 'cmdline-history': {'mark': 'history'},
      \ 'eskk': {'mark': 'eskk', 'matchers': [], 'sorters': []},
      \ })

  call ddc#custom#patch_global('autoCompleteEvents', [
      \ 'InsertEnter', 'TextChangedI', 'TextChangedP',
      \ 'CmdlineEnter', 'CmdlineChanged',
      \ ])

  call ddc#custom#patch_global('completionMenu', 'pum.vim')

  inoremap <silent><expr> <TAB>
        \ pum#visible() ? '<Cmd>call pum#map#insert_relative(+1)<CR>' :
        \ (col('.') <= 1 <Bar><Bar> getline('.')[col('.') - 2] =~# '\s') ?
        \ '<TAB>' : ddc#manual_complete()
  inoremap <S-Tab> <Cmd>call pum#map#insert_relative(-1)<CR>
  inoremap <C-n>   <Cmd>call pum#map#select_relative(+1)<CR>
  inoremap <C-p>   <Cmd>call pum#map#select_relative(-1)<CR>
  inoremap <C-k>   <Cmd>call pum#map#confirm()<CR>
  inoremap <C-e>   <Cmd>call pum#map#cancel()<CR>

  call ddc#enable()
'''

[[plugins]]
repo = 'Shougo/pum.vim'

[[plugins]]
repo = 'Shougo/ddc-around'
on_source = 'ddc.vim'

[[plugins]]
repo = 'Shougo/ddc-matcher_head'
on_source = 'ddc.vim'

[[plugins]]
repo = 'Shougo/ddc-matcher_length'
on_source = 'ddc.vim'

[[plugins]]
repo = 'Shougo/ddc-sorter_rank'
on_source = 'ddc.vim'

[[plugins]]
repo = 'Shougo/ddc-cmdline-history'
on_source = 'ddc.vim'

[[plugins]]
repo = 'Shougo/ddc-converter_remove_overlap'
on_source = 'ddc.vim'

[[plugins]]
repo = 'LumaKernel/ddc-file'
on_source = 'ddc.vim'

[[plugins]]
repo = 'Shougo/ddc-omni'

[[plugins]]
repo = 'Shougo/ddc-nvim-lsp'
on_source = 'nvim-lspconfig'

[[plugins]]
repo = 'neovim/nvim-lspconfig'
depends = ['impatient.nvim', 'nvim-lspinstall']
on_ft = [
  'javascript',
  'javascriptreact',
  'typescript',
  'typescriptreact',
  'dart'
]
if = 'has("nvim")'
depends = 'ddc.vim'
hook_add = '''
" Keymaps
nnoremap <silent><Leader>D :lua vim.lsp.buf.declaration()<CR>
nnoremap <silent><Leader>d :lua vim.lsp.buf.definition()<CR>
nnoremap <silent><Leader>t :lua vim.lsp.buf.type_definition()<CR>
nnoremap <silent><Leader>i :lua vim.lsp.buf.implementation()<CR>
nnoremap <silent><Leader>c :lua vim.lsp.buf.references()<CR>
nnoremap <silent><Leader>r :lua vim.lsp.buf.rename()<CR>
nnoremap <silent><Leader>a :lua vim.lsp.buf.code_action()<CR>

nnoremap <silent><C-h> :lua vim.lsp.buf.hover()<CR>
nnoremap <silent>K :lua vim.lsp.buf.signature_help()<CR>

nnoremap <silent>[d :lua vim.lsp.diagnostic.goto_prev()<CR>
nnoremap <silent>]d :lua vim.lsp.diagnostic.goto_next()<CR>
nnoremap <silent><Leader>ld :lua vim.lsp.diagnostic.show_line_diagnostics()<CR>
nnoremap <silent><Leader>lld :lua vim.lsp.diagnostic.set_loclist()<CR>

lua << EOF
  local langs = {
    "bash",
    "cmake",
    -- "css",
    "cpp",
    "dockerfile",
    "go",
    "graphql",
    -- "html",
    -- "json",
    "lua",
    "python",
    "ruby",
    "rust",
    "tailwindcss",
    "typescript",
    "vim",
    "yaml"
  }
  local installed_servers = require'lspinstall'.installed_servers()

  local function has_server(lang)
    for _, server in pairs(installed_servers) do
      if server == lang then
        return true
      end
    end

    return false
  end

  for _, lang in pairs(langs) do
    if has_server(lang) == false then
      require'lspinstall'.install_server(lang)
    end
  end

  local function setup_servers()
    require'lspinstall'.setup()
    for _, server in pairs(installed_servers) do
      require'lspconfig'[server].setup{}
    end
  end

  setup_servers()

  require'lspconfig'.dartls.setup{}
EOF
'''

[[plugins]]
repo = 'tyru/eskk.vim'
on_source = 'ddc.vim'
hook_add = '''
 imap <silent> jk <Plug>(eskk:toggle)
 cmap <silent> jk <Plug>(eskk:toggle)
  let g:eskk#directory = expand('~/.eskk')
  let g:eskk#dictionary = {
        \   'path': expand('~/.eskk-jisyo'),
        \   'sorted': 0,
        \   'encoding': 'utf-8',
        \}
  let g:eskk#large_dictionary = {
        \   'path': '~/.config/SKK-JISYO.L',
        \   'sorted': 1,
        \   'encoding': 'utf-8',
        \}
  let g:eskk#server = {
        \   'host': 'localhost',
        \   'port': 1178
        \}
  let g:eskk#kakutei_when_unique_candidate = v:true
  let g:enable_completion = v:false
  let g:eskk#keep_state = v:false
  let g:eskk#egg_like_newline = v:true
  let g:eskk#tab_select_completion = v:true
'''
Shougo commented 3 years ago

OH, it is hard to test... What LSP do you use for TypeScript? It seems typescript-language-server.

We have not ESP skills.

Shougo commented 3 years ago

Not working on Typescript file.

Please upload the reproduce instruction. It is hard to test.

Shougo commented 3 years ago

It works for me without TypeScript projects.

スクリーンショット_2021-10-22_09-33-16

Shougo commented 3 years ago

The minimal vimrc:


if &compatible
  set nocompatible
endif

set runtimepath^=~/work/ddc.vim
set runtimepath^=~/work/denops.vim
set runtimepath^=~/work/ddc-matcher_head
set runtimepath^=~/work/ddc-sorter_rank

if has('nvim')
  set runtimepath+=~/src/nvim-lspconfig
  set runtimepath^=~/work/ddc-nvim-lsp

  lua << EOF
  require'lspconfig'.tsserver.setup{}
EOF
endif

set completeopt=menuone,noinsert

filetype plugin indent on
syntax enable

call ddc#custom#patch_global('sources', ['nvim-lsp'])
call ddc#custom#patch_global('sourceOptions', {
      \ '_': {
      \   'matchers': ['matcher_head'],
      \   'sorters': ['sorter_rank'],
      \ },
      \ 'nvim-lsp': {'mark': 'nvimlsp', 'forceCompletionPattern': '\.|:|->|"\w*/'},
      \ })
call ddc#enable()
```j
susiyaki commented 3 years ago

It caused by nvim-lspconfig section hook. Maybe I didn't put lspinstall module in nvim/lua but called it so couldn't complete setup.

Thanks!

Shougo commented 3 years ago

Oh, OK.