diff --git a/roles/neovim/files/autoload/opdavies.vim b/roles/neovim/files/autoload/opdavies.vim new file mode 100644 index 0000000..449666b --- /dev/null +++ b/roles/neovim/files/autoload/opdavies.vim @@ -0,0 +1,12 @@ +if !exists('*opdavies#save_and_exec') + function! opdavies#save_and_exec() abort + if &filetype == 'vim' + :silent! write + :source % + elseif &filetype == 'lua' + :silent! write + :luafile % + endif + return + endfunction +endif diff --git a/roles/neovim/files/lua/opdavies/options.lua b/roles/neovim/files/lua/opdavies/options.lua index 935e400..631ccc4 100644 --- a/roles/neovim/files/lua/opdavies/options.lua +++ b/roles/neovim/files/lua/opdavies/options.lua @@ -27,7 +27,7 @@ local function set_key_mappings() local options = { noremap = true } - map("n", "so", ":luafile ~/.config/nvim/init.lua", options) + map("n", "so", ":call opdavies#save_and_exec()", options) -- Format paragraphs to an 80 character line length. map("n", "g", "gqap", options)