Skip to content

Commit

Permalink
feat: allow other exts
Browse files Browse the repository at this point in the history
  • Loading branch information
phanen committed Apr 19, 2024
1 parent 6c476e4 commit 23319f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lua/fzf-lua-overlay/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ end

M.create_notes = function(_, opts)
local query = require('fzf-lua').get_last_query()
if not query or query == '' then query = os.date '%m-%d' end
local path = vim.fn.expand(('%s/%s.md'):format(opts.cwd, query))
-- no input then use date as name
if not query or query == '' then query = os.date('%m-%d') .. '.md' end
-- no ext -> append `.md`
local path = vim.fn.expand(('%s/%s'):format(opts.cwd, query))
if #(vim.split(query, '.', { plain = true })) == 1 then path = path .. '.md' end
if not vim.uv.fs_stat(path) then
local file = io.open(path, 'a')
if not file then
vim.notify(('fail to create file %s'):format(path))
return
end
vim.notify(('%s has been created'):format(path))
file:close()
local u = require('fzf-lua-overlay.util')
local ok = u.write_file(path, 'a')
if not ok then return vim.notify(('fail to create file %s'):format(path)) end
end
vim.cmd.e(path)
vim.notify(('%s has been created'):format(path), vim.log.levels.INFO)
end

M.delete_files = function(selected, opts)
Expand All @@ -40,7 +40,7 @@ M.delete_files = function(selected, opts)
['default'] = function(sel)
if sel[1] == 'YES' and vim.uv.fs_stat(path) then
vim.uv.fs_unlink(path)
vim.notify(('%s has been deleted'):format(path))
vim.notify(('%s has been deleted'):format(path), vim.log.levels.INFO)
end
_fn(_opts)
end,
Expand Down
1 change: 1 addition & 0 deletions plugin/fzf-lua-overlay.vim
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function! s:fzf_lua_overlay_complete(arg, line, pos) abort
\"recentfiles",
\'rtp',
\"scriptnames",
\"snips",
\"todo_comment",
\"todos",
\"zoxide",
Expand Down

0 comments on commit 23319f9

Please sign in to comment.