From a605d46294274a50559123f99569febf398ebd9b Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Thu, 29 Dec 2022 04:24:48 +0200 Subject: [PATCH] nvim plugins and configs --- config/nvim/init.lua | 62 +++++++++++++++++++++++--- config/nvim/lua/custom/plugins.lua | 31 +++++++++++++ config/nvim/plugin/packer_compiled.lua | 21 +++++++++ 3 files changed, 108 insertions(+), 6 deletions(-) diff --git a/config/nvim/init.lua b/config/nvim/init.lua index c29d0e5..a448b0b 100644 --- a/config/nvim/init.lua +++ b/config/nvim/init.lua @@ -151,10 +151,10 @@ vim.api.nvim_create_autocmd('TextYankPost', { -- See `:help lualine.txt` require('lualine').setup { options = { - icons_enabled = true, - theme = 'auto', - component_separators = '|', - section_separators = '', + icons_enabled = true, + theme = 'auto', + component_separators = '|', + section_separators = '', }, } @@ -164,8 +164,11 @@ require('Comment').setup() -- Enable `lukas-reineke/indent-blankline.nvim` -- See `:help indent_blankline.txt` require('indent_blankline').setup { - char = '┊', - show_trailing_blankline_indent = false, + -- char = '┊', + show_trailing_blankline_indent = true, + space_char_blankline = " ", + show_current_context = true, + show_current_context_start = true, } -- Gitsigns @@ -442,5 +445,52 @@ cmp.setup { }, } +-- barbar keymaps +local map = vim.api.nvim_set_keymap +local opts = { noremap = true, silent = true } + +-- Move to previous/next +map('n', '', 'BufferPrevious', opts) +map('n', '', 'BufferNext', opts) +-- Re-order to previous/next +map('n', '', 'BufferMovePrevious', opts) +map('n', '>', 'BufferMoveNext', opts) +-- Goto buffer in position... +map('n', '', 'BufferGoto 1', opts) +map('n', '', 'BufferGoto 2', opts) +map('n', '', 'BufferGoto 3', opts) +map('n', '', 'BufferGoto 4', opts) +map('n', '', 'BufferGoto 5', opts) +map('n', '', 'BufferGoto 6', opts) +map('n', '', 'BufferGoto 7', opts) +map('n', '', 'BufferGoto 8', opts) +map('n', '', 'BufferGoto 9', opts) +map('n', '', 'BufferLast', opts) +-- Pin/unpin buffer +map('n', '', 'BufferPin', opts) +-- Close buffer +map('n', '', 'BufferClose', opts) +-- Wipeout buffer +-- :BufferWipeout +-- Close commands +-- :BufferCloseAllButCurrent +-- :BufferCloseAllButPinned +-- :BufferCloseAllButCurrentOrPinned +-- :BufferCloseBuffersLeft +-- :BufferCloseBuffersRight +-- Magic buffer-picking mode +map('n', '', 'BufferPick', opts) +-- Sort automatically by... +map('n', 'bb', 'BufferOrderByBufferNumber', opts) +map('n', 'bd', 'BufferOrderByDirectory', opts) +map('n', 'bl', 'BufferOrderByLanguage', opts) +map('n', 'bw', 'BufferOrderByWindowNumber', opts) + +-- Other: +-- :BarbarEnable - enables barbar (enabled by default) +-- :BarbarDisable - very bad command, should never be used + + + -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/config/nvim/lua/custom/plugins.lua b/config/nvim/lua/custom/plugins.lua index a2b330c..b693c34 100644 --- a/config/nvim/lua/custom/plugins.lua +++ b/config/nvim/lua/custom/plugins.lua @@ -9,5 +9,36 @@ return function(use) -- catppuccin theme use { "catppuccin/nvim", as = "catppuccin" } vim.cmd.colorscheme('catppuccin-latte') + + -- https://github.com/iamcco/markdown-preview.nvim + use({ + "iamcco/markdown-preview.nvim", + run = function() vim.fn["mkdp#util#install"]() end, + }) + + -- https://github.com/romgrk/barbar.nvim + use 'nvim-tree/nvim-web-devicons' + use {'romgrk/barbar.nvim', wants = 'nvim-web-devicons'} + + -- https://github.com/ThePrimeagen/refactoring.nvim + use { + "ThePrimeagen/refactoring.nvim", + requires = { + {"nvim-lua/plenary.nvim"}, + {"nvim-treesitter/nvim-treesitter"} + } + } + -- Remaps for the refactoring operations currently offered by the plugin + vim.api.nvim_set_keymap("v", "re", [[ lua require('refactoring').refactor('Extract Function')]], {noremap = true, silent = true, expr = false}) + vim.api.nvim_set_keymap("v", "rf", [[ lua require('refactoring').refactor('Extract Function To File')]], {noremap = true, silent = true, expr = false}) + vim.api.nvim_set_keymap("v", "rv", [[ lua require('refactoring').refactor('Extract Variable')]], {noremap = true, silent = true, expr = false}) + vim.api.nvim_set_keymap("v", "ri", [[ lua require('refactoring').refactor('Inline Variable')]], {noremap = true, silent = true, expr = false}) + + -- Extract block doesn't need visual mode + vim.api.nvim_set_keymap("n", "rb", [[ lua require('refactoring').refactor('Extract Block')]], {noremap = true, silent = true, expr = false}) + vim.api.nvim_set_keymap("n", "rbf", [[ lua require('refactoring').refactor('Extract Block To File')]], {noremap = true, silent = true, expr = false}) + + -- Inline variable can also pick up the identifier currently under the cursor without visual mode + vim.api.nvim_set_keymap("n", "ri", [[ lua require('refactoring').refactor('Inline Variable')]], {noremap = true, silent = true, expr = false}) end diff --git a/config/nvim/plugin/packer_compiled.lua b/config/nvim/plugin/packer_compiled.lua index 4f6ab49..2613de4 100644 --- a/config/nvim/plugin/packer_compiled.lua +++ b/config/nvim/plugin/packer_compiled.lua @@ -84,6 +84,12 @@ _G.packer_plugins = { path = "/Users/ivuorinen/.local/share/nvim/site/pack/packer/start/LuaSnip", url = "https://github.com/L3MON4D3/LuaSnip" }, + ["barbar.nvim"] = { + loaded = true, + path = "/Users/ivuorinen/.local/share/nvim/site/pack/packer/start/barbar.nvim", + url = "https://github.com/romgrk/barbar.nvim", + wants = { "nvim-web-devicons" } + }, catppuccin = { loaded = true, path = "/Users/ivuorinen/.local/share/nvim/site/pack/packer/start/catppuccin", @@ -119,6 +125,11 @@ _G.packer_plugins = { path = "/Users/ivuorinen/.local/share/nvim/site/pack/packer/start/lualine.nvim", url = "https://github.com/nvim-lualine/lualine.nvim" }, + ["markdown-preview.nvim"] = { + loaded = true, + path = "/Users/ivuorinen/.local/share/nvim/site/pack/packer/start/markdown-preview.nvim", + url = "https://github.com/iamcco/markdown-preview.nvim" + }, ["mason-lspconfig.nvim"] = { loaded = true, path = "/Users/ivuorinen/.local/share/nvim/site/pack/packer/start/mason-lspconfig.nvim", @@ -151,6 +162,11 @@ _G.packer_plugins = { path = "/Users/ivuorinen/.local/share/nvim/site/pack/packer/opt/nvim-treesitter-textobjects", url = "https://github.com/nvim-treesitter/nvim-treesitter-textobjects" }, + ["nvim-web-devicons"] = { + loaded = true, + path = "/Users/ivuorinen/.local/share/nvim/site/pack/packer/start/nvim-web-devicons", + url = "https://github.com/nvim-tree/nvim-web-devicons" + }, ["packer.nvim"] = { loaded = true, path = "/Users/ivuorinen/.local/share/nvim/site/pack/packer/start/packer.nvim", @@ -166,6 +182,11 @@ _G.packer_plugins = { path = "/Users/ivuorinen/.local/share/nvim/site/pack/packer/start/plenary.nvim", url = "https://github.com/nvim-lua/plenary.nvim" }, + ["refactoring.nvim"] = { + loaded = true, + path = "/Users/ivuorinen/.local/share/nvim/site/pack/packer/start/refactoring.nvim", + url = "https://github.com/ThePrimeagen/refactoring.nvim" + }, ["telescope-fzf-native.nvim"] = { cond = { true }, loaded = false,