Skip to content

Commit

Permalink
Add fzf-make as a floatting terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
Sigmanificient committed Dec 30, 2024
1 parent ff1205f commit b378c39
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 10 deletions.
1 change: 1 addition & 0 deletions home/nvim/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
nodejs
xclip
ecsls-pkg
(pkgs.callPackage ./fzf-make.nix { })
];
};
}
44 changes: 44 additions & 0 deletions home/nvim/fzf-make.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{ lib
, rustPlatform
, fetchFromGitHub
, makeBinaryWrapper
, runtimeShell
, bat
, gnugrep
, gnumake
}:

rustPlatform.buildRustPackage rec {
pname = "fzf-make";
version = "0.52.0";

src = fetchFromGitHub {
owner = "kyu08";
repo = "fzf-make";
rev = "v${version}";
hash = "sha256-KJdGUo7qSMIDJ8jvcBX/cla8pQkB/EGytIP0YzV/3fY=";
};

cargoHash = "sha256-nrttuY9x61aE3RJOtbUWZbqOX6ZRyghQSruu5EdX470=";

useFetchCargoVendor = true;

nativeBuildInputs = [ makeBinaryWrapper ];

patches = [ ./test.patch ];

postInstall = ''
wrapProgram $out/bin/fzf-make \
--set SHELL ${runtimeShell} \
--suffix PATH : ${lib.makeBinPath [ bat gnugrep gnumake ]}
'';

meta = {
description = "Fuzzy finder for Makefile";
inherit (src.meta) homepage;
changelog = "https://github.com/kyu08/fzf-make/releases/tag/${src.rev}";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ figsoda sigmanificient ];
mainProgram = "fzf-make";
};
}
1 change: 0 additions & 1 deletion home/nvim/lua/lazy_plugins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ return apply_shortcut({
priority = 1000,
},
{ "wakatime/vim-wakatime", lazy = false },
"Sigmanificient/vim-epitech",
{
"VonHeikemen/lsp-zero.nvim",
_user_conf = "lsp",
Expand Down
24 changes: 15 additions & 9 deletions home/nvim/lua/plugins/toggleterm.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
local Terminal = require("toggleterm.terminal").Terminal

local lazygit = Terminal:new({
cmd = "lazygit || nix run nixpkgs#lazygit",
hidden = true,
direction = "float",
on_open = function(term)
vim.api.nvim_buf_set_keymap(
local floating_term = function(do_cmd)
return Terminal:new({
cmd = do_cmd;
hidden = true,
direction = "float",
on_open = function(term)
vim.api.nvim_buf_set_keymap(
term.bufnr,
"n", "q", "<cmd>close<CR>",
{ noremap = true, silent = true }
)
end,
})
)
end,
})
end

local lazygit = floating_term("lazygit || nix run nixpkgs#lazygit");
local fzf_make = floating_term("fzf-make || nix run nixpkgs#fzf-make");

vim.keymap.set("n", "<leader>gl", function() lazygit:toggle() end)
vim.keymap.set("n", "<leader>fz", function() fzf_make:toggle() end)
23 changes: 23 additions & 0 deletions home/nvim/patch-syntax-higlighting.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
diff --git a/src/usecase/tui/ui.rs b/src/usecase/tui/ui.rs
index 8016872..c2fd518 100644
--- a/src/usecase/tui/ui.rs
+++ b/src/usecase/tui/ui.rs
@@ -98,11 +98,13 @@ fn render_preview_block(model: &SelectCommandState, f: &mut Frame, chunk: ratatu
match (selecting_command, start_index_and_end_index, command_row_index) {
(Some(_), Some((start_index, _)), Some(command_row_index)) => {
let ss = SyntaxSet::load_defaults_newlines();
- // HACK: `ml` is specified intentionally because it highlights `Makefile` and `json` files in a good way.(No unnecessary background color)
- // lua, hs: `-- .*` is highlighted (but URL is highlighted with background color))
- // md: no background color, but highlighted words are not so many
- let syntax = ss.find_syntax_by_extension("ml").unwrap();
- let theme = &mut ThemeSet::load_defaults().themes["base16-ocean.dark"].clone();
+
+ let mut ts = ThemeSet::load_defaults();
+ ts.add_from_folder("./").unwrap();
+ // dbg!(&ts.themes);
+
+ let theme = &mut ts.themes["OneHalfDark"].clone();
+ let syntax = ss.find_syntax_by_extension("mk").unwrap();

let mut lines = vec![];
for (index, line) in source_lines.iter().enumerate() {

0 comments on commit b378c39

Please sign in to comment.