From c86f67f0f7599a665b7a9e735fadce7a0c1cf2f4 Mon Sep 17 00:00:00 2001 From: "RingOfStorms (Joshua Bell)" Date: Tue, 30 Apr 2024 17:51:26 -0500 Subject: [PATCH] preparring plugin lists --- README.md | 97 ++++++++++++++++++++++++++++++++------ flake.nix | 72 ++++++++++------------------ init.lua | 41 ++++++++++++---- lua/plugins/catppuccin.lua | 1 - 4 files changed, 138 insertions(+), 73 deletions(-) diff --git a/README.md b/README.md index 557858f..44a8e6e 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,38 @@ # NVIM config +Goals: +- Works with or without nix + ## Running -### With Nix (Recommended) +### With Nix +```sh nix run "." +``` -### On any system - -Enture all prequisites are installed: -- neovim -- Evertying listed in flake.nix `runtime dependencies` variable near the top of the file +### Without Nix +- Must have all required programs installed and available on path + - neovim >= 0.5 + - 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 - -Install neovim config (backup old version first if present): -``` +```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 +rm -rf ~/.local/state/nvim +``` ## NOTES/TODOS @@ -27,7 +40,63 @@ nvim --headless "+Lazy! sync" +qa - Checkout cargo-bloat, cargo-cache, cargo-outdated - memcache sccache - For scratches, just make an input box for custom extension rather than predefined list - for find files, ignore git, capital F for find all +- better copilot alternatives? Local LLM usage only? etc? -- plugins to check out: - - https://github.com/declancm/cinnamon.nvim - - https://github.com/folke/noice.nvim +- plugins to install: + - pocco81/auto-save.nvim + - folke/noice.nvim - messages/cmdline/popupmenu updates + - rmagatti/auto-session - session management + - TODO look for alternatives? I am not a huge fan of this as it causes some issues on startup sometimes. I really only care about window placements and I want the rest to load naturally + - preservim/nerdcommenter - [un]comment support + - uga-rosa/ccc.nvim - color picker for hex codes etc + - zbirenbaum/copilot.lua + - Does github's work for me now? github/copilot.vim + - zbirenbaum/copilot-cmp + - chrisgrieser/nvim-early-retirement - auto close buffers + - voldikss/vim-floaterm + - GIT + - lewis6991/gitsigns.nvim + - Neogitorg/neogit ??? remove? I dont use this much... + - kdheepak/lazygit.nvim ?? remove? + - sindrets/diffview.nvim ? as long as this works without the above. + - rest-nvim/rest.nvim - http curl commands + - TODO I want a better alternative to this. One that shows streaming responses/curl as is. Can I just run curl myself easily? + - RRethy/vim-illuminate - show token under cursor throughout file + - lukas-reineke/indent-blankline.nvim - indent lines + - TODO figure out tabs vs spaces thing with arrows vs bars. + - nvim-lualine/lualine.nvim + - TODO look at other buffer lines, is this still the best? What do others use? + - LSP stuff... figure out from scratch using kickstart/lazynvim as an example + - rust, ts, js, nix, lua, + - lvimuser/lsp-inlayhints.nvim L3MON4D3/LuaSnip hrsh7th/nvim-cmp williamboman/mason.nvim folke/neodev.nvim williamboman/mason-lspconfig.nvim neovim/nvim-lspconfig simrat39/rust-tools.nvim Saecki/crates.nvim + - how cna we do language specific tooling per project integrated with neovim here? Like different rust versions in current shell etc? + - MASON when not nix, otherwise yes + - lnc3l0t/glow.nvim - markdown preview + - null_ls replacement?? need a formater replacement, diff between lsp reformat? + - cspell? vs built in spell check? + - Almo7aya/openingh.nvim + - tpope/vim-surround + - nvim-telescope/telescope-file-browser.nvim ?? do I want to keep this? + - nvim-telescope/telescope.nvim + - nvim-telescope/telescope-fzf-native.nvim + - nvim-telescope/telescope-ui-select.nvim (use this with scratch files?) + - johmsalas/text-case.nvim + - nvim-treesitter/nvim-treesitter + - mbbill/undotree + - nvim-lua/plenary.nvim + - rcarriga/nvim-notify ??? is this replaced by noice?? + - folke/which-key.nvim + +- check out + - https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-bufremove.md + - OR https://github.com/famiu/bufdelete.nvim + - https://github.com/onsails/lspkind.nvim + - declancm/cinnamon.nvim - smooth scroll effect + - https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-align.md + +- plugins I decided to remove from my old config + - jinh0/eyeliner.nvim + - David-Kunz/gen.nvim - ollama integration + - Neogitorg/neogit ?? + - kdheepak/lazygit.nvim ?? + - null_ls diff --git a/flake.nix b/flake.nix index 44fcc53..93dd092 100644 --- a/flake.nix +++ b/flake.nix @@ -6,6 +6,7 @@ flake-utils.url = "github:numtide/flake-utils"; + # Names should always be `nvim_plugin-[lazy plugin name]` "nvim_plugin-folke/lazy.nvim" = { url = "github:folke/lazy.nvim"; flake = false; @@ -23,54 +24,31 @@ pkgs = nixpkgs.legacyPackages.${system}; lib = nixpkgs.lib; - # This will look at all inputs and grab any prefixed with `nvim_plugin-` - nvimPluginPaths = "NVIM_PLUGIN_PATHS=" + lib.generators.toLua - { - multiline = false; - indent = false; - } - ( - builtins.foldl' - (dirs: name: - { - "${name}" = inputs.${name}.outPath; - } // dirs) - { } - (builtins.filter - (n: builtins.substring 0 12 n == "nvim_plugin-") - (builtins.attrNames inputs)) - ) - ; - nvimConfigStorePath = ''NVIM_CONFIG_STORE_PATH="${./.}"''; + # 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: + { + "${name}" = inputs.${name}.outPath; + } // dirs) + { } + (builtins.filter + (n: builtins.substring 0 12 n == "nvim_plugin-") + (builtins.attrNames inputs)); + }); runtimeDependencies = with pkgs; [ - ripgrep - curl - cowsay + ripgrep # search + fd # search + fzf # search fuzzy + curl # http requests + glow # markdown renderer nodePackages.cspell - ]; + ] ++ builtins.attrValues pkgs.vimPlugins.nvim-treesitter.grammarPlugins; - treesitterParsers = builtins.attrValues pkgs.vimPlugins.nvim-treesitter.grammarPlugins; - - # https://zimbatm.com/notes/1000-instances-of-nixpkgs - # Read article for why we don't do the below version - # pkgs = import nixpkgs { - # inherit system; - # }; - - # TODO - # cpsell = pkgs.nodePackages.cpsell; - - # source = nixpkgs.lib.cleanSourceWith { - # src = self; - # filter = name: type: - # let - # base = baseNameOf name; - # in - # nixpkgs.lib.cleanSourceFilter - # name - # type && (base != ".git") && (base != "flake.nix") && (base != "flake.lock"); - # }; + # treesitterParsers = builtins.attrValues pkgs.vimPlugins.nvim-treesitter.grammarPlugins; in { packages = { @@ -81,12 +59,10 @@ (pkgs.neovimUtils.makeNeovimConfig { withPython3 = false; customRC = '' - lua IS_NIX=true - lua ${nvimPluginPaths} - lua ${nvimConfigStorePath} + lua ${luaNixGlobal} luafile ${./.}/init.lua - set runtimepath^=${builtins.concatStringsSep "," treesitterParsers} ''; + # set runtimepath^=${builtins.concatStringsSep "," treesitterParsers} }) ).overrideAttrs (old: { diff --git a/init.lua b/init.lua index e8e1535..0f1801d 100644 --- a/init.lua +++ b/init.lua @@ -1,11 +1,9 @@ -print("LOADING... is nix: " .. vim.inspect(IS_NIX)) - -if IS_NIX then +if NIX then -- Add my lua dir to the path. THIS IS NOT RECURSIVE! -- For recursive we can do something like this: https://github.com/RingOfStorms/nvim/blob/0b833d555c69e88b450a10eec4e39a782bad1037/init.lua#L1-L17 - -- However this pollutes the path, it oculd be limited to just init files but this approach here one level deep is adequate for my own needs - package.path = package.path .. ";" .. NVIM_CONFIG_STORE_PATH .. "/lua/?.lua" - package.path = package.path .. ";" .. NVIM_CONFIG_STORE_PATH .. "/lua/?/init.lua" + -- However this pollutes the path, it could be limited to just init files but this approach here one level deep is adequate for my own needs + package.path = package.path .. ";" .. NIX.storePath .. "/lua/?.lua" + package.path = package.path .. ";" .. NIX.storePath .. "/lua/?/init.lua" end require("options") @@ -14,7 +12,7 @@ require("keymaps") -- When using nix, it will set lazy via LAZY env variable. local lazypath = vim.env.LAZY or (vim.fn.stdpath("data") .. "/lazy/lazy.nvim") if not vim.loop.fs_stat(lazypath) then - if IS_NIX then + if NIX then error("LAZY environment variable to nix store was not found: " .. vim.env.LAZY) return end @@ -34,17 +32,40 @@ end vim.opt.rtp:prepend(lazypath) -- Setup lazy +local function ensure_table(object) + return type(object) == "table" and object or { object } +end function getSpec() - if IS_NIX then + if NIX then + -- Convert plugins to use nix store, this auto sets the `dir` property for us on all plugins. + function convertPluginToNixStore(plugin) + local p = ensure_table(plugin) + local nixName = "nvim_plugin-" .. p[1] + if not NIX.pluginPaths[nixName] then + error("Plugin is missing in the nix store, ensure it is in the nix flake inputs: " .. p[1]) + end + p.dir = NIX.pluginPaths[nixName] + p.name = p.name or p[1] + p.url = "not_used_in_nix" + if p.dependencies then + p.dependencies = ensure_table(p.dependencies) + for i, dep in ipairs(p.dependencies) do + p.dependencies[i] = convertPluginToNixStore(dep) + end + end + return p + end + local plugins = {} local plugins_path = debug.getinfo(2, "S").source:sub(2):match("(.*/)") .. "lua/plugins" for _, file in ipairs(vim.fn.readdir(plugins_path, [[v:val =~ '\.lua$']])) do local plugin = string.sub(file, 0, -5) - table.insert(plugins, require("plugins." .. plugin)) + table.insert(plugins, convertPluginToNixStore(require("plugins." .. plugin))) end + print("PLUGINS" .. vim.inspect(plugins)) return plugins else - -- TODO I want this to work in the nixos version + -- TODO I want this to work in the nixos versionhttps://github.com/RingOfStorms/nvim/blob/nix-flake/init.lua#L39-L55 -- but it is not resolving properly to the nix store. -- Will revisit at some point, instead we manually pull them -- in above with a directory scan. diff --git a/lua/plugins/catppuccin.lua b/lua/plugins/catppuccin.lua index 708b14f..8568992 100644 --- a/lua/plugins/catppuccin.lua +++ b/lua/plugins/catppuccin.lua @@ -1,6 +1,5 @@ return { "catppuccin/nvim", - dir = IS_NIX and NVIM_PLUGIN_PATHS["nvim_plugin-catppuccin/nvim"] or nil, opts = { flavour = "mocha", -- latte, frappe, macchiato, mocha (default) color_overrides = {