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
```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? <leader>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
- <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 <https://github.com/tpope/vim-surround/tree/master>
- 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 <https://github.com/gennaro-tedesco/nvim-possession/tree/main> 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
- <https://github.com/onsails/lspkind.nvim>
- <https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-align.md>
- <https://github.com/tpope/vim-abolish>

34
flake.lock generated
View file

@ -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",

View file

@ -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:
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.
version = "hydrogen";
pkgs = nixpkgs.legacyPackages.${system};
lib = nixpkgs.lib;
# 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,18 +90,20 @@
"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; } ({
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:
{
"${name}" = inputs.${name}.outPath;
} // dirs)
nixPkgsPlugins
(builtins.filter
(n: builtins.substring 0 12 n == "nvim_plugin-")
(builtins.attrNames inputs));
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; [
@ -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"''
];
});
};
});
}
);
}

View file

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

View file

@ -70,6 +70,7 @@ return {
-- completions whenever it has completion options available.
["<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.
-- So if you have a snippet that's like:
-- function $name($args)
@ -78,16 +79,16 @@ return {
--
-- <c-l> will move you to the right of each of the expansion locations.
-- <c-h> is similar, except moving you backwards.
["<C-l>"] = cmp.mapping(function()
if luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
end
end, { "i", "s" }),
["<C-h>"] = cmp.mapping(function()
if luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
end
end, { "i", "s" }),
-- ["<C-l>"] = cmp.mapping(function()
-- if luasnip.expand_or_locally_jumpable() then
-- luasnip.expand_or_jump()
-- end
-- end, { "i", "s" }),
-- ["<C-h>"] = 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

View file

@ -10,6 +10,7 @@ return {
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 file

@ -3,12 +3,18 @@ return {
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 = {
@ -18,6 +24,8 @@ return {
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

View file

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

View file

@ -10,7 +10,7 @@ return {
{
"<leader>,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....
},
},
}