From b0c61768db6566a320d221e82c02edee08ed97e5 Mon Sep 17 00:00:00 2001 From: "RingOfStorms (Joshua Bell)" Date: Thu, 2 May 2024 23:51:15 -0500 Subject: [PATCH] several small updates --- README.md | 25 ++- flake.lock | 34 --- flake.nix | 94 +++++---- lua/keymaps.lua | 211 ++++++++++--------- lua/plugins/cmp_autocompletion.lua | 21 +- lua/plugins/editor_noice.lua | 69 +++--- lua/plugins/formatter.lua | 64 +++--- lua/plugins/telescope.lua | 326 +++++++++++++++-------------- lua/plugins/text_case.lua | 3 +- 9 files changed, 432 insertions(+), 415 deletions(-) diff --git a/README.md b/README.md index 543e1a5..cca1199 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ nix run 'github:ringofstorms/nvim/nix-flake' ``` in NixOS + ```nix -- in flake.nix#inputs ringofstorms-nvim = { @@ -26,8 +27,8 @@ environment.systemPackages = with pkgs; [ ]; ``` - ### Without Nix + TODO update this section - Must have all required programs installed and available on path @@ -35,18 +36,23 @@ TODO update this section - Evertying listed in flake.nix `runtime dependencies` variable near the top of the file - These must be available on the path - Treesitter/Lazy/Mason will install all other requirements needed on other systems + ```sh git clone https://github.com/RingOfStorms/nvim ~/.config/nvim nvim --headless "+Lazy! sync" +qa ``` + Backup existing config: + ```sh DATE=$(date +"%Y%m%d") mv ~/.config/nvim ~/.config/nvim_$DATE.bak mv ~/.local/share/nvim ~/.local/share/nvim_$DATE.bak mv ~/.local/state/nvim ~/.local/state/nvim_$DATE.bak ``` + or remove existing config: + ```sh rm -rf ~/.config/nvim rm -rf ~/.local/share/nvim @@ -55,21 +61,26 @@ rm -rf ~/.local/state/nvim ## NOTES/TODOS +- h/l movement broken in insert mode, probably due to cmp hotkeys +- h/l in telescope +- arrows still work in insert mode and telescope, need to remove trying to break arrow key habit + FUTURE + - Make a new HTTP plugin for running curl commands from .http files - similar to est-nvim/rest.nvim but support streaming etc and show command output - Execute selected command and open output into a buffer/popup window? cx - generate command, like scratch open a popup of things that can be generated. UUID/other stuff? -- https://github.com/mawkler/nvim/blob/06cde9dbaedab2bb36c06025c07589c93d2c6d6b/lua/configs/luasnip.lua#L37-L50 +- - Checkout cargo-bloat, cargo-cache, cargo-outdated - memcache sccache - For scratches, just make an input box for custom extension rather than predefined list -- freaking learn to use surround more often https://github.com/tpope/vim-surround/tree/master +- freaking learn to use surround more often - make my own session saving impl - Only save visible buffers/tabs/splits - per branch per directory - - something like https://github.com/gennaro-tedesco/nvim-possession/tree/main but fully managed + - something like but fully managed - copilot? local llm? - check out - - https://github.com/onsails/lspkind.nvim - - https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-align.md - - https://github.com/tpope/vim-abolish + - + - + - diff --git a/flake.lock b/flake.lock index 1bde335..dbe1695 100644 --- a/flake.lock +++ b/flake.lock @@ -1,23 +1,5 @@ { "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1714635257, @@ -68,26 +50,10 @@ }, "root": { "inputs": { - "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", "nvim_plugin-chrisgrieser/nvim-early-retirement": "nvim_plugin-chrisgrieser/nvim-early-retirement", "nvim_plugin-declancm/cinnamon.nvim": "nvim_plugin-declancm/cinnamon.nvim" } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 388c049..dbc39cd 100644 --- a/flake.nix +++ b/flake.nix @@ -3,7 +3,6 @@ # Nixpkgs / NixOS version to use. inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - flake-utils.url = "github:numtide/flake-utils"; # Names should always be `nvim_plugin-[lazy plugin name]` # Only need to add plugins as flake inputs if they are: @@ -18,18 +17,36 @@ flake = false; }; }; - outputs = { self, nixpkgs, flake-utils, ... } @ inputs: - # Takes all top level attributes and changes them to `attribute.${system} = old value` - flake-utils.lib.eachDefaultSystem (system: - let - # Anytime there is a huge breaking change that old state files wont - # work then we make a new version name. Helps separate any files. - version = "hydrogen"; - pkgs = nixpkgs.legacyPackages.${system}; - lib = nixpkgs.lib; + outputs = + { self, nixpkgs, ... }@inputs: + let + # Anytime there is a huge breaking change that old state files wont + # work then we make a new version name. Helps separate any files and + # "version" my neovim flake + # ================== + version = "helium"; + # =================== + + inherit (nixpkgs) lib; + withSystem = + f: + lib.fold lib.recursiveUpdate { } ( + map f [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-linux" + "aarch64-darwin" + ] + ); + in + # Takes all top level attributes and changes them to `attribute.${system} = old value` + withSystem ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; - lazyPath = pkgs.vimPlugins.lazy-nvim; # inputs."nvim_plugin-folke/lazy.nvim" # Plugins provided in nixpkgs, match the naming scheme above for keys + lazyPath = pkgs.vimPlugins.lazy-nvim; nixPkgsPlugins = with pkgs.vimPlugins; { "nvim_plugin-folke/lazy.nvim" = lazyPath; "nvim_plugin-nvim-treesitter/nvim-treesitter" = nvim-treesitter.withAllGrammars; @@ -73,19 +90,21 @@ "nvim_plugin-folke/neodev.nvim" = neodev-nvim; }; # This will be how we put any nix related stuff into our lua config - luaNixGlobal = "NIX=" + lib.generators.toLua { multiline = false; indent = false; } ({ - storePath = "${./.}"; - # This will look at all inputs and grab any prefixed with `nvim_plugin-` - pluginPaths = builtins.foldl' - (dirs: name: + luaNixGlobal = + "NIX=" + + + lib.generators.toLua { - "${name}" = inputs.${name}.outPath; - } // dirs) - nixPkgsPlugins - (builtins.filter - (n: builtins.substring 0 12 n == "nvim_plugin-") - (builtins.attrNames inputs)); - }); + multiline = false; + indent = false; + } + ({ + storePath = "${./.}"; + # This will look at all inputs and grab any prefixed with `nvim_plugin-` + pluginPaths = + builtins.foldl' (dirs: name: { "${name}" = inputs.${name}.outPath; } // dirs) nixPkgsPlugins + (builtins.filter (n: builtins.substring 0 12 n == "nvim_plugin-") (builtins.attrNames inputs)); + }); runtimeDependencies = with pkgs; [ # tools @@ -100,7 +119,9 @@ biome # (t|s)j[x] # formatters stylua + nixfmt-rfc-style nodePackages.prettier + markdownlint-cli2 # LSPs lua-language-server nodePackages.typescript-language-server @@ -111,20 +132,19 @@ ]; in { - packages = { + packages.${system} = { default = self.packages.${system}.neovim; neovim = - (pkgs.wrapNeovimUnstable - pkgs.neovim-unwrapped - (pkgs.neovimUtils.makeNeovimConfig { + (pkgs.wrapNeovimUnstable pkgs.neovim-unwrapped ( + pkgs.neovimUtils.makeNeovimConfig { withPython3 = false; customRC = '' lua ${luaNixGlobal} luafile ${./.}/init.lua set runtimepath^=${builtins.concatStringsSep "," (builtins.attrValues pkgs.vimPlugins.nvim-treesitter.grammarPlugins)} ''; - }) - ).overrideAttrs + } + )).overrideAttrs (old: { generatedWrapperArgs = old.generatedWrapperArgs or [ ] ++ [ # Add runtime dependencies to neovim path @@ -140,20 +160,20 @@ # All things at runtime should be deletable since we are using nix to handle downloads and bins # so I've chosen to put everything into the local state directory. "--run" - "export NVIM_FLAKE_BASE_DIR=\"\${XDG_STATE_HOME:-\$HOME/.local/state}\"" + ''export NVIM_FLAKE_BASE_DIR="''${XDG_STATE_HOME:-$HOME/.local/state}"'' "--run" - "export XDG_CONFIG_HOME=\"$NVIM_FLAKE_BASE_DIR/nvim_ringofstorms_${version}/config\"" + ''export XDG_CONFIG_HOME="$NVIM_FLAKE_BASE_DIR/nvim_ringofstorms_${version}/config"'' "--run" - "export XDG_DATA_HOME=\"$NVIM_FLAKE_BASE_DIR/nvim_ringofstorms_${version}/share\"" + ''export XDG_DATA_HOME="$NVIM_FLAKE_BASE_DIR/nvim_ringofstorms_${version}/share"'' "--run" - "export XDG_RUNTIME_DIR=\"$NVIM_FLAKE_BASE_DIR/nvim_ringofstorms_${version}/run\"" + ''export XDG_RUNTIME_DIR="$NVIM_FLAKE_BASE_DIR/nvim_ringofstorms_${version}/run"'' "--run" - "export XDG_STATE_HOME=\"$NVIM_FLAKE_BASE_DIR/nvim_ringofstorms_${version}/state\"" + ''export XDG_STATE_HOME="$NVIM_FLAKE_BASE_DIR/nvim_ringofstorms_${version}/state"'' "--run" - "export XDG_CACHE_HOME=\"$NVIM_FLAKE_BASE_DIR/nvim_ringofstorms_${version}/cache\"" + ''export XDG_CACHE_HOME="$NVIM_FLAKE_BASE_DIR/nvim_ringofstorms_${version}/cache"'' ]; }); }; - }); + } + ); } - diff --git a/lua/keymaps.lua b/lua/keymaps.lua index 07f3667..3ac393c 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -13,112 +13,117 @@ vim.g.maplocalleader = " " local nvx = { "n", "v", "x" } +-- TODO remove this notify and replace with a once I have trained well enough +local hjklNotid = nil +local hjklNotification = function() + hjklNotid = vim.notify("use h/j/k/l to move", 4, { replace = hjklNotid }) +end U.keymaps({ - -- Basic - { "", 'echo "use h/j/k/l to move!"', mode = nvx }, - { "", 'echo "use h/j/k/l to move!"', mode = nvx }, - { "", 'echo "use h/j/k/l to move!"', mode = nvx }, - { "", 'echo "use h/j/k/l to move!"', mode = nvx }, - { ";", ":", desc = "No shift to enter command mode with semicolon. Alias ; to :", mode = nvx }, - { "Q", "", mode = nvx }, -- don't do normal Q quit - { "a", "ggVG", desc = "Select all", mode = nvx }, - { "Q", "SessionSaveqa!", desc = "Quit all", mode = nvx }, - { "y", '"+y', desc = "Copy to system clipboard", mode = nvx }, - { "p", '"+p', desc = "Paste from system clipboard", mode = nvx }, - { "", "nohlsearch", desc = "Clear search on escape" }, - { "", "nohlsearch", desc = "Clear search on return" }, - { "|", "vsplit", desc = "Vertical Split" }, - { "\\", "split", desc = "Horizontal Split" }, - { "", "", desc = "Go back " }, - { - "J", - ":m '>+1gv=gv", - desc = "Visually move block down", - mode = "v", - }, - { - "K", - ":m '<-2gv=gv", - desc = "Visually move block up", - mode = "v", - }, - { "", "", desc = "Escape the terminal", mode = "t" }, + -- Basic + { "", hjklNotification, mode = { "n", "v", "x", "i" } }, + { "", hjklNotification, mode = { "n", "v", "x", "i" } }, + { "", hjklNotification, mode = { "n", "v", "x", "i" } }, + { "", hjklNotification, mode = { "n", "v", "x", "i" } }, + { ";", ":", desc = "No shift to enter command mode with semicolon. Alias ; to :", mode = nvx }, + { "Q", "", mode = nvx }, -- don't do normal Q quit + { "a", "ggVG", desc = "Select all", mode = nvx }, + { "Q", "SessionSaveqa!", desc = "Quit all", mode = nvx }, + { "y", '"+y', desc = "Copy to system clipboard", mode = nvx }, + { "p", '"+p', desc = "Paste from system clipboard", mode = nvx }, + { "", "nohlsearch", desc = "Clear search on escape" }, + { "", "nohlsearch", desc = "Clear search on return" }, + { "|", "vsplit", desc = "Vertical Split" }, + { "\\", "split", desc = "Horizontal Split" }, + { "", "", desc = "Go back " }, + { + "J", + ":m '>+1gv=gv", + desc = "Visually move block down", + mode = "v", + }, + { + "K", + ":m '<-2gv=gv", + desc = "Visually move block up", + mode = "v", + }, + { "", "", desc = "Escape the terminal", mode = "t" }, - -- Buffers - { "b", "b#", desc = "Switch to last buffer", mode = nvx }, - { - "q", - function() - -- Custom close/quit - -- * if non empty buffer, we will simply open a new empty buffer unless - -- it is in the close always list - -- * if empty buffer, then we will quit this buffer - local close_always = { "quickfix", "help", "nofile", "noice", "httpResult" } - if - U.table_contains(close_always, vim.bo.buftype) - or (vim.api.nvim_buf_line_count(0) == 1 and vim.api.nvim_buf_get_lines(0, 0, 1, -1)[1] == "") - then - vim.cmd("silent confirm q") - else - vim.cmd("enew") - end - end, - desc = "Quit/Close current", - mode = nvx, - }, - { - "S", - "set equalalwaysset noequalalways", - desc = "Equalize/resize screens evenly", - mode = nvx, - }, - { "", "h", desc = "Move window left current", mode = nvx }, - { "", "j", desc = "Move window below current", mode = nvx }, - { "", "k", desc = "Move window above current", mode = nvx }, - { "", "l", desc = "Move window right current", mode = nvx }, + -- Buffers + { "b", "b#", desc = "Switch to last buffer", mode = nvx }, + { + "q", + function() + -- Custom close/quit + -- * if non empty buffer, we will simply open a new empty buffer unless + -- it is in the close always list + -- * if empty buffer, then we will quit this buffer + local close_always = { "quickfix", "help", "nofile", "noice", "httpResult" } + if + U.table_contains(close_always, vim.bo.buftype) + or (vim.api.nvim_buf_line_count(0) == 1 and vim.api.nvim_buf_get_lines(0, 0, 1, -1)[1] == "") + then + vim.cmd("silent confirm q") + else + vim.cmd("enew") + end + end, + desc = "Quit/Close current", + mode = nvx, + }, + { + "S", + "set equalalwaysset noequalalways", + desc = "Equalize/resize screens evenly", + mode = nvx, + }, + { "", "h", desc = "Move window left current", mode = nvx }, + { "", "j", desc = "Move window below current", mode = nvx }, + { "", "k", desc = "Move window above current", mode = nvx }, + { "", "l", desc = "Move window right current", mode = nvx }, - -- Editor - { "J", "mzJ`z", desc = "Move line below onto this line" }, - { -- TODO stay here, are these already mapped? - "]d", - vim.diagnostic.goto_next, - desc = "Go to next diagnostic message", - }, - { - "[d", - vim.diagnostic.goto_prev, - desc = "Go to previous diagnostic message", - }, - { ">", "> gv", desc = "Indent selection", mode = "v" }, - { "<", "< gv", desc = "Outdent selection", mode = "v" }, - { "p", '"_dP', desc = "Paste without yanking replaced content", mode = "v" }, - -- TODO take r from http requests? - { "", '"hy:%s/h//g', desc = "Replace current selection", mode = "v" }, - { "", "", desc = "Up", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, - { "", "", desc = "Down", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, - { "", "", desc = "Left", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, - { "", "", desc = "Right", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, - { "", "", desc = "End", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, - { "", "", desc = "Home", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, + -- Editor + { "J", "mzJ`z", desc = "Move line below onto this line" }, + { -- TODO stay here, are these already mapped? + "]d", + vim.diagnostic.goto_next, + desc = "Go to next diagnostic message", + }, + { + "[d", + vim.diagnostic.goto_prev, + desc = "Go to previous diagnostic message", + }, + { ">", "> gv", desc = "Indent selection", mode = "v" }, + { "<", "< gv", desc = "Outdent selection", mode = "v" }, + { "p", '"_dP', desc = "Paste without yanking replaced content", mode = "v" }, + -- TODO take r from http requests? + { "", '"hy:%s/h//g', desc = "Replace current selection", mode = "v" }, + { "", "", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, + { "", "", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, + { "", "", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, + { "", "", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, + { "", "", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, + { "", "", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, - -- Tabs - -- TODO revisit, do I even need these tab things? - { "tn", "tabnew", desc = "Create new tab", mode = nvx }, - { "tq", "tabclose", desc = "Close current tab", mode = nvx }, - { "H", "tabprevious", desc = "Move to previous tab" }, - { "L", "tabnext", desc = "Move to next tab" }, + -- Tabs + -- TODO revisit, do I even need these tab things? + { "tn", "tabnew", desc = "Create new tab", mode = nvx }, + { "tq", "tabclose", desc = "Close current tab", mode = nvx }, + { "H", "tabprevious", desc = "Move to previous tab" }, + { "L", "tabnext", desc = "Move to next tab" }, - -- LSP/IDE/etc TODO move to lsp config file - { - "ld", - vim.diagnostic.open_float, - desc = "Show diagnostic message", - mode = nvx, - }, - { - "ll", - vim.diagnostic.setloclist, - desc = "Show diagnostics in quickfix list", - mode = nvx, - }, + -- LSP/IDE/etc TODO move to lsp config file + { + "ld", + vim.diagnostic.open_float, + desc = "Show diagnostic message", + mode = nvx, + }, + { + "ll", + vim.diagnostic.setloclist, + desc = "Show diagnostics in quickfix list", + mode = nvx, + }, }) diff --git a/lua/plugins/cmp_autocompletion.lua b/lua/plugins/cmp_autocompletion.lua index 97ea107..e9dd17c 100644 --- a/lua/plugins/cmp_autocompletion.lua +++ b/lua/plugins/cmp_autocompletion.lua @@ -70,6 +70,7 @@ return { -- completions whenever it has completion options available. [""] = cmp.mapping.complete({}), + -- TODO remove these or make them soemthing else, this collided with my normal movements in insert mode -- Think of as moving to the right of your snippet expansion. -- So if you have a snippet that's like: -- function $name($args) @@ -78,16 +79,16 @@ return { -- -- will move you to the right of each of the expansion locations. -- is similar, except moving you backwards. - [""] = cmp.mapping(function() - if luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - end - end, { "i", "s" }), - [""] = cmp.mapping(function() - if luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - end - end, { "i", "s" }), + -- [""] = cmp.mapping(function() + -- if luasnip.expand_or_locally_jumpable() then + -- luasnip.expand_or_jump() + -- end + -- end, { "i", "s" }), + -- [""] = cmp.mapping(function() + -- if luasnip.locally_jumpable(-1) then + -- luasnip.jump(-1) + -- end + -- end, { "i", "s" }), -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps diff --git a/lua/plugins/editor_noice.lua b/lua/plugins/editor_noice.lua index 9c54035..c0870d1 100644 --- a/lua/plugins/editor_noice.lua +++ b/lua/plugins/editor_noice.lua @@ -1,36 +1,37 @@ return { - "folke/noice.nvim", - dependencies = { - "MunifTanjim/nui.nvim", - "rcarriga/nvim-notify", - { "nvim-telescope/telescope.nvim", optional = true }, - }, - event = "VeryLazy", - opts = { - routes = { - -- I want telescope-ui-select to trigger here not noice - { filter = { event = "lsp", kind = "search_count" }, opts = { skip = true } }, - }, - messages = { - view = "mini", -- default view for messages - view_error = "notify", -- view for errors - view_warn = "mini", -- view for warnings - view_history = "messages", -- view for :messages - view_search = false, -- view for search count messages. Set to `false` to disable - }, - lsp = { - -- override markdown rendering so that **cmp** and other plugins use **Treesitter** - override = { - ["vim.lsp.util.convert_input_to_markdown_lines"] = true, - ["vim.lsp.util.stylize_markdown"] = true, - ["cmp.entry.get_documentation"] = true, -- requires hrsh7th/nvim-cmp - }, - }, - }, - config = function(_, opts) - require("noice").setup(opts) - U.safeRequire("telescope", function(t) - t.load_extension("noice") - end) - end, + "folke/noice.nvim", + dependencies = { + "MunifTanjim/nui.nvim", + "rcarriga/nvim-notify", + { "nvim-telescope/telescope.nvim", optional = true }, + }, + event = "VeryLazy", + opts = { + routes = { + -- I want telescope-ui-select to trigger here not noice + { filter = { event = "lsp", kind = "search_count" }, opts = { skip = true } }, + { filter = { event = "lsp" }, opts = { skip = true } }, -- TODO come back to this, im having weird issues with insert mode getting broken. + }, + messages = { + view = "mini", -- default view for messages + view_error = "notify", -- view for errors + view_warn = "mini", -- view for warnings + view_history = "messages", -- view for :messages + view_search = false, -- view for search count messages. Set to `false` to disable + }, + lsp = { + -- override markdown rendering so that **cmp** and other plugins use **Treesitter** + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + ["cmp.entry.get_documentation"] = true, -- requires hrsh7th/nvim-cmp + }, + }, + }, + config = function(_, opts) + require("noice").setup(opts) + U.safeRequire("telescope", function(t) + t.load_extension("noice") + end) + end, } diff --git a/lua/plugins/formatter.lua b/lua/plugins/formatter.lua index 3ce73e9..4384f9a 100644 --- a/lua/plugins/formatter.lua +++ b/lua/plugins/formatter.lua @@ -1,30 +1,38 @@ return { - "stevearc/conform.nvim", - opts = { - -- https://github.com/stevearc/conform.nvim?tab=readme-ov-file#setup - notify_on_error = true, - formatters_by_ft = { - lua = { "stylua" }, - typescript = { { "prettierd", "prettier" } }, - typescriptreact = { { "prettierd", "prettier" } }, - javascript = { { "prettierd", "prettier" } }, - javascriptreact = { { "prettierd", "prettier" } }, - }, - }, - keys = { - { - "l", - function() - require("conform").format({ async = true, lsp_fallback = true }, function(err, edited) - if edited then - print("Formatted!") - else - print("Nothing to format!") - end - end) - end, - mode = { "n", "v", "x" }, - desc = "Format buffer", - }, - }, + "stevearc/conform.nvim", + opts = { + -- https://github.com/stevearc/conform.nvim?tab=readme-ov-file#setup + notify_on_error = true, + -- Note that all these need to be available at runtime, add them to flake.nix#runtimeDependencies + formatters_by_ft = { + lua = { "stylua" }, + nix = { "nixfmt" }, + typescript = { { "prettierd", "prettier" } }, + typescriptreact = { { "prettierd", "prettier" } }, + javascript = { { "prettierd", "prettier" } }, + javascriptreact = { { "prettierd", "prettier" } }, + -- TODO revisit these I'd like to use them but they are not in nixpkgs yet + -- https://nixos.org/guides/nix-pills/ + -- markdown = { "mdslw", "mdsf"}, + markdown = { "markdownlint-cli2" }, + }, + }, + keys = { + { + "l", + function() + require("conform").format({ async = true, lsp_fallback = true }, function(err, edited) + if edited then + print("Formatted!") + elseif err then + print(err) + else + print("Nothing to format!") + end + end) + end, + mode = { "n", "v", "x" }, + desc = "Format buffer", + }, + }, } diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 7311fdf..f353eb7 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -1,163 +1,169 @@ return { - "nvim-telescope/telescope.nvim", - dependencies = { - { "nvim-lua/plenary.nvim" }, - { "nvim-telescope/telescope-fzf-native.nvim" }, - { "nvim-telescope/telescope-ui-select.nvim" }, - }, - init = function() - U.cmd_executable("rg", { - [false] = function() - vim.notify("rg not installed, live grep will not function.", 2) - end, - }) - end, - cmd = "Telescope", - opts = function() - return { - pickers = { - buffers = { - sort_lastused = true, - }, - find_files = { - hidden = true, - sort_lastused = true, - }, - live_grep = { - hidden = true, - }, - }, - defaults = { - file_ignore_patterns = { "node_modules", "package-lock.json", "target", ".git" }, - mappings = { - i = { - [""] = "move_selection_next", - [""] = "move_selection_previous", - }, - }, - vimgrep_arguments = { - "rg", - "--hidden", - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--smart-case", - }, - }, - extensions = { - ["ui-select"] = { - require("telescope.themes").get_cursor(), - }, - ["notify"] = {}, - }, - } - end, - config = function(_, opts) - local ts = require("telescope") - ts.setup(opts) - ts.load_extension("ui-select") + "nvim-telescope/telescope.nvim", + dependencies = { + { "nvim-lua/plenary.nvim" }, + { "nvim-telescope/telescope-fzf-native.nvim" }, + { "nvim-telescope/telescope-ui-select.nvim" }, + }, + init = function() + U.cmd_executable("rg", { + [false] = function() + vim.notify("rg not installed, live grep will not function.", 2) + end, + }) + end, + cmd = "Telescope", + opts = function() + return { + pickers = { + buffers = { + sort_lastused = true, + }, + find_files = { + hidden = true, + sort_lastused = true, + }, + live_grep = { + hidden = true, + }, + }, + defaults = { + file_ignore_patterns = { "node_modules", "package-lock.json", "target", ".git" }, + mappings = { + i = { + [""] = "move_selection_next", + [""] = "move_selection_previous", + [""] = false, + [""] = false, + [""] = false, + [""] = false, + [""] = false, + [""] = false, + }, + }, + vimgrep_arguments = { + "rg", + "--hidden", + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--smart-case", + }, + }, + extensions = { + ["ui-select"] = { + require("telescope.themes").get_cursor(), + }, + ["notify"] = {}, + }, + } + end, + config = function(_, opts) + local ts = require("telescope") + ts.setup(opts) + ts.load_extension("ui-select") - if package.loaded["notify"] then - ts.load_extension("notify") - U.keymaps({ - { - "fn", - "Telescope notify", - desc = "Telescope search notifications", - mode = { "n", "v", "x" }, - }, - }) - end - end, - -- https://github.com/nvim-telescope/telescope.nvim?tab=readme-ov-file#pickers - keys = { - { - "fr", - function() - require("telescope.builtin").resume() - end, - desc = "Resume last telescope", - }, - { - "f/", - function() - require("telescope.builtin").current_buffer_fuzzy_find( - require("telescope.themes").get_dropdown({ winblend = 10, previewer = false }) - ) - end, - desc = "Fuzzy find/search in current buffer fuzzy.", - }, - { - "fh", - function() - require("telescope.builtin").help_tags() - end, - desc = "Find help", - }, - { - "ff", - function() - require("telescope.builtin").find_files({ - hidden = true, - }) - end, - desc = "Find Files", - }, - { - "fg", - function() - require("telescope.builtin").git_files({ - hidden = true, - }) - end, - desc = "Find Git only Files", - }, - { - "fw", - function() - U.cmd_executable("rg", { - function() - require("telescope.builtin").live_grep({ - hidden = true, - }) - end, - function() - vim.notify("rg not installed, find words will not function.", 3) - end, - }) - end, - desc = "Find Words", - }, - { - "fc", - function() - require("telescope.builtin").commands() - end, - desc = "Find Commands", - }, - { - "fk", - function() - require("telescope.builtin").keymaps() - end, - desc = "Find Keymap", - }, - { - "fb", - function() - require("telescope.builtin").buffers() - end, - desc = "Find Buffer", - }, - { - "lfr", - function() - require("telescope.builtin").lsp_references() - end, - desc = "Find LSP References", - mode = { "n", "v", "x" }, - }, - }, + if package.loaded["notify"] then + ts.load_extension("notify") + U.keymaps({ + { + "fn", + "Telescope notify", + desc = "Telescope search notifications", + mode = { "n", "v", "x" }, + }, + }) + end + end, + -- https://github.com/nvim-telescope/telescope.nvim?tab=readme-ov-file#pickers + keys = { + { + "fr", + function() + require("telescope.builtin").resume() + end, + desc = "Resume last telescope", + }, + { + "f/", + function() + require("telescope.builtin").current_buffer_fuzzy_find( + require("telescope.themes").get_dropdown({ winblend = 10, previewer = false }) + ) + end, + desc = "Fuzzy find/search in current buffer fuzzy.", + }, + { + "fh", + function() + require("telescope.builtin").help_tags() + end, + desc = "Find help", + }, + { + "ff", + function() + require("telescope.builtin").find_files({ + hidden = true, + }) + end, + desc = "Find Files", + }, + { + "fg", + function() + require("telescope.builtin").git_files({ + hidden = true, + }) + end, + desc = "Find Git only Files", + }, + { + "fw", + function() + U.cmd_executable("rg", { + function() + require("telescope.builtin").live_grep({ + hidden = true, + }) + end, + function() + vim.notify("rg not installed, find words will not function.", 3) + end, + }) + end, + desc = "Find Words", + }, + { + "fc", + function() + require("telescope.builtin").commands() + end, + desc = "Find Commands", + }, + { + "fk", + function() + require("telescope.builtin").keymaps() + end, + desc = "Find Keymap", + }, + { + "fb", + function() + require("telescope.builtin").buffers() + end, + desc = "Find Buffer", + }, + { + "lfr", + function() + require("telescope.builtin").lsp_references() + end, + desc = "Find LSP References", + mode = { "n", "v", "x" }, + }, + }, } diff --git a/lua/plugins/text_case.lua b/lua/plugins/text_case.lua index 4b35e81..1d580c8 100644 --- a/lua/plugins/text_case.lua +++ b/lua/plugins/text_case.lua @@ -10,7 +10,7 @@ return { { ",c", function() - if next(vim.lsp.buf_get_clients()) ~= nil then + if next(vim.lsp.get_active_clients()) ~= nil then -- TODO test that this works vim.cmd("TextCaseOpenTelescopeLSPChange") else @@ -19,7 +19,6 @@ return { end, desc = "Change case of selection", mode = { "n", "v", "x" }, - silent = true, -- TODO add this to most things.... }, }, }