Updated puppet config in nvim

This commit is contained in:
Ben Vincent 2023-10-22 18:52:41 +11:00
parent d54f1fa754
commit 07778c29e3
4 changed files with 39 additions and 11 deletions

View File

@ -197,3 +197,5 @@ require('onedark').setup {
style = 'darker' style = 'darker'
} }
require('onedark').load() require('onedark').load()
require('func.puppet')

View File

@ -1,6 +1,6 @@
-- FUNCTIONS -- -- FUNCTIONS --
-- puppet language functions -- all language functions
vim.cmd [[ vim.cmd [[
augroup lang_all augroup lang_all
autocmd! autocmd!
@ -8,11 +8,12 @@ vim.cmd [[
augroup END augroup END
]] ]]
-- puppet language functions -- puppet language keybindings
vim.cmd [[ vim.cmd [[
augroup lang_puppet augroup lang_puppet
autocmd! autocmd!
autocmd FileType puppet luafile ~/.config/nvim/lua/func/puppet.lua autocmd FileType puppet nnoremap <buffer> <Leader>g :call OpenPuppetClassOrTemplate()<CR>
autocmd FileType puppet nnoremap <buffer> <Leader>t :call OpenPuppetTestMode()<CR>
augroup END augroup END
]] ]]

View File

@ -35,7 +35,7 @@ endfunction
-- follow links to classes -- follow links to classes
vim.cmd([[ vim.cmd([[
function! OpenPuppetClass() function! OpenPuppetProfileOrRole()
" Get the line under the cursor " Get the line under the cursor
let line = getline(".") let line = getline(".")
@ -77,8 +77,8 @@ function! OpenPuppetTemplate()
" Get the line under the cursor " Get the line under the cursor
let line = getline(".") let line = getline(".")
" Use regex to find the full template name " Use regex to find the full template name (erb or epp)
let template = matchstr(line, 'profiles\/.*\.erb') let template = matchstr(line, 'profiles\/.*\.\(erb\|epp\)')
" Initialize an empty variable for the new directory path " Initialize an empty variable for the new directory path
let newpath = "" let newpath = ""
@ -100,9 +100,31 @@ function! OpenPuppetTemplate()
endfunction endfunction
]]) ]])
-- keybindings -- open puppet resource
vim.cmd([[ vim.cmd([[
nnoremap <Leader>g :call OpenPuppetClass()<CR> function! OpenPuppetClassOrTemplate()
nnoremap <Leader>h :call OpenPuppetTemplate()<CR> " Get the line under the cursor
nnoremap <Leader>t :call OpenPuppetTestMode()<CR> let line = getline(".")
" Check if it's a template (erb or epp)
if line =~ 'profiles\/.*\.\(erb\|epp\)'
call OpenPuppetTemplate()
return
endif
" Check if it's an included class (profiles:: or roles::)
if line =~ '\(profiles\|roles\)::'
call OpenPuppetProfileOrRole()
return
endif
" If none of the above, show an error message
echo "Unrecognized puppet resource."
endfunction
]]) ]])
-- -- keybindings
-- vim.cmd([[
-- nnoremap <Leader>g :call OpenPuppetClassOrTemplate()<CR>
-- nnoremap <Leader>t :call OpenPuppetTestMode()<CR>
-- ]])

View File

@ -3,6 +3,9 @@ set-option -g prefix C-a
unbind C-a unbind C-a
bind C-a send-prefix bind C-a send-prefix
# fix home/end issues in neovim
set -g default-terminal "tmux-256color"
# Enable mouse support # Enable mouse support
set-option -g mouse on set-option -g mouse on