2020
2121local function quit () vim .cmd .quit () end
2222
23+ local function parse_entries (s , o )
24+ return vim .tbl_map (function (e )
25+ e = FzfLua .path .entry_to_file (e --[[ @as string]] , o )
26+ e .path = FzfLua .path .relative_to (assert (e .path ), vim .uv .cwd ())
27+ return e
28+ end , s )
29+ end
30+
2331local function posix_exec (cmd , ...)
2432 local _is_win = fn .has (" win32" ) == 1 or fn .has (" win64" ) == 1
2533 if type (cmd ) ~= " string" or _is_win or not ffi then return end
2634 ffi .C .execl (cmd , cmd , ... )
2735end
2836
29- local function parse_entry (e ) return e and e :match (" %((.-)%)" ) or nil end
30-
3137_G .fzf_tty_get_width = function ()
3238 if not ffi then return (assert (uv .new_tty (0 , false )):get_winsize ()) end
3339 local TIOCGWINSZ = 0x5413
@@ -107,18 +113,25 @@ return {
107113 [" --border" ] = HAS_TMUX and " rounded" or " top" ,
108114 [" --tmux" ] = (function () return not HAS_TMUX and false or nil end )(),
109115 },
116+ hls = {
117+ title = " diffAdd" ,
118+ title_flags = " Visual" ,
119+ header_bind = " Directory" ,
120+ header_text = " WarningMsg" ,
121+ live_prompt = " ErrorMsg" ,
122+ },
110123 actions = {
111124 files = {
112125 true ,
113126 [" esc" ] = quit ,
114127 [" ctrl-c" ] = quit ,
115128 [" enter" ] = function (s , o )
116- local entries = vim . tbl_map (
117- function (e ) return FzfLua . path . entry_to_file ( e , o ) end , s )
118- entries = vim . tbl_map ( function ( e )
119- e . path = FzfLua . path . relative_to ( e . path , vim . uv . cwd ())
120- return e
121- end , entries )
129+ local entries = parse_entries ( s , o )
130+ vim . tbl_map ( function (e ) io.stdout : write ( e . path .. " \n " ) end , entries )
131+ quit ( )
132+ end ,
133+ [ " ctrl-q " ] = function ( s , o )
134+ local entries = parse_entries ( s , o )
122135 if ffi and # entries == 1 then
123136 posix_exec (fn .exepath (" nvim" ), entries [1 ].path ,
124137 entries [1 ].line and (" +" .. entries [1 ].line ) or nil ,
@@ -131,7 +144,6 @@ return {
131144 end , entries ), file )
132145 posix_exec (fn .exepath (" nvim" ), " -q" , file )
133146 end
134- io.stdout :write (vim .json .encode (entries ) .. " \n " )
135147 quit ()
136148 end ,
137149 [" ctrl-x" ] = function (_ , o )
@@ -149,7 +161,8 @@ return {
149161 serverlist = {
150162 actions = {
151163 [" enter" ] = function (s )
152- local remote = parse_entry (s [1 ])
164+ assert (s [1 ])
165+ local remote = s [1 ]:match (" %((.-)%)" )
153166 posix_exec (fn .exepath (" nvim" ), " --remote-ui" , " --server" , remote )
154167 end
155168 }
0 commit comments