Compare commits
3 Commits
28fbb75b47
...
ff66a92104
| Author | SHA1 | Date | |
|---|---|---|---|
| ff66a92104 | |||
| 7fef9a8760 | |||
| 6757fc6aec |
@@ -107,4 +107,8 @@ mod4 + ctrl + shift + l
|
||||
mod4 + ctrl + shift + s
|
||||
systemctl suspend
|
||||
|
||||
# toggle light/dark theme
|
||||
mod4 + F6
|
||||
~/bin/lupan-set-theme toggle
|
||||
|
||||
# vim:ft=sxhkdrc
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
# for ssh logins, install and configure the libpam-umask package.
|
||||
#umask 022
|
||||
|
||||
export EDITOR=nvim
|
||||
export VISUAL=nvim
|
||||
export EDITOR=vis
|
||||
export VISUAL=vis
|
||||
|
||||
# if running bash
|
||||
if [ -n "$BASH_VERSION" ]; then
|
||||
|
||||
2
vis/.config/vis/global-marks.txt
Normal file
2
vis/.config/vis/global-marks.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
/home/lupan/dotfiles/Makefile:23:22: (PREFIX): make -C dwm install PREFIX="${HOME}/.local"
|
||||
/home/lupan/dotfiles/Makefile:41:15: (clock): install-lupan-clock:
|
||||
@@ -48,7 +48,9 @@ local function open_file_pos(line, open_cmd)
|
||||
local file = iter()
|
||||
local line_num = nil_or_tonumber(iter())
|
||||
local col = nil_or_tonumber(iter()) or 1
|
||||
open_file(file, open_cmd)
|
||||
if open_cmd ~= 'e' or vis.win.file ~= file then
|
||||
open_file(file, open_cmd)
|
||||
end
|
||||
if line_num ~= nil then
|
||||
vis.win.selection:to(line_num, col)
|
||||
end
|
||||
@@ -120,6 +122,30 @@ local function fzf_reload(cmd)
|
||||
' --bind "alt-enter:unbind(change,alt-enter)+change-prompt(2. fzf> )+enable-search+clear-query"'
|
||||
end
|
||||
|
||||
local function add_global_mark()
|
||||
local file = vis.win.file.path
|
||||
if file ~= nil then
|
||||
local code, out, err = vis:pipe('vis-menu -p "global mark comment:"', true)
|
||||
if code == 0 then
|
||||
local prefix = file .. ':' .. vis.win.selection.line .. ':' .. vis.win.selection.col .. ': '
|
||||
local line = vis.win.file.lines[vis.win.selection.line]
|
||||
out = out:gsub('\n$', '')
|
||||
if out ~= '' then
|
||||
prefix = prefix .. '(' .. out .. '): '
|
||||
end
|
||||
out = io.open(os.getenv('HOME') .. '/.config/vis/global-marks.txt', 'a')
|
||||
out:write(prefix .. line .. '\n')
|
||||
out:close()
|
||||
elseif err ~= nil then
|
||||
vis:info(err)
|
||||
elseif code ~= 0 then
|
||||
vis:info('Program exit code ' .. code)
|
||||
end
|
||||
else
|
||||
vis:info('Save file first')
|
||||
end
|
||||
end
|
||||
|
||||
local ripgrep = 'rg --column --line-number --color=always --smart-case'
|
||||
|
||||
vis.events.subscribe(vis.events.INIT, function()
|
||||
@@ -150,10 +176,22 @@ vis.events.subscribe(vis.events.INIT, function()
|
||||
search(fzf_reload(ripgrep))
|
||||
end, 'fzf: rg')
|
||||
|
||||
vis:map(vis.modes.NORMAL, ' hg', function()
|
||||
search(fzf_reload(ripgrep .. ' -.'))
|
||||
end, 'fzf: rg with hidden files')
|
||||
|
||||
vis:map(vis.modes.NORMAL, ' /', function()
|
||||
search(fzf_reload(ripgrep .. ' --with-filename {q} ' .. escape_and_quoted(vis.win.file.path)))
|
||||
end, 'fzf: rg current file')
|
||||
|
||||
vis:map(vis.modes.NORMAL, ' ff', function()
|
||||
search('fd --type f | fzf')
|
||||
end, 'fzf: files')
|
||||
|
||||
vis:map(vis.modes.NORMAL, ' fh', function()
|
||||
search('fd -H --type f | fzf')
|
||||
end, 'fzf: files with hidden files')
|
||||
|
||||
vis:map(vis.modes.NORMAL, ' .', function()
|
||||
local path = vis.win.file.path
|
||||
if path then
|
||||
@@ -163,7 +201,18 @@ vis.events.subscribe(vis.events.INIT, function()
|
||||
else
|
||||
search('fd --type f | fzf')
|
||||
end
|
||||
end, 'fzf: current dir files')
|
||||
end, 'fzf in file directory')
|
||||
|
||||
vis:map(vis.modes.NORMAL, ' h.', function()
|
||||
local path = vis.win.file.path
|
||||
if path then
|
||||
local dir = path:match('^.*/')
|
||||
local arg = escape_and_quoted(dir)
|
||||
search('fd -H --type f "" ' .. arg .. ' | fzf')
|
||||
else
|
||||
search('fd -H --type f | fzf')
|
||||
end
|
||||
end, 'fzf in file directory with hidden files')
|
||||
|
||||
vis:map(vis.modes.NORMAL, ' gf', function()
|
||||
search('git ls-files | fzf')
|
||||
@@ -202,6 +251,31 @@ vis.events.subscribe(vis.events.INIT, function()
|
||||
vis:command('cd ' .. path)
|
||||
end)
|
||||
end, 'fzf change directory')
|
||||
|
||||
vis:map(vis.modes.NORMAL, ' yy', function()
|
||||
vis:command('!yazi')
|
||||
end, 'yazi')
|
||||
|
||||
vis:map(vis.modes.NORMAL, ' y.', function()
|
||||
local path = vis.win.file.path
|
||||
if path then
|
||||
local dir = path:match('^.*/')
|
||||
local arg = escape_and_quoted(dir)
|
||||
vis:command('!cd ' .. arg .. ' && yazi')
|
||||
else
|
||||
vis:command('!yazi')
|
||||
end
|
||||
end, 'yazi in file directory')
|
||||
|
||||
vis:map(vis.modes.NORMAL, ' ma', add_global_mark, 'global marks: add')
|
||||
|
||||
vis:map(vis.modes.NORMAL, ' mj', function()
|
||||
search('cat ~/.config/vis/global-marks.txt | fzf --tac')
|
||||
end, 'global marks: jump')
|
||||
|
||||
vis:map(vis.modes.NORMAL, ' me', function()
|
||||
vis:command('o ~/.config/vis/global-marks.txt')
|
||||
end, 'global marks: edit')
|
||||
end)
|
||||
|
||||
vis.events.subscribe(vis.events.WIN_OPEN, function(win)
|
||||
|
||||
@@ -5,13 +5,13 @@ imv = [
|
||||
zathura = [
|
||||
{ run = 'zathura "$@"', orphan = true },
|
||||
]
|
||||
nvim_cd = [
|
||||
{ run = 'nvim -c "cd $@"', block = true }
|
||||
fzf_vis = [
|
||||
{ run = 'cd "$@" && fd --type f | fzf --bind "enter:become(vis {})"', block = true }
|
||||
]
|
||||
|
||||
[open]
|
||||
prepend_rules = [
|
||||
{ mime = "image/*", use = "imv" },
|
||||
{ mime = "application/pdf", use = "zathura" },
|
||||
{ mime = "inode/directory", use = "nvim_cd" }
|
||||
{ mime = "inode/directory", use = "fzf_vis" }
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user