Skip to content

Commit baea6c5

Browse files
committed
hoogle-w3m + vim integration
1 parent 4680e0e commit baea6c5

File tree

4 files changed

+84
-29
lines changed

4 files changed

+84
-29
lines changed

nix/configuration.nix

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -836,37 +836,13 @@ in {
836836
import ./tabby-admin.nix {sock = "./tabby.sock";}
837837
}/bin/tabby-admin";
838838
}
839-
// fj.mkFirejailCustom {
839+
// fj.mkFirejailOffline {
840840
pkg = "vi";
841841
exe = "${vi}/bin/vi";
842-
profile = pkgs.writeText "vi.local" ''
843-
no3d
844-
nosound
845-
apparmor
846-
caps.drop all
847-
machine-id
848-
net none
849-
netfilter
850-
nodvd
851-
nogroups
852-
noinput
853-
nonewprivs
854-
noprinters
855-
noroot
856-
notv
857-
nou2f
858-
novideo
859-
shell none
860-
861-
disable-mnt
862-
seccomp
863-
x11 none
864-
865-
dbus-system none
866-
dbus-user none
867-
868-
restrict-namespaces
869-
'';
842+
}
843+
// fj.mkFirejailOffline {
844+
pkg = "hoogle-w3m";
845+
exe = "${import ./hoogle-w3m.nix}/bin/hoogle-w3m";
870846
};
871847
#
872848
# Home

nix/firejail.nix

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,41 @@ in rec {
2222
inherit profile;
2323
};
2424
};
25+
mkFirejailOffline = {
26+
pkg,
27+
exe,
28+
}:
29+
mkFirejailCustom {
30+
inherit pkg exe;
31+
profile = pkgs.writeText "${pkg}.local" ''
32+
no3d
33+
nosound
34+
apparmor
35+
caps.drop all
36+
machine-id
37+
net none
38+
netfilter
39+
nodvd
40+
nogroups
41+
noinput
42+
nonewprivs
43+
noprinters
44+
noroot
45+
notv
46+
nou2f
47+
novideo
48+
shell none
49+
50+
disable-mnt
51+
seccomp
52+
x11 none
53+
54+
dbus-system none
55+
dbus-user none
56+
57+
restrict-namespaces
58+
'';
59+
};
2560
mkFirejailProfile = {
2661
pkg,
2762
dir,

nix/hoogle-w3m.nix

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
let
2+
pkgs = import ./nixpkgs.nix;
3+
in
4+
pkgs.writeShellApplication {
5+
name = "hoogle-w3m";
6+
text = ''
7+
hoogle serve --port=8081 &
8+
9+
HOOGLE_PID="$!"
10+
11+
cleanup() {
12+
kill "$HOOGLE_PID" 2>/dev/null
13+
exit 0
14+
}
15+
16+
trap cleanup SIGINT SIGTERM EXIT
17+
18+
${pkgs.w3m}/bin/w3m -o confirm_qq=0 "http://localhost:8081/?hoogle=$*"
19+
20+
cleanup
21+
'';
22+
}

pub/vi/vimrc.vim

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,3 +783,25 @@ let g:neoformat_toml_prettier = {
783783
let g:tabby_agent_start_command = ["tabby-agent", "--stdio"]
784784
let g:tabby_inline_completion_trigger = "manual"
785785
let g:tabby_inline_completion_keybinding_accept = '<M-\>'
786+
787+
"
788+
" => Hoogle
789+
"
790+
791+
function! HoogleW3m(str)
792+
tabnew
793+
execute "terminal hoogle-w3m '" . a:str . "'"
794+
endfunction
795+
796+
function! HoogleW3mVisual() range
797+
let l:saved_reg = @"
798+
execute "normal! vgvy"
799+
let l:pattern = @"
800+
call CmdLine("H " . l:pattern)
801+
let @/ = l:pattern
802+
let @" = l:saved_reg
803+
endfunction
804+
805+
command! -nargs=* H call HoogleW3m(<q-args>)
806+
nnoremap <silent> H :call HoogleW3m(expand("<cword>"))<CR>
807+
vnoremap <silent> H :call HoogleW3mVisual()<CR>

0 commit comments

Comments
 (0)