-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
144 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
local cfg = require('fzf-lua-overlay.config').opts | ||
|
||
local notes_history = vim.fs.joinpath(cfg.cache_dir, 'notes_history') | ||
|
||
return { | ||
name = 'files', | ||
opts = { | ||
cwd = cfg.notes_dir, | ||
-- stylua: ignore | ||
actions = { | ||
['ctrl-g'] = function(...) require('fzf-lua-overlay.actions').toggle_daily(...) end, | ||
['ctrl-n'] = function(...) require('fzf-lua-overlay.actions').create_notes(...) end, | ||
['ctrl-x'] = function(...) require('fzf-lua-overlay.actions').delete_files(...) end, | ||
}, | ||
fzf_opts = { ['--history'] = notes_history }, | ||
file_icons = false, | ||
git_icons = false, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,59 @@ | ||
local M = {} | ||
|
||
local url = 'https://api.github.com/gitignore/templates' | ||
|
||
return { | ||
name = 'fzf_exec', | ||
opts = { | ||
prompt = 'gitignore> ', | ||
actions = { | ||
['default'] = function(selected) | ||
local util = require('fzf-lua-overlay.util') | ||
local gitroot = util.find_gitroot() | ||
if not gitroot then | ||
vim.notify('not in a git repository') | ||
end | ||
local path = vim.fs.joinpath(gitroot, '.gitignore') | ||
vim.print(path) | ||
if vim.uv.fs_stat(path) then | ||
local confirm = vim.fn.confirm('Override?', '&Yes\n&No') | ||
if confirm ~= 1 then | ||
return | ||
end | ||
local cache_dir = require('fzf-lua-overlay.config').opts.cache_dir | ||
local cache_path = vim.fs.joinpath(cache_dir, 'gitignore.json') | ||
|
||
M.name = 'fzf_exec' | ||
|
||
M.opts = { | ||
prompt = 'gitignore> ', | ||
actions = { | ||
['default'] = function(selected) | ||
local util = require('fzf-lua-overlay.util') | ||
local gitroot = util.find_gitroot() | ||
if not gitroot then | ||
vim.notify('not in a git repository') | ||
end | ||
local path = vim.fs.joinpath(gitroot, '.gitignore') | ||
vim.print(path) | ||
if vim.uv.fs_stat(path) then | ||
local confirm = vim.fn.confirm('Override?', '&Yes\n&No') | ||
if confirm ~= 1 then | ||
return | ||
end | ||
local template_url = ('%s/%s'):format(url, selected[1]) | ||
local content = vim.fn.system { 'curl', '-s', template_url } | ||
content = vim.json.decode(content).source | ||
util.write_file(path, content) | ||
vim.cmd.e(path) | ||
end, | ||
}, | ||
end | ||
local template_url = ('%s/%s'):format(url, selected[1]) | ||
local content = vim.fn.system({ 'curl', '-s', template_url }) | ||
content = vim.json.decode(content).source | ||
util.write_file(path, content) | ||
vim.cmd.e(path) | ||
end, | ||
}, | ||
fzf_exec_arg = function(fzf_cb) | ||
local util = require('fzf-lua-overlay.util') | ||
local cfg = require('fzf-lua-overlay.config').opts | ||
} | ||
|
||
M.fzf_exec_arg = function(fzf_cb) | ||
local util = require('fzf-lua-overlay.util') | ||
|
||
local path = cfg.gitignore | ||
local json | ||
if not vim.uv.fs_stat(cache_path) then | ||
local json_str = vim.fn.system({ 'curl', '-s', url }) | ||
util.write_file(cache_path, json_str) | ||
json = vim.json.decode(json_str) | ||
end | ||
json = json or util.read_json(cache_path) | ||
|
||
local json | ||
if not vim.uv.fs_stat(path) then | ||
local json_str = vim.fn.system { 'curl', '-s', url } | ||
util.write_file(path, json_str) | ||
json = vim.json.decode(json_str) | ||
coroutine.wrap(function() | ||
local co = coroutine.running() | ||
for _, item in ipairs(json) do | ||
fzf_cb(item, function() | ||
coroutine.resume(co) | ||
end) | ||
coroutine.yield() | ||
end | ||
json = json or util.read_json(path) | ||
|
||
coroutine.wrap(function() | ||
local co = coroutine.running() | ||
for _, item in ipairs(json) do | ||
fzf_cb(item, function() | ||
coroutine.resume(co) | ||
end) | ||
coroutine.yield() | ||
end | ||
fzf_cb() | ||
end)() | ||
end, | ||
} | ||
fzf_cb() | ||
end)() | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,59 @@ | ||
local url = 'https://api.github.com/licenses' | ||
|
||
return { | ||
name = 'fzf_exec', | ||
opts = { | ||
prompt = 'license> ', | ||
actions = { | ||
['default'] = function(selected) | ||
local util = require('fzf-lua-overlay.util') | ||
local gitroot = util.find_gitroot() | ||
if not gitroot then | ||
vim.notify('not in a git repository') | ||
end | ||
local path = vim.fs.joinpath(gitroot, 'LICENSE') | ||
vim.print(path) | ||
if vim.uv.fs_stat(path) then | ||
local confirm = vim.fn.confirm('Override?', '&Yes\n&No') | ||
if confirm ~= 1 then | ||
return | ||
end | ||
local cache_dir = require('fzf-lua-overlay.config').opts.cache_dir | ||
local cache_path = vim.fs.joinpath(cache_dir, 'license.json') | ||
|
||
local M = {} | ||
|
||
M.name = 'fzf_exec' | ||
M.prompt = 'license> ' | ||
|
||
M.opts = { | ||
actions = { | ||
['default'] = function(selected) | ||
local util = require('fzf-lua-overlay.util') | ||
local gitroot = util.find_gitroot() | ||
if not gitroot then | ||
vim.notify('not in a git repository') | ||
end | ||
local path = vim.fs.joinpath(gitroot, 'LICENSE') | ||
vim.print(path) | ||
if vim.uv.fs_stat(path) then | ||
local confirm = vim.fn.confirm('Override?', '&Yes\n&No') | ||
if confirm ~= 1 then | ||
return | ||
end | ||
local template_url = ('%s/%s'):format(url, selected[1]) | ||
local content = vim.fn.system { 'curl', '-s', template_url } | ||
content = vim.json.decode(content).body | ||
util.write_file(path, content) | ||
vim.cmd.e(path) | ||
end, | ||
}, | ||
end | ||
local template_url = ('%s/%s'):format(url, selected[1]) | ||
local content = vim.fn.system { 'curl', '-s', template_url } | ||
content = vim.json.decode(content).body | ||
util.write_file(path, content) | ||
vim.cmd.e(path) | ||
end, | ||
}, | ||
fzf_exec_arg = function(fzf_cb) | ||
local util = require('fzf-lua-overlay.util') | ||
local cfg = require('fzf-lua-overlay.config').opts | ||
} | ||
|
||
M.fzf_exec_arg = function(fzf_cb) | ||
local util = require('fzf-lua-overlay.util') | ||
|
||
local path = cfg.license | ||
local json | ||
if not vim.uv.fs_stat(cache_path) then | ||
local json_str = vim.fn.system { 'curl', '-s', url } | ||
util.write_file(cache_path, json_str) | ||
json = vim.json.decode(json_str) | ||
end | ||
json = json or util.read_json(cache_path) | ||
|
||
local json | ||
if not vim.uv.fs_stat(path) then | ||
local json_str = vim.fn.system { 'curl', '-s', url } | ||
util.write_file(path, json_str) | ||
json = vim.json.decode(json_str) | ||
coroutine.wrap(function() | ||
local co = coroutine.running() | ||
for _, item in ipairs(json) do | ||
fzf_cb(item.key, function() | ||
coroutine.resume(co) | ||
end) | ||
coroutine.yield() | ||
end | ||
json = json or util.read_json(path) | ||
|
||
coroutine.wrap(function() | ||
local co = coroutine.running() | ||
for _, item in ipairs(json) do | ||
fzf_cb(item.key, function() | ||
coroutine.resume(co) | ||
end) | ||
coroutine.yield() | ||
end | ||
fzf_cb() | ||
end)() | ||
end, | ||
} | ||
fzf_cb() | ||
end)() | ||
end | ||
|
||
return M |