Shougo / ddu-ui-ff

Fuzzy finder UI for ddu.vim
MIT License
55 stars 26 forks source link

Support nvim-0.9.0 earlier #116

Closed uga-rosa closed 1 year ago

uga-rosa commented 1 year ago

The title for floating window is added in 0.9.0

uga-rosa commented 1 year ago

Changing the supported version to 0.9.0 or higher is one of the countermeasures. In that case, close this PR.

peacock0803sz commented 1 year ago

Here's the Dockerfile for reproduce problem, there are 4 patterns at neovim base-image: It raise an error calling StartDdu user-defined command.

FROM ubuntu:22.04 as base
ENV VIM_HOME=/root/.vim
RUN apt-get update && apt-get upgrade -y && apt-get install -yqq curl ca-certificates git

RUN mkdir -p ${VIM_HOME}/plugins && \
  git clone https://github.com/Shougo/ddu.vim.git ${VIM_HOME}/plugins/ddu.vim && \
  git clone https://github.com/Shougo/ddu-ui-ff.git ${VIM_HOME}/plugins/ddu-ui-ff && \
  git clone https://github.com/Shougo/ddu-source-file_rec.git ${VIM_HOME}/plugins/ddu-source-file_rec && \
  git clone https://github.com/Shougo/ddu-kind-file.git ${VIM_HOME}/plugins/ddu-kind-file && \
  git clone https://github.com/Shougo/ddu-filter-matcher_substring.git ${VIM_HOME}/plugins/ddu-filter-matcher_substring

COPY <<EOF ${VIM_HOME}/vimrc
set runtimepath+=/root/.vim/plugins/ddu.vim
set runtimepath+=/root/.vim/plugins/ddu-ui-ff
set runtimepath+=/root/.vim/plugins/ddu-source-file_rec
set runtimepath+=/root/.vim/plugins/ddu-kind-file
set runtimepath+=/root/.vim/plugins/ddu-filter-matcher_substring

call ddu#custom#patch_global(#{
      \\ ui: 'ff',
      \\ uiParams: #{
      \\     ff: #{
      \\         split: 'floating',
      \\         previewFloating: v:true,
      \\         previewFloatingBoder: 'single',
      \\     },
      \\ },
      \\ sourceOptions: #{
      \\     _: #{
      \\         matchers: ['matcher_substring'],
      \\     },
      \\ },
      \\ kindOptions: #{
      \\     file: #{ defaultAction: 'open' }
      \\ },
\\ })

function DduFfMap() abort
  nmap <buffer><silent><nowait> / <Cmd>call ddu#ui#do_action('openFilterWindow')<CR>
  nmap <buffer><silent><nowait> <CR> <Cmd>call ddu#ui#do_action('itemAction')<CR>
  nmap <buffer><silent><nowait> + <Cmd>call ddu#ui#do_action('chooseAction')<CR>
  nmap <buffer><silent><nowait> > <Cmd>call ddu#ui#do_action('preview')<CR>
  nmap <buffer><silent><nowait> q <Cmd>call ddu#ui#do_action('quit')<CR>
endfunction

function DduFfFilterMap() abort
  imap <buffer><silent> <CR> <ESC><Cmd>call ddu#ui#do_action('leaveFilterWindow')<CR>
  nmap <buffer><silent> q <Cmd>call ddu#ui#do_action('closeFilterWindow')<CR>
endfunction

augroup PlugDduUiFf
    autocmd! FileType ddu-ff call DduFfMap()
    autocmd! FileType ddu-ff-filter call DduFfFilterMap()
augroup END
echo('ddu.vim loaded')

command! StartDdu call ddu#start(#{ sources: [#{ name: 'file_rec' }], ui: 'ff' })
nmap <Space>f <Cmd>StartDdu<CR>
EOF

# vim-denops/neovim ONLY provides neovim v0.8.0
FROM ghcr.io/vim-denops/neovim as neovim

# peacock0803sz/neovim provides neovim v0.9.0 or later
# FROM ghcr.io/peacock0803sz/neovim:v5.0.0-nvim-0.9.0 as neovim
# FROM ghcr.io/peacock0803sz/neovim:v5.0.0-nvim-stable as neovim
# FROM ghcr.io/peacock0803sz/neovim:v5.0.0-nvim-nightly as neovim

RUN apt-get update && apt-get upgrade -y && apt-get install -y git fd-find
COPY --from=base /root/.vim /root/.vim
RUN mkdir -p /root/.config/nvim && cp /root/.vim/vimrc /root/.config/nvim/init.vim

WORKDIR /root/.vim/plugins/ddu.vim

Image difference is simply neovim versions. Followings are making patched images:

curl https://raw.githubusercontent.com/vim-denops/denops-dockerfile/main/Dockerfile.neovim > Dockerfile
docker build -t denops-neovim:v5.0.0-nvim-0.9.0 --build-arg DENOPS_VERSION=v5.0.0 --build-arg NEOVIM_VERSION=v0.9.0 .
docker build -t denops-neovim:v5.0.0-nvim-stable --build-arg DENOPS_VERSION=v5.0.0 --build-arg NEOVIM_VERSION=stable .
docker build -t denops-neovim:v5.0.0-nvim-nightly --build-arg DENOPS_VERSION=v5.0.0 --build-arg NEOVIM_VERSION=nightly .
peacock0803sz commented 1 year ago

It works with @uga-rosa 's patch! 🎉

Shougo commented 1 year ago

Thanks.