Closed uga-rosa closed 1 year ago
In the first, it is not ddu-kind-file
issue. It is ddu-ui-ff
issue.
And Filetype
event is fired. foldmethod
is already set.
But fold is not enabled yes.
I have fixed the problem in ddu-ui-ff
.
Note: it is experimental fix. I may revert the change.
Reason: you have opened the file by insert mode. The fold is disabled in insert mode.
ddu-ui-ff
executes :stopinsert
, but it is lazy executed. So it is in insert mode when you open files.
So the title should be fold is not enabled when opening file in insert mode
And please don't use dein.vim if it is not needed.
set runtimepath+=~/work/denops.vim
set runtimepath+=~/work/ddu.vim
set runtimepath+=~/work/ddu-ui-ff
set runtimepath+=~/work/ddu-source-file_rec
set runtimepath+=~/work/ddu-filter-matcher_substring
set runtimepath+=~/work/ddu-kind-file
call ddu#custom#patch_global({
\ 'sources': [{'name': 'file_rec'}],
\ 'ui': 'ff',
\ 'input': '.toml',
\ 'uiParams': {
\ 'ff': {
\ 'startFilter': v:true,
\ },
\ },
\ 'sourceOptions': {
\ '_': {
\ 'ignoreCase': v:true,
\ 'matchers': ['matcher_substring'],
\ },
\ },
\ 'kindOptions': {
\ '_': {
\ 'defaultAction': 'open',
\ },
\ },
\})
augroup my-ddu-ff
autocmd!
autocmd FileType ddu-ff call <SID>ddu_ff_mapping()
autocmd FileType ddu-ff-filter call <SID>ddu_ff_filter_mapping()
augroup END
function! s:ddu_ff_mapping() abort
nnoremap <buffer><silent> <CR> <Cmd>call ddu#ui#do_action('itemAction')<CR>
nnoremap <buffer><silent> i <Cmd>call ddu#ui#do_action('openFilterWindow')<CR>
endfunction
function! s:ddu_ff_filter_mapping() abort
inoremap <buffer><silent> <CR> <ESC><Cmd>call ddu#ui#do_action('itemAction')<CR>
nnoremap <buffer><silent> <CR> <Cmd>call ddu#ui#do_action('itemAction')<CR>
inoremap <buffer><silent> <C-n> <Cmd>call ddu#ui#ff#execute('normal! j')<CR>
inoremap <buffer><silent> <C-p> <Cmd>call ddu#ui#ff#execute('normal! k')<CR>
endfunction
" Show cursorline
set cursorline
set debug=msg
filetype plugin indent on
autocmd FileType toml call s:toml_config()
function! s:toml_config()
set foldmethod=expr
set foldexpr=<SID>fold_expr(v:lnum)
function! s:fold_expr(lnum) abort
let line = getline(a:lnum)
return line ==# '' || line[0:3] ==# ' '
endfunction
endfunction
call ddu#start()
This is the real minimal vimrc.
function! s:ddu_ff_filter_mapping() abort
inoremap <buffer><silent> <CR> <ESC><Cmd>call ddu#ui#do_action('itemAction')<CR>
nnoremap <buffer><silent> <CR> <Cmd>call ddu#ui#do_action('itemAction')<CR>
inoremap <buffer><silent> <C-n> <Cmd>call ddu#ui#ff#execute('normal! j')<CR>
inoremap <buffer><silent> <C-p> <Cmd>call ddu#ui#ff#execute('normal! k')<CR>
endfunction
Not only do you remove dependence on dein.vim, but you also add <ESC>
in the imap <CR>
? So you are saying that this is a problem that needs to be corrected in the way it is mapped? If so, this should be mentioned in the help.
OK. I get it. I have fixed. Please update ddu-ui-ff
again.
I have confirmed that it has been fixed. Tysm!
I have noticed that the settings for each file type configured in dein's ftplugin are not being loaded when I open by ddu.vim.
The minimum configuration is the following two files, but essentially init.vim alone should probably suffice. The last line hooks
:echom
to the FileType eventcall dein#begin('/tmp/dein') call dein#add('vim-denops/denops.vim') call dein#add('Shougo/ddu.vim') call dein#add('Shougo/ddu-ui-ff') call dein#add('Shougo/ddu-source-file_rec') call dein#add('Shougo/ddu-kind-file') call dein#load_toml('~/.config/minimal/ftplugin.toml') call dein#end()
call ddu#custom#patch_global({ \ 'sources': [{'name': 'filerec'}], \ 'ui': 'ff', \ 'uiParams': { \ 'ff': { \ 'startFilter': v:true, \ }, \ }, \ 'kindOptions': { \ '': { \ 'defaultAction': 'open', \ }, \ }, })
augroup my-ddu-ff autocmd! autocmd FileType ddu-ff callddu_ff_mapping()
autocmd FileType ddu-ff-filter call ddu_ff_filter_mapping()
augroup END
function! s:ddu_ff_mapping() abort nnoremap call ddu#ui#do_action('itemAction')
endfunction
function! s:ddu_ff_filter_mapping() abort inoremap call ddu#ui#do_action('itemAction')
inoremap call ddu#ui#ff#execute('normal! j')
inoremap call ddu#ui#ff#execute('normal! k')
endfunction
" Indent by 4 spaces set tabstop=4 set shiftwidth=4 set expandtab
" Show cursorline set cursorline
autocmd FileType * echom &ft
Reproduce steps:
XDG_CONFIG_HOME/minimal/
.$ NVIM_APPNAME=minimal nvim
).:call ddu#start({})
)<C-n>
/<C-p>
and open it with<CR>
(these three are mapped in insert mode).<CR>
), you will see that it is properly folded.