-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fzf-make as a floatting terminal
- Loading branch information
1 parent
ff1205f
commit b378c39
Showing
5 changed files
with
83 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ | |
nodejs | ||
xclip | ||
ecsls-pkg | ||
(pkgs.callPackage ./fzf-make.nix { }) | ||
]; | ||
}; | ||
} |
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,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"; | ||
}; | ||
} |
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 |
---|---|---|
@@ -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) |
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,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() { |