Compare commits

..

3 Commits

3 changed files with 52 additions and 94 deletions

View File

@@ -48,42 +48,6 @@ set -g status-left-length 50
set -g status-right "#[fg=#316781]#[bg=#316781]#[fg=#abb5ba] %H:%M #[bg=default]#[fg=#316781] " set -g status-right "#[fg=#316781]#[bg=#316781]#[fg=#abb5ba] %H:%M #[bg=default]#[fg=#316781] "
set-window-option -g window-status-current-format '#[fg=#316781]#[bg=#316781]#[fg=#abb5ba] #I:#W#F #[fg=#316781]#[bg=black]' set-window-option -g window-status-current-format '#[fg=#316781]#[bg=#316781]#[fg=#abb5ba] #I:#W#F #[fg=#316781]#[bg=black]'
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?\.?(view|n?vim?x?)(-wrapped)?(diff)?$'"
bind-key -n 'M-h' if-shell "$is_vim" 'send-keys M-h' 'select-pane -L'
bind-key -n 'M-j' if-shell "$is_vim" 'send-keys M-j' 'select-pane -D'
bind-key -n 'M-k' if-shell "$is_vim" 'send-keys M-k' 'select-pane -U'
bind-key -n 'M-l' if-shell "$is_vim" 'send-keys M-l' 'select-pane -R'
bind-key -n 'M-n' if-shell "$is_vim" 'send-keys M-n' 'select-window -n'
bind-key -n 'M-p' if-shell "$is_vim" 'send-keys M-p' 'select-window -p'
bind-key -T copy-mode-vi 'M-h' select-pane -L
bind-key -T copy-mode-vi 'M-j' select-pane -D
bind-key -T copy-mode-vi 'M-k' select-pane -U
bind-key -T copy-mode-vi 'M-l' select-pane -R
bind-key -T copy-mode-vi 'M-n' select-window -n
bind-key -T copy-mode-vi 'M-p' select-window -p
bind -n 'M-H' if-shell "$is_vim" 'send-keys M-H' 'resize-pane -L 1'
bind -n 'M-J' if-shell "$is_vim" 'send-keys M-J' 'resize-pane -D 1'
bind -n 'M-K' if-shell "$is_vim" 'send-keys M-K' 'resize-pane -U 1'
bind -n 'M-L' if-shell "$is_vim" 'send-keys M-L' 'resize-pane -R 1'
bind-key -T copy-mode-vi M-H resize-pane -L 1
bind-key -T copy-mode-vi M-J resize-pane -D 1
bind-key -T copy-mode-vi M-K resize-pane -U 1
bind-key -T copy-mode-vi M-L resize-pane -R 1
bind -n 'C-M-h' if-shell "$is_vim" 'send-keys C-M-h' 'swap-pane -s "{left-of}"'
bind -n 'C-M-j' if-shell "$is_vim" 'send-keys C-M-j' 'swap-pane -s "{down-of}"'
bind -n 'C-M-k' if-shell "$is_vim" 'send-keys C-M-k' 'swap-pane -s "{up-of}"'
bind -n 'C-M-l' if-shell "$is_vim" 'send-keys C-M-l' 'swap-pane -s "{right-of}"'
bind-key -T copy-mode-vi C-M-h swap-pane -s "{left-of}"
bind-key -T copy-mode-vi C-M-j swap-pane -s "{down-of}"
bind-key -T copy-mode-vi C-M-k swap-pane -s "{up-of}"
bind-key -T copy-mode-vi C-M-l swap-pane -s "{right-of}"
bind-key -n M-0 run-shell tmux-session-menu bind-key -n M-0 run-shell tmux-session-menu
bind -T copy-mode-vi v send -X begin-selection bind -T copy-mode-vi v send -X begin-selection

View File

@@ -1,71 +1,65 @@
-- Copyright 2006-2025 Mitchell. See LICENSE. -- Copyright 2006-2025 Mitchell. See LICENSE.
-- Go LPeg lexer. -- templ LPeg lexer.
local lexer = lexer local lexer = lexer
local starts_line = lexer.starts_line
local P, S = lpeg.P, lpeg.S local P, S = lpeg.P, lpeg.S
local lex = lexer.new(...) local lex = lexer.new(..., {inherit = lexer.load('go')})
-- Keywords. local close_paren = lex:tag(lexer.OPERATOR, P(')'))
lex:add_rule('keyword', lex:tag(lexer.KEYWORD, lex:word_match(lexer.KEYWORD))) local open_brace = lex:tag(lexer.OPERATOR, P('{'))
local close_brace = lex:tag(lexer.OPERATOR, P('}'))
local colon = lex:tag(lexer.OPERATOR, P(':'))
local at = lex:tag(lexer.OPERATOR, P('@'))
local ws = lex:get_rule('whitespace')
local ident = lex:get_rule('identifier')
-- Constants. local html = lexer.load('html')
lex:add_rule('constant', lex:tag(lexer.CONSTANT_BUILTIN, lex:word_match(lexer.CONSTANT_BUILTIN))) local go_expr = lexer.load('go', 'go.expr')
local go_stmt1 = lexer.load('go', 'go.stmt1')
local go_stmt2 = lexer.load('go', 'go.stmt2')
local go_stmt3 = lexer.load('go', 'go.stmt3')
local for_ = lex:tag(lexer.KEYWORD, lexer.word_match('for if switch'))
local else_ = close_brace * ws^0 * lex:tag(lexer.KEYWORD, P('else'))
local case_ = lex:tag(lexer.KEYWORD, lexer.word_match('case default'))
html:embed(go_expr, open_brace, close_brace * close_brace^-1)
html:embed(go_stmt1, starts_line(for_ + else_, true), open_brace * #lexer.newline)
html:embed(go_stmt2, starts_line(case_, true), colon * #lexer.newline)
html:embed(go_stmt3, starts_line(at, true), (ident + open_brace + close_paren) * #lexer.newline)
-- Types. local func_block_start = close_paren * ws^0 * open_brace
lex:add_rule('type', lex:tag(lexer.TYPE, lex:word_match(lexer.TYPE)))
-- Functions. lex:set_word_list(lexer.KEYWORD, 'templ css script', true)
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. local function starts_with(keyword)
lex:add_rule('identifier', lex:tag(lexer.IDENTIFIER, lexer.word)) local prefix = '\n' .. keyword .. '%s'
return function(input, index)
local i = index - 1024
if i < 1 then
i = 1
end
local s = input:sub(i, index)
local k = 0
repeat
i = s:find('\n%w', i)
if i then
k = i
i = i + 2
end
until not i
return k > 0 and s:find(prefix, k) and true
end
end
-- Strings. lex:embed(html, func_block_start * P(starts_with("templ")), starts_line(close_brace))
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 css = lexer.load('css')
local line_comment = lexer.to_eol('//') local css_go_expr = lexer.load('go', 'go.expr2')
local block_comment = lexer.range('/*', '*/') css:embed(css_go_expr, open_brace, close_brace)
lex:add_rule('comment', lex:tag(lexer.COMMENT, line_comment + block_comment)) lex:embed(css, func_block_start * P(starts_with("css")), starts_line(close_brace))
-- Numbers. local js = lexer.load('javascript')
lex:add_rule('number', lex:tag(lexer.NUMBER, lexer.number * P('i')^-1)) lex:embed(js, func_block_start * P(starts_with("script")), starts_line(close_brace))
-- 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 return lex

View File

@@ -64,7 +64,7 @@ local function open_file_current_line(open_cmd)
end end
local function escape_and_quoted(s) local function escape_and_quoted(s)
return "'" .. s:gsub("'", "\\'") .. "'" return "'" .. s:gsub("'", [['"'"']]) .. "'"
end end
local function cmd_action(cmd, action) local function cmd_action(cmd, action)
@@ -238,7 +238,7 @@ vis.events.subscribe(vis.events.INIT, function()
vis:command('!lazygit') vis:command('!lazygit')
end, 'lazygit') end, 'lazygit')
vis:map(vis.modes.NORMAL, ' jl', function() vis:map(vis.modes.NORMAL, ' gj', function()
vis:command('!lazyjj') vis:command('!lazyjj')
end, 'lazyjj') end, 'lazyjj')