diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 12ce31b..cc9a734 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -197,3 +197,5 @@ require('onedark').setup { style = 'darker' } require('onedark').load() + +require('func.puppet') diff --git a/.config/nvim/lua/func.lua b/.config/nvim/lua/func.lua index a301016..06d2fcd 100644 --- a/.config/nvim/lua/func.lua +++ b/.config/nvim/lua/func.lua @@ -1,6 +1,6 @@ -- FUNCTIONS -- --- puppet language functions +-- all language functions vim.cmd [[ augroup lang_all autocmd! @@ -8,11 +8,12 @@ vim.cmd [[ augroup END ]] --- puppet language functions +-- puppet language keybindings vim.cmd [[ augroup lang_puppet - autocmd! - autocmd FileType puppet luafile ~/.config/nvim/lua/func/puppet.lua + autocmd! + autocmd FileType puppet nnoremap g :call OpenPuppetClassOrTemplate() + autocmd FileType puppet nnoremap t :call OpenPuppetTestMode() augroup END ]] diff --git a/.config/nvim/lua/func/puppet.lua b/.config/nvim/lua/func/puppet.lua index ddeb2af..e726650 100644 --- a/.config/nvim/lua/func/puppet.lua +++ b/.config/nvim/lua/func/puppet.lua @@ -35,7 +35,7 @@ endfunction -- follow links to classes vim.cmd([[ -function! OpenPuppetClass() +function! OpenPuppetProfileOrRole() " Get the line under the cursor let line = getline(".") @@ -77,8 +77,8 @@ function! OpenPuppetTemplate() " Get the line under the cursor let line = getline(".") - " Use regex to find the full template name - let template = matchstr(line, 'profiles\/.*\.erb') + " Use regex to find the full template name (erb or epp) + let template = matchstr(line, 'profiles\/.*\.\(erb\|epp\)') " Initialize an empty variable for the new directory path let newpath = "" @@ -100,9 +100,31 @@ function! OpenPuppetTemplate() endfunction ]]) --- keybindings +-- open puppet resource vim.cmd([[ -nnoremap g :call OpenPuppetClass() -nnoremap h :call OpenPuppetTemplate() -nnoremap t :call OpenPuppetTestMode() +function! OpenPuppetClassOrTemplate() + " Get the line under the cursor + 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 g :call OpenPuppetClassOrTemplate() +-- nnoremap t :call OpenPuppetTestMode() +-- ]]) diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf index 2a87d3c..2e71a67 100644 --- a/.config/tmux/tmux.conf +++ b/.config/tmux/tmux.conf @@ -3,6 +3,9 @@ set-option -g prefix C-a unbind C-a bind C-a send-prefix +# fix home/end issues in neovim +set -g default-terminal "tmux-256color" + # Enable mouse support set-option -g mouse on