several small updates

This commit is contained in:
RingOfStorms (Joshua Bell) 2024-05-02 23:51:15 -05:00
parent 545b3d492f
commit b0c61768db
9 changed files with 432 additions and 415 deletions

View file

@ -14,6 +14,7 @@ nix run 'github:ringofstorms/nvim/nix-flake'
``` ```
in NixOS in NixOS
```nix ```nix
-- in flake.nix#inputs -- in flake.nix#inputs
ringofstorms-nvim = { ringofstorms-nvim = {
@ -26,8 +27,8 @@ environment.systemPackages = with pkgs; [
]; ];
``` ```
### Without Nix ### Without Nix
TODO update this section TODO update this section
- Must have all required programs installed and available on path - 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 - Evertying listed in flake.nix `runtime dependencies` variable near the top of the file
- These must be available on the path - These must be available on the path
- Treesitter/Lazy/Mason will install all other requirements needed on other systems - Treesitter/Lazy/Mason will install all other requirements needed on other systems
```sh ```sh
git clone https://github.com/RingOfStorms/nvim ~/.config/nvim git clone https://github.com/RingOfStorms/nvim ~/.config/nvim
nvim --headless "+Lazy! sync" +qa nvim --headless "+Lazy! sync" +qa
``` ```
Backup existing config: Backup existing config:
```sh ```sh
DATE=$(date +"%Y%m%d") DATE=$(date +"%Y%m%d")
mv ~/.config/nvim ~/.config/nvim_$DATE.bak mv ~/.config/nvim ~/.config/nvim_$DATE.bak
mv ~/.local/share/nvim ~/.local/share/nvim_$DATE.bak mv ~/.local/share/nvim ~/.local/share/nvim_$DATE.bak
mv ~/.local/state/nvim ~/.local/state/nvim_$DATE.bak mv ~/.local/state/nvim ~/.local/state/nvim_$DATE.bak
``` ```
or remove existing config: or remove existing config:
```sh ```sh
rm -rf ~/.config/nvim rm -rf ~/.config/nvim
rm -rf ~/.local/share/nvim rm -rf ~/.local/share/nvim
@ -55,21 +61,26 @@ rm -rf ~/.local/state/nvim
## NOTES/TODOS ## 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 FUTURE
- Make a new HTTP plugin for running curl commands from .http files - 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 - 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? <leader>cx - Execute selected command and open output into a buffer/popup window? <leader>cx
- generate command, like scratch open a popup of things that can be generated. UUID/other stuff? - 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 - <https://github.com/mawkler/nvim/blob/06cde9dbaedab2bb36c06025c07589c93d2c6d6b/lua/configs/luasnip.lua#L37-L50>
- Checkout cargo-bloat, cargo-cache, cargo-outdated - memcache sccache - Checkout cargo-bloat, cargo-cache, cargo-outdated - memcache sccache
- For scratches, just make an input box for custom extension rather than predefined list - 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 <https://github.com/tpope/vim-surround/tree/master>
- make my own session saving impl - make my own session saving impl
- Only save visible buffers/tabs/splits - Only save visible buffers/tabs/splits
- per branch per directory - per branch per directory
- something like https://github.com/gennaro-tedesco/nvim-possession/tree/main but fully managed - something like <https://github.com/gennaro-tedesco/nvim-possession/tree/main> but fully managed
- copilot? local llm? - copilot? local llm?
- check out - check out
- https://github.com/onsails/lspkind.nvim - <https://github.com/onsails/lspkind.nvim>
- https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-align.md - <https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-align.md>
- https://github.com/tpope/vim-abolish - <https://github.com/tpope/vim-abolish>

34
flake.lock generated
View file

@ -1,23 +1,5 @@
{ {
"nodes": { "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": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1714635257, "lastModified": 1714635257,
@ -68,26 +50,10 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nvim_plugin-chrisgrieser/nvim-early-retirement": "nvim_plugin-chrisgrieser/nvim-early-retirement", "nvim_plugin-chrisgrieser/nvim-early-retirement": "nvim_plugin-chrisgrieser/nvim-early-retirement",
"nvim_plugin-declancm/cinnamon.nvim": "nvim_plugin-declancm/cinnamon.nvim" "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", "root": "root",

View file

@ -3,7 +3,6 @@
# Nixpkgs / NixOS version to use. # Nixpkgs / NixOS version to use.
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
# Names should always be `nvim_plugin-[lazy plugin name]` # Names should always be `nvim_plugin-[lazy plugin name]`
# Only need to add plugins as flake inputs if they are: # Only need to add plugins as flake inputs if they are:
@ -18,18 +17,36 @@
flake = false; flake = false;
}; };
}; };
outputs = { self, nixpkgs, flake-utils, ... } @ inputs: outputs =
# Takes all top level attributes and changes them to `attribute.${system} = old value` { self, nixpkgs, ... }@inputs:
flake-utils.lib.eachDefaultSystem (system:
let let
# Anytime there is a huge breaking change that old state files wont # Anytime there is a huge breaking change that old state files wont
# work then we make a new version name. Helps separate any files. # work then we make a new version name. Helps separate any files and
version = "hydrogen"; # "version" my neovim flake
pkgs = nixpkgs.legacyPackages.${system}; # ==================
lib = nixpkgs.lib; 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 # Plugins provided in nixpkgs, match the naming scheme above for keys
lazyPath = pkgs.vimPlugins.lazy-nvim;
nixPkgsPlugins = with pkgs.vimPlugins; { nixPkgsPlugins = with pkgs.vimPlugins; {
"nvim_plugin-folke/lazy.nvim" = lazyPath; "nvim_plugin-folke/lazy.nvim" = lazyPath;
"nvim_plugin-nvim-treesitter/nvim-treesitter" = nvim-treesitter.withAllGrammars; "nvim_plugin-nvim-treesitter/nvim-treesitter" = nvim-treesitter.withAllGrammars;
@ -73,18 +90,20 @@
"nvim_plugin-folke/neodev.nvim" = neodev-nvim; "nvim_plugin-folke/neodev.nvim" = neodev-nvim;
}; };
# This will be how we put any nix related stuff into our lua config # This will be how we put any nix related stuff into our lua config
luaNixGlobal = "NIX=" + lib.generators.toLua { multiline = false; indent = false; } ({ luaNixGlobal =
"NIX="
+
lib.generators.toLua
{
multiline = false;
indent = false;
}
({
storePath = "${./.}"; storePath = "${./.}";
# This will look at all inputs and grab any prefixed with `nvim_plugin-` # This will look at all inputs and grab any prefixed with `nvim_plugin-`
pluginPaths = builtins.foldl' pluginPaths =
(dirs: name: builtins.foldl' (dirs: name: { "${name}" = inputs.${name}.outPath; } // dirs) nixPkgsPlugins
{ (builtins.filter (n: builtins.substring 0 12 n == "nvim_plugin-") (builtins.attrNames inputs));
"${name}" = inputs.${name}.outPath;
} // dirs)
nixPkgsPlugins
(builtins.filter
(n: builtins.substring 0 12 n == "nvim_plugin-")
(builtins.attrNames inputs));
}); });
runtimeDependencies = with pkgs; [ runtimeDependencies = with pkgs; [
@ -100,7 +119,9 @@
biome # (t|s)j[x] biome # (t|s)j[x]
# formatters # formatters
stylua stylua
nixfmt-rfc-style
nodePackages.prettier nodePackages.prettier
markdownlint-cli2
# LSPs # LSPs
lua-language-server lua-language-server
nodePackages.typescript-language-server nodePackages.typescript-language-server
@ -111,20 +132,19 @@
]; ];
in in
{ {
packages = { packages.${system} = {
default = self.packages.${system}.neovim; default = self.packages.${system}.neovim;
neovim = neovim =
(pkgs.wrapNeovimUnstable (pkgs.wrapNeovimUnstable pkgs.neovim-unwrapped (
pkgs.neovim-unwrapped pkgs.neovimUtils.makeNeovimConfig {
(pkgs.neovimUtils.makeNeovimConfig {
withPython3 = false; withPython3 = false;
customRC = '' customRC = ''
lua ${luaNixGlobal} lua ${luaNixGlobal}
luafile ${./.}/init.lua luafile ${./.}/init.lua
set runtimepath^=${builtins.concatStringsSep "," (builtins.attrValues pkgs.vimPlugins.nvim-treesitter.grammarPlugins)} set runtimepath^=${builtins.concatStringsSep "," (builtins.attrValues pkgs.vimPlugins.nvim-treesitter.grammarPlugins)}
''; '';
}) }
).overrideAttrs )).overrideAttrs
(old: { (old: {
generatedWrapperArgs = old.generatedWrapperArgs or [ ] ++ [ generatedWrapperArgs = old.generatedWrapperArgs or [ ] ++ [
# Add runtime dependencies to neovim path # 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 # 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. # so I've chosen to put everything into the local state directory.
"--run" "--run"
"export NVIM_FLAKE_BASE_DIR=\"\${XDG_STATE_HOME:-\$HOME/.local/state}\"" ''export NVIM_FLAKE_BASE_DIR="''${XDG_STATE_HOME:-$HOME/.local/state}"''
"--run" "--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" "--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" "--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" "--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" "--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"''
]; ];
}); });
}; };
});
} }
);
}

View file

@ -13,12 +13,17 @@ vim.g.maplocalleader = " "
local nvx = { "n", "v", "x" } local nvx = { "n", "v", "x" }
-- TODO remove this notify and replace with a <nop> 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({ U.keymaps({
-- Basic -- Basic
{ "<left>", '<cmd>echo "use h/j/k/l to move!"<cr>', mode = nvx }, { "<left>", hjklNotification, mode = { "n", "v", "x", "i" } },
{ "<right>", '<cmd>echo "use h/j/k/l to move!"<cr>', mode = nvx }, { "<right>", hjklNotification, mode = { "n", "v", "x", "i" } },
{ "<up>", '<cmd>echo "use h/j/k/l to move!"<cr>', mode = nvx }, { "<up>", hjklNotification, mode = { "n", "v", "x", "i" } },
{ "<down>", '<cmd>echo "use h/j/k/l to move!"<cr>', mode = nvx }, { "<down>", hjklNotification, mode = { "n", "v", "x", "i" } },
{ ";", ":", desc = "No shift to enter command mode with semicolon. Alias ; to :", mode = nvx }, { ";", ":", desc = "No shift to enter command mode with semicolon. Alias ; to :", mode = nvx },
{ "<leader>Q", "<nop>", mode = nvx }, -- don't do normal Q quit { "<leader>Q", "<nop>", mode = nvx }, -- don't do normal Q quit
{ "<leader>a", "<esc>ggVG", desc = "Select all", mode = nvx }, { "<leader>a", "<esc>ggVG", desc = "Select all", mode = nvx },
@ -94,12 +99,12 @@ U.keymaps({
{ "p", '"_dP', desc = "Paste without yanking replaced content", mode = "v" }, { "p", '"_dP', desc = "Paste without yanking replaced content", mode = "v" },
-- TODO take <leader>r from http requests? -- TODO take <leader>r from http requests?
{ "<C-r>", '"hy:%s/<C-r>h//g<left><left>', desc = "Replace current selection", mode = "v" }, { "<C-r>", '"hy:%s/<C-r>h//g<left><left>', desc = "Replace current selection", mode = "v" },
{ "<C-k>", "<Up>", desc = "Up", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, { "<C-k>", "<Up>", mode = { "i", "c" }, desc = "Movements in insert/command mode" },
{ "<C-j>", "<Down>", desc = "Down", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, { "<C-j>", "<Down>", mode = { "i", "c" }, desc = "Movements in insert/command mode" },
{ "<C-h>", "<Left>", desc = "Left", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, { "<C-h>", "<Left>", mode = { "i", "c" }, desc = "Movements in insert/command mode" },
{ "<C-l>", "<Right>", desc = "Right", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, { "<C-l>", "<Right>", mode = { "i", "c" }, desc = "Movements in insert/command mode" },
{ "<C-4>", "<End>", desc = "End", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, { "<C-4>", "<End>", mode = { "i", "c" }, desc = "Movements in insert/command mode" },
{ "<C-6>", "<Home>", desc = "Home", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, { "<C-6>", "<Home>", mode = { "i", "c" }, desc = "Movements in insert/command mode" },
-- Tabs -- Tabs
-- TODO revisit, do I even need these tab things? -- TODO revisit, do I even need these tab things?

View file

@ -70,6 +70,7 @@ return {
-- completions whenever it has completion options available. -- completions whenever it has completion options available.
["<C-c>"] = cmp.mapping.complete({}), ["<C-c>"] = cmp.mapping.complete({}),
-- TODO remove these or make them soemthing else, this collided with my normal movements in insert mode
-- Think of <c-l> as moving to the right of your snippet expansion. -- Think of <c-l> as moving to the right of your snippet expansion.
-- So if you have a snippet that's like: -- So if you have a snippet that's like:
-- function $name($args) -- function $name($args)
@ -78,16 +79,16 @@ return {
-- --
-- <c-l> will move you to the right of each of the expansion locations. -- <c-l> will move you to the right of each of the expansion locations.
-- <c-h> is similar, except moving you backwards. -- <c-h> is similar, except moving you backwards.
["<C-l>"] = cmp.mapping(function() -- ["<C-l>"] = cmp.mapping(function()
if luasnip.expand_or_locally_jumpable() then -- if luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump() -- luasnip.expand_or_jump()
end -- end
end, { "i", "s" }), -- end, { "i", "s" }),
["<C-h>"] = cmp.mapping(function() -- ["<C-h>"] = cmp.mapping(function()
if luasnip.locally_jumpable(-1) then -- if luasnip.locally_jumpable(-1) then
luasnip.jump(-1) -- luasnip.jump(-1)
end -- end
end, { "i", "s" }), -- end, { "i", "s" }),
-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps

View file

@ -10,6 +10,7 @@ return {
routes = { routes = {
-- I want telescope-ui-select to trigger here not noice -- I want telescope-ui-select to trigger here not noice
{ filter = { event = "lsp", kind = "search_count" }, opts = { skip = true } }, { 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 = { messages = {
view = "mini", -- default view for messages view = "mini", -- default view for messages

View file

@ -3,12 +3,18 @@ return {
opts = { opts = {
-- https://github.com/stevearc/conform.nvim?tab=readme-ov-file#setup -- https://github.com/stevearc/conform.nvim?tab=readme-ov-file#setup
notify_on_error = true, notify_on_error = true,
-- Note that all these need to be available at runtime, add them to flake.nix#runtimeDependencies
formatters_by_ft = { formatters_by_ft = {
lua = { "stylua" }, lua = { "stylua" },
nix = { "nixfmt" },
typescript = { { "prettierd", "prettier" } }, typescript = { { "prettierd", "prettier" } },
typescriptreact = { { "prettierd", "prettier" } }, typescriptreact = { { "prettierd", "prettier" } },
javascript = { { "prettierd", "prettier" } }, javascript = { { "prettierd", "prettier" } },
javascriptreact = { { "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 = { keys = {
@ -18,6 +24,8 @@ return {
require("conform").format({ async = true, lsp_fallback = true }, function(err, edited) require("conform").format({ async = true, lsp_fallback = true }, function(err, edited)
if edited then if edited then
print("Formatted!") print("Formatted!")
elseif err then
print(err)
else else
print("Nothing to format!") print("Nothing to format!")
end end

View file

@ -33,6 +33,12 @@ return {
i = { i = {
["<C-j>"] = "move_selection_next", ["<C-j>"] = "move_selection_next",
["<C-k>"] = "move_selection_previous", ["<C-k>"] = "move_selection_previous",
["<C-h>"] = false,
["<C-l>"] = false,
["<up>"] = false,
["<down>"] = false,
["<left>"] = false,
["<right>"] = false,
}, },
}, },
vimgrep_arguments = { vimgrep_arguments = {

View file

@ -10,7 +10,7 @@ return {
{ {
"<leader>,c", "<leader>,c",
function() function()
if next(vim.lsp.buf_get_clients()) ~= nil then if next(vim.lsp.get_active_clients()) ~= nil then
-- TODO test that this works -- TODO test that this works
vim.cmd("TextCaseOpenTelescopeLSPChange") vim.cmd("TextCaseOpenTelescopeLSPChange")
else else
@ -19,7 +19,6 @@ return {
end, end,
desc = "Change case of selection", desc = "Change case of selection",
mode = { "n", "v", "x" }, mode = { "n", "v", "x" },
silent = true, -- TODO add this to most things....
}, },
}, },
} }