diff --git a/flake.lock b/flake.lock index d671881..2116ff4 100644 --- a/flake.lock +++ b/flake.lock @@ -202,22 +202,6 @@ "type": "github" } }, - "impatient-nvim-src": { - "flake": false, - "locked": { - "lastModified": 1668271823, - "narHash": "sha256-tsdTHbUC0kYOGonJ1TLIsHnv/RgWGTqHKY3xVj80mxM=", - "owner": "lewis6991", - "repo": "impatient.nvim", - "rev": "d3dd30ff0b811756e735eb9020609fa315bfbbcc", - "type": "github" - }, - "original": { - "owner": "lewis6991", - "repo": "impatient.nvim", - "type": "github" - } - }, "lualine-nvim-src": { "flake": false, "locked": { @@ -453,38 +437,6 @@ "type": "github" } }, - "nvim-web-devicons-src": { - "flake": false, - "locked": { - "lastModified": 1669423115, - "narHash": "sha256-Wyd4HnV+aQrh4Z2KdwCdi84glzIbQt8/y7NRGf67hcw=", - "owner": "kyazdani42", - "repo": "nvim-web-devicons", - "rev": "189ad3790d57c548896a78522fd8b0d0fc11be31", - "type": "github" - }, - "original": { - "owner": "kyazdani42", - "repo": "nvim-web-devicons", - "type": "github" - } - }, - "plenary-nvim-src": { - "flake": false, - "locked": { - "lastModified": 1664607953, - "narHash": "sha256-lIdBrVpi+vUudeotjFAuw4C0VT8TPoFE9cVVAQEsAYU=", - "owner": "nvim-lua", - "repo": "plenary.nvim", - "rev": "4b7e52044bbb84242158d977a50c4cbcd85070c7", - "type": "github" - }, - "original": { - "owner": "nvim-lua", - "repo": "plenary.nvim", - "type": "github" - } - }, "root": { "inputs": { "Comment-nvim-src": "Comment-nvim-src", @@ -495,7 +447,6 @@ "firefox-darwin": "firefox-darwin", "gitsigns-nvim-src": "gitsigns-nvim-src", "home-manager": "home-manager", - "impatient-nvim-src": "impatient-nvim-src", "lualine-nvim-src": "lualine-nvim-src", "nil": "nil", "nix2vim": "nix2vim", @@ -506,14 +457,10 @@ "nvim-lspconfig-src": "nvim-lspconfig-src", "nvim-tree-lua-src": "nvim-tree-lua-src", "nvim-treesitter-src": "nvim-treesitter-src", - "nvim-web-devicons-src": "nvim-web-devicons-src", - "plenary-nvim-src": "plenary-nvim-src", "telescope-nvim-src": "telescope-nvim-src", "telescope-project-nvim-src": "telescope-project-nvim-src", "toggleterm-nvim-src": "toggleterm-nvim-src", - "vim-bbye-src": "vim-bbye-src", - "vim-repeat-src": "vim-repeat-src", - "vim-surround-src": "vim-surround-src", + "vim-matchup-src": "vim-matchup-src", "wallpapers": "wallpapers", "wsl": "wsl" } @@ -606,51 +553,19 @@ "type": "github" } }, - "vim-bbye-src": { + "vim-matchup-src": { "flake": false, "locked": { - "lastModified": 1520078493, - "narHash": "sha256-xJMZQ/27TgwAnvPVH1fjF6SLOA9jvXmbfcwV0NZ1kTY=", - "owner": "moll", - "repo": "vim-bbye", - "rev": "25ef93ac5a87526111f43e5110675032dbcacf56", + "lastModified": 1668349349, + "narHash": "sha256-Btpninxq1B7/iIsn106hvPx1v5BPyLwADd2YcmliEZw=", + "owner": "andymass", + "repo": "vim-matchup", + "rev": "55e3330436784fb8ccc35a5cfeb13e48bab9dcd2", "type": "github" }, "original": { - "owner": "moll", - "repo": "vim-bbye", - "type": "github" - } - }, - "vim-repeat-src": { - "flake": false, - "locked": { - "lastModified": 1611544268, - "narHash": "sha256-8rfZa3uKXB3TRCqaDHZ6DfzNbm7WaYnLvmTNzYtnKHg=", - "owner": "tpope", - "repo": "vim-repeat", - "rev": "24afe922e6a05891756ecf331f39a1f6743d3d5a", - "type": "github" - }, - "original": { - "owner": "tpope", - "repo": "vim-repeat", - "type": "github" - } - }, - "vim-surround-src": { - "flake": false, - "locked": { - "lastModified": 1666730476, - "narHash": "sha256-DZE5tkmnT+lAvx/RQHaDEgEJXRKsy56KJY919xiH1lE=", - "owner": "tpope", - "repo": "vim-surround", - "rev": "3d188ed2113431cf8dac77be61b842acb64433d9", - "type": "github" - }, - "original": { - "owner": "tpope", - "repo": "vim-surround", + "owner": "andymass", + "repo": "vim-matchup", "type": "github" } }, diff --git a/flake.nix b/flake.nix index 99db524..93cd82f 100644 --- a/flake.nix +++ b/flake.nix @@ -63,34 +63,22 @@ url = "github:hrsh7th/cmp-buffer"; flake = false; }; - plenary-nvim-src = { - url = "github:nvim-lua/plenary.nvim"; - flake = false; - }; null-ls-nvim-src = { url = "github:jose-elias-alvarez/null-ls.nvim"; flake = false; }; - vim-surround-src = { - url = "github:tpope/vim-surround"; - flake = false; - }; - vim-repeat-src = { - url = "github:tpope/vim-repeat"; - flake = false; - }; Comment-nvim-src = { url = "github:numToStr/Comment.nvim"; flake = false; }; - impatient-nvim-src = { - url = "github:lewis6991/impatient.nvim"; - flake = false; - }; nvim-treesitter-src = { url = "github:nvim-treesitter/nvim-treesitter"; flake = false; }; + vim-matchup-src = { + url = "github:andymass/vim-matchup"; + flake = false; + }; telescope-nvim-src = { url = "github:nvim-telescope/telescope.nvim"; flake = false; @@ -111,18 +99,10 @@ url = "github:hoob3rt/lualine.nvim"; flake = false; }; - nvim-web-devicons-src = { - url = "github:kyazdani42/nvim-web-devicons"; - flake = false; - }; bufferline-nvim-src = { url = "github:akinsho/bufferline.nvim"; flake = false; }; - vim-bbye-src = { - url = "github:moll/vim-bbye"; - flake = false; - }; nvim-tree-lua-src = { url = "github:kyazdani42/nvim-tree.lua"; flake = false; @@ -192,48 +172,10 @@ imports = [ ./modules/neovim/plugins/gitsigns.nix ./modules/neovim/plugins/misc.nix - # ({ pkgs, dsl, ... }: - # # with dsl; - # { - # plugins = [ pkgs.vimPlugins.gitsigns-nvim ]; - # setup.gitsigns = { }; - # lua = '' - # vim.keymap.set("", "", "", { silent = true }) - # vim.g.mapleader = " " - # vim.g.maplocalleader = " " - # local gitsigns = require("gitsigns") - # vim.keymap.set("n", "gB", gitsigns.blame_line) - # vim.keymap.set("n", "gp", gitsigns.preview_hunk) - # vim.keymap.set("v", "gp", gitsigns.preview_hunk) - # vim.keymap.set("n", "gd", gitsigns.diffthis) - # vim.keymap.set("v", "gd", gitsigns.diffthis) - # vim.keymap.set("n", "rgf", gitsigns.reset_buffer) - # vim.keymap.set("v", "hs", gitsigns.stage_hunk) - # vim.keymap.set("v", "hr", gitsigns.reset_hunk) - # vim.keymap.set("v", "hr", gitsigns.reset_hunk) - # - # -- Navigation - # vim.keymap.set("n", "]g", function() - # if vim.wo.diff then - # return "]g" - # end - # vim.schedule(function() - # gitsigns.next_hunk() - # end) - # return "" - # end, { expr = true }) - # - # vim.keymap.set("n", "[g", function() - # if vim.wo.diff then - # return "[g" - # end - # vim.schedule(function() - # gitsigns.prev_hunk() - # end) - # return "" - # end, { expr = true }) - # ''; - # }) + ./modules/neovim/plugins/syntax.nix + ./modules/neovim/plugins/statusline.nix + ./modules/neovim/plugins/bufferline.nix + ./modules/neovim/plugins/telescope.nix ]; }; diff --git a/modules/neovim/lua/settings.lua b/modules/neovim/lua/settings.lua index b54e05a..ef447f7 100644 --- a/modules/neovim/lua/settings.lua +++ b/modules/neovim/lua/settings.lua @@ -2,42 +2,11 @@ -- Settings -- =========================================================================== -vim.o.termguicolors = true --- Set to truecolor -vim.o.hidden = true --- Don't unload buffers when leaving them -vim.wo.number = true --- Show line numbers -vim.wo.relativenumber = true --- Relative numbers instead of absolute -vim.o.list = true --- Reveal whitespace with dashes -vim.o.expandtab = true --- Tabs into spaces -vim.o.shiftwidth = 4 --- Amount to shift with > key -vim.o.softtabstop = 4 --- Amount to shift with key -vim.o.ignorecase = true --- Ignore case when searching -vim.o.smartcase = true --- Check case when using capitals in search -vim.o.infercase = true --- Don't match cases when completing suggestions -vim.o.incsearch = true --- Search while typing -vim.o.visualbell = true --- No sounds -vim.o.scrolljump = 1 --- Number of lines to scroll -vim.o.scrolloff = 3 --- Margin of lines to see while scrolling -vim.o.splitright = true --- Vertical splits on the right side -vim.o.splitbelow = true --- Horizontal splits on the bottom side -vim.o.pastetoggle = "" --- Use F3 to enter raw paste mode -vim.o.clipboard = "unnamedplus" --- Uses system clipboard for yanking -vim.o.updatetime = 300 --- Faster diagnostics -vim.o.mouse = "nv" --- Mouse interaction / scrolling - --- Neovim features -vim.o.inccommand = "split" --- Live preview search and replace ---- Required for nvim-cmp completion -vim.opt.completeopt = { - "menu", - "menuone", - "noselect", -} - -- Remember last position when reopening file vim.api.nvim_exec( [[ au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif -]], +]] , false ) @@ -54,7 +23,7 @@ vim.api.nvim_exec( if !isdirectory(&backupdir) call mkdir(&backupdir, "p") endif -]], +]] , false ) @@ -63,7 +32,7 @@ vim.api.nvim_exec( [[ au FileType tex inoremap ;bf \textbf{}i au BufWritePost *.tex silent! execute "!pdflatex -output-directory=%:p:h % >/dev/null 2>&1" | redraw! -]], +]] , false ) @@ -71,7 +40,7 @@ vim.api.nvim_exec( vim.api.nvim_exec( [[ au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 250 } -]], +]] , false ) diff --git a/modules/neovim/plugins-overlay.nix b/modules/neovim/plugins-overlay.nix index 5296426..274ad5b 100644 --- a/modules/neovim/plugins-overlay.nix +++ b/modules/neovim/plugins-overlay.nix @@ -24,13 +24,10 @@ in { cmp-buffer = (withSrc prev.vimPlugins.cmp-buffer inputs.cmp-buffer); plenary-nvim = (withSrc prev.vimPlugins.plenary-nvim inputs.plenary-nvim); null-ls-nvim = (withSrc prev.vimPlugins.null-ls-nvim inputs.null-ls-nvim); - vim-surround = (withSrc prev.vimPlugins.vim-surround inputs.vim-surround); - vim-repeat = (withSrc prev.vimPlugins.vim-repeat inputs.vim-repeat); comment-nvim = (withSrc prev.vimPlugins.comment-nvim inputs.comment-nvim); - impatient-nvim = - (withSrc prev.vimPlugins.impatient-nvim inputs.impatient-nvim); nvim-treesitter = (withSrc prev.vimPlugins.nvim-treesitter inputs.nvim-treesitter); + vim-matchup = (withSrc prev.vimPlugins.vim-matchup inputs.vim-matchup); telescope-nvim = (withSrc prev.vimPlugins.telescope-nvim inputs.telescope-nvim); telescope-project-nvim = (withSrc prev.vimPlugins.telescope-project-nvim @@ -39,11 +36,8 @@ in { (withSrc prev.vimPlugins.toggleterm-nvim inputs.toggleterm-nvim); gitsigns-nvim = (withSrc prev.vimPlugins.gitsigns-nvim inputs.gitsigns-nvim); lualine-nvim = (withSrc prev.vimPlugins.lualine-nvim inputs.lualine-nvim); - nvim-web-devicons = - (withSrc prev.vimPlugins.nvim-web-devicons inputs.nvim-web-devicons); bufferline-nvim = (withSrc prev.vimPlugins.bufferline-nvim inputs.bufferline-nvim); - vim-bbye = (withSrc prev.vimPlugins.vim-bbye inputs.vim-bbye); nvim-tree-lua = (withSrc prev.vimPlugins.nvim-tree-lua inputs.nvim-tree-lua); # Packaging plugins with Nix diff --git a/modules/neovim/plugins/bufferline.nix b/modules/neovim/plugins/bufferline.nix new file mode 100644 index 0000000..73a6514 --- /dev/null +++ b/modules/neovim/plugins/bufferline.nix @@ -0,0 +1,22 @@ +{ pkgs, ... }: { + plugins = [ + pkgs.vimPlugins.bufferline-nvim + pkgs.vimPlugins.vim-bbye # Better closing of buffers + ]; + setup.bufferline = { + options = { + diagnostics = "nvim_lsp"; + always_show_bufferline = false; + separator_style = "slant"; + offsets = [{ filetype = "NvimTree"; }]; + }; + }; + lua = '' + -- Move buffers + vim.keymap.set("n", "L", ":BufferLineCycleNext", { silent = true }) + vim.keymap.set("n", "H", ":BufferLineCyclePrev", { silent = true }) + + -- Kill buffer + vim.keymap.set("n", "x", " :Bdelete", { silent = true }) + ''; +} diff --git a/modules/neovim/plugins/misc.nix b/modules/neovim/plugins/misc.nix index 154d179..3223e7e 100644 --- a/modules/neovim/plugins/misc.nix +++ b/modules/neovim/plugins/misc.nix @@ -1,6 +1,4 @@ -{ pkgs, dsl, ... }: -# with dsl; -{ +{ pkgs, lib, ... }: { plugins = [ pkgs.vimPlugins.vim-surround pkgs.vimPlugins.vim-eunuch @@ -8,9 +6,38 @@ pkgs.vimPlugins.vim-fugitive pkgs.vimPlugins.vim-repeat pkgs.vimPlugins.comment-nvim + pkgs.vimPlugins.impatient-nvim ]; setup.Comment = { }; - lua = '' + + vim.o.termguicolors = true; # Set to truecolor + vim.o.hidden = true; # Don't unload buffers when leaving them + vim.wo.number = true; # Show line numbers + vim.wo.relativenumber = true; # Relative numbers instead of absolute + vim.o.list = true; # Reveal whitespace with dashes + vim.o.expandtab = true; # Tabs into spaces + vim.o.shiftwidth = 4; # Amount to shift with > key + vim.o.softtabstop = 4; # Amount to shift with key + vim.o.ignorecase = true; # Ignore case when searching + vim.o.smartcase = true; # Check case when using capitals in search + vim.o.infercase = true; # Don't match cases when completing suggestions + vim.o.incsearch = true; # Search while typing + vim.o.visualbell = true; # No sounds + vim.o.scrolljump = 1; # Number of lines to scroll + vim.o.scrolloff = 3; # Margin of lines to see while scrolling + vim.o.splitright = true; # Vertical splits on the right side + vim.o.splitbelow = true; # Horizontal splits on the bottom side + vim.o.pastetoggle = ""; # Use F3 to enter raw paste mode + vim.o.clipboard = "unnamedplus"; # Uses system clipboard for yanking + vim.o.updatetime = 300; # Faster diagnostics + vim.o.mouse = "nv"; # Mouse interaction / scrolling + vim.o.inccommand = "split"; # Live preview search and replace + + # Required for nvim-cmp completion + vim.opt.completeopt = [ "menu" "menuone" "noselect" ]; + + lua = lib.mkBefore '' + require("impatient") ${builtins.readFile ../lua/keybinds.lua}; ${builtins.readFile ../lua/settings.lua}; ''; diff --git a/modules/neovim/plugins/statusline.nix b/modules/neovim/plugins/statusline.nix new file mode 100644 index 0000000..96c8bf7 --- /dev/null +++ b/modules/neovim/plugins/statusline.nix @@ -0,0 +1,9 @@ +{ pkgs, ... }: { + plugins = [ pkgs.vimPlugins.lualine-nvim ]; + setup.lualine = { + options = { + theme = "gruvbox"; + icons_enabled = true; + }; + }; +} diff --git a/modules/neovim/plugins/syntax.nix b/modules/neovim/plugins/syntax.nix new file mode 100644 index 0000000..0f223e5 --- /dev/null +++ b/modules/neovim/plugins/syntax.nix @@ -0,0 +1,52 @@ +{ pkgs, ... }: { + + plugins = [ + (pkgs.vimPlugins.nvim-treesitter.withPlugins (plugins: + with pkgs.tree-sitter-grammars; [ + tree-sitter-hcl + tree-sitter-python + tree-sitter-lua + tree-sitter-nix + tree-sitter-fish + tree-sitter-toml + tree-sitter-yaml + tree-sitter-json + ])) + pkgs.vimPlugins.vim-matchup # Better % jumping in languages + pkgs.vimPlugins.nginx-vim + pkgs.vimPlugins.vim-helm + pkgs.vimPlugins.vim-puppet + ]; + + setup."nvim-treesitter.configs" = { + highlight = { enable = true; }; + indent = { enable = true; }; + + textobjects = { + select = { + enable = true; + lookahead = true; # Jump forward automatically + + keymaps = { + "['af']" = "@function.outer"; + "['if']" = "@function.inner"; + "['ac']" = "@class.outer"; + "['ic']" = "@class.inner"; + "['al']" = "@loop.outer"; + "['il']" = "@loop.inner"; + "['aa']" = "@call.outer"; + "['ia']" = "@call.inner"; + "['ar']" = "@parameter.outer"; + "['ir']" = "@parameter.inner"; + "['aC']" = "@comment.outer"; + "['iC']" = "@comment.outer"; + "['a/']" = "@comment.outer"; + "['i/']" = "@comment.outer"; + "['a;']" = "@statement.outer"; + "['i;']" = "@statement.outer"; + }; + }; + }; + }; + +} diff --git a/modules/neovim/plugins/telescope.nix b/modules/neovim/plugins/telescope.nix new file mode 100644 index 0000000..7fad646 --- /dev/null +++ b/modules/neovim/plugins/telescope.nix @@ -0,0 +1,108 @@ +{ pkgs, dsl, ... }: + +with dsl; + +{ + + plugins = [ + pkgs.vimPlugins.telescope-nvim + pkgs.vimPlugins.telescope-project-nvim + pkgs.vimPlugins.telescope-fzy-native-nvim + pkgs.vimPlugins.telescope-file-browser-nvim + pkgs.vimPlugins.telescope-zoxide + ]; + + setup.telescope = { + defaults = { + mappings = { + i = { + "['']" = rawLua "require('telescope.actions').close"; + "['']" = "which_key"; + }; + }; + }; + pickers = { + find_files = { theme = "ivy"; }; + oldfiles = { theme = "ivy"; }; + buffers = { theme = "dropdown"; }; + }; + extensions = { + fzy_native = { }; + zoxide = { }; + project = { base_dirs = [ "~/dev" ]; }; + }; + }; + + lua = '' + local telescope = require("telescope.builtin") + vim.keymap.set("n", "k", telescope.keymaps) + vim.keymap.set("n", "/", telescope.live_grep) + vim.keymap.set("n", "ff", telescope.find_files) + vim.keymap.set("n", "fp", telescope.git_files) + vim.keymap.set("n", "fw", telescope.grep_string) + vim.keymap.set("n", "b", telescope.buffers) + vim.keymap.set("n", "hh", telescope.help_tags) + vim.keymap.set("n", "fr", telescope.oldfiles) + vim.keymap.set("n", "cc", telescope.commands) + vim.keymap.set("n", "gc", telescope.git_commits) + vim.keymap.set("n", "gf", telescope.git_bcommits) + vim.keymap.set("n", "gb", telescope.git_branches) + vim.keymap.set("n", "gs", telescope.git_status) + vim.keymap.set("n", "s", telescope.current_buffer_fuzzy_find) + + vim.keymap.set("n", "N", function() + local opts = { + prompt_title = "Search Notes", + cwd = "$NOTES_PATH", + } + telescope.live_grep(opts) + end) + + vim.keymap.set("n", "fN", function() + local opts = { + prompt_title = "Find Notes", + cwd = "$NOTES_PATH", + } + telescope.find_files(opts) + end) + + vim.keymap.set("n", "cr", function() + local opts = require("telescope.themes").get_ivy({ + layout_config = { + bottom_pane = { + height = 15, + }, + }, + }) + telescope.command_history(opts) + end) + + -- zoxide + vim.keymap.set("n", "fz", require("telescope").extensions.zoxide.list) + + -- project + require("telescope").load_extension("project") + vim.keymap.set("n", "", function() + local opts = require("telescope.themes").get_ivy({ + layout_config = { + bottom_pane = { + height = 10, + }, + }, + }) + require("telescope").extensions.project.project(opts) + end) + + -- file browser + require("telescope").load_extension("file_browser") + vim.keymap.set("n", "fa", require("telescope").extensions.file_browser.file_browser) + vim.keymap.set("n", "fD", function() + local opts = { + prompt_title = "Find Downloads", + cwd = "~/downloads", + } + require("telescope").extensions.file_browser.file_browser(opts) + end) + ''; + +}