From c4ab75c313e5df55123eb099f0b7aa0fc3a58151 Mon Sep 17 00:00:00 2001 From: afonso Date: Thu, 28 Nov 2024 18:32:53 +0000 Subject: [PATCH] [nvim] some stuff including clipboard stuff --- .config/nvim/lazy-lock.json | 24 ++++++----- .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 ++++++++ 5 files changed, 81 insertions(+), 34 deletions(-) diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 2913395..e63c1f5 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -2,6 +2,7 @@ "LuaSnip": { "branch": "master", "commit": "659c4479529a05cc9b05ef762639a09d366cc690" }, "blame.nvim": { "branch": "main", "commit": "39bb4cda9e658d053a43919b10ca52c0a4d738e1" }, "cellular-automaton.nvim": { "branch": "main", "commit": "11aea08aa084f9d523b0142c2cd9441b8ede09ed" }, + "cinnamon.nvim": { "branch": "master", "commit": "ecd211e46a1d4fb0efffbdb2c2bbd59785605870" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, @@ -9,36 +10,37 @@ "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "conform.nvim": { "branch": "master", "commit": "8c354323201d04530727d8bdcc4669791ee082ef" }, - "dressing.nvim": { "branch": "master", "commit": "43b8f74e0b1e3f41e51f640f8efa3bcd401cea0d" }, - "flutter-tools.nvim": { "branch": "main", "commit": "7e6d8611d8606efca64cb8cf1ca07550b7087d1c" }, + "conform.nvim": { "branch": "master", "commit": "023f795dbcf32d4351b6a9ed2e613d471b5bb812" }, + "copilot.lua": { "branch": "master", "commit": "f8d8d872bb319f640d5177dad5fbf01f7a16d7d0" }, + "dressing.nvim": { "branch": "master", "commit": "fc78a3ca96f4db9f8893bb7e2fd9823e0780451b" }, + "flutter-tools.nvim": { "branch": "main", "commit": "fb976f0e83296d011be95701085ff4711a89de94" }, "friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" }, - "fzf-lua": { "branch": "main", "commit": "9503aff787bfb278ab7b067a426187f97babc209" }, + "fzf-lua": { "branch": "main", "commit": "2a7eb32871a131e24021dd1756865e475fe7e274" }, "gruvbox-material": { "branch": "master", "commit": "b16dcd787db5ba9302b54ebeac186784c2aed29a" }, - "harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" }, + "harpoon": { "branch": "harpoon2", "commit": "a84ab829eaf3678b586609888ef52f7779102263" }, "inc-rename.nvim": { "branch": "main", "commit": "8ba77017ca468f3029bf88ef409c2d20476ea66b" }, "lazy.nvim": { "branch": "main", "commit": "7967abe55752aa90532e6bb4bd4663fe27a264cb" }, "lspkind.nvim": { "branch": "master", "commit": "a700f1436d4a938b1a1a93c9962dc796afbaef4d" }, "ltex-extra.nvim": { "branch": "master", "commit": "24acd044ce7a26b3cdb537cbd094de37c3e1ac45" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "4d0e5b49363cac187326998b96aa6a2884e0e89b" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "cab00668464d2914d0752b86168b4a431cc93eb2" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "8b9363d83b5d779813cdd2819b8308651cec2a09" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "mini.ai": { "branch": "main", "commit": "31c149067d38b97720d2a179619f7745a0006ecc" }, - "noice.nvim": { "branch": "main", "commit": "2087bbf8cd64482b47fb5f33b5e0eabf329ab14b" }, + "noice.nvim": { "branch": "main", "commit": "6e0c8dcc61282782ac7fa4b9b4b0c910fd3f83d9" }, "nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" }, "nvim-autopairs": { "branch": "master", "commit": "ee297f215e95a60b01fde33275cc3c820eddeebe" }, "nvim-bqf": { "branch": "main", "commit": "1b24dc6050c34e8cd377b6b4cd6abe40509e0187" }, "nvim-cmp": { "branch": "perf", "commit": "6c3d595f3223c1ae7392d4fde1626355439af6c1" }, - "nvim-dap": { "branch": "master", "commit": "8517126e9323e346f6a99b3b594c5a940b914dcd" }, + "nvim-dap": { "branch": "master", "commit": "29d1f8814fa4fcc194ec574de998a42a22ebbe4a" }, "nvim-dap-ui": { "branch": "master", "commit": "ffa89839f97bad360e78428d5c740fdad9a0ff02" }, - "nvim-lspconfig": { "branch": "master", "commit": "d2d153a179ed59aa7134d7ebdf4d7dcb156efa22" }, + "nvim-lspconfig": { "branch": "master", "commit": "87c7c83ce62971e0bdb29bb32b8ad2b19c8f95d0" }, "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, - "nvim-treesitter": { "branch": "master", "commit": "7646c1c12a3121562aa87fd79aace48c728ac096" }, + "nvim-treesitter": { "branch": "master", "commit": "13c7caf8a602488b37cdefe8543c4cfdd5947d9d" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "3e450cd85243da99dc23ebbf14f9c70e9a0c26a4" }, "nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" }, "obsidian.nvim": { "branch": "main", "commit": "ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b" }, - "oil.nvim": { "branch": "master", "commit": "8735d185b37457bd899cd4e47a4517b899407949" }, + "oil.nvim": { "branch": "master", "commit": "8ea40b5506115b6d355e304dd9ee5089f7d78601" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, "refactoring.nvim": { "branch": "master", "commit": "53ed6854e0bba64d467c58e87084dcf8b1c22d36" }, "rustaceanvim": { "branch": "master", "commit": "8ece53be36515cb9e76f3d03511643636469502d" }, 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",