From 49b0f23821690ac4b58aa4edf5f4608b43f1e8bf Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Mon, 21 Aug 2023 19:27:20 +0300 Subject: nvim: change cutlass suite and fix telescope + cmp issues --- .config/nvim/lazy-lock.json | 24 +++++------ .config/nvim/lua/plugins/cmp.lua | 56 ++++++++++++++++++++++--- .config/nvim/lua/plugins/cutlass.lua | 75 +++++++++++++++++++++++++--------- .config/nvim/lua/plugins/telescope.lua | 32 +++++++++------ 4 files changed, 139 insertions(+), 48 deletions(-) (limited to '.config/nvim') diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 34a93f4..b2bb81a 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -2,7 +2,7 @@ "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, "LuaSnip": { "branch": "master", "commit": "c4d6298347f7707e9757351b2ee03d0c00da5c20" }, "barbar.nvim": { "branch": "master", "commit": "8cca17ea0ced3ba564e5da972a25600edafe7d7b" }, - "catppuccin": { "branch": "main", "commit": "490078b1593c6609e6a50ad5001e7902ea601824" }, + "catppuccin": { "branch": "main", "commit": "e2d6ce295eb537c92b567ec5d31f120de46e8d13" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, @@ -12,27 +12,28 @@ "dial.nvim": { "branch": "master", "commit": "c6657df5453a6cbe4e8356e1675e9652cadc332f" }, "fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" }, "friendly-snippets": { "branch": "main", "commit": "377d45475b49e37460a902d6d569d2093d4037d0" }, - "gitsigns.nvim": { "branch": "main", "commit": "5a2b1205841bc06ffb15719b14d54987e17b22ae" }, + "gitsigns.nvim": { "branch": "main", "commit": "749267aaa863c30d721c9913699c5d94e0c07dd3" }, "indent-blankline.nvim": { "branch": "master", "commit": "4541d690816cb99a7fc248f1486aa87f3abce91c" }, "lazy.nvim": { "branch": "main", "commit": "dac844ed617dda4f9ec85eb88e9629ad2add5e05" }, "leap.nvim": { "branch": "main", "commit": "5efe985cf68fac3b6a6dfe7a75fbfaca8db2af9c" }, "ltex-extra.nvim": { "branch": "master", "commit": "9bed99b2b8488cc2daf66c76d2e0cf051ee80d13" }, "lualine.nvim": { "branch": "master", "commit": "45e27ca739c7be6c49e5496d14fcf45a303c3a63" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "e86a4c84ff35240639643ffed56ee1c4d55f538e" }, - "mason.nvim": { "branch": "main", "commit": "b5bb138312dbd3f7729197ca659cbe5221d36a03" }, - "neodev.nvim": { "branch": "main", "commit": "47dacc6d8f74936f7719351b025421df740c789b" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "2997f467881ac4faa6f8c5e7065e3a672297c8ad" }, + "mason.nvim": { "branch": "main", "commit": "a51c2d063c5377ee9e58c5f9cda7c7436787be72" }, + "neodev.nvim": { "branch": "main", "commit": "e9bc652e22f9cd1892630bf019db363ac403ee39" }, "nvim-autopairs": { "branch": "master", "commit": "ae5b41ce880a6d850055e262d6dfebd362bb276e" }, "nvim-cmp": { "branch": "main", "commit": "51f1e11a89ec701221877532ee1a23557d291dd5" }, - "nvim-lspconfig": { "branch": "master", "commit": "0d29cad8de3b2c654315203fc1fe12fde722a18a" }, + "nvim-lspconfig": { "branch": "master", "commit": "67f151e84daddc86cc65f5d935e592f76b9f4496" }, "nvim-surround": { "branch": "main", "commit": "0d6882635817a2677749a330127d12ac30a4f3c8" }, - "nvim-tree.lua": { "branch": "master", "commit": "18c7a3119839adc4599d838726deae662859c8b2" }, - "nvim-treesitter": { "branch": "master", "commit": "add1864bbf2d3b8e789ec6b4715bb5a4073e3b60" }, + "nvim-tree.lua": { "branch": "master", "commit": "920868dba13466586897a8f40220eca6b2caac41" }, + "nvim-treesitter": { "branch": "master", "commit": "7c935d6bd5ecb36e7c6cf6678e1eaa38b85111f3" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "56272167a6dead91c47c02dbdbfe1ae5643c59f5" }, "nvim-ufo": { "branch": "main", "commit": "aebd36bf5447862671356fcd5d4a8708ce6c9470" }, "nvim-web-devicons": { "branch": "master", "commit": "cfc8824cc1db316a276b36517f093baccb8e799a" }, "plenary.nvim": { "branch": "master", "commit": "267282a9ce242bbb0c5dc31445b6d353bed978bb" }, "promise-async": { "branch": "main", "commit": "e94f35161b8c5d4a4ca3b6ff93dd073eb9214c0e" }, "rust-tools.nvim": { "branch": "master", "commit": "0cc8adab23117783a0292a0c8a2fbed1005dc645" }, + "substitute.nvim": { "branch": "main", "commit": "89dbe55cccee36bcb5e2be8c2d92ff8716601734" }, "tabular": { "branch": "master", "commit": "339091ac4dd1f17e225fe7d57b48aff55f99b23a" }, "targets.vim": { "branch": "master", "commit": "642d3a4ce306264b05ea3219920b13ea80931767" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "9bc8237565ded606e6c366a71c64c0af25cd7a50" }, @@ -45,10 +46,9 @@ "vim-illuminate": { "branch": "master", "commit": "76f28e858f1caae87bfa45fb4fd09e4b053fc45b" }, "vim-move": { "branch": "master", "commit": "244a2908ffbca3d09529b3ec24c2c090f489f401" }, "vim-repeat": { "branch": "master", "commit": "24afe922e6a05891756ecf331f39a1f6743d3d5a" }, - "vim-subversive": { "branch": "master", "commit": "6286cda3f9222bfd490fe34a00a2d8cd4925adec" }, "vim-unimpaired": { "branch": "master", "commit": "6d44a6dc2ec34607c41ec78acf81657248580bf1" }, - "vim-yoink": { "branch": "master", "commit": "89ed6934679fdbc3c20f552b50b1f869f624cd22" }, - "vimtex": { "branch": "master", "commit": "e3d0bea39dbcb6e064db751b646c958342a3460f" }, + "vimtex": { "branch": "master", "commit": "534fd725f2475a9083b032e402c7e73b8a3fc6bb" }, "vimwiki": { "branch": "dev", "commit": "f0fe154ede6b11e3db9b058b930005a056a3d1c6" }, - "which-key.nvim": { "branch": "main", "commit": "7ccf476ebe0445a741b64e36c78a682c1c6118b7" } + "which-key.nvim": { "branch": "main", "commit": "7ccf476ebe0445a741b64e36c78a682c1c6118b7" }, + "yanky.nvim": { "branch": "main", "commit": "95c2f006ea6eaed2b2d8b8b4943b8fcf13faf03f" } } \ No newline at end of file diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua index 78ff9a9..828d7c2 100644 --- a/.config/nvim/lua/plugins/cmp.lua +++ b/.config/nvim/lua/plugins/cmp.lua @@ -1,4 +1,3 @@ --- autocompletion return { { "hrsh7th/nvim-cmp", @@ -46,18 +45,35 @@ return { TypeParameter = "", } + ---@diagnostic disable-next-line: missing-fields cmp.setup({ - enabled = true, + enabled = function() + -- disable autocompletion in prompt + local buftype = vim.api.nvim_buf_get_option(0, "buftype") + if buftype == "prompt" then return false end + + local context = require 'cmp.config.context' + -- disable autocompletion in comments + return not context.in_treesitter_capture("comment") and not context.in_syntax_group("Comment") + end, + ---@diagnostic disable-next-line: missing-fields + completion = { + completeopt = "menu,menuone,noselect", + }, + window = { + documentation = cmp.config.window.bordered(), + completion = cmp.config.window.bordered(), + }, snippet = { expand = function(args) luasnip.lsp_expand(args.body) end, }, mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.select_prev_item(), [""] = cmp.mapping.select_next_item(), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false, @@ -81,6 +97,7 @@ return { end end, { "i", "s" }), }), + ---@diagnostic disable-next-line: missing-fields formatting = { fields = { "kind", "abbr", "menu" }, format = function(entry, vim_item) @@ -103,12 +120,41 @@ return { }, }) - -- If you want insert `(` after select function or method item + -- insert `(` after select function or method item local cmp_autopairs = require('nvim-autopairs.completion.cmp') cmp.event:on( 'confirm_done', cmp_autopairs.on_confirm_done() ) + + ---@diagnostic disable-next-line: missing-fields + cmp.setup.filetype('gitcommit', { + sources = cmp.config.sources({ + { name = 'git' }, + }, { + { name = 'buffer' }, + }) + }) + + -- use buffer source for `/` . + ---@diagnostic disable-next-line: missing-fields + cmp.setup.cmdline('/', { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' } + } + }) + + -- use cmdline & path source for ':' . + ---@diagnostic disable-next-line: missing-fields + cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) + }) end, }, } diff --git a/.config/nvim/lua/plugins/cutlass.lua b/.config/nvim/lua/plugins/cutlass.lua index 0b8ef52..b9332a9 100644 --- a/.config/nvim/lua/plugins/cutlass.lua +++ b/.config/nvim/lua/plugins/cutlass.lua @@ -3,26 +3,36 @@ return { 'svermeulen/vim-cutlass', }, { - 'svermeulen/vim-subversive', + 'gbprod/substitute.nvim', config = function() local map = require("helpers.keys").map - -- substitute from yank - map('n', 'ys', '(SubversiveSubstitute)', "substitute from yank") - map('n', 'yss', '(SubversiveSubstituteLine)', "substitute from yank, line") - map('n', 'yS', '(SubversiveSubstituteToEndOfLine)', "substitute from yank, eol") + map("n", "s", require('substitute').operator, "substitute") + map("n", "ss", require('substitute').line, "substitute: linewise") + map("n", "S", require('substitute').eol, "substitute: eol") + map("x", "s", require('substitute').visual, "substitute: visual") - -- substitute over range - map( { 'n', 'x' }, 's', '(SubversiveSubstituteRange)', "start substitude over range") - map('n', 'ss', '(SubversiveSubstituteWordRange)', "start substitude over range") - end + map("n", "s", require('substitute.range').operator, "substitute: over range") + map("x", "s", require('substitute.range').visual, "substitute: over visual") + map("n", "ss", require('substitute.range').word, "substitute: with word over range") + + map("n", "sx", require('substitute.exchange').operator, "exchange") + map("n", "sxx", require('substitute.exchange').line, "exchange line") + map("x", "sX", require('substitute.exchange').visual, "exchange visual") + map("n", "sxc", require('substitute.exchange').cancel, "exchange cancel") + + require("substitute").setup({ + highlight_substituted_text = { + enabled = true, + timer = 300, + }, + }) + end, }, { - 'svermeulen/vim-yoink', + "gbprod/yanky.nvim", config = function() - vim.g.yoinkIncludeDeleteOperations = 1 - - -- fix the Target STRING not available + -- fix Target STRING not available vim.g.clipboard = { name = 'xsel_override', copy = { @@ -38,14 +48,41 @@ return { local map = require("helpers.keys").map - -- yoink paste - map('n', 'p', '(YoinkPaste_p)') - map('n', 'P', '(YoinkPaste_P)') + map({ "n", "x" }, 'p', '(YankyPutAfter)') + map({ "n", "x" }, 'P', '(YankyPutBefore)') + + map("n", "", "(YankyCycleForward)") + map("n", "", "(YankyCycleBackward)") - -- iterate over yank list - map('n', '', '(YoinkPostPasteSwapBack)') - map('n', '', '(YoinkPostPasteSwapForward)') + local utils = require("yanky.utils") + local mapping = require("yanky.telescope.mapping") + + require("yanky").setup({ + ring = { + history_length = 100, + storage = "shada", + sync_with_numbered_registers = true, + cancel_event = "update", + ignore_registers = { "_" }, + }, + system_clipboard = { + sync_with_ring = true, + }, + picker = { + telescope = { + use_default_mappings = false, + mappings = { + default = mapping.set_register(utils.get_default_register()), + }, + }, + }, + highlight = { + on_put = true, + on_yank = true, + timer = 300, + }, + }) end, } } diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua index ecea32b..be6fdd7 100644 --- a/.config/nvim/lua/plugins/telescope.lua +++ b/.config/nvim/lua/plugins/telescope.lua @@ -1,6 +1,7 @@ return { { "nvim-telescope/telescope.nvim", + priority = 500, dependencies = { "nvim-lua/plenary.nvim", { @@ -8,38 +9,45 @@ return { build = "make", cond = vim.fn.executable("make") == 1 }, + "gbprod/yanky.nvim", }, + lazy = false, config = function() require('telescope').setup({ + defaults = { + path_display = { "truncate" }, + }, extensions = { fzf = { - fuzzy = true, -- false will only do exact matching + fuzzy = true, -- false will only do exact matching override_generic_sorter = true, override_file_sorter = true, case_mode = "smart_case", - } - } + }, + }, }) -- Enable telescope fzf native, if installed pcall(require("telescope").load_extension, "fzf") local map = require("helpers.keys").map - map("n", "fr", require("telescope.builtin").oldfiles, "recently opened") - map("n", "", require("telescope.builtin").buffers, "open buffers") + map("n", "fr", require("telescope.builtin").oldfiles, "🔭: recently opened") + map("n", "", require("telescope.builtin").buffers, "🔭: open buffers") map("n", "/", function() - -- You can pass additional configuration to telescope to change theme, layout, etc. + -- you can pass additional configuration to telescope to change theme, layout, etc. require("telescope.builtin").current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({ winblend = 10, previewer = false, })) - end, "search in current buffer") + end, "🔭: search in current buffer") - map("n", "sf", require("telescope.builtin").find_files, "files") - map("n", "sh", require("telescope.builtin").help_tags, "help") - map("n", "sw", require("telescope.builtin").grep_string, "current word") - map("n", "sg", require("telescope.builtin").live_grep, "grep") - map("n", "sd", require("telescope.builtin").diagnostics, "diagnostics") + map("n", "sf", require("telescope.builtin").find_files, "🔭: find files") + map("n", "sh", require("telescope.builtin").help_tags, "🔭: help") + map("n", "sw", require("telescope.builtin").grep_string, "🔭: current word") + map("n", "sg", require("telescope.builtin").live_grep, "🔭: live grep") + map("n", "sd", require("telescope.builtin").diagnostics, "🔭: diagnostics") + require("telescope").load_extension("yank_history") + map("n", "sp", require("telescope").extensions.yank_history.yank_history, "🔭: yank history") end, }, } -- cgit v1.2.3-70-g09d2