fix: yazi opener
This commit is contained in:
parent
27482b20d7
commit
53b83b3471
4 changed files with 58 additions and 41 deletions
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
osConfig,
|
||||
...
|
||||
|
|
@ -11,6 +12,17 @@ let
|
|||
dataDir = "${config.home.homeDirectory}/${relativeDir}";
|
||||
in
|
||||
{
|
||||
programs.nvf.settings.vim.extraPackages = with pkgs; [
|
||||
imagemagick # for image.nvim
|
||||
];
|
||||
|
||||
programs.nvf.settings.vim.utility.images.image-nvim = {
|
||||
enable = true;
|
||||
setupOpts = {
|
||||
backend = "kitty";
|
||||
};
|
||||
};
|
||||
|
||||
programs.nvf.settings.vim.utility.leetcode-nvim = {
|
||||
enable = true;
|
||||
setupOpts = {
|
||||
|
|
@ -18,7 +30,7 @@ in
|
|||
lang = "rust";
|
||||
plugins.non_standalone = true;
|
||||
storage.home = mkLuaInline ''"${dataDir}"'';
|
||||
injector = mkLuaInline ''
|
||||
injector = mkLuaInline /* lua */ ''
|
||||
{
|
||||
['rust'] = {
|
||||
before = { '#[allow(dead_code)]', 'fn main() {}', '#[allow(dead_code)]', 'struct Solution;' },
|
||||
|
|
@ -26,42 +38,39 @@ in
|
|||
}
|
||||
'';
|
||||
hooks."question_enter" = [
|
||||
(mkLuaInline
|
||||
# lua
|
||||
''
|
||||
function (question)
|
||||
if question.lang ~= 'rust' then
|
||||
return
|
||||
end
|
||||
|
||||
local config = require("leetcode.config")
|
||||
local problem_dir = config.user.storage.home .. "/Cargo.toml"
|
||||
local content = [[
|
||||
[package]
|
||||
name = "leetcode"
|
||||
edition = "2024"
|
||||
|
||||
[lib]
|
||||
name = "%s"
|
||||
path = "%s"
|
||||
|
||||
[dependencies]
|
||||
rand = "0.8"
|
||||
regex = "1"
|
||||
itertools = "0.14.0"
|
||||
]]
|
||||
|
||||
local file = io.open(problem_dir, "w")
|
||||
if file then
|
||||
local formatted = (content:gsub(" +", "")):format(question.q.frontend_id, question:path())
|
||||
file:write(formatted)
|
||||
file:close()
|
||||
else
|
||||
print("Failed to open file " .. problem_dir)
|
||||
end
|
||||
(mkLuaInline /* lua */ ''
|
||||
function (question)
|
||||
if question.lang ~= 'rust' then
|
||||
return
|
||||
end
|
||||
''
|
||||
)
|
||||
|
||||
local config = require("leetcode.config")
|
||||
local problem_dir = config.user.storage.home .. "/Cargo.toml"
|
||||
local content = [[
|
||||
[package]
|
||||
name = "leetcode"
|
||||
edition = "2024"
|
||||
|
||||
[lib]
|
||||
name = "%s"
|
||||
path = "%s"
|
||||
|
||||
[dependencies]
|
||||
rand = "0.8"
|
||||
regex = "1"
|
||||
itertools = "0.14.0"
|
||||
]]
|
||||
|
||||
local file = io.open(problem_dir, "w")
|
||||
if file then
|
||||
local formatted = (content:gsub(" +", "")):format(question.q.frontend_id, question:path())
|
||||
file:write(formatted)
|
||||
file:close()
|
||||
else
|
||||
print("Failed to open file " .. problem_dir)
|
||||
end
|
||||
end
|
||||
'')
|
||||
];
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue