From d187b47c6d0fe5ff764ef103c7d1980250ee290b Mon Sep 17 00:00:00 2001 From: Rob Sutton Date: Fri, 30 Dec 2022 18:15:55 -0500 Subject: [PATCH] feat(clipboard): support clipboard configuration --- kitchen.yml | 12 +++++++++++ nvim/clipboard.sls | 21 +++++++++++++++++++ nvim/parameters/defaults.yaml | 12 +++++++++++ .../integration/default/controls/clipboard.rb | 11 ++++++++++ 4 files changed, 56 insertions(+) create mode 100644 nvim/clipboard.sls create mode 100644 test/integration/default/controls/clipboard.rb diff --git a/kitchen.yml b/kitchen.yml index 9c6179c..9849593 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -372,3 +372,15 @@ suites: - path: test/integration/default controls: - nvim.vimplug.sensible + - name: clipboard + provisioner: + state_top: + base: + '*': + - nvim._mapdata + - nvim.clipboard + verifier: + inspec_tests: + - path: test/integration/default + controls: + - nvim.clipboard diff --git a/nvim/clipboard.sls b/nvim/clipboard.sls new file mode 100644 index 0000000..b675f59 --- /dev/null +++ b/nvim/clipboard.sls @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# vim: ft=sls + +{#- Get the `tplroot` from `tpldir` #} +{%- set tplroot = tpldir.split('/')[0] %} +{%- from tplroot ~ "/map.jinja" import mapdata as nvim with context %} +{% set vimplug_install = nvim | traverse("vimplug", False) %} +{% set clipboard = nvim | traverse("clipboard", {}) %} +{% set win32yank_version = "0.0.4" %} +{% set win32yank_suffix = "x64" %} +{% set win32yank_sourcehash = "33a747a92da60fb65e668edbf7661d3d902411a2d545fe9dc08623cecd142a20" %} + +{% if clipboard.win32yank is defined %} +win32yank_downloaded: + archive.extracted: + - name: {{ nvim.clipboard.win32yank.path }} + - enforce_toplevel: False + - trim_output: 0 + - source: https://github.com/equalsraf/win32yank/releases/download/v{{ win32yank_version }}/win32yank-{{ win32yank_suffix }}.zip + - source_hash: {{ win32yank_sourcehash }} +{% endif %} diff --git a/nvim/parameters/defaults.yaml b/nvim/parameters/defaults.yaml index 74d8af7..0a8e425 100644 --- a/nvim/parameters/defaults.yaml +++ b/nvim/parameters/defaults.yaml @@ -3,7 +3,19 @@ # # Set default values. --- +{% set kernelrelease = salt.grains.get("kernelrelease", None) %} +{% if kernelrelease.find("WSL") != -1 %} +{% set clipboard_type = "win32yank" %} +{% endif %} values: + {% if clipboard_type is defined %} + kernelrelease: {{ kernelrelease }} + clipboard: + {{ clipboard_type }}: + {% if clipboard_type == "win32yank" %} + path: /opt/nvim/current/bin/ + {% endif %} + {% endif %} install: source: github pkg: diff --git a/test/integration/default/controls/clipboard.rb b/test/integration/default/controls/clipboard.rb new file mode 100644 index 0000000..5cc2b27 --- /dev/null +++ b/test/integration/default/controls/clipboard.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +control 'nvim.clipboard' do + title 'Check clipboard is configured' + only_if('on WSL') do + file('/proc/version').content =~ /WSL/ + end + describe file('/opt/nvim/current/bin/win32yank.exe') do + it { should exist } + end +end