Compare commits
3 Commits
3f34f1c684
...
ebec63e48c
| Author | SHA1 | Date | |
|---|---|---|---|
| ebec63e48c | |||
| b600226065 | |||
| 4398125c7b |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,3 +9,4 @@ lupan-wm/target
|
|||||||
__pycache__
|
__pycache__
|
||||||
/dwm
|
/dwm
|
||||||
/st
|
/st
|
||||||
|
/vis/.config/vis/plugins/
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# example dkrc to provide a close-to-default setup and
|
|
||||||
# show some basic command usage with error reporting
|
|
||||||
|
|
||||||
# determine where to place the log file
|
# determine where to place the log file
|
||||||
logfile="$HOME/.dkrc.log"
|
logfile="$HOME/.dkrc.log"
|
||||||
[ -d "$HOME/.local/share/xorg" ] && logfile="$HOME/.local/share/xorg/dkrc.log"
|
[ -d "$HOME/.local/share/xorg" ] && logfile="$HOME/.local/share/xorg/dkrc.log"
|
||||||
@@ -55,8 +52,7 @@ fi
|
|||||||
# ws=6 name="6" \
|
# ws=6 name="6" \
|
||||||
|
|
||||||
# enable static workspaces assigned to monitors (relevant for multiple monitors)
|
# enable static workspaces assigned to monitors (relevant for multiple monitors)
|
||||||
#echo $(polybar -m | sed 's/+/:/g' | awk -F: '{print $3, $1}' | sort -n | cut -d' ' -f2) | read mon1 mon2 mon3
|
monitors=$(polybar -m | sed 's/+/:/g' | awk -F: '{print $3, $1}' | sort -n | cut -d' ' -f2 | xargs)
|
||||||
monitors=$(polybar -m | sed 's/+/:/g' | awk -F: '{print $3, $1}' | sort -n | cut -d' ' -f2)
|
|
||||||
mon1=$(echo $monitors | cut -d' ' -f1)
|
mon1=$(echo $monitors | cut -d' ' -f1)
|
||||||
mon2=$(echo $monitors | cut -d' ' -f2)
|
mon2=$(echo $monitors | cut -d' ' -f2)
|
||||||
mon3=$(echo $monitors | cut -d' ' -f3)
|
mon3=$(echo $monitors | cut -d' ' -f3)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
# launcher
|
# launcher
|
||||||
mod4 + p
|
mod4 + p
|
||||||
dmenu_run -fn 'Fira Code Nerd Font Ret:size=13'
|
dmenu_run -fn 'Fira Code Nerd Font Ret:size=13'
|
||||||
|
|
||||||
# terminal
|
# terminal
|
||||||
mod4 + shift + Return
|
mod4 + shift + Return
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ separator-foreground = ${colors.disabled}
|
|||||||
font-0 = Fira Code Nerd Font:size=18;4
|
font-0 = Fira Code Nerd Font:size=18;4
|
||||||
|
|
||||||
modules-left = xworkspaces xwindow
|
modules-left = xworkspaces xwindow
|
||||||
modules-right = filesystem pulseaudio xkeyboard memory cpu temperature wlan eth date
|
modules-right = filesystem pulseaudio xkeyboard memory cpu wlan eth date
|
||||||
|
|
||||||
cursor-click = pointer
|
cursor-click = pointer
|
||||||
cursor-scroll = ns-resize
|
cursor-scroll = ns-resize
|
||||||
|
|||||||
@@ -14,3 +14,11 @@ fi
|
|||||||
|
|
||||||
alias nocaps='setxkbmap pl -option ctrl:nocaps'
|
alias nocaps='setxkbmap pl -option ctrl:nocaps'
|
||||||
alias fixdp='xrandr --output DP-0 --right-of DP-2'
|
alias fixdp='xrandr --output DP-0 --right-of DP-2'
|
||||||
|
|
||||||
|
vf() {
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
vis $(fzf)
|
||||||
|
else
|
||||||
|
vis $(fzf -q $1)
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|||||||
71
vis/.config/vis/lexers/templ.lua
Normal file
71
vis/.config/vis/lexers/templ.lua
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
-- Copyright 2006-2025 Mitchell. See LICENSE.
|
||||||
|
-- Go LPeg lexer.
|
||||||
|
|
||||||
|
local lexer = lexer
|
||||||
|
local P, S = lpeg.P, lpeg.S
|
||||||
|
|
||||||
|
local lex = lexer.new(...)
|
||||||
|
|
||||||
|
-- Keywords.
|
||||||
|
lex:add_rule('keyword', lex:tag(lexer.KEYWORD, lex:word_match(lexer.KEYWORD)))
|
||||||
|
|
||||||
|
-- Constants.
|
||||||
|
lex:add_rule('constant', lex:tag(lexer.CONSTANT_BUILTIN, lex:word_match(lexer.CONSTANT_BUILTIN)))
|
||||||
|
|
||||||
|
-- Types.
|
||||||
|
lex:add_rule('type', lex:tag(lexer.TYPE, lex:word_match(lexer.TYPE)))
|
||||||
|
|
||||||
|
-- Functions.
|
||||||
|
local builtin_func = -lpeg.B('.') *
|
||||||
|
lex:tag(lexer.FUNCTION_BUILTIN, lex:word_match(lexer.FUNCTION_BUILTIN))
|
||||||
|
local func = lex:tag(lexer.FUNCTION, lexer.word)
|
||||||
|
local method = lpeg.B('.') * lex:tag(lexer.FUNCTION_METHOD, lexer.word)
|
||||||
|
lex:add_rule('function', (builtin_func + method + func) * #(lexer.space^0 * '('))
|
||||||
|
|
||||||
|
-- Identifiers.
|
||||||
|
lex:add_rule('identifier', lex:tag(lexer.IDENTIFIER, lexer.word))
|
||||||
|
|
||||||
|
-- Strings.
|
||||||
|
local sq_str = lexer.range("'", true)
|
||||||
|
local dq_str = lexer.range('"', true)
|
||||||
|
local raw_str = lexer.range('`', false, false)
|
||||||
|
lex:add_rule('string', lex:tag(lexer.STRING, sq_str + dq_str + raw_str))
|
||||||
|
|
||||||
|
-- Comments.
|
||||||
|
local line_comment = lexer.to_eol('//')
|
||||||
|
local block_comment = lexer.range('/*', '*/')
|
||||||
|
lex:add_rule('comment', lex:tag(lexer.COMMENT, line_comment + block_comment))
|
||||||
|
|
||||||
|
-- Numbers.
|
||||||
|
lex:add_rule('number', lex:tag(lexer.NUMBER, lexer.number * P('i')^-1))
|
||||||
|
|
||||||
|
-- Operators.
|
||||||
|
lex:add_rule('operator', lex:tag(lexer.OPERATOR, S('+-*/%&|^<>=!~:;.,()[]{}@')))
|
||||||
|
|
||||||
|
-- Fold points.
|
||||||
|
lex:add_fold_point(lexer.OPERATOR, '{', '}')
|
||||||
|
lex:add_fold_point(lexer.COMMENT, '/*', '*/')
|
||||||
|
|
||||||
|
-- Word lists.
|
||||||
|
lex:set_word_list(lexer.KEYWORD, {
|
||||||
|
'break', 'case', 'chan', 'const', 'continue', 'default', 'defer', 'else', 'fallthrough', 'for',
|
||||||
|
'func', 'go', 'goto', 'if', 'import', 'interface', 'map', 'package', 'range', 'return', 'select',
|
||||||
|
'struct', 'switch', 'type', 'var', 'templ'
|
||||||
|
})
|
||||||
|
|
||||||
|
lex:set_word_list(lexer.CONSTANT_BUILTIN, 'true false iota nil')
|
||||||
|
|
||||||
|
lex:set_word_list(lexer.TYPE, {
|
||||||
|
'any', 'bool', 'byte', 'comparable', 'complex64', 'complex128', 'error', 'float32', 'float64',
|
||||||
|
'int', 'int8', 'int16', 'int32', 'int64', 'rune', 'string', 'uint', 'uint8', 'uint16', 'uint32',
|
||||||
|
'uint64', 'uintptr'
|
||||||
|
})
|
||||||
|
|
||||||
|
lex:set_word_list(lexer.FUNCTION_BUILTIN, {
|
||||||
|
'append', 'cap', 'close', 'complex', 'copy', 'delete', 'imag', 'len', 'make', 'new', 'panic',
|
||||||
|
'print', 'println', 'real', 'recover'
|
||||||
|
})
|
||||||
|
|
||||||
|
lexer.property['scintillua.comment'] = '//'
|
||||||
|
|
||||||
|
return lex
|
||||||
204
vis/.config/vis/visrc.lua
Normal file
204
vis/.config/vis/visrc.lua
Normal file
@@ -0,0 +1,204 @@
|
|||||||
|
require('vis')
|
||||||
|
|
||||||
|
local plug = (function()
|
||||||
|
if not pcall(require, 'plugins/vis-plug') then
|
||||||
|
os.execute('git clone --quiet https://github.com/erf/vis-plug ' ..
|
||||||
|
(os.getenv('XDG_CONFIG_HOME') or os.getenv('HOME') .. '/.config')
|
||||||
|
.. '/vis/plugins/vis-plug')
|
||||||
|
end
|
||||||
|
return require('plugins/vis-plug')
|
||||||
|
end)()
|
||||||
|
|
||||||
|
plug = require('plugins/vis-plug')
|
||||||
|
|
||||||
|
local plugins = {
|
||||||
|
{
|
||||||
|
'scaramacai/vis-themes',
|
||||||
|
theme = true,
|
||||||
|
file = 'almostnord',
|
||||||
|
-- file = 'strange-morning',
|
||||||
|
},
|
||||||
|
{ 'https://gitlab.com/muhq/vis-lspc', alias = 'lspc' },
|
||||||
|
{ 'lutobler/vis-commentary' },
|
||||||
|
{ 'https://repo.or.cz/vis-surround.git' },
|
||||||
|
{ 'peaceant/vis-fzf-mru', file = 'fzf-mru', alias = 'fzfmru' },
|
||||||
|
{ 'https://gitlab.com/muhq/vis-build' },
|
||||||
|
{ 'erf/vis-cursors' },
|
||||||
|
}
|
||||||
|
|
||||||
|
plug.init(plugins, true)
|
||||||
|
|
||||||
|
vis.ftdetect.filetypes.templ = {
|
||||||
|
ext = { "%.templ$" },
|
||||||
|
}
|
||||||
|
|
||||||
|
plug.plugins.lspc.message_level = 2
|
||||||
|
|
||||||
|
plug.plugins.lspc.ls_map.templ = {
|
||||||
|
name = 'templ-lsp',
|
||||||
|
cmd = 'templ lsp',
|
||||||
|
}
|
||||||
|
|
||||||
|
plug.plugins.fzfmru.fzfmru_history = 60
|
||||||
|
|
||||||
|
local function open_file(file, cmd)
|
||||||
|
vis:command((cmd or 'o') .. ' ' .. file)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function nil_or_tonumber(s)
|
||||||
|
return s and tonumber(s)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function open_file_pos(line, open_cmd)
|
||||||
|
local iter = string.gmatch(line, '[^:]+')
|
||||||
|
local file = iter()
|
||||||
|
local line_num = nil_or_tonumber(iter())
|
||||||
|
local col = nil_or_tonumber(iter()) or 1
|
||||||
|
open_file(file, open_cmd)
|
||||||
|
if line_num ~= nil then
|
||||||
|
vis.win.selection:to(line_num, col)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function open_file_current_line(open_cmd)
|
||||||
|
local line = vis.win.file.lines[vis.win.selection.line]
|
||||||
|
vis:info(line)
|
||||||
|
open_file_pos(line)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function escape_and_quoted(s)
|
||||||
|
return "'" .. s:gsub("'", "\\'") .. "'"
|
||||||
|
end
|
||||||
|
|
||||||
|
local function search(cmd)
|
||||||
|
if cmd:match('^fzf ') and vis.register ~= '"' then
|
||||||
|
local reg = string.gsub(vis.registers[vis.register][1], '%z', '')
|
||||||
|
if reg ~= '' then
|
||||||
|
cmd = cmd .. ' --query=' .. escape_and_quoted(reg)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local code, out, err = vis:pipe(cmd, true)
|
||||||
|
if code == 0 then
|
||||||
|
open_file_pos(out, 'e')
|
||||||
|
elseif err ~= nil then
|
||||||
|
vis:info(err)
|
||||||
|
elseif code ~= 0 then
|
||||||
|
vis:info('Program exit code ' .. code)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local file_slots = {}
|
||||||
|
|
||||||
|
local function set_file_slot(num)
|
||||||
|
local file = vis.win.file.path
|
||||||
|
if file ~= nil then
|
||||||
|
file_slots[num] = file
|
||||||
|
vis:info('File slot [' .. num .. '] updated')
|
||||||
|
else
|
||||||
|
vis:info('Window has no file')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function open_file_slot(num, open_cmd)
|
||||||
|
local file = file_slots[num]
|
||||||
|
if file == nil then
|
||||||
|
vis:info('File slot [' .. num .. '] empty')
|
||||||
|
elseif file == vis.win.file.path then
|
||||||
|
vis:info('File slot [' .. num .. '] is the same file, no file change')
|
||||||
|
else
|
||||||
|
vis:info('File slot [' .. num .. '] open')
|
||||||
|
open_file(file, open_cmd)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function fzf_reload(cmd)
|
||||||
|
local prompt = escape_and_quoted('1. ' .. cmd:match('^%w*') .. '> ')
|
||||||
|
if not cmd:match('{q}') then
|
||||||
|
cmd = cmd .. ' {q}'
|
||||||
|
end
|
||||||
|
return 'fzf --ansi --bind "start:reload:' .. cmd .. '" --bind "change:reload:' .. cmd .. ' || true"' ..
|
||||||
|
' --prompt ' .. prompt ..
|
||||||
|
' --bind "alt-enter:unbind(change,alt-enter)+change-prompt(2. fzf> )+enable-search+clear-query"'
|
||||||
|
end
|
||||||
|
|
||||||
|
local ripgrep = 'rg --column --line-number --color=always --smart-case'
|
||||||
|
|
||||||
|
vis.events.subscribe(vis.events.INIT, function()
|
||||||
|
vis:command('set autoindent')
|
||||||
|
|
||||||
|
vis:command_register('search', function(argv, force, win, selection, range)
|
||||||
|
search(argv[1])
|
||||||
|
end)
|
||||||
|
|
||||||
|
vis:map(vis.modes.NORMAL, '<M-k>', '<vis-window-prev>')
|
||||||
|
vis:map(vis.modes.NORMAL, '<M-j>', '<vis-window-next>')
|
||||||
|
vis:map(vis.modes.NORMAL, ' K', '<vis-window-prev>:q<Enter>', 'close previous window')
|
||||||
|
vis:map(vis.modes.NORMAL, ' J', '<vis-window-next>:q<Enter><vis-window-prev>', 'close next window')
|
||||||
|
|
||||||
|
vis:map(vis.modes.NORMAL, ' l[', ':lspc-prev-diagnostic<Enter>')
|
||||||
|
vis:map(vis.modes.NORMAL, ' l]', ':lspc-next-diagnostic<Enter>')
|
||||||
|
vis:map(vis.modes.NORMAL, ' l=', ':lspc-format<Enter>')
|
||||||
|
|
||||||
|
for num = 1, 9 do
|
||||||
|
vis:map(vis.modes.NORMAL, ' s' .. num, function() set_file_slot(num) end, 'set file slot ' .. num)
|
||||||
|
vis:map(vis.modes.NORMAL, ' ' .. num, function() open_file_slot(num, 'e') end, 'open file slot ' .. num)
|
||||||
|
vis:map(vis.modes.NORMAL, ' h' .. num, function() open_file_slot(num, 'o') end, 'open file slot ' .. num)
|
||||||
|
vis:map(vis.modes.NORMAL, ' v' .. num, function() open_file_slot(num, 'vsplit') end,
|
||||||
|
'open file slot ' .. num)
|
||||||
|
end
|
||||||
|
|
||||||
|
vis:map(vis.modes.NORMAL, ' fg', function()
|
||||||
|
search(fzf_reload(ripgrep))
|
||||||
|
end, 'fzf: rg')
|
||||||
|
|
||||||
|
vis:map(vis.modes.NORMAL, ' ff', function()
|
||||||
|
search('fd --type f | fzf')
|
||||||
|
end, 'fzf: files')
|
||||||
|
|
||||||
|
vis:map(vis.modes.NORMAL, ' .', function()
|
||||||
|
local path = vis.win.file.path
|
||||||
|
if path then
|
||||||
|
local dir = path:match('^.*/')
|
||||||
|
local arg = escape_and_quoted(dir)
|
||||||
|
search('fd --type f "" ' .. arg .. ' | fzf')
|
||||||
|
else
|
||||||
|
search('fd --type f | fzf')
|
||||||
|
end
|
||||||
|
end, 'fzf: current dir files')
|
||||||
|
|
||||||
|
vis:map(vis.modes.NORMAL, ' gf', function()
|
||||||
|
search('git ls-files | fzf')
|
||||||
|
end, 'fzf: git files')
|
||||||
|
|
||||||
|
vis:map(vis.modes.NORMAL, ' gg', function()
|
||||||
|
search(fzf_reload('git grep --column --line-number --color=always'))
|
||||||
|
end, 'fzf: jj grep')
|
||||||
|
|
||||||
|
vis:map(vis.modes.NORMAL, ' gl', function()
|
||||||
|
vis:command('!lazygit')
|
||||||
|
end, 'lazygit')
|
||||||
|
|
||||||
|
vis:map(vis.modes.NORMAL, ' jf', function()
|
||||||
|
search('jj file list | fzf')
|
||||||
|
end, 'fzf: jj files')
|
||||||
|
|
||||||
|
vis:map(vis.modes.NORMAL, ' jg', function()
|
||||||
|
search(fzf_reload(ripgrep .. ' {q} $(jj file list | xargs)'))
|
||||||
|
end, 'fzf: jj grep')
|
||||||
|
|
||||||
|
vis:map(vis.modes.NORMAL, ' jl', function()
|
||||||
|
vis:command('!lazyjj')
|
||||||
|
end, 'fzf open')
|
||||||
|
|
||||||
|
vis:map(vis.modes.NORMAL, ' ', function()
|
||||||
|
vis:command('fzfmru')
|
||||||
|
end, 'fzf recent')
|
||||||
|
|
||||||
|
vis:map(vis.modes.NORMAL, 'gf', function()
|
||||||
|
open_file_current_line('o')
|
||||||
|
end, 'open file from current line (with line and col')
|
||||||
|
end)
|
||||||
|
|
||||||
|
vis.events.subscribe(vis.events.WIN_OPEN, function(win)
|
||||||
|
vis:command('set relativenumber')
|
||||||
|
end)
|
||||||
Reference in New Issue
Block a user