From ab00294b74b4ab40ba14e5cfe07423640b16dcad Mon Sep 17 00:00:00 2001 From: Daniel Kempkens Date: Tue, 2 Aug 2022 22:50:56 +0200 Subject: [PATCH] nvim: Handle clipboard via osc52 --- home/config/nvim/init.fnl | 8 -------- home/config/nvim/plugins/osc52.fnl | 14 ++++++++++++++ home/programs/nvim/default.nix | 6 ++++++ home/programs/nvim/plugins.nix | 11 +++++++++++ home/programs/nvim/plugins.yaml | 1 + 5 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 home/config/nvim/plugins/osc52.fnl diff --git a/home/config/nvim/init.fnl b/home/config/nvim/init.fnl index d2e9be8..6015278 100644 --- a/home/config/nvim/init.fnl +++ b/home/config/nvim/init.fnl @@ -60,14 +60,6 @@ (set o.swapfile false) (set o.undofile true) (set o.undodir (.. (os.getenv :HOME) :/.local/share/nvim/undo//)) - ;; Clipboard - (if (= uname.sysname :Darwin) - (do - (set g.clipboard {:name :pbcopy - :copy {:+ :pbcopy :* :pbcopy} - :paste {:+ :pbpaste :* :pbpaste} - :cache_enabled 0}) - (o.clipboard:prepend :unnamedplus))) ;; Theme (let [theme (require :nifoc.theme)] (theme.setup)) diff --git a/home/config/nvim/plugins/osc52.fnl b/home/config/nvim/plugins/osc52.fnl new file mode 100644 index 0000000..c63213b --- /dev/null +++ b/home/config/nvim/plugins/osc52.fnl @@ -0,0 +1,14 @@ +(let [osc52 (require :osc52)] + (fn copy [lines _] + (-> lines + (table.concat "\n") + (osc52.copy))) + + (fn paste [] + [(vim.fn.split (vim.fn.getreg "") "\n") (vim.fn.getregtype "")]) + + (set vim.g.clipboard {:name :osc52 + :copy {:+ copy :* copy} + :paste {:+ paste :* paste}}) + (vim.opt.clipboard:prepend :unnamedplus)) + diff --git a/home/programs/nvim/default.nix b/home/programs/nvim/default.nix index 123d11f..43f5b49 100644 --- a/home/programs/nvim/default.nix +++ b/home/programs/nvim/default.nix @@ -67,6 +67,12 @@ in nvim-web-devicons # Keybindings + { + plugin = nvim-osc52; + config = builtins.readFile ../../config/nvim/plugins/osc52.fnl; + type = "fennel"; + } + { plugin = yanky-nvim; config = builtins.readFile ../../config/nvim/plugins/yanky.fnl; diff --git a/home/programs/nvim/plugins.nix b/home/programs/nvim/plugins.nix index c6a3f5c..14ea16d 100644 --- a/home/programs/nvim/plugins.nix +++ b/home/programs/nvim/plugins.nix @@ -45,6 +45,17 @@ fetchSubmodules = false; }; }; + nvim-osc52 = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "nvim-osc52"; + version = "2022-07-31"; + src = pkgs.fetchFromGitHub { + owner = "ojroques"; + repo = "nvim-osc52"; + rev = "0f25ebe9eb5050bb242e947c42134a851391a73e"; + sha256 = "0csd7ymia5k9pqrq8fr12yykiw4ssm06gsbz63i6xsgpvgmwnpv7"; + fetchSubmodules = false; + }; + }; yanky-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { pname = "yanky.nvim"; version = "2022-07-29"; diff --git a/home/programs/nvim/plugins.yaml b/home/programs/nvim/plugins.yaml index a702416..30cb473 100644 --- a/home/programs/nvim/plugins.yaml +++ b/home/programs/nvim/plugins.yaml @@ -7,6 +7,7 @@ - src: kyazdani42/nvim-web-devicons # Keybindings +- src: ojroques/nvim-osc52 - src: gbprod/yanky.nvim - src: gbprod/cutlass.nvim - src: gbprod/substitute.nvim