diff options
author | Yigit Sever | 2023-08-21 19:27:20 +0300 |
---|---|---|
committer | Yigit Sever | 2023-08-21 19:27:20 +0300 |
commit | 49b0f23821690ac4b58aa4edf5f4608b43f1e8bf (patch) | |
tree | 8cea82a347a71f83dcd7a94ea45af4986c26422f /.config/nvim/lua | |
parent | 37638b4f5cc813466186d38fde551708ad0ecd3d (diff) | |
download | dotfiles-49b0f23821690ac4b58aa4edf5f4608b43f1e8bf.tar.gz dotfiles-49b0f23821690ac4b58aa4edf5f4608b43f1e8bf.tar.bz2 dotfiles-49b0f23821690ac4b58aa4edf5f4608b43f1e8bf.zip |
nvim: change cutlass suite
and fix telescope + cmp issues
Diffstat (limited to '.config/nvim/lua')
-rw-r--r-- | .config/nvim/lua/plugins/cmp.lua | 56 | ||||
-rw-r--r-- | .config/nvim/lua/plugins/cutlass.lua | 75 | ||||
-rw-r--r-- | .config/nvim/lua/plugins/telescope.lua | 32 |
3 files changed, 127 insertions, 36 deletions
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 @@ | |||
1 | -- autocompletion | ||
2 | return { | 1 | return { |
3 | { | 2 | { |
4 | "hrsh7th/nvim-cmp", | 3 | "hrsh7th/nvim-cmp", |
@@ -46,18 +45,35 @@ return { | |||
46 | TypeParameter = "", | 45 | TypeParameter = "", |
47 | } | 46 | } |
48 | 47 | ||
48 | ---@diagnostic disable-next-line: missing-fields | ||
49 | cmp.setup({ | 49 | cmp.setup({ |
50 | enabled = true, | 50 | enabled = function() |
51 | -- disable autocompletion in prompt | ||
52 | local buftype = vim.api.nvim_buf_get_option(0, "buftype") | ||
53 | if buftype == "prompt" then return false end | ||
54 | |||
55 | local context = require 'cmp.config.context' | ||
56 | -- disable autocompletion in comments | ||
57 | return not context.in_treesitter_capture("comment") and not context.in_syntax_group("Comment") | ||
58 | end, | ||
59 | ---@diagnostic disable-next-line: missing-fields | ||
60 | completion = { | ||
61 | completeopt = "menu,menuone,noselect", | ||
62 | }, | ||
63 | window = { | ||
64 | documentation = cmp.config.window.bordered(), | ||
65 | completion = cmp.config.window.bordered(), | ||
66 | }, | ||
51 | snippet = { | 67 | snippet = { |
52 | expand = function(args) | 68 | expand = function(args) |
53 | luasnip.lsp_expand(args.body) | 69 | luasnip.lsp_expand(args.body) |
54 | end, | 70 | end, |
55 | }, | 71 | }, |
56 | mapping = cmp.mapping.preset.insert({ | 72 | mapping = cmp.mapping.preset.insert({ |
73 | ["<C-f>"] = cmp.mapping.scroll_docs(-4), | ||
74 | ["<C-d>"] = cmp.mapping.scroll_docs(4), | ||
57 | ["<C-k>"] = cmp.mapping.select_prev_item(), | 75 | ["<C-k>"] = cmp.mapping.select_prev_item(), |
58 | ["<C-j>"] = cmp.mapping.select_next_item(), | 76 | ["<C-j>"] = cmp.mapping.select_next_item(), |
59 | ["<C-d>"] = cmp.mapping.scroll_docs(-4), | ||
60 | ["<C-f>"] = cmp.mapping.scroll_docs(4), | ||
61 | ["<CR>"] = cmp.mapping.confirm({ | 77 | ["<CR>"] = cmp.mapping.confirm({ |
62 | behavior = cmp.ConfirmBehavior.Replace, | 78 | behavior = cmp.ConfirmBehavior.Replace, |
63 | select = false, | 79 | select = false, |
@@ -81,6 +97,7 @@ return { | |||
81 | end | 97 | end |
82 | end, { "i", "s" }), | 98 | end, { "i", "s" }), |
83 | }), | 99 | }), |
100 | ---@diagnostic disable-next-line: missing-fields | ||
84 | formatting = { | 101 | formatting = { |
85 | fields = { "kind", "abbr", "menu" }, | 102 | fields = { "kind", "abbr", "menu" }, |
86 | format = function(entry, vim_item) | 103 | format = function(entry, vim_item) |
@@ -103,12 +120,41 @@ return { | |||
103 | }, | 120 | }, |
104 | }) | 121 | }) |
105 | 122 | ||
106 | -- If you want insert `(` after select function or method item | 123 | -- insert `(` after select function or method item |
107 | local cmp_autopairs = require('nvim-autopairs.completion.cmp') | 124 | local cmp_autopairs = require('nvim-autopairs.completion.cmp') |
108 | cmp.event:on( | 125 | cmp.event:on( |
109 | 'confirm_done', | 126 | 'confirm_done', |
110 | cmp_autopairs.on_confirm_done() | 127 | cmp_autopairs.on_confirm_done() |
111 | ) | 128 | ) |
129 | |||
130 | ---@diagnostic disable-next-line: missing-fields | ||
131 | cmp.setup.filetype('gitcommit', { | ||
132 | sources = cmp.config.sources({ | ||
133 | { name = 'git' }, | ||
134 | }, { | ||
135 | { name = 'buffer' }, | ||
136 | }) | ||
137 | }) | ||
138 | |||
139 | -- use buffer source for `/` . | ||
140 | ---@diagnostic disable-next-line: missing-fields | ||
141 | cmp.setup.cmdline('/', { | ||
142 | mapping = cmp.mapping.preset.cmdline(), | ||
143 | sources = { | ||
144 | { name = 'buffer' } | ||
145 | } | ||
146 | }) | ||
147 | |||
148 | -- use cmdline & path source for ':' . | ||
149 | ---@diagnostic disable-next-line: missing-fields | ||
150 | cmp.setup.cmdline(':', { | ||
151 | mapping = cmp.mapping.preset.cmdline(), | ||
152 | sources = cmp.config.sources({ | ||
153 | { name = 'path' } | ||
154 | }, { | ||
155 | { name = 'cmdline' } | ||
156 | }) | ||
157 | }) | ||
112 | end, | 158 | end, |
113 | }, | 159 | }, |
114 | } | 160 | } |
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 { | |||
3 | 'svermeulen/vim-cutlass', | 3 | 'svermeulen/vim-cutlass', |
4 | }, | 4 | }, |
5 | { | 5 | { |
6 | 'svermeulen/vim-subversive', | 6 | 'gbprod/substitute.nvim', |
7 | config = function() | 7 | config = function() |
8 | local map = require("helpers.keys").map | 8 | local map = require("helpers.keys").map |
9 | 9 | ||
10 | -- substitute from yank | 10 | map("n", "s", require('substitute').operator, "substitute") |
11 | map('n', '<Leader>ys', '<plug>(SubversiveSubstitute)', "substitute from yank") | 11 | map("n", "ss", require('substitute').line, "substitute: linewise") |
12 | map('n', '<Leader>yss', '<plug>(SubversiveSubstituteLine)', "substitute from yank, line") | 12 | map("n", "S", require('substitute').eol, "substitute: eol") |
13 | map('n', '<Leader>yS', '<plug>(SubversiveSubstituteToEndOfLine)', "substitute from yank, eol") | 13 | map("x", "s", require('substitute').visual, "substitute: visual") |
14 | 14 | ||
15 | -- substitute over range | 15 | map("n", "<leader>s", require('substitute.range').operator, "substitute: over range") |
16 | map( { 'n', 'x' }, '<Leader>s', '<plug>(SubversiveSubstituteRange)', "start substitude over range") | 16 | map("x", "<leader>s", require('substitute.range').visual, "substitute: over visual") |
17 | map('n', '<Leader>ss', '<plug>(SubversiveSubstituteWordRange)', "start substitude over range") | 17 | map("n", "<leader>ss", require('substitute.range').word, "substitute: with word over range") |
18 | end | 18 | |
19 | map("n", "sx", require('substitute.exchange').operator, "exchange") | ||
20 | map("n", "sxx", require('substitute.exchange').line, "exchange line") | ||
21 | map("x", "sX", require('substitute.exchange').visual, "exchange visual") | ||
22 | map("n", "sxc", require('substitute.exchange').cancel, "exchange cancel") | ||
23 | |||
24 | require("substitute").setup({ | ||
25 | highlight_substituted_text = { | ||
26 | enabled = true, | ||
27 | timer = 300, | ||
28 | }, | ||
29 | }) | ||
30 | end, | ||
19 | }, | 31 | }, |
20 | { | 32 | { |
21 | 'svermeulen/vim-yoink', | 33 | "gbprod/yanky.nvim", |
22 | config = function() | 34 | config = function() |
23 | vim.g.yoinkIncludeDeleteOperations = 1 | 35 | -- fix Target STRING not available |
24 | |||
25 | -- fix the Target STRING not available | ||
26 | vim.g.clipboard = { | 36 | vim.g.clipboard = { |
27 | name = 'xsel_override', | 37 | name = 'xsel_override', |
28 | copy = { | 38 | copy = { |
@@ -38,14 +48,41 @@ return { | |||
38 | 48 | ||
39 | local map = require("helpers.keys").map | 49 | local map = require("helpers.keys").map |
40 | 50 | ||
41 | -- yoink paste | 51 | map({ "n", "x" }, 'p', '<Plug>(YankyPutAfter)') |
42 | map('n', 'p', '<Plug>(YoinkPaste_p)') | 52 | map({ "n", "x" }, 'P', '<Plug>(YankyPutBefore)') |
43 | map('n', 'P', '<Plug>(YoinkPaste_P)') | 53 | |
54 | map("n", "<c-n>", "<Plug>(YankyCycleForward)") | ||
55 | map("n", "<c-p>", "<Plug>(YankyCycleBackward)") | ||
44 | 56 | ||
45 | -- iterate over yank list | 57 | local utils = require("yanky.utils") |
46 | map('n', '<c-n>', '<Plug>(YoinkPostPasteSwapBack)') | 58 | local mapping = require("yanky.telescope.mapping") |
47 | map('n', '<c-p>', '<Plug>(YoinkPostPasteSwapForward)') | 59 | |
60 | require("yanky").setup({ | ||
61 | ring = { | ||
62 | history_length = 100, | ||
63 | storage = "shada", | ||
64 | sync_with_numbered_registers = true, | ||
65 | cancel_event = "update", | ||
66 | ignore_registers = { "_" }, | ||
67 | }, | ||
68 | system_clipboard = { | ||
69 | sync_with_ring = true, | ||
70 | }, | ||
71 | picker = { | ||
72 | telescope = { | ||
73 | use_default_mappings = false, | ||
74 | mappings = { | ||
75 | default = mapping.set_register(utils.get_default_register()), | ||
76 | }, | ||
77 | }, | ||
78 | }, | ||
79 | highlight = { | ||
80 | on_put = true, | ||
81 | on_yank = true, | ||
82 | timer = 300, | ||
83 | }, | ||
48 | 84 | ||
85 | }) | ||
49 | end, | 86 | end, |
50 | } | 87 | } |
51 | } | 88 | } |
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 @@ | |||
1 | return { | 1 | return { |
2 | { | 2 | { |
3 | "nvim-telescope/telescope.nvim", | 3 | "nvim-telescope/telescope.nvim", |
4 | priority = 500, | ||
4 | dependencies = { | 5 | dependencies = { |
5 | "nvim-lua/plenary.nvim", | 6 | "nvim-lua/plenary.nvim", |
6 | { | 7 | { |
@@ -8,38 +9,45 @@ return { | |||
8 | build = "make", | 9 | build = "make", |
9 | cond = vim.fn.executable("make") == 1 | 10 | cond = vim.fn.executable("make") == 1 |
10 | }, | 11 | }, |
12 | "gbprod/yanky.nvim", | ||
11 | }, | 13 | }, |
14 | lazy = false, | ||
12 | config = function() | 15 | config = function() |
13 | require('telescope').setup({ | 16 | require('telescope').setup({ |
17 | defaults = { | ||
18 | path_display = { "truncate" }, | ||
19 | }, | ||
14 | extensions = { | 20 | extensions = { |
15 | fzf = { | 21 | fzf = { |
16 | fuzzy = true, -- false will only do exact matching | 22 | fuzzy = true, -- false will only do exact matching |
17 | override_generic_sorter = true, | 23 | override_generic_sorter = true, |
18 | override_file_sorter = true, | 24 | override_file_sorter = true, |
19 | case_mode = "smart_case", | 25 | case_mode = "smart_case", |
20 | } | 26 | }, |
21 | } | 27 | }, |
22 | }) | 28 | }) |
23 | -- Enable telescope fzf native, if installed | 29 | -- Enable telescope fzf native, if installed |
24 | pcall(require("telescope").load_extension, "fzf") | 30 | pcall(require("telescope").load_extension, "fzf") |
25 | 31 | ||
26 | local map = require("helpers.keys").map | 32 | local map = require("helpers.keys").map |
27 | 33 | ||
28 | map("n", "<leader>fr", require("telescope.builtin").oldfiles, "recently opened") | 34 | map("n", "<leader>fr", require("telescope.builtin").oldfiles, "🔭: recently opened") |
29 | map("n", "<leader><space>", require("telescope.builtin").buffers, "open buffers") | 35 | map("n", "<leader><space>", require("telescope.builtin").buffers, "🔭: open buffers") |
30 | map("n", "<leader>/", function() | 36 | map("n", "<leader>/", function() |
31 | -- You can pass additional configuration to telescope to change theme, layout, etc. | 37 | -- you can pass additional configuration to telescope to change theme, layout, etc. |
32 | require("telescope.builtin").current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({ | 38 | require("telescope.builtin").current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({ |
33 | winblend = 10, | 39 | winblend = 10, |
34 | previewer = false, | 40 | previewer = false, |
35 | })) | 41 | })) |
36 | end, "search in current buffer") | 42 | end, "🔭: search in current buffer") |
37 | 43 | ||
38 | map("n", "<leader>sf", require("telescope.builtin").find_files, "files") | 44 | map("n", "<leader>sf", require("telescope.builtin").find_files, "🔭: find files") |
39 | map("n", "<leader>sh", require("telescope.builtin").help_tags, "help") | 45 | map("n", "<leader>sh", require("telescope.builtin").help_tags, "🔭: help") |
40 | map("n", "<leader>sw", require("telescope.builtin").grep_string, "current word") | 46 | map("n", "<leader>sw", require("telescope.builtin").grep_string, "🔭: current word") |
41 | map("n", "<leader>sg", require("telescope.builtin").live_grep, "grep") | 47 | map("n", "<leader>sg", require("telescope.builtin").live_grep, "🔭: live grep") |
42 | map("n", "<leader>sd", require("telescope.builtin").diagnostics, "diagnostics") | 48 | map("n", "<leader>sd", require("telescope.builtin").diagnostics, "🔭: diagnostics") |
49 | require("telescope").load_extension("yank_history") | ||
50 | map("n", "<leader>sp", require("telescope").extensions.yank_history.yank_history, "🔭: yank history") | ||
43 | end, | 51 | end, |
44 | }, | 52 | }, |
45 | } | 53 | } |