From 97cde4780d5a0f287bb448140c72bfd3066b983a Mon Sep 17 00:00:00 2001 From: afranco Date: Thu, 28 Nov 2024 18:32:53 +0000 Subject: [PATCH] chore(nvim): some stuff including clipboard stuff --- .config/nvim/lua/core/keymaps.lua | 10 +++++ .config/nvim/lua/plugins/cmp.lua | 62 ++++++++++++++++++---------- .config/nvim/lua/plugins/editing.lua | 1 - .config/nvim/lua/plugins/ui.lua | 18 ++++++++ 4 files changed, 68 insertions(+), 23 deletions(-) diff --git a/.config/nvim/lua/core/keymaps.lua b/.config/nvim/lua/core/keymaps.lua index a2e4af7..3ef2e92 100644 --- a/.config/nvim/lua/core/keymaps.lua +++ b/.config/nvim/lua/core/keymaps.lua @@ -9,3 +9,13 @@ vim.keymap.set("n", "", "bp") vim.keymap.set("n", "", "bn") --jk as escape vim.keymap.set("i", "jk","") +-- Copy to system clipboard +vim.keymap.set({ 'n', 'x' }, 'gy', '"+y', { desc = 'Copy to system clipboard' }) +-- Paste from system clipboard in normal mode +vim.keymap.set('n', 'gp', '"+p', { desc = 'Paste from system clipboard' }) +-- Paste from system clipboard in visual mode without overwriting the clipboard +vim.keymap.set('x', 'gp', '"+P', { desc = 'Paste from system clipboard' }) +--Center screen after some motions +vim.keymap.set("n", "", "zz", {desc = "Center cursor after moving down half-page"}) +vim.keymap.set("n", "", "zz", {desc = "Center cursor after moving down half-page"}) +vim.keymap.set("n", "G", "Gzz", {desc = "Center cursor after moving down half-page"}) diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua index 2e85eaf..7f96934 100644 --- a/.config/nvim/lua/plugins/cmp.lua +++ b/.config/nvim/lua/plugins/cmp.lua @@ -21,8 +21,9 @@ return { local luasnip = require("luasnip") require("luasnip/loaders/from_vscode").lazy_load() - local lspkind = require("lspkind") + vim.opt.pumheight = 15 + local lspkind = require("lspkind") cmp.setup({ snippet = { expand = function(args) @@ -58,22 +59,33 @@ return { end), }, formatting = { - fields = { "kind", "abbr", "menu" }, - format = lspkind.cmp_format({ - mode = "symbol_text", - maxwidth = 50, - ellipsis_char = "...", - show_labelDetails = true, - - before = function(entry, vim_item) - vim_item.menu = ({ - nvim_lsp = "[LSP]", - nvim_lua = "[NVIM LSP]", - path = "[Path]", - })[entry.source.name] - return vim_item - end, - }), + fields = { "kind", "abbr" }, + format = function(entry, vim_item) + local formatted_entry = lspkind.cmp_format({ + mode = "symbol", + maxwidth = { + menu = 0 + }, + show_labelDetails = false + })(entry, vim_item) + formatted_entry.kind = (formatted_entry.kind or "") .. " " + -- local item = entry:get_completion_item() + -- if item.detail then + -- local detail = item.detail + -- if string.find(detail, "->") ~= nil then + -- local return_arrow = vim.split(detail, "->", { trimempty = true }) + -- detail = vim.trim(return_arrow[2] or "") + -- end + -- if string.len(detail) <= 10 then + -- print("<=10 " .. detail) + -- formatted_entry.menu = detail + -- else + -- print(">10 " .. detail) + -- formatted_entry.menu = nil + -- end + -- end + return formatted_entry + end }, preselect = cmp.PreselectMode.None, sorting = { @@ -82,9 +94,6 @@ return { cmp.config.compare.offset, cmp.config.compare.exact, cmp.config.compare.score, - cmp.config.compare.kind, - cmp.config.compare.recently_used, - cmp.config.compare.locality, --Make entries that start with underline appear after function(entry1, entry2) @@ -98,12 +107,17 @@ return { return true end end, + + cmp.config.compare.kind, + cmp.config.compare.sort_text, + cmp.config.compare.length, + cmp.config.compare.order, }, }, sources = cmp.config.sources({ { name = "nvim_lua" }, { name = "nvim_lsp" }, - { name = "luasnip" }, + --{ name = "luasnip" }, { name = "path" }, }, { { name = "buffer", keyword_length = 5 }, @@ -117,7 +131,11 @@ return { border = "rounded", winhighlight = "Normal:Normal,FloatBorder:Normal,CursorLine:Visual,Search:None", }, - } + }, + experimental = { + native_menu = false, + ghost_text = false, + }, }) local cmp_autopairs = require("nvim-autopairs.completion.cmp") diff --git a/.config/nvim/lua/plugins/editing.lua b/.config/nvim/lua/plugins/editing.lua index 21fa183..9436788 100644 --- a/.config/nvim/lua/plugins/editing.lua +++ b/.config/nvim/lua/plugins/editing.lua @@ -22,7 +22,6 @@ return { }) end, }, - { "epwalsh/obsidian.nvim", version = "v3.9.0", diff --git a/.config/nvim/lua/plugins/ui.lua b/.config/nvim/lua/plugins/ui.lua index d7b6034..bd98dc4 100644 --- a/.config/nvim/lua/plugins/ui.lua +++ b/.config/nvim/lua/plugins/ui.lua @@ -1,4 +1,5 @@ return { + { "vimpostor/vim-tpipeline", config = function() @@ -73,6 +74,23 @@ return { -- } -- } -- }, + { + "karb94/neoscroll.nvim", + config = function() + local neoscroll = require('neoscroll') + neoscroll.setup({ + hide_cursor = false, + }) + local keymap = { + [""] = function() neoscroll.ctrl_u({ duration = 150 }) end, + [""] = function() neoscroll.ctrl_d({ duration = 150 }) end, + } + local modes = { 'n', 'v', 'x' } + for key, func in pairs(keymap) do + vim.keymap.set(modes, key, func) + end + end + }, { "folke/zen-mode.nvim", event = "VeryLazy",