From 65dea4ed80979288bc350241fbc386333857581a Mon Sep 17 00:00:00 2001 From: jiriks74 Date: Mon, 23 Sep 2024 17:38:17 +0200 Subject: [PATCH] feat(plugins, keymaps): Add plugins, move plugins to nix, update keymaps Added: - [aerial.nvim](https://github.com/stevearc/aerial.nvim) - [better-escape.nvim](https://github.com/max397574/better-escape.nvim) - [dressing.nvim](https://github.com/stevearc/dressing.nvim) - [ident-blankline.nvim](https://github.com/lukas-reineke/indent-blankline.nvim) - [nvim-notify](https://github.com/rcarriga/nvim-notify) - [todo-comments.nvim](https://github.com/folke/todo-comments.nvim) Moved plugin source from Github to Nix: - [Comment.nvim](https://github.com/numToStr/Comment.nvim) - [neo-tree.nvim](https://github.com/numToStr/Comment.nvim) Mapped windown switching to `l` group - Eg. `ls` for signature help --- flake.lock | 34 --------------------------------- flake.nix | 8 -------- nix/neovim-overlay.nix | 10 ++++++++-- nvim/plugin/aerial.lua | 17 +++++++++++++++++ nvim/plugin/autocommands.lua | 4 ++-- nvim/plugin/ident-blankline.lua | 33 ++++++++++++++++++++++++++++++++ nvim/plugin/keymaps.lua | 10 ++++++---- nvim/plugin/plugins.lua | 2 ++ nvim/plugin/treesitter.lua | 4 ++-- 9 files changed, 70 insertions(+), 52 deletions(-) create mode 100644 nvim/plugin/aerial.lua create mode 100644 nvim/plugin/ident-blankline.lua diff --git a/flake.lock b/flake.lock index 39fca91..80b6516 100644 --- a/flake.lock +++ b/flake.lock @@ -1,21 +1,5 @@ { "nodes": { - "comment-nvim": { - "flake": false, - "locked": { - "lastModified": 1717957420, - "narHash": "sha256-h0kPue5Eqd5aeu4VoLH45pF0DmWWo1d8SnLICSQ63zc=", - "owner": "numToStr", - "repo": "Comment.nvim", - "rev": "e30b7f2008e52442154b66f7c519bfd2f1e32acb", - "type": "github" - }, - "original": { - "owner": "numToStr", - "repo": "Comment.nvim", - "type": "github" - } - }, "flake-compat": { "flake": false, "locked": { @@ -151,22 +135,6 @@ "type": "github" } }, - "neotree": { - "flake": false, - "locked": { - "lastModified": 1726542367, - "narHash": "sha256-Lqt0KJNT9HmpJwZoWChYeVBrDWhscRe8COqVCwgcTwk=", - "owner": "nvim-neo-tree", - "repo": "neo-tree.nvim", - "rev": "a77af2e764c5ed4038d27d1c463fa49cd4794e07", - "type": "github" - }, - "original": { - "owner": "nvim-neo-tree", - "repo": "neo-tree.nvim", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1718714799, @@ -245,10 +213,8 @@ }, "root": { "inputs": { - "comment-nvim": "comment-nvim", "flake-utils": "flake-utils", "gen-luarc": "gen-luarc", - "neotree": "neotree", "nixpkgs": "nixpkgs_2", "presence-nvim": "presence-nvim" } diff --git a/flake.nix b/flake.nix index 94ced7f..7d9420f 100644 --- a/flake.nix +++ b/flake.nix @@ -12,14 +12,6 @@ url = "github:jiriks74/presence.nvim"; flake = false; }; - comment-nvim = { - url = "github:numToStr/Comment.nvim"; - flake = false; - }; - neotree = { - url = "github:nvim-neo-tree/neo-tree.nvim"; - flake = false; - }; # wf-nvim = { # url = "github:Cassin01/wf.nvim"; # flake = false; diff --git a/nix/neovim-overlay.nix b/nix/neovim-overlay.nix index 89deb89..fc17291 100644 --- a/nix/neovim-overlay.nix +++ b/nix/neovim-overlay.nix @@ -66,9 +66,12 @@ with final.pkgs.lib; let # UI lualine-nvim # Status line | https://github.com/nvim-lualine/lualine.nvim/ + dressing-nvim # Improve the default vim.ui interfaces | https://github.com/stevearc/dressing.nvim nvim-navic # Add LSP location to lualine | https://github.com/SmiteshP/nvim-navic statuscol-nvim # Status column | https://github.com/luukvbaal/statuscol.nvim/ nvim-treesitter-context # nvim-treesitter-context + indent-blankline-nvim # Indent guides for Neovim | https://github.com/lukas-reineke/indent-blankline.nvim + nvim-notify # A fancy, configurable, notification manager for NeoVim | https://github.com/rcarriga/nvim-notify # ^ UI # language support @@ -80,12 +83,15 @@ with final.pkgs.lib; let nvim-surround # https://github.com/kylechui/nvim-surround/ nvim-treesitter-textobjects # https://github.com/nvim-treesitter/nvim-treesitter-textobjects/ nvim-ts-context-commentstring # https://github.com/joosepalviste/nvim-ts-context-commentstring/ - (mkNvimPlugin inputs.comment-nvim "Comment.nvim") # https://github.com/numToStr/Comment.nvim - (mkNvimPlugin inputs.neotree "neo-tree.nvim") # https://github.com/numToStr/Comment.nvim + comment-nvim # https://github.com/numToStr/Comment.nvim + neo-tree-nvim # https://github.com/numToStr/Comment.nvim + aerial-nvim # Plugin for a code outline window | https://github.com/stevearc/aerial.nvim # ^ navigation/editing enhancement plugins # Useful utilities + todo-comments-nvim # Highlight, list and search todo comments in your projects | https://github.com/folke/todo-comments.nvim nvim-unception # Prevent nested neovim sessions | nvim-unception + better-escape-nvim # Map keys without delay when typing | https://github.com/max397574/better-escape.nvim # ^ Useful utilities # libraries that other plugins depend on diff --git a/nvim/plugin/aerial.lua b/nvim/plugin/aerial.lua new file mode 100644 index 0000000..7440a94 --- /dev/null +++ b/nvim/plugin/aerial.lua @@ -0,0 +1,17 @@ +if vim.g.did_load_aerial_plugin then + return +end +vim.g.did_load_aerial_plugin = true + +require("aerial").setup({ + -- optionally use on_attach to set keymaps when aerial has attached to a buffer + on_attach = function(bufnr) + -- Jump forwards/backwards with '{' and '}' + vim.keymap.set("n", "{", "AerialPrev", { buffer = bufnr }) + vim.keymap.set("n", "}", "AerialNext", { buffer = bufnr }) + end, +}) +-- You probably also want to set a keymap to toggle aerial +vim.keymap.set("n", "a", "AerialToggle!") + + diff --git a/nvim/plugin/autocommands.lua b/nvim/plugin/autocommands.lua index b3a3e58..3778d6c 100644 --- a/nvim/plugin/autocommands.lua +++ b/nvim/plugin/autocommands.lua @@ -80,9 +80,9 @@ vim.api.nvim_create_autocmd('LspAttach', { keymap.set('n', 'gd', vim.lsp.buf.definition, { desc = 'lsp [g]o to [d]efinition' }) keymap.set('n', 'K', vim.lsp.buf.hover, { desc = '[lsp] hover' }) keymap.set('n', 'gi', vim.lsp.buf.implementation, { desc = 'lsp [g]o to [i]mplementation' }) - keymap.set('n', '', vim.lsp.buf.signature_help, { desc = '[lsp] signature help' }) + keymap.set('n', 'ls', vim.lsp.buf.signature_help, { desc = '[l]sp [s]ignature help' }) keymap.set('n', '', vim.lsp.buf.code_action, { desc = '[lsp] code action' }) - keymap.set('n', '', vim.lsp.codelens.run, { desc = '[lsp] run code lens' }) + keymap.set('n', 'll', vim.lsp.codelens.run, { desc = '[l]sp run code [l]ens' }) keymap.set('n', 'gr', vim.lsp.buf.references, { desc = 'lsp [g]et [r]eferences' }) wk.add({ diff --git a/nvim/plugin/ident-blankline.lua b/nvim/plugin/ident-blankline.lua new file mode 100644 index 0000000..a0365b5 --- /dev/null +++ b/nvim/plugin/ident-blankline.lua @@ -0,0 +1,33 @@ +if vim.g.did_load_ibl_plugin then + return +end +vim.g.did_load_ibl_plugin = true + +local highlight = { + "RainbowRed", + "RainbowYellow", + "RainbowBlue", + "RainbowOrange", + "RainbowGreen", + "RainbowViolet", + "RainbowCyan", +} + +local hooks = require "ibl.hooks" +-- create the highlight groups in the highlight setup hook, so they are reset +-- every time the colorscheme changes +hooks.register(hooks.type.HIGHLIGHT_SETUP, function() + vim.api.nvim_set_hl(0, "RainbowRed", { fg = "#E06C75" }) + vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#E5C07B" }) + vim.api.nvim_set_hl(0, "RainbowBlue", { fg = "#61AFEF" }) + vim.api.nvim_set_hl(0, "RainbowOrange", { fg = "#D19A66" }) + vim.api.nvim_set_hl(0, "RainbowGreen", { fg = "#98C379" }) + vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#C678DD" }) + vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#56B6C2" }) +end) + +require("ibl").setup{ + indent = { + highlight = highlight + } +} diff --git a/nvim/plugin/keymaps.lua b/nvim/plugin/keymaps.lua index 91840cf..bd10414 100644 --- a/nvim/plugin/keymaps.lua +++ b/nvim/plugin/keymaps.lua @@ -189,10 +189,12 @@ keymap.set('n', '', 'zz', { desc = 'move [u]p half-page and center' }) keymap.set('n', '', 'zz', { desc = 'move DOWN [f]ull-page and center' }) keymap.set('n', '', 'zz', { desc = 'move UP full-page and center' }) -keymap.set('n', '', 'wincmd h', { desc = 'focus left window' }) -keymap.set('n', '', 'wincmd j', { desc = 'focus bottom window' }) -keymap.set('n', '', 'wincmd k', { desc = 'focus top window' }) -keymap.set('n', '', 'wincmd l', { desc = 'focus right window' }) +keymap.set('n', '', 'wincmd h', { desc = 'focus left window' }) +keymap.set('n', '', 'wincmd j', { desc = 'focus bottom window' }) +keymap.set('n', '', 'wincmd k', { desc = 'focus top window' }) +keymap.set('n', '', 'wincmd l', { desc = 'focus right window' }) + +keymap.set('n', 'tt', 'TodoTelescope', { desc = '[t]elescope [t]odo comments'}) --- Disabled keymaps [enable at your own risk] diff --git a/nvim/plugin/plugins.lua b/nvim/plugin/plugins.lua index f792f14..3bc9059 100644 --- a/nvim/plugin/plugins.lua +++ b/nvim/plugin/plugins.lua @@ -12,3 +12,5 @@ require("dapui").setup() require('nvim-surround').setup() require('which-key').setup() require('Comment').setup() +require("better_escape").setup() +require("todo-comments").setup() diff --git a/nvim/plugin/treesitter.lua b/nvim/plugin/treesitter.lua index d137f23..9144084 100644 --- a/nvim/plugin/treesitter.lua +++ b/nvim/plugin/treesitter.lua @@ -50,10 +50,10 @@ configs.setup { swap = { enable = true, swap_next = { - ['a'] = '@parameter.inner', + ['sa'] = '@parameter.inner', }, swap_previous = { - ['A'] = '@parameter.inner', + ['sA'] = '@parameter.inner', }, }, move = {