more solid nvim clipboard inside tmux
This commit is contained in:
43
.config/nvim/lua/kamu/clipboard.lua
Normal file
43
.config/nvim/lua/kamu/clipboard.lua
Normal file
@@ -0,0 +1,43 @@
|
||||
-- https://mitchellt.com/2022/05/15/WSL-Neovim-Lua-and-the-Windows-Clipboard.html
|
||||
if os.getenv('WSL_DISTRO_NAME') ~= nil then
|
||||
vim.g.clipboard = {
|
||||
name = 'wsl clipboard',
|
||||
copy = {
|
||||
["+"] = { "clip.exe" },
|
||||
["*"] = { "clip.exe" }
|
||||
},
|
||||
paste = {
|
||||
["+"] = { 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))' },
|
||||
["*"] = { 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))' }
|
||||
},
|
||||
cache_enabled = true
|
||||
}
|
||||
elseif vim.env.TMUX ~= nil then
|
||||
local copy = { 'tmux', 'load-buffer', '-w', '-' }
|
||||
local paste = { 'bash', '-c', 'tmux refresh-client -l && sleep 0.05 && tmux save-buffer -' }
|
||||
vim.g.clipboard = {
|
||||
name = 'tmux',
|
||||
copy = {
|
||||
['+'] = copy,
|
||||
['*'] = copy,
|
||||
},
|
||||
paste = {
|
||||
['+'] = paste,
|
||||
['*'] = paste,
|
||||
},
|
||||
cache_enabled = 0,
|
||||
}
|
||||
else
|
||||
vim.g.clipboard = {
|
||||
name = 'OSC 52',
|
||||
copy = {
|
||||
['+'] = require('vim.ui.clipboard.osc52').copy('+'),
|
||||
['*'] = require('vim.ui.clipboard.osc52').copy('*'),
|
||||
},
|
||||
paste = {
|
||||
['+'] = require('vim.ui.clipboard.osc52').paste('+'),
|
||||
['*'] = require('vim.ui.clipboard.osc52').paste('*'),
|
||||
},
|
||||
cache_enabled = true
|
||||
}
|
||||
end
|
||||
@@ -1,7 +1,7 @@
|
||||
vim.g.mapleader = ' '
|
||||
|
||||
require("kamu.clipboard")
|
||||
require("kamu.options")
|
||||
--require("kamu.commands")
|
||||
require("kamu.lazy")
|
||||
require("kamu.keymaps")
|
||||
|
||||
|
||||
@@ -21,11 +21,8 @@ vim.keymap.set("n", "<space><space>x", "<cmd>source %<CR>")
|
||||
vim.keymap.set("n", "<space>x", ":.lua<CR>")
|
||||
vim.keymap.set("v", "<space>x", ":lua<CR>")
|
||||
|
||||
-- Highlight when yanking text
|
||||
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||
desc = "Highlight when yanking text",
|
||||
group = vim.api.nvim_create_augroup("highlight-yank", { clear = true }),
|
||||
callback = function()
|
||||
vim.highlight.on_yank()
|
||||
end,
|
||||
})
|
||||
-- copy to system clipboard
|
||||
vim.keymap.set("v", "<space>y", "\"+y")
|
||||
vim.keymap.set("n", "<space>y", "\"+y")
|
||||
vim.keymap.set("v", "<space>p", "\"+p")
|
||||
vim.keymap.set("n", "<space>p", "\"+p")
|
||||
|
||||
@@ -1,35 +1,3 @@
|
||||
local in_wsl = os.getenv('WSL_DISTRO_NAME') ~= nil
|
||||
|
||||
-- https://mitchellt.com/2022/05/15/WSL-Neovim-Lua-and-the-Windows-Clipboard.html
|
||||
if in_wsl then
|
||||
vim.g.clipboard = {
|
||||
name = 'wsl clipboard',
|
||||
copy = {
|
||||
["+"] = { "clip.exe" },
|
||||
["*"] = { "clip.exe" }
|
||||
},
|
||||
paste = {
|
||||
["+"] = { 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))' },
|
||||
["*"] = { 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))' } },
|
||||
cache_enabled = true
|
||||
}
|
||||
end
|
||||
|
||||
-- if in_wsl then
|
||||
-- vim.g.clipboard = {
|
||||
-- name = 'WslClipboard',
|
||||
-- copy = {
|
||||
-- ['+'] = 'clip.exe',
|
||||
-- ['*'] = 'clip.exe',
|
||||
-- },
|
||||
-- paste = {
|
||||
-- ['+'] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
|
||||
-- ['*'] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
|
||||
-- },
|
||||
-- cache_enabled = false,
|
||||
-- }
|
||||
-- end
|
||||
|
||||
-- Highlight on Yank
|
||||
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||
desc = "Highlight when yanking text",
|
||||
@@ -88,10 +56,9 @@ local options = {
|
||||
inccommand = 'split',
|
||||
cursorline = true,
|
||||
|
||||
-- guicursor = "a:block"
|
||||
-- guicursor = "a:block"
|
||||
}
|
||||
|
||||
for option, value in pairs(options) do
|
||||
vim.opt[option] = value
|
||||
end
|
||||
|
||||
|
||||
@@ -14,8 +14,10 @@ return {
|
||||
},
|
||||
},
|
||||
},
|
||||
build = 'cargo build --release',
|
||||
version = '*',
|
||||
-- build = 'cargo build --release',
|
||||
opts = {
|
||||
snippets = { preset = 'luasnip' },
|
||||
keymap = { preset = 'super-tab' },
|
||||
appearance = {
|
||||
use_nvim_cmp_as_default = true,
|
||||
@@ -41,16 +43,16 @@ return {
|
||||
},
|
||||
},
|
||||
ghost_text = {
|
||||
enabled = true
|
||||
enabled = false
|
||||
}
|
||||
},
|
||||
signature = { enabled = true },
|
||||
sources = {
|
||||
default = { 'lsp', 'path', 'luasnip', 'buffer' },
|
||||
default = { 'lsp', 'path', 'snippets', 'buffer' },
|
||||
-- TODO: add cmp-emoji as another cmp source -- needs https://github.com/Saghen/blink.compat
|
||||
per_filetype = {
|
||||
tex = { 'lsp', 'path', 'luasnip', 'buffer' },
|
||||
lua = { 'lsp', 'path', 'luasnip', 'buffer', 'lazydev' },
|
||||
tex = { 'lsp', 'path', 'snippets', 'buffer' },
|
||||
lua = { 'lsp', 'path', 'snippets', 'buffer', 'lazydev' },
|
||||
},
|
||||
providers = {
|
||||
lazydev = {
|
||||
@@ -58,27 +60,8 @@ return {
|
||||
module = "lazydev.integrations.blink",
|
||||
fallbacks = { "lsp" },
|
||||
},
|
||||
luasnip = {
|
||||
|
||||
name = 'Luasnip',
|
||||
module = 'blink.cmp.sources.luasnip',
|
||||
opts = {
|
||||
use_show_condition = true,
|
||||
show_autosnippets = true,
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
snippets = {
|
||||
expand = function(snippet) require('luasnip').lsp_expand(snippet) end,
|
||||
active = function(filter)
|
||||
if filter and filter.direction then
|
||||
return require('luasnip').jumpable(filter.direction)
|
||||
end
|
||||
return require('luasnip').in_snippet()
|
||||
end,
|
||||
jump = function(direction) require('luasnip').jump(direction) end,
|
||||
},
|
||||
},
|
||||
|
||||
config = function(_, opts)
|
||||
|
||||
@@ -1,78 +1,109 @@
|
||||
return {
|
||||
-- lsp client plugin
|
||||
"neovim/nvim-lspconfig", -- https://github.com/neovim/nvim-lspconfig
|
||||
dependencies = {
|
||||
"williamboman/mason.nvim", -- https://github.com/williamboman/mason.nvim
|
||||
"williamboman/mason-lspconfig.nvim", -- https://github.com/williamboman/mason-lspconfig.nvim bridges the gab between lspconfig and mason
|
||||
'saghen/blink.cmp',
|
||||
},
|
||||
config = function()
|
||||
local capabilities = require('blink.cmp').get_lsp_capabilities()
|
||||
{
|
||||
-- lsp client plugin
|
||||
"neovim/nvim-lspconfig", -- https://github.com/neovim/nvim-lspconfig
|
||||
dependencies = {
|
||||
"williamboman/mason.nvim", -- https://github.com/williamboman/mason.nvim
|
||||
"williamboman/mason-lspconfig.nvim", -- https://github.com/williamboman/mason-lspconfig.nvim bridges the gab between lspconfig and mason
|
||||
'saghen/blink.cmp',
|
||||
},
|
||||
config = function()
|
||||
local capabilities = require('blink.cmp').get_lsp_capabilities()
|
||||
|
||||
require('mason').setup()
|
||||
require('mason-lspconfig').setup({
|
||||
ensure_installed = {
|
||||
'lua_ls',
|
||||
'astro',
|
||||
'ansiblels',
|
||||
},
|
||||
handlers = {
|
||||
function(server_name)
|
||||
require("lspconfig")[server_name].setup({
|
||||
capabilities = capabilities
|
||||
})
|
||||
end,
|
||||
require('mason').setup()
|
||||
require('mason-lspconfig').setup({
|
||||
ensure_installed = {
|
||||
'lua_ls',
|
||||
},
|
||||
handlers = {
|
||||
function(server_name)
|
||||
require("lspconfig")[server_name].setup({
|
||||
capabilities = capabilities
|
||||
})
|
||||
end,
|
||||
|
||||
["ansiblels"] = function()
|
||||
require("lspconfig")['ansiblels'].setup({
|
||||
filetypes = {
|
||||
"yaml",
|
||||
},
|
||||
})
|
||||
end,
|
||||
["astro"] = function()
|
||||
require("lspconfig")['astro'].setup({
|
||||
filetypes = {
|
||||
"astro",
|
||||
},
|
||||
})
|
||||
end,
|
||||
["ansiblels"] = function()
|
||||
require("lspconfig")['ansiblels'].setup({
|
||||
filetypes = {
|
||||
"yaml",
|
||||
},
|
||||
})
|
||||
end,
|
||||
["rust-analyzer"] = function()
|
||||
require("lspconfig")['rust-analyzer'].setup({
|
||||
cargo = {
|
||||
buildScripts = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
filetypes = {
|
||||
"rs",
|
||||
},
|
||||
rustfmt = {
|
||||
extraArgs = { "+nightly" },
|
||||
},
|
||||
})
|
||||
end,
|
||||
["astro"] = function()
|
||||
require("lspconfig")['astro'].setup({
|
||||
filetypes = {
|
||||
"astro",
|
||||
},
|
||||
})
|
||||
end,
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
-- group = vim.api.nvim_create_augroup('KamuLspConfig', {}),
|
||||
callback = function(ev)
|
||||
local opts = { buffer = ev.buf }
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
if not client then return end
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
-- group = vim.api.nvim_create_augroup('KamuLspConfig', {}),
|
||||
callback = function(ev)
|
||||
local opts = { buffer = ev.buf }
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
if not client then return end
|
||||
|
||||
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
|
||||
vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts)
|
||||
vim.keymap.set("n", "<leader>ca", function() vim.lsp.buf.code_action() end, opts)
|
||||
vim.keymap.set('n', '<space>f', function()
|
||||
vim.lsp.buf.format { async = true }
|
||||
end, opts)
|
||||
vim.keymap.set("n", "<leader>gd", function() vim.lsp.buf.definition() end, opts)
|
||||
vim.keymap.set("n", "<leader>gr", function() vim.lsp.buf.references() end, opts)
|
||||
vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts)
|
||||
vim.keymap.set("n", "<leader>ca", function() vim.lsp.buf.code_action() end, opts)
|
||||
vim.keymap.set('n', '<space>f', function()
|
||||
vim.lsp.buf.format { async = true }
|
||||
end, opts)
|
||||
|
||||
vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
|
||||
vim.keymap.set("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts)
|
||||
vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts)
|
||||
vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
|
||||
vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts)
|
||||
vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
|
||||
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
|
||||
vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
|
||||
vim.keymap.set("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts)
|
||||
vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts)
|
||||
vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
|
||||
vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
|
||||
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
|
||||
|
||||
-- Format on save
|
||||
if client.supports_method('textDocument/formatting') and vim.bo.filetype == "lua" then
|
||||
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||
buffer = ev.buf,
|
||||
-- Format on save
|
||||
if client.supports_method('textDocument/formatting') and vim.bo.filetype == "lua" then
|
||||
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||
buffer = ev.buf,
|
||||
callback = function()
|
||||
vim.lsp.buf.format({ bufnr = ev.buf, id = client.id })
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
vim.opt.updatetime = 100
|
||||
|
||||
-- Show diagnostic popup on cursor hover
|
||||
local diag_float_grp = vim.api.nvim_create_augroup("DiagnosticFloat", { clear = true })
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
callback = function()
|
||||
vim.lsp.buf.format({ bufnr = ev.buf, id = client.id })
|
||||
vim.diagnostic.open_float(nil, { focusable = false })
|
||||
end,
|
||||
group = diag_float_grp,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
},
|
||||
-- {
|
||||
-- 'mrcjkb/rustaceanvim',
|
||||
-- version = '^5', -- Recommended
|
||||
-- lazy = false, -- This plugin is already lazy
|
||||
-- }
|
||||
}
|
||||
|
||||
@@ -3,39 +3,17 @@ return {
|
||||
priority = 1000,
|
||||
lazy = false,
|
||||
keys = {
|
||||
{ "<leader>sh", "<cmd>lua Snacks.notifier.show_history()<CR>", mode = "n", desc = "Show the notification History" }
|
||||
{ "<leader>sh", "<cmd>lua Snacks.notifier.show_history()<CR>", mode = "n", desc = "Show the notification History" },
|
||||
{ "<leader><space>", function() Snacks.picker.smart() end, desc = "Smart Find Files" },
|
||||
},
|
||||
opts = {
|
||||
dashboard = { enabled = true },
|
||||
bigfile = { enabled = true },
|
||||
notifier = {
|
||||
enabled = true,
|
||||
{
|
||||
timeout = 3000, -- default timeout in ms
|
||||
width = { min = 40, max = 0.4 },
|
||||
height = { min = 1, max = 0.6 },
|
||||
margin = { top = 0, right = 1, bottom = 0 },
|
||||
padding = true, -- add 1 cell of left/right padding to the notification window
|
||||
sort = { "level", "added" }, -- sort by level and time
|
||||
level = vim.log.levels.TRACE,
|
||||
icons = {
|
||||
error = " ",
|
||||
warn = " ",
|
||||
info = " ",
|
||||
debug = " ",
|
||||
trace = " ",
|
||||
},
|
||||
keep = function(notif)
|
||||
return vim.fn.getcmdpos() > 0
|
||||
end,
|
||||
style = "compact",
|
||||
top_down = true, -- place notifications from top to bottom
|
||||
date_format = "%R", -- time format for notifications
|
||||
more_format = " ↓ %d lines ",
|
||||
refresh = 50, -- refresh at most every 50ms
|
||||
}
|
||||
},
|
||||
notifier = { enabled = true },
|
||||
quickfile = { enabled = true },
|
||||
picker = { enabled = true },
|
||||
statuscolumn = { enabled = true },
|
||||
image = { enabled = true },
|
||||
words = { enabled = true },
|
||||
},
|
||||
init = function()
|
||||
|
||||
@@ -20,7 +20,6 @@ return {
|
||||
"javascript",
|
||||
"dockerfile",
|
||||
"html",
|
||||
"latex",
|
||||
"css",
|
||||
"scss",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user