From 2d8917bd24587b8c6aa8bdd8814fcc37a27773ee Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado Date: Sat, 3 Feb 2024 02:34:32 -0600 Subject: refactor: all rust in one config, rename gitsigns to git --- lua/plugins/crates.lua | 9 --------- lua/plugins/git.lua | 31 +++++++++++++++++++++++++++++++ lua/plugins/gitsigns.lua | 31 ------------------------------- lua/plugins/rust.lua | 27 +++++++++++++++++++-------- 4 files changed, 50 insertions(+), 48 deletions(-) delete mode 100644 lua/plugins/crates.lua create mode 100644 lua/plugins/git.lua delete mode 100644 lua/plugins/gitsigns.lua (limited to 'lua') diff --git a/lua/plugins/crates.lua b/lua/plugins/crates.lua deleted file mode 100644 index e0c46be..0000000 --- a/lua/plugins/crates.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - 'Saecki/crates.nvim', - ft = { 'rust', 'toml' }, - config = function(_, opts) - local crates = require('crates') - crates.setup(opts) - crates.show() - end -} diff --git a/lua/plugins/git.lua b/lua/plugins/git.lua new file mode 100644 index 0000000..a40a3dc --- /dev/null +++ b/lua/plugins/git.lua @@ -0,0 +1,31 @@ +return { + 'lewis6991/gitsigns.nvim', + opts = { + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + }, + signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` + numhl = true, -- Toggle with `:Gitsigns toggle_numhl` + linehl = false, -- Toggle with `:Gitsigns toggle_linehl` + word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` + on_attach = function(bufnr) + local gs = require('gitsigns') + + -- TODO: use this function for most of the keymaps across plugins? + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + map('n', 'gp', gs.prev_hunk, { desc = '[g]it: [p]revious hunk' }) + map('n', 'gn', gs.next_hunk, { desc = '[g]it: [n]ext hunk' }) + map('n', 'gv', gs.preview_hunk, { desc = '[g]it: [v]iew hunk' }) + map('n', 'gb', gs.toggle_current_line_blame, { desc = '[g]it: [b]lame toggle' }) + end, + }, +} diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua deleted file mode 100644 index a40a3dc..0000000 --- a/lua/plugins/gitsigns.lua +++ /dev/null @@ -1,31 +0,0 @@ -return { - 'lewis6991/gitsigns.nvim', - opts = { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, - signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` - numhl = true, -- Toggle with `:Gitsigns toggle_numhl` - linehl = false, -- Toggle with `:Gitsigns toggle_linehl` - word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` - on_attach = function(bufnr) - local gs = require('gitsigns') - - -- TODO: use this function for most of the keymaps across plugins? - local function map(mode, l, r, opts) - opts = opts or {} - opts.buffer = bufnr - vim.keymap.set(mode, l, r, opts) - end - - map('n', 'gp', gs.prev_hunk, { desc = '[g]it: [p]revious hunk' }) - map('n', 'gn', gs.next_hunk, { desc = '[g]it: [n]ext hunk' }) - map('n', 'gv', gs.preview_hunk, { desc = '[g]it: [v]iew hunk' }) - map('n', 'gb', gs.toggle_current_line_blame, { desc = '[g]it: [b]lame toggle' }) - end, - }, -} diff --git a/lua/plugins/rust.lua b/lua/plugins/rust.lua index e4bc53f..358248d 100644 --- a/lua/plugins/rust.lua +++ b/lua/plugins/rust.lua @@ -1,10 +1,21 @@ return { - -- For debugging capabilities, need to change the config - -- from lspconfig into it's own thing, for more: - -- https://www.youtube.com/watch?v=mh_EJhH49Ms - 'rust-lang/rust.vim', - ft = 'rust', - init = function() - vim.g.rustfmt_autosave = 1 - end + { + -- For debugging capabilities, need to change the config + -- from lspconfig into it's own thing, for more: + -- https://www.youtube.com/watch?v=mh_EJhH49Ms + 'rust-lang/rust.vim', + ft = 'rust', + init = function() + vim.g.rustfmt_autosave = 1 + end + }, + { + 'Saecki/crates.nvim', + ft = { 'rust', 'toml' }, + config = function(_, opts) + local crates = require('crates') + crates.setup(opts) + crates.show() + end + }, } -- cgit v1.2.3-54-g00ecf