Skip to content

Commit

Permalink
chore(ddu): follow latest
Browse files Browse the repository at this point in the history
  • Loading branch information
ttak0422 committed Aug 4, 2024
1 parent 969f778 commit 98a944f
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 95 deletions.
112 changes: 60 additions & 52 deletions denops/ddu.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { BaseConfig } from "https://deno.land/x/[email protected]/types.ts";
import { ConfigArguments } from "https://deno.land/x/[email protected]/base/config.ts";
import { Denops, fn } from "https://deno.land/x/[email protected]/deps.ts";
import {
Params as FfParams,
Ui as FfUi,
} from "https://deno.land/x/[email protected]/ff.ts";
import { BaseConfig, Denops } from "jsr:@shougo/ddu-vim@~5.0.0/types";
import { ConfigArguments } from "jsr:@shougo/ddu-vim@~5.0.0/config";
import { Params as FfParams } from "jsr:@shougo/ddu-ui-ff@~1.2.0";
import { Params as FilerParams } from "jsr:@shougo/ddu-ui-filer@~1.2.0";
import * as fn from "jsr:@denops/std@~7.0.1/function";

export class Config extends BaseConfig {
override config({
Expand All @@ -16,57 +14,57 @@ export class Config extends BaseConfig {
setAlias("source", "mrw", "mr");
setAlias("source", "mrr", "mr");

const ffParamsDefault = new FfUi().params();
const ffUiParams: FfParams = {
...ffParamsDefault,
ignoreEmpty: true,
startAutoAction: false,
autoAction: {
name: "preview",
delay: 250, // same as telescope.nvim
},
autoResize: false,
displaySourceName: "no",
floatingBorder: "none",
split: "floating",
winCol: "&columns / 4",
winWidth: "&columns / 2",
winRow: "&lines / 3",
filterFloatingPosition: "top",
filterSplitDirection: "topleft",
highlights: {
filterText: "Statement",
floating: "NormalFloat",
floatingBorder: "none",
selected: "CursorLine",
},
onPreview: async (args: { denops: Denops; previewWinId: number }) => {
await fn.win_execute(args.denops, args.previewWinId, "normal! zt");
},
previewFloating: true,
previewFloatingBorder: "none",
previewSplit: "vertical",
previewCol: "1",
previewWidth: "&columns / 2 - 2",
previewHeight: "&lines / 3",
prompt: " ",
statusline: false,
};

contextBuilder.patchGlobal({
sources: ["file", "file_rec", "file_external", "mr", "ghq"],
ui: "ff",
profile: false,
sources: ["file", "file_rec", "file_external", "mr", "ghq"],
// TODO:
uiOptions: {},
uiParams: {
ff: ffUiParams,
ff: {
autoAction: {
name: "preview",
delay: 250, // same as telescope.nvim
},
filterSplitDirection: "floating",
floatingBorder: "none",
highlights: {
filterText: "Statement",
floating: "Normal",
floatingBorder: "Special",
},
maxHighlightItems: 50,
onPreview: async (args: { denops: Denops; previewWinId: number }) => {
await fn.win_execute(args.denops, args.previewWinId, "normal! zt");
},
previewFloating: true,
previewFloatingBorder: "single",
updateTime: 0,
winWidth: 100,
} as Partial<FfParams>,
filer: {
previewFloating: true,
sort: "filename",
sortTreesFirst: true,
split: "no",
toggle: true,
} as Partial<FilerParams>,
},
sourceOptions: {
_: {
matchers: ["matcher_fzf"],
sorters: ["sorter_fzf"],
smartCase: true,
},
mru: {
matchers: ["matcher_ignore_files", "matcher_relative", "matcher_fzf"],
},
mrw: {
matchers: ["matcher_ignore_files", "matcher_relative", "matcher_fzf"],
},
mrr: {
matchers: ["matcher_ignore_files", "matcher_relative", "matcher_fzf"],
},
file: {
matchers: ["matcher_substring", "matcher_hidden"],
sorters: ["sorter_alpha"],
Expand Down Expand Up @@ -101,18 +99,18 @@ export class Config extends BaseConfig {
file_fd: {
cmd: ["fd", ".", "-H", "-t", "f", "--exclude", ".git"],
},
rg: {
args: ["--json"],
},
},
filterOptions: {},
filterParams: {
matcher_substring: {
highlightMatched: "Search",
},
matcher_fzf: {
highlightMatched: "Search",
},
matcher_ignore_files: {
ignoreGlobs: [],
ignorePatterns: [/.*\/COMMIT_EDITMSG$/],
},
converter_hl_dir: {
hlGroup: ["Directory", "Keyword"],
},
Expand All @@ -121,11 +119,21 @@ export class Config extends BaseConfig {
file: {
defaultAction: "open",
},
url: {
defaultAction: "browse",
},
},
kindParams: {},
actionOptions: {},
actionParams: {},
actionOptions: {
narrow: {
quit: false,
},
tabopen: {
quit: false,
},
},
});

return Promise.resolve();
}
}
6 changes: 1 addition & 5 deletions main/after.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ let
};
ddu-ff = {
language = "vim";
code = read ../vim/after/ddu-ff.vim;
};
ddu-ff-filter = {
language = "vim";
code = read ../vim/after/ddu-ff-filter.vim;
code = read ../vim/after/ddu-ui-ff.vim;
};
NeogitStatus = {
language = "vim";
Expand Down
6 changes: 3 additions & 3 deletions main/denops.nix
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ rec {
ddu-filter-converter_display_word
ddu-kind-file
ddu-commands-vim
ddu-filter-matcher_ignore_files
ddu-filter-matcher_relative
];
depends = [
denops
Expand All @@ -87,9 +89,7 @@ rec {
postConfig = {
language = "vim";
code = read ../vim/ddu.vim;
args = {
ts_config = ../denops/ddu.ts;
};
args.ts_config = ../denops/ddu.ts;
};
hooks.commands = [
"Ddu"
Expand Down
16 changes: 0 additions & 16 deletions vim/after/ddu-ff-filter.vim

This file was deleted.

3 changes: 3 additions & 0 deletions vim/after/ddu-ff.vim → vim/after/ddu-ui-ff.vim
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
setlocal cursorline
nnoremap <buffer> i <Cmd>call ddu#ui#do_action('openFilterWindow')<CR>
nnoremap <buffer> q <Cmd>call ddu#ui#do_action('quit')<CR>
nnoremap <buffer> <C-c> <Cmd>call ddu#ui#do_action('quit')<CR>
nnoremap <buffer> <CR> <Cmd>call ddu#ui#do_action('itemAction')<CR>
nnoremap <buffer> <Space> <Cmd>call ddu#ui#do_action('toggleSelectItem')<CR>
nnoremap <buffer><C-n> <Cmd>call ddu#ui#do_action('cursorNext', #{ loop: v:true })<CR>
nnoremap <buffer><C-p> <Cmd>call ddu#ui#do_action('cursorPrevious', #{ loop: v:true })<CR>
40 changes: 21 additions & 19 deletions vim/ddu.vim
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
" setup
call ddu#custom#load_config(s:args['ts_config'])

" Note: the matchers should be empty for performance
function! s:ddu_rg_live() abort
call ddu#start({
\ 'name': 'rg',
\ 'sources': [{
\ 'name': 'rg',
\ 'options': {
\ 'matchers': [],
\ 'volatile': v:true,
\ },
\ }],
\ 'uiParams': {
\ 'ff': {
\ 'ignoreEmpty': v:false,
\ 'autoResize': v:false,
\ }
\ },
\ })
function s:ddu_send_all_to_qf() abort
call ddu#ui#do_action('clearSelectAllItems')
call ddu#ui#do_action('toggleAllItems')
call ddu#ui#do_action('itemAction', { 'name': 'quickfix'})
endfunction

command! DduRgLive call <SID>ddu_rg_live()
function s:ddu_ff_filter_open() abort
call ddu#ui#ff#save_cmaps([
\ '<C-f>', '<C-b>', '<C-c>', '<C-q>', '<CR>',
\ ])
cnoremap <C-n> <Cmd>call ddu#ui#do_action('cursorNext', #{ loop: v:true })<CR>
cnoremap <C-p> <Cmd>call ddu#ui#do_action('cursorPrevious', #{ loop: v:true })<CR>
cnoremap <C-c> <ESC><Cmd>call ddu#ui#do_action('quit')<CR>
cnoremap <C-q> <ESC><Cmd>call <SID>ddu_send_all_to_qf()<CR>
cnoremap <CR> <ESC><Cmd>call ddu#ui#do_action('itemAction')<CR>
endfunction

function s:ddu_ff_filter_close() abort
call ddu#ui#ff#restore_cmaps()
endfunction

au User Ddu:ui:ff:openFilterWindow call s:ddu_ff_filter_open()
au User Ddu:ui:ff:closeFilterWindow call s:ddu_ff_filter_close()

0 comments on commit 98a944f

Please sign in to comment.