Skip to content

Commit

Permalink
feat: add osc52 to remote clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
cfcosta committed Jul 28, 2023
1 parent 5fbd908 commit c1ae250
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 134 deletions.
145 changes: 19 additions & 126 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
};
};

aiken = {
url = "github:aiken-lang/aiken";
inputs.nixpkgs.follows = "nixpkgs";
};

cmp-buffer = {
url = "github:hrsh7th/cmp-buffer";
flake = false;
Expand Down Expand Up @@ -152,10 +147,13 @@
url = "github:folke/trouble.nvim";
flake = false;
};
osc52 = {
url = "github:ojroques/nvim-osc52";
flake = false;
};
};

outputs =
inputs@{ self, nixpkgs, flake-utils, home-manager, nightvim, aiken, ... }:
outputs = inputs@{ self, nixpkgs, flake-utils, home-manager, nightvim, ... }:
let
hmModule = { options, config, lib, pkgs, ... }: {
imports = [
Expand Down
2 changes: 1 addition & 1 deletion plugins/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ with deps.nightvim.lib; {
})
(mkPlugin "nvim-lspconfig" nvim-lspconfig {
inputs = with pkgs; [
deps.aiken.packages.${pkgs.system}.default
gopls
luajitPackages.lua-lsp
nixd
Expand Down Expand Up @@ -102,6 +101,7 @@ with deps.nightvim.lib; {
(mkPlugin "indent-blankline" indent-blankline {
config = builtins.readFile ./indentline.lua;
})
(mkPlugin "nvim-osc52" osc52 { config = builtins.readFile ./osc52.lua; })
(mkPlugin "neorg" neorg { config = builtins.readFile ./neorg.lua; })
(mkPlugin "cmp-buffer" cmp-buffer { config = ""; })
(mkPlugin "cmp-cmdline" cmp-cmdline { config = ""; })
Expand Down
17 changes: 17 additions & 0 deletions plugins/osc52.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
local function copy(lines, _)
require("osc52").copy(table.concat(lines, "\n"))
end

local function paste()
return { vim.fn.split(vim.fn.getreg "", "\n"), vim.fn.getregtype "" }
end

vim.g.clipboard = {
name = "osc52",
copy = { ["+"] = copy, ["*"] = copy },
paste = { ["+"] = paste, ["*"] = paste },
}

-- Now the '+' register will copy to system clipboard using OSC52
vim.keymap.set("n", "<leader>c", '"+y')
vim.keymap.set("n", "<leader>cc", '"+yy')

0 comments on commit c1ae250

Please sign in to comment.