multiple updates
vim/nvim functions/keys shell aliases waybar config password-store submodule
This commit is contained in:
parent
d935c04dad
commit
14159884fa
@ -4,7 +4,10 @@
|
||||
vim.cmd [[
|
||||
augroup lang_all
|
||||
autocmd!
|
||||
autocmd FileType * luafile ~/.config/nvim/lua/func/utils.lua
|
||||
autocmd FileType * luafile ~/.config/nvim/lua/func/tabline.lua
|
||||
autocmd FileType * luafile ~/.config/nvim/lua/func/popterm.lua
|
||||
autocmd FileType * luafile ~/.config/nvim/lua/func/sessions.lua
|
||||
augroup END
|
||||
]]
|
||||
|
||||
@ -12,7 +15,10 @@ vim.cmd [[
|
||||
vim.cmd [[
|
||||
augroup lang_puppet
|
||||
autocmd!
|
||||
autocmd FileType puppet nnoremap <buffer> <Leader>g :call OpenPuppetClassOrTemplate()<CR>
|
||||
autocmd FileType puppet nnoremap <buffer> <Leader>gg :call OpenPuppetClassOrTemplate(tab)<CR>
|
||||
autocmd FileType puppet nnoremap <buffer> <Leader>gt :call OpenPuppetClassOrTemplate(tab)<CR>
|
||||
autocmd FileType puppet nnoremap <buffer> <Leader>gh :call OpenPuppetClassOrTemplate(horizontal)<CR>
|
||||
autocmd FileType puppet nnoremap <buffer> <Leader>gv :call OpenPuppetClassOrTemplate(vertical)<CR>
|
||||
autocmd FileType puppet nnoremap <buffer> <Leader>t :call OpenPuppetTestMode()<CR>
|
||||
autocmd BufNewFile site/roles/manifests/**.pp call ApplyPuppetTemplate()
|
||||
autocmd BufNewFile site/profiles/manifests/**.pp call ApplyPuppetTemplate()
|
||||
|
||||
38
.config/nvim/lua/func/popterm.lua
Normal file
38
.config/nvim/lua/func/popterm.lua
Normal file
@ -0,0 +1,38 @@
|
||||
-- enter testmode
|
||||
vim.cmd([[
|
||||
" nvim-only config
|
||||
if has('nvim')
|
||||
|
||||
function! OpenCenteredTerminal()
|
||||
" Calculate the desired width and height as 80% of the current window size
|
||||
let height = float2nr((&lines * 0.8) / 1)
|
||||
let width = float2nr((&columns * 0.8) / 1)
|
||||
|
||||
" Calculate the top and left positions to center the terminal
|
||||
let top = float2nr((&lines - height) / 2)
|
||||
let left = float2nr((&columns - width) / 2)
|
||||
|
||||
" Define options for the floating window, including its size and position
|
||||
let opts = {'relative': 'editor', 'row': top, 'col': left, 'width': width, 'height': height, 'style': 'minimal'}
|
||||
|
||||
" Create a new buffer for the terminal, set it to not listed and with no swapfile
|
||||
let buf = nvim_create_buf(v:false, v:true)
|
||||
|
||||
" Open a new window with the terminal buffer, applying the specified options
|
||||
call nvim_open_win(buf, v:true, opts)
|
||||
|
||||
" Run the default shell in the terminal
|
||||
call termopen($SHELL)
|
||||
|
||||
" Adjust the focus to the newly opened terminal window
|
||||
startinsert
|
||||
endfunction
|
||||
|
||||
" Define the :Popterm command to open the centered terminal
|
||||
command! Popterm call OpenCenteredTerminal()
|
||||
highlight Terminal guibg=#000000 guifg=none
|
||||
nnoremap T :Popterm<CR>
|
||||
autocmd TermOpen * setlocal winhighlight=Normal:Terminal
|
||||
|
||||
endif
|
||||
]])
|
||||
@ -35,7 +35,7 @@ endfunction
|
||||
|
||||
-- follow links to classes
|
||||
vim.cmd([[
|
||||
function! OpenPuppetProfileOrRole()
|
||||
function! OpenPuppetProfileOrRole(layout)
|
||||
|
||||
" Get the line under the cursor
|
||||
let line = getline(".")
|
||||
@ -65,14 +65,21 @@ function! OpenPuppetProfileOrRole()
|
||||
let fullpath = dirpath . filepath . ".pp"
|
||||
|
||||
" Open the file in a new tab
|
||||
execute "tabedit " . fullpath
|
||||
|
||||
if a:layout == 'horizontal'
|
||||
execute 'split ' . fullpath
|
||||
elseif a:layout == 'vertical'
|
||||
execute 'vsplit ' . fullpath
|
||||
elseif a:layout == 'tab'
|
||||
execute 'tabedit ' . fullpath
|
||||
else
|
||||
echo "Invalid layout specified."
|
||||
endif
|
||||
endfunction
|
||||
]])
|
||||
|
||||
-- follow links to templates
|
||||
vim.cmd([[
|
||||
function! OpenPuppetTemplate()
|
||||
function! OpenPuppetTemplate(layout)
|
||||
|
||||
" Get the line under the cursor
|
||||
let line = getline(".")
|
||||
@ -95,8 +102,15 @@ function! OpenPuppetTemplate()
|
||||
let fullpath = newpath
|
||||
|
||||
" Open the file in a new tab
|
||||
execute "tabedit " . fullpath
|
||||
|
||||
if a:layout == 'horizontal'
|
||||
execute 'split ' . fullpath
|
||||
elseif a:layout == 'vertical'
|
||||
execute 'vsplit ' . fullpath
|
||||
elseif a:layout == 'tab'
|
||||
execute 'tabedit ' . fullpath
|
||||
else
|
||||
echo "Invalid layout specified."
|
||||
endif
|
||||
endfunction
|
||||
]])
|
||||
|
||||
|
||||
22
.config/nvim/lua/func/sessions.lua
Normal file
22
.config/nvim/lua/func/sessions.lua
Normal file
@ -0,0 +1,22 @@
|
||||
vim.cmd([[
|
||||
command! SaveSession call SaveSession()
|
||||
function! SaveSession()
|
||||
let session_file = g:session_dir . GetRepositoryName() . '_' . GetCurrentGitBranch() . '.vim'
|
||||
execute 'mksession! ' . session_file
|
||||
echo "Session saved to " . session_file
|
||||
endfunction
|
||||
|
||||
command! LoadSession call LoadSession()
|
||||
function! LoadSession()
|
||||
let session_file = g:session_dir . GetRepositoryName() . '_' . GetCurrentGitBranch() . '.vim'
|
||||
if filereadable(session_file)
|
||||
execute 'source ' . session_file
|
||||
echo "Session loaded from " . session_file
|
||||
else
|
||||
echo "No session found for the current Git branch in the repository"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
nnoremap <silent> <Leader>ss :SaveSession<CR>
|
||||
nnoremap <silent> <Leader>sl :LoadSession<CR>
|
||||
]])
|
||||
43
.config/nvim/lua/func/tabline.lua
Normal file
43
.config/nvim/lua/func/tabline.lua
Normal file
@ -0,0 +1,43 @@
|
||||
vim.cmd([[
|
||||
set showtabline=2
|
||||
set tabline=%!TabLineNumbered()
|
||||
|
||||
function! TabLineNumbered()
|
||||
let s = ''
|
||||
let wn = ''
|
||||
let t = tabpagenr()
|
||||
let i = 1
|
||||
while i <= tabpagenr('$')
|
||||
let buflist = tabpagebuflist(i)
|
||||
let buf = buflist[tabpagewinnr(i) - 1]
|
||||
let file = fnamemodify(bufname(buf), ':t')
|
||||
if i == t
|
||||
let s .= '%' . i . 'T'
|
||||
let s .= '%#TabLineSel#'
|
||||
let wn .= '%' . i . 'T'
|
||||
let wn .= '%#TabLineSel#'
|
||||
else
|
||||
let s .= '%' . i . 'T'
|
||||
let s .= '%#TabLine#'
|
||||
let wn .= '%' . i . 'T'
|
||||
let wn .= '%#TabLine#'
|
||||
endif
|
||||
|
||||
let s .= ' ' . i . ' '
|
||||
let wn .= ' ' . i . ' '
|
||||
|
||||
" Truncate the file name if it's too long
|
||||
if len(file) > 20
|
||||
let file = strpart(file, 0, 20) . '..'
|
||||
endif
|
||||
let s .= file . ' '
|
||||
let wn .= file . ' '
|
||||
let s .= '%T'
|
||||
let wn .= '%T'
|
||||
let s .= '%#TabLine#|'
|
||||
let wn .= '%#TabLine#|'
|
||||
let i += 1
|
||||
endwhile
|
||||
return s
|
||||
endfunction
|
||||
]])
|
||||
14
.config/nvim/lua/func/utils.lua
Normal file
14
.config/nvim/lua/func/utils.lua
Normal file
@ -0,0 +1,14 @@
|
||||
vim.cmd([[
|
||||
function! GetRepositoryName()
|
||||
let repo_path = system("git -C " . getcwd() . " rev-parse --show-toplevel")
|
||||
let repo_name = fnamemodify(trim(repo_path), ':t')
|
||||
let repo_name_clean = substitute(repo_name, '[\/\-\s]', '_', 'g')
|
||||
return repo_name_clean
|
||||
endfunction
|
||||
|
||||
function! GetCurrentGitBranch()
|
||||
let l:branch = system("git -C " . getcwd() . " branch --show-current")
|
||||
let l:branch_clean = substitute(trim(l:branch), '[\/\-\s]', '_', 'g')
|
||||
return l:branch_clean
|
||||
endfunction
|
||||
]])
|
||||
@ -45,4 +45,9 @@ map('', '<C-n>', ':NvimTreeToggle<CR>', {})
|
||||
map('n', 'l', ':IndentLinesToggle<CR>', {})
|
||||
map('n', 't', ':TagbarToggle<CR>', {})
|
||||
map('n', 'ff', [[:Telescope find_files]], {})
|
||||
map('n', 'T', ':lua require("FTerm").toggle()<CR>', {})
|
||||
-- map('n', 'T', ':lua require("FTerm").toggle()<CR>', {})
|
||||
|
||||
-- Open a file in a vertical split, horizontal split and move a split to a new tab
|
||||
map('n', '<Leader>sv', ':vsplit ', {noremap = true, silent = false})
|
||||
map('n', '<Leader>sh', ':split ', {noremap = true, silent = false})
|
||||
map('n', '<Leader>mt', ':tabedit %<CR>', {noremap = true, silent = true})
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit ffde3d6a5fa4ec163abf5923c1aba6c28ac6d47b
|
||||
Subproject commit 8bafa7394bfcb8cfbafc43190be64cee6e70aa7c
|
||||
@ -59,6 +59,7 @@ alias sshconfig="$EDITOR ~/.ssh/config"
|
||||
alias edithosts="sudoedit /etc/hosts"
|
||||
alias vimrc="(cd ~/.config/nvim/; $EDITOR)"
|
||||
alias tigrc="$EDITOR $HOME/.config/tig/config"
|
||||
alias swayrc="$EDITOR ~/.config/sway/config"
|
||||
|
||||
# yadm
|
||||
alias yap="yadm add -p"
|
||||
@ -81,8 +82,16 @@ alias lvcreate='sudo lvcreate'
|
||||
alias lvresize='sudo lvresize'
|
||||
|
||||
# BTRFS
|
||||
alias snapshot_home="sudo btrfs subvol snapshot /mnt/btrfsroot/home /.snaps/home@$(date '+%Y-%m-%d_%H-%M-%S')"
|
||||
alias snapshot_rootfs="sudo btrfs subvol snapshot /mnt/btrfsroot/rootfs /.snaps/rootfs@$(date '+%Y-%m-%d_%H-%M-%S')"
|
||||
alias snapshot_home="sudo btrfs subvol snapshot /mnt/btrfsroot/@home /.snaps/home@$(date +'%Y%m%d')"
|
||||
alias snapshot_rootfs="sudo btrfs subvol snapshot /mnt/btrfsroot/@rootfs /.snaps/rootfs@$(date +'%Y%m%d')"
|
||||
|
||||
# sudo rm /mnt/btrfsroot/@snaps/home-latest
|
||||
# sudo btrfs subvolume snapshot -r /mnt/btrfsroot/@home /mnt/btrfsroot/@snaps/home-$(shdate)
|
||||
# sudo ln -s /mnt/btrfsroot/@snaps/home-$(shdate) /mnt/btrfsroot/@snaps/home-latest
|
||||
|
||||
# sudo rm /mnt/btrfsroot/@snaps/rootfs-latest
|
||||
# sudo btrfs subvolume snapshot -r /mnt/btrfsroot/@rootfs /mnt/btrfsroot/@snaps/rootfs-$(shdate)
|
||||
# sudo ln -s /mnt/btrfsroot/@snaps/rootfs-$(shdate) /mnt/btrfsroot/@snaps/rootfs-latest
|
||||
|
||||
# youtube-dl
|
||||
alias soundcloud-dl='youtube-dlc --extract-audio --audio-format vorbis --audio-quality 2'
|
||||
|
||||
@ -68,7 +68,7 @@
|
||||
"tooltip": false
|
||||
},
|
||||
"clock#3": {
|
||||
"format": "{:%m-%d}",
|
||||
"format": "{:%Y-%m-%d}",
|
||||
"tooltip": false
|
||||
},
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user