diff options
| author | brustybee <bee@4d2.org> | 2026-03-09 17:02:03 +0530 |
|---|---|---|
| committer | brustybee <bee@4d2.org> | 2026-03-09 17:02:03 +0530 |
| commit | 972e5f9c68cc433c5fc26adf92cd25b293a3776a (patch) | |
| tree | c5930854787316181d07854048d9627538017ceb | |
One shot upload
| -rw-r--r-- | cats.nix | 190 | ||||
| -rw-r--r-- | flake.lock | 468 | ||||
| -rw-r--r-- | flake.nix | 111 | ||||
| -rw-r--r-- | ftplugin/java.lua | 5 | ||||
| -rw-r--r-- | init.lua | 6 | ||||
| -rw-r--r-- | lua/colorscheme_persistence.lua | 50 | ||||
| -rw-r--r-- | lua/config/colorschemes.lua | 82 | ||||
| -rw-r--r-- | lua/config/init.lua | 4 | ||||
| -rw-r--r-- | lua/config/keys.lua | 35 | ||||
| -rw-r--r-- | lua/config/lsp.lua | 91 | ||||
| -rw-r--r-- | lua/config/options.lua | 51 | ||||
| -rw-r--r-- | lua/nixCatsUtils/lzUtils.lua | 36 | ||||
| -rw-r--r-- | lua/plugins/ai.lua | 29 | ||||
| -rw-r--r-- | lua/plugins/completion.lua | 65 | ||||
| -rw-r--r-- | lua/plugins/debug.lua | 90 | ||||
| -rw-r--r-- | lua/plugins/formatter.lua | 46 | ||||
| -rw-r--r-- | lua/plugins/general.lua | 94 | ||||
| -rw-r--r-- | lua/plugins/git.lua | 98 | ||||
| -rw-r--r-- | lua/plugins/init.lua | 12 | ||||
| -rw-r--r-- | lua/plugins/linter.lua | 40 | ||||
| -rw-r--r-- | lua/plugins/misc.lua | 50 | ||||
| -rw-r--r-- | lua/plugins/picker.lua | 142 | ||||
| -rw-r--r-- | lua/plugins/tsitter.lua | 115 | ||||
| -rw-r--r-- | package.nix | 89 | ||||
| -rw-r--r-- | stylua.toml | 11 |
25 files changed, 2010 insertions, 0 deletions
diff --git a/cats.nix b/cats.nix new file mode 100644 index 0000000..42a996a --- /dev/null +++ b/cats.nix @@ -0,0 +1,190 @@ +inputs: +let + inherit (inputs.nixcats) utils; +in +{ + pkgs, + settings, + categories, + extra, + name, + mkPlugin, + ... +}@packageDef: +{ + lspsAndRuntimeDeps = with pkgs; { + general = [ + fd + ripgrep + lsof + tree-sitter + # lldb + ]; + + markdown = [ + marksman + harper + ]; + + typst = [ + tinymist + ]; + + nix = [ + nixd + nil + nixfmt + ]; + + java = [ + jdt-language-server + google-java-format + ]; + + lua = [ + lua-language-server + stylua + ]; + + python = [ + ruff + zuban + ]; + + zig = [ + zls + ]; + + toml = [ + tombi + ]; + javascript = [ + eslint + prettierd + typescript-language-server + ]; + }; + + startupPlugins = with pkgs.vimPlugins; { + theme = [ + kanagawa-nvim + vague-nvim + kanso-nvim + rose-pine + catppuccin-nvim + tokyonight-nvim + gruvbox-material-nvim + onedark-nvim + onedarkpro-nvim + ]; + + ui = [ + nvim-web-devicons + ]; + + general = [ + pkgs.neovimPlugins.lze + pkgs.neovimPlugins.lzextras + nvim-lspconfig + ]; + + rust = [ + rustaceanvim + ]; + + extras = [ + plenary-nvim + ]; + }; + + optionalPlugins = with pkgs.vimPlugins; { + core = { + general = [ + oil-nvim + guess-indent-nvim + undotree + nvim-surround + conform-nvim + nvim-lint + lazydev-nvim + ]; + + picker = { + mini = [ + mini-pick + mini-extra + ]; + telescope = [ + telescope-nvim + telescope-fzf-native-nvim + telescope-ui-select-nvim + ]; + }; + + git = [ + pkgs.neovimPlugins.neogit + gitsigns-nvim + ]; + + completion = [ + blink-cmp + blink-ripgrep-nvim + friendly-snippets + ]; + }; + + tsitter = [ + nvim-treesitter.withAllGrammars + nvim-treesitter-textobjects + # (nvim-treesitter.withPlugins ( + # plugins: + # with plugins; [ + # nix + # lua + # rust + # cpp + # c + # go + # yaml + # python + # javascript + # typescript + # toml + # json + # ] + # )) + ]; + + debug = [ + nvim-dap + nvim-dap-ui + nvim-dap-virtual-text + nvim-dap-go + ]; + + misc = [ + obsidian-nvim + typst-preview-nvim + ]; + + ai = [ + pkgs.neovimPlugins.opencode-nvim + ]; + }; + + sharedLibraries = { + general = with pkgs; [ + # libgit2 + ]; + }; + + environmentVariables = { + }; + + extraWrapperArgs = { + }; + + extraLuaPackages = { + test = [ (_: [ ]) ]; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..7fc9811 --- /dev/null +++ b/flake.lock @@ -0,0 +1,468 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1767039857, + "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", + "owner": "NixOS", + "repo": "flake-compat", + "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "neovim-nightly-overlay", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1772408722, + "narHash": "sha256-rHuJtdcOjK7rAHpHphUb1iCvgkU3GpfvicLMwwnfMT0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f20dc5d9b8027381c474144ecabc9034d6a839a3", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1769996383, + "narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "57928607ea566b5db3ad13af0e57e921e6b12381", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_3": { + "inputs": { + "nixpkgs-lib": [ + "plugins-rustaceanvim", + "neovim-nightly-overlay", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1769996383, + "narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "57928607ea566b5db3ad13af0e57e921e6b12381", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "gen-luarc": { + "inputs": { + "flake-parts": [ + "plugins-rustaceanvim", + "flake-parts" + ], + "git-hooks": [ + "plugins-rustaceanvim", + "git-hooks" + ], + "luvit-meta": "luvit-meta", + "nixpkgs": [ + "plugins-rustaceanvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1755304025, + "narHash": "sha256-xVKfjFwc0zMbLMjLTiHz+0llggkjs93SmHkhaa9S3M4=", + "owner": "mrcjkb", + "repo": "nix-gen-luarc-json", + "rev": "1865b0ebb753ae5324d7381b1fa8c98c04ec7509", + "type": "github" + }, + "original": { + "owner": "mrcjkb", + "repo": "nix-gen-luarc-json", + "type": "github" + } + }, + "git-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "plugins-rustaceanvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1769939035, + "narHash": "sha256-Fok2AmefgVA0+eprw2NDwqKkPGEI5wvR+twiZagBvrg=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "a8ca480175326551d6c4121498316261cbb5b260", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "plugins-rustaceanvim", + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "luvit-meta": { + "flake": false, + "locked": { + "lastModified": 1705776742, + "narHash": "sha256-zAAptV/oLuLAAsa2zSB/6fxlElk4+jNZd/cPr9oxFig=", + "owner": "Bilal2453", + "repo": "luvit-meta", + "rev": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60", + "type": "github" + }, + "original": { + "owner": "Bilal2453", + "repo": "luvit-meta", + "type": "github" + } + }, + "neovim-nightly-overlay": { + "inputs": { + "flake-parts": "flake-parts", + "neovim-src": "neovim-src", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1773014724, + "narHash": "sha256-foUFwEwhjSnjJVD6gkiR2SlaYhvzV9bwsUQlLUu2DjQ=", + "owner": "nix-community", + "repo": "neovim-nightly-overlay", + "rev": "b955e58bea690fdbfc20ff7c249e481ca169ca33", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "neovim-nightly-overlay", + "type": "github" + } + }, + "neovim-nightly-overlay_2": { + "inputs": { + "flake-parts": "flake-parts_3", + "neovim-src": "neovim-src_2", + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1770509107, + "narHash": "sha256-YsfKRbd5fbcb2VTxywzAGpc4txXApMXfG0vtxEldt7Q=", + "owner": "nix-community", + "repo": "neovim-nightly-overlay", + "rev": "0bb52596f3ea543781d2c20b1c2ee495a174a7d5", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "neovim-nightly-overlay", + "type": "github" + } + }, + "neovim-src": { + "flake": false, + "locked": { + "lastModified": 1773014294, + "narHash": "sha256-JLAIrpQTp8u6blb5iZrAx36fNe65LT+JOUvxiLxlN+8=", + "owner": "neovim", + "repo": "neovim", + "rev": "61f166ec409b7621fcc42e4da40d6ccb19973749", + "type": "github" + }, + "original": { + "owner": "neovim", + "repo": "neovim", + "type": "github" + } + }, + "neovim-src_2": { + "flake": false, + "locked": { + "lastModified": 1770505476, + "narHash": "sha256-HvlTxVEso/hl9lwweHerBRLtI/q05SQTxDr2l0Njfig=", + "owner": "neovim", + "repo": "neovim", + "rev": "ed8fbd2e2992cb264cb62585098a1c7acc5c4585", + "type": "github" + }, + "original": { + "owner": "neovim", + "repo": "neovim", + "type": "github" + } + }, + "nixCats": { + "locked": { + "lastModified": 1770584904, + "narHash": "sha256-9Zaz8lbKF2W9pwXZEnbiGsicHdBoU+dHt3Wv3mCJoZ8=", + "owner": "BirdeeHub", + "repo": "nixCats-nvim", + "rev": "538fdde784d2909700d97a8ef307783b33a86fb1", + "type": "github" + }, + "original": { + "owner": "BirdeeHub", + "repo": "nixCats-nvim", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1772771118, + "narHash": "sha256-xWzaTvmmACR/SRWtABgI/Z97lcqwJAeoSd5QW1KdK1s=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e38213b91d3786389a446dfce4ff5a8aaf6012f2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1769909678, + "narHash": "sha256-cBEymOf4/o3FD5AZnzC3J9hLbiZ+QDT/KDuyHXVJOpM=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "72716169fe93074c333e8d0173151350670b824c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1772927210, + "narHash": "sha256-FdRDRoV0jRTiPK5ID22BaUX5P0wdsclpxtIOjaEy9Lo=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "0e6cdd5be64608ef630c2e41f8d51d484468492f", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1770380644, + "narHash": "sha256-P7dWMHRUWG5m4G+06jDyThXO7kwSk46C1kgjEWcybkE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ae67888ff7ef9dff69b3cf0cc0fbfbcd3a722abe", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1770380644, + "narHash": "sha256-P7dWMHRUWG5m4G+06jDyThXO7kwSk46C1kgjEWcybkE=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "ae67888ff7ef9dff69b3cf0cc0fbfbcd3a722abe", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "plugins-lze": { + "flake": false, + "locked": { + "lastModified": 1772949858, + "narHash": "sha256-skLhmn/MvxOZbrBiceF/xiLRRmmEs6ZQS2sGrBrUyLU=", + "owner": "BirdeeHub", + "repo": "lze", + "rev": "a3ba1a2d469d4ab26acb629aba8c7d70a6cbe558", + "type": "github" + }, + "original": { + "owner": "BirdeeHub", + "repo": "lze", + "type": "github" + } + }, + "plugins-lzextras": { + "flake": false, + "locked": { + "lastModified": 1772949841, + "narHash": "sha256-MQ1h2R5axM3u6mLNTDzXF/40o8+U0JOWb48UTQO9jfc=", + "owner": "BirdeeHub", + "repo": "lzextras", + "rev": "a6ac9a7bee380881af2dfbfd238ccb1697d677d7", + "type": "github" + }, + "original": { + "owner": "BirdeeHub", + "repo": "lzextras", + "type": "github" + } + }, + "plugins-neogit": { + "flake": false, + "locked": { + "lastModified": 1772820817, + "narHash": "sha256-dELzsOqSIvQvfl3fXTQg2ZkIILmlRWVWb+ogqeoJDYE=", + "owner": "NeogitOrg", + "repo": "neogit", + "rev": "8fd90675caf8b847280ca56f464b66030adad876", + "type": "github" + }, + "original": { + "owner": "NeogitOrg", + "repo": "neogit", + "type": "github" + } + }, + "plugins-opencode-nvim": { + "flake": false, + "locked": { + "lastModified": 1772989697, + "narHash": "sha256-xxB6TKn0Nv9GoYc7Mz+rhAUX8OXaHSkD3zZzFgSSHkQ=", + "owner": "NickvanDyke", + "repo": "opencode.nvim", + "rev": "47f92ab676bf1c3d00a40100429c7b089f81a5fc", + "type": "github" + }, + "original": { + "owner": "NickvanDyke", + "repo": "opencode.nvim", + "type": "github" + } + }, + "plugins-rustaceanvim": { + "inputs": { + "flake-parts": "flake-parts_2", + "gen-luarc": "gen-luarc", + "git-hooks": "git-hooks", + "neovim-nightly-overlay": "neovim-nightly-overlay_2", + "nixpkgs": "nixpkgs_4", + "vimcats": "vimcats" + }, + "locked": { + "lastModified": 1772653557, + "narHash": "sha256-7UTu+AKuGqPqZzM1WJ9s4qQklE27LEilaHO9vpCgC1o=", + "owner": "mrcjkb", + "repo": "rustaceanvim", + "rev": "f2f0c1231a5b019dbc1fd6dafac1751c878925a3", + "type": "github" + }, + "original": { + "owner": "mrcjkb", + "repo": "rustaceanvim", + "type": "github" + } + }, + "root": { + "inputs": { + "neovim-nightly-overlay": "neovim-nightly-overlay", + "nixCats": "nixCats", + "nixpkgs": "nixpkgs_2", + "plugins-lze": "plugins-lze", + "plugins-lzextras": "plugins-lzextras", + "plugins-neogit": "plugins-neogit", + "plugins-opencode-nvim": "plugins-opencode-nvim", + "plugins-rustaceanvim": "plugins-rustaceanvim" + } + }, + "vimcats": { + "inputs": { + "flake-parts": [ + "plugins-rustaceanvim", + "flake-parts" + ], + "git-hooks": [ + "plugins-rustaceanvim", + "git-hooks" + ], + "nixpkgs": [ + "plugins-rustaceanvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1767630708, + "narHash": "sha256-i2QZbDqaIMfYQfXZtbvsu2wcgfDYR8Kb19ZMagtCZg8=", + "owner": "mrcjkb", + "repo": "vimcats", + "rev": "869ee28be8f056e2482fd8bbfbaa23dd237aafd4", + "type": "github" + }, + "original": { + "owner": "mrcjkb", + "repo": "vimcats", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..8be4059 --- /dev/null +++ b/flake.nix @@ -0,0 +1,111 @@ +{ + description = "A Lua-natic's neovim flake, with extra cats! nixCats!"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + nixCats.url = "github:BirdeeHub/nixCats-nvim"; + plugins-rustaceanvim.url = "github:mrcjkb/rustaceanvim"; + plugins-opencode-nvim.url = "github:NickvanDyke/opencode.nvim"; + plugins-opencode-nvim.flake = false; + plugins-neogit.url = "github:NeogitOrg/neogit"; + plugins-neogit.flake = false; + neovim-nightly-overlay = { + url = "github:nix-community/neovim-nightly-overlay"; + }; + plugins-lze = { + url = "github:BirdeeHub/lze"; + flake = false; + }; + plugins-lzextras = { + url = "github:BirdeeHub/lzextras"; + flake = false; + }; + }; + + outputs = + { + self, + nixpkgs, + nixCats, + ... + }@inputs: + let + inherit (nixCats) utils; + luaPath = ./.; + forEachSystem = utils.eachSystem nixpkgs.lib.platforms.all; + extra_pkg_config = { + allowUnfree = true; + }; + + dependencyOverlays = [ + (utils.standardPluginOverlay inputs) + ]; + + categoryDefinitions = import ./cats.nix inputs; + packageDefinitions = import ./package.nix inputs; + defaultPackageName = "beeVim"; + in + forEachSystem ( + system: + let + nixCatsBuilder = utils.baseBuilder luaPath { + inherit + nixpkgs + system + dependencyOverlays + extra_pkg_config + ; + } categoryDefinitions packageDefinitions; + defaultPackage = nixCatsBuilder defaultPackageName; + pkgs = import nixpkgs { inherit system; }; + in + { + packages = utils.mkAllWithDefault defaultPackage; + devShells = { + default = pkgs.mkShell { + name = defaultPackageName; + packages = [ defaultPackage ]; + inputsFrom = [ ]; + shellHook = ""; + }; + }; + } + ) + // ( + let + nixosModule = utils.mkNixosModules { + moduleNamespace = [ defaultPackageName ]; + inherit + defaultPackageName + dependencyOverlays + luaPath + categoryDefinitions + packageDefinitions + extra_pkg_config + nixpkgs + ; + }; + homeModule = utils.mkHomeModules { + moduleNamespace = [ defaultPackageName ]; + inherit + defaultPackageName + dependencyOverlays + luaPath + categoryDefinitions + packageDefinitions + extra_pkg_config + nixpkgs + ; + }; + in + { + overlays = utils.makeOverlays luaPath { + inherit nixpkgs dependencyOverlays extra_pkg_config; + } categoryDefinitions packageDefinitions defaultPackageName; + nixosModules.default = nixosModule; + homeModules.default = homeModule; + inherit utils nixosModule homeModule; + inherit (utils) templates; + } + ); +} diff --git a/ftplugin/java.lua b/ftplugin/java.lua new file mode 100644 index 0000000..7a67f3b --- /dev/null +++ b/ftplugin/java.lua @@ -0,0 +1,5 @@ +vim.schedule(function() + if vim.bo.filetype == "java" then + require("LSPs.java_jdtls").setupJDTLS() + end +end) diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..34d4a53 --- /dev/null +++ b/init.lua @@ -0,0 +1,6 @@ +require("lze").register_handlers(require("nixCatsUtils.lzUtils").for_cat) + +require("config") +require("lze").load({ { import = "plugins" } }) + +require("colorscheme_persistence") diff --git a/lua/colorscheme_persistence.lua b/lua/colorscheme_persistence.lua new file mode 100644 index 0000000..e5f6cda --- /dev/null +++ b/lua/colorscheme_persistence.lua @@ -0,0 +1,50 @@ +local M = {} + +-- (~/.local/share/nvim/last_theme.txt) +local theme_cache_path = vim.fn.stdpath("data") .. "/last_theme.txt" + +M.is_programmatic_change = false + +function M.load_theme() + local theme = "" + + local f = io.open(theme_cache_path, "r") + if f then + theme = f:read("*all"):gsub("%s+", "") + f:close() + end + + if theme == "" then + theme = nixCats.extra("colorscheme") + end + + M.is_programmatic_change = true + local status, _ = pcall(vim.cmd.colorscheme, theme) + + -- just to be safe + if not status then + vim.cmd.colorscheme("habamax") + end +end + +vim.api.nvim_create_autocmd("ColorScheme", { + callback = function(args) + -- If the change was programmatic (like at startup), don't overwrite the file + if M.is_programmatic_change then + M.is_programmatic_change = false -- Reset for the next manual change + return + end + + -- Save the new theme name to the file + local theme_name = args.match + local f = io.open(theme_cache_path, "w") + if f then + f:write(theme_name) + f:close() + end + end, +}) + +M.load_theme() + +return M diff --git a/lua/config/colorschemes.lua b/lua/config/colorschemes.lua new file mode 100644 index 0000000..f09ecd3 --- /dev/null +++ b/lua/config/colorschemes.lua @@ -0,0 +1,82 @@ +if nixCats("theme") then + require("vague").setup({ + transparent = true, + bold = false, + }) + + require("gruvbox-material").setup({ + italics = true, + contrast = "medium", + comments = { + italics = true, + }, + background = { + transparent = true, + }, + float = { + force_background = true, + background_color = nil, + }, + }) + + require("kanso").setup({ + compile = true, + transparent = true, + dimInactive = false, + terminalColors = true, + overrides = function(colors) + local theme = colors.theme + return { + Pmenu = { fg = theme.ui.fg, bg = theme.ui.bg_p1 }, + NormalFloat = { bg = theme.ui.bg_p1 }, + FloatTitle = { fg = theme.ui.special, bg = theme.ui.bg_p1 }, + FloatBorder = { fg = theme.ui.shade0, bg = theme.ui.bg_p1 }, + } + end, + background = { + dark = "ink", + light = "pearl", + }, + foreground = "default", + }) + + require("rose-pine").setup({ + styles = { + bold = true, + italic = true, + transparency = true, + }, + }) + + require("kanagawa").setup({ + compile = true, + undercurl = true, + commentStyle = { italic = true }, + functionStyle = {}, + keywordStyle = { italic = true }, + statementStyle = { bold = true }, + typeStyle = {}, + transparent = true, + dimInactive = false, + terminalColors = true, + colors = { + palette = {}, + theme = { + wave = {}, + lotus = {}, + dragon = {}, + all = { ui = { bg_gutter = "none" } }, + }, + }, + overrides = function(colors) + return {} + end, + theme = "dragon", + background = { + dark = "dragon", + light = "lotus", + }, + }) +end + +return {} diff --git a/lua/config/init.lua b/lua/config/init.lua new file mode 100644 index 0000000..2be1996 --- /dev/null +++ b/lua/config/init.lua @@ -0,0 +1,4 @@ +require("config.options") +require("config.colorschemes") +require("config.keys") +require("config.lsp") diff --git a/lua/config/keys.lua b/lua/config/keys.lua new file mode 100644 index 0000000..518b9c1 --- /dev/null +++ b/lua/config/keys.lua @@ -0,0 +1,35 @@ +vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv", { silent = true }) +vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv", { silent = true }) + +vim.keymap.set("n", "J", "mzJ`z", { silent = true }) +vim.keymap.set("n", "<C-d>", "<C-d>zz", { silent = true }) +vim.keymap.set("n", "<C-u>", "<C-u>zz", { silent = true }) +vim.keymap.set("n", "n", "nzzzv", { silent = true }) +vim.keymap.set("n", "N", "Nzzzv", { silent = true }) +vim.keymap.set({ "n", "v" }, "<leader>y", [["+y]]) +vim.keymap.set({ "n", "v" }, "<leader>d", [["_d"]]) + +vim.keymap.set("n", "q:", "<nop>") -- disable that annoying cmd history buffer thingy + +vim.keymap.set("n", "<C-k>", "<cmd>cnext<CR>zz") +vim.keymap.set("n", "<C-j>", "<cmd>cprev<CR>zz") +vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz") +vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz") +vim.keymap.set("n", "<leader>bn", "<cmd>bn<CR>") +vim.keymap.set("n", "<leader>bp", "<cmd>bp<CR>") + +vim.keymap.set("n", "<leader>u", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]]) +vim.keymap.set("n", "<leader>px", "<cmd>!chmod +x %<CR>") +vim.keymap.set("n", "", "<cmd>nohlsearch<CR>") + +local function hover_cap(opts) + opts = vim.tbl_deep_extend("force", opts or {}, { + max_width = 100, + max_height = 25, + wrap = true, + }) + return vim.lsp.buf.hover(opts) +end + +vim.keymap.set("n", "K", hover_cap, { silent = true }) +-- vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, { desc = "Rename Symbol" }) diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua new file mode 100644 index 0000000..2e7cf05 --- /dev/null +++ b/lua/config/lsp.lua @@ -0,0 +1,91 @@ +vim.lsp.inlay_hint.enable(true) +vim.lsp.enable({ + "clangd", + "lua_ls", + "nixd", + "nil_ls", + "zls", + "pyrefly", + "marksman", + "harper", + "tinymist", + "gopls", + "tombi", +}) + +vim.lsp.config("nil_ls", { + settings = { + formatting = { + command = { "nixfmt" }, + }, + }, +}) + +vim.lsp.config("lua_ls", { + settings = { + Lua = { + codeLens = { enable = true }, + hint = { + enable = true, + semicolon = "Disable", + }, + workspace = { + checkThirdParty = false, + -- IMPORTANT: Leave library empty here. + -- lazydev will inject the correct Nix store paths dynamically. + library = {}, + }, + runtime = { + version = "LuaJIT", + -- Setting this to false allows lazydev to find files + -- outside your immediate workspace (like Nix store plugins) + pathStrict = false, + }, + }, + }, +}) + +vim.lsp.config("*", { + capabilities = { textDocument = { semanticTokens = { multilineTokenSupport = true } } }, + root_markers = { ".git", ".editorconfig", "flake.nix", "shell.nix" }, +}) + +vim.diagnostic.config({ + severity_sort = true, + severity_sort_priority = { + Error = 100, + Warn = 90, + Hint = 50, + Info = 10, + }, +}) + +local RustLsp = function(mode, keymap, action, bufnr) + vim.keymap.set(mode, keymap, function() + vim.cmd.RustLsp(action) + end, { silent = true, buffer = bufnr }) +end + +vim.g.rustaceanvim = { + tools = {}, + server = { + on_attach = function(client, bufnr) + RustLsp({ "n", "x" }, "gra", "codeAction", bufnr) + RustLsp("n", "<leader>ee", "explainError", bufnr) + RustLsp("n", "K", { "hover", "actions" }, bufnr) + RustLsp("n", "L", { "hover", "range" }, bufnr) + end, + default_settings = { + ["rust-analyzer"] = { + checkOnSave = { + enable = false, + command = "clippy", + }, + procMacro = { + enable = true, + }, + }, + }, + }, + dap = {}, +} diff --git a/lua/config/options.lua b/lua/config/options.lua new file mode 100644 index 0000000..c50b859 --- /dev/null +++ b/lua/config/options.lua @@ -0,0 +1,51 @@ +vim.loader.enable() +vim.g.mapleader = " " +vim.g.maplocalleader = " " +vim.o.updatetime = 1500 + +vim.opt.inccommand = "split" + +vim.opt.undofile = false +vim.opt.undodir = vim.fn.expand("~/.local/share/nvim/undo") + +vim.o.termguicolors = true +-- vim.opt.guicursor = "n-v-c-sm:block,ci-ve:ver25,r-cr-o:hor20" +vim.o.showmode = true +vim.o.showcmd = false +vim.o.signcolumn = "yes" +vim.o.cursorline = true +vim.o.cursorlineopt = "number" -- Restricts the highlight ONLY to the number column +vim.o.background = "dark" +vim.o.conceallevel = 2 +vim.o.autoread = true + +vim.o.nu = true +vim.o.relativenumber = true + +vim.o.mouse = "" +vim.o.scrolloff = 21 +vim.g.loaded_netrwPlugin = 1 +vim.g.loaded_netrw = 1 + +vim.o.expandtab = true +vim.o.tabstop = 4 +vim.o.softtabstop = 4 +vim.o.shiftwidth = 4 +vim.o.smartindent = false +vim.o.smarttab = true +vim.o.breakindent = true +vim.o.autoindent = true + +vim.o.wrap = false +vim.o.linebreak = false + +vim.o.hlsearch = true +vim.o.incsearch = true + +vim.o.title = true +vim.o.swapfile = false + +vim.opt.foldlevel = 99 +vim.opt.foldlevelstart = 99 +vim.opt.foldenable = true +vim.o.foldmethod = "expr" diff --git a/lua/nixCatsUtils/lzUtils.lua b/lua/nixCatsUtils/lzUtils.lua new file mode 100644 index 0000000..2e2393d --- /dev/null +++ b/lua/nixCatsUtils/lzUtils.lua @@ -0,0 +1,36 @@ +--[[ + This directory is the luaUtils template. + You can choose what things from it that you would like to use. + And then delete the rest. + Everything in this directory is optional. +--]] + +local M = {} +-- A nixCats specific lze handler that you can use to conditionally enable by category easier. +-- at the start of your config, register with +-- require('lze').register_handlers(require('nixCatsUtils.lzUtils').for_cat) +-- before any calls to require('lze').load using the handler have been made. +-- accepts: +-- for_cat = { "your" "cat" }; +-- for_cat = { cat = { "your" "cat" }, default = bool } +-- for_cat = "your.cat"; +-- for_cat = { cat = "your.cat", default = bool } +-- where default is an alternate value for when nixCats was NOT used to install the config +M.for_cat = { + spec_field = "for_cat", + set_lazy = false, + modify = function(plugin) + if type(plugin.for_cat) == "table" and plugin.for_cat.cat ~= nil then + if vim.g[ [[nixCats-special-rtp-entry-nixCats]] ] ~= nil then + plugin.enabled = nixCats(plugin.for_cat.cat) or false + else + plugin.enabled = plugin.for_cat.default + end + else + plugin.enabled = nixCats(plugin.for_cat) or false + end + return plugin + end, +} + +return M diff --git a/lua/plugins/ai.lua b/lua/plugins/ai.lua new file mode 100644 index 0000000..0aa51d8 --- /dev/null +++ b/lua/plugins/ai.lua @@ -0,0 +1,29 @@ +return { + { + "opencode-nvim", + for_cat = "ai", + keys = { + -- stylua: ignore start + { '<leader>co', function() require('opencode').toggle() end, desc = 'Toggle opencode' }, + { '<leader>ca', function() require('opencode').ask() end, desc = 'Ask opencode', mode = { 'n', 'v' } }, + { '<leader>cA', function() require('opencode').ask('@buffer ', { submit = true }) end, desc = 'Ask opencode about current file', mode = { 'n', 'v' } }, + { '<leader>cn', function() require('opencode').command('session.new') end, desc = 'New session' }, + { '<leader>ce', function() require('opencode').prompt('Explain @this and its context') end, desc = 'Explain code at cursor', mode = { 'n', 'v' } }, + { '<leader>cr', function() require('opencode').prompt('Review @buffer for correctness and readability') end, desc = 'Review file' }, + { '<leader>cf', function() require('opencode').prompt('Fix @diagnostics') end, desc = 'Fix errors' }, + { '<leader>cp', function() require('opencode').prompt('Optimize @this for performance and readability') end, desc = 'Optimize selection', mode = 'v' }, + { '<leader>cd', function() require('opencode').prompt('Add documentation comments for @this') end, desc = 'Document selection', mode = 'v' }, + { '<leader>ct', function() require('opencode').prompt('Add tests for @this') end, desc = 'Test selection', mode = 'v' }, + { '<leader>cs', function() require('opencode').select() end, desc = 'Select opencode action', mode = { 'n', 'v' } }, + -- stylua: ignore end + }, + before = function() + vim.g.opencode_opts = { + providers = { + enabled = "terminal", + tmux = {}, + }, + } + end, + }, +} diff --git a/lua/plugins/completion.lua b/lua/plugins/completion.lua new file mode 100644 index 0000000..79946e1 --- /dev/null +++ b/lua/plugins/completion.lua @@ -0,0 +1,65 @@ +return { + { + "blink.cmp", + event = { "InsertEnter", "CmdlineEnter" }, + for_cat = "core.completion", + load = function(name) + require("lzextras").loaders.multi({ + name, + -- "blink-ripgrep.nvim", + "friendly-snippets", + }) + end, + after = function(_) + require("blink.cmp").setup({ + keymap = { preset = "default" }, + appearance = { nerd_font_variant = "mono" }, + signature = { enabled = false }, + completion = { + documentation = { + auto_show = false, + }, + menu = { + draw = { + columns = { + { "label", "label_description", gap = 1 }, + { "kind_icon", "kind", gap = 1 }, + }, + treesitter = { "lsp" }, + }, + }, + }, + sources = { + default = { "lsp", "path", "snippets", "buffer", "cmdline", "omni" }, + providers = { + path = { + score_offset = 25, + }, + lsp = { + fallbacks = {}, + score_offset = 20, + }, + snippets = { + score_offset = 20, + }, + buffer = { + score_offset = 5, + }, + -- ripgrep = { + -- module = "blink-ripgrep", + -- name = "Ripgrep", + -- opts = { + -- project_root_marker = { ".git", "flake.nix", "flake.lock" }, + -- backend = { + -- use = "gitgrep-or-ripgrep", + -- customize_icon_highlight = false, + -- }, + -- }, + -- }, + }, + }, + fuzzy = { implementation = "prefer_rust_with_warning" }, + }) + end, + }, +} diff --git a/lua/plugins/debug.lua b/lua/plugins/debug.lua new file mode 100644 index 0000000..659336b --- /dev/null +++ b/lua/plugins/debug.lua @@ -0,0 +1,90 @@ +return { + { + "nvim-dap-go", + for_cat = { cat = "go", default = false }, + on_plugin = { "nvim-dap" }, + after = function(_) + require("dap-go").setup() + end, + }, + { + "nvim-dap", + for_cat = "debug", + on_require = { "dap" }, + keys = { + { "<F5>", desc = "Debug: Start/Continue" }, + { "<F2>", desc = "Debug: Step Into" }, + { "<F3>", desc = "Debug: Step Over" }, + { "<F4>", desc = "Debug: Step Out" }, + { "<leader>b", desc = "Debug: Toggle Breakpoint" }, + { "<leader>B", desc = "Debug: Set Breakpoint" }, + { "<F7>", desc = "Debug: See last session result." }, + }, + load = function(name) + require("lzextras").loaders.multi({ + name, + "nvim-dap-ui", + "nvim-dap-virtual-text", + }) + end, + after = function(_) + local dap = require("dap") + local dapui = require("dapui") + + -- Basic debugging keymaps, feel free to change to your liking! + vim.keymap.set("n", "<F5>", dap.continue, { desc = "Debug: Start/Continue" }) + vim.keymap.set("n", "<F2>", dap.step_into, { desc = "Debug: Step Into" }) + vim.keymap.set("n", "<F3>", dap.step_over, { desc = "Debug: Step Over" }) + vim.keymap.set("n", "<F4>", dap.step_out, { desc = "Debug: Step Out" }) + vim.keymap.set("n", "<leader>b", dap.toggle_breakpoint, { desc = "Debug: Toggle Breakpoint" }) + vim.keymap.set("n", "<leader>B", function() + dap.set_breakpoint(vim.fn.input("Breakpoint condition: ")) + end, { desc = "Debug: Set Breakpoint" }) + + -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. + vim.keymap.set("n", "<F7>", dapui.toggle, { desc = "Debug: See last session result." }) + + dap.listeners.after.event_initialized["dapui_config"] = dapui.open + dap.listeners.before.event_terminated["dapui_config"] = dapui.close + dap.listeners.before.event_exited["dapui_config"] = dapui.close + + -- Dap UI setup + -- For more information, see |:help nvim-dap-ui| + dapui.setup() + + require("nvim-dap-virtual-text").setup({ + -- enabled = true, -- enable this plugin (the default) + -- enabled_commands = true, -- create commands DapVirtualTextEnable, DapVirtualTextDisable, DapVirtualTextToggle, (DapVirtualTextForceRefresh for refreshing when debug adapter did not notify its termination) + -- highlight_changed_variables = true, -- highlight changed values with NvimDapVirtualTextChanged, else always NvimDapVirtualText + -- highlight_new_as_changed = false, -- highlight new variables in the same way as changed variables (if highlight_changed_variables) + -- show_stop_reason = true, -- show stop reason when stopped for exceptions + -- commented = false, -- prefix virtual text with comment string + -- only_first_definition = true, -- only show virtual text at first definition (if there are multiple) + -- all_references = false, -- show virtual text on all all references of the variable (not only definitions) + -- clear_on_continue = false, -- clear virtual text on "continue" (might cause flickering when stepping) + -- --- A callback that determines how a variable is displayed or whether it should be omitted + -- --- variable Variable https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable + -- --- buf number + -- --- stackframe dap.StackFrame https://microsoft.github.io/debug-adapter-protocol/specification#Types_StackFrame + -- --- node userdata tree-sitter node identified as variable definition of reference (see `:h tsnode`) + -- --- options nvim_dap_virtual_text_options Current options for nvim-dap-virtual-text + -- --- string|nil A text how the virtual text should be displayed or nil, if this variable shouldn't be displayed + -- display_callback = function(variable, buf, stackframe, node, options) + -- if options.virt_text_pos == "inline" then + -- return " = " .. variable.value + -- else + -- return variable.name .. " = " .. variable.value + -- end + -- end, + -- -- position of virtual text, see `:h nvim_buf_set_extmark()`, default tries to inline the virtual text. Use 'eol' to set to end of line + -- virt_text_pos = vim.fn.has("nvim-0.10") == 1 and "inline" or "eol", + -- + -- -- experimental features: + -- all_frames = false, -- show virtual text for all stack frames not only current. Only works for debugpy on my machine. + -- virt_lines = false, -- show virtual lines instead of virtual text (will flicker!) + -- virt_text_win_col = nil, -- position the virtual text at a fixed window column (starting from the first text column) , + -- -- e.g. 80 to position at column 80, see `:h nvim_buf_set_extmark()` + }) + end, + }, +} diff --git a/lua/plugins/formatter.lua b/lua/plugins/formatter.lua new file mode 100644 index 0000000..cc600e5 --- /dev/null +++ b/lua/plugins/formatter.lua @@ -0,0 +1,46 @@ +return { + { + "conform.nvim", + event = { "BufReadPre", "BufNewFile" }, + for_cats = "core.general", + after = function() + local conform = require("conform") + + conform.setup({ + format_after_save = { + lsp_format = "fallback", + quiet = true, + }, + + formatters_by_ft = { + lua = { "stylua" }, + go = { "gofmt" }, + rust = { "rustfmt" }, + toml = { "tombi" }, + java = { "google-java-format" }, + cmake = { "cmake_format" }, + typescript = { "prettierd" }, + javascript = { "prettierd" }, + c = { "clang-format" }, + cpp = { "clang-format" }, + python = { "ruff_fix", "ruff_organize_imports", "ruff_format" }, + }, + + formatters = { + ["google-java-format"] = { + prepend_args = { "--aosp" }, + }, + ["clang-format"] = { + prepend_args = { "-style={BasedOnStyle: LLVM, IndentWidth: 4, TabWidth: 4, UseTab: Never}" }, + }, + }, + }) + + vim.keymap.set({ "n", "v" }, "<leader>lf", function() + conform.format({ async = true }) + end, { + desc = "Language format", + }) + end, + }, +} diff --git a/lua/plugins/general.lua b/lua/plugins/general.lua new file mode 100644 index 0000000..f115247 --- /dev/null +++ b/lua/plugins/general.lua @@ -0,0 +1,94 @@ +return { + { + "guess-indent.nvim", + for_cat = "core.general", + event = "DeferredUIEnter", + after = function() + require("guess-indent").setup({ + auto_cmd = true, + override_editorconfig = true, + filetype_exclude = { + "netrw", + "tutor", + "oil", + "gitcommit", + }, + buftype_exclude = { + "help", + "nofile", + "terminal", + "prompt", + }, + on_tab_options = { + ["expandtab"] = false, + }, + on_space_options = { + ["expandtab"] = true, + ["tabstop"] = "detected", + ["softtabstop"] = "detected", + ["shiftwidth"] = "detected", + }, + }) + end, + }, + { + "nvim-surround", + for_cat = "core.general", + event = { "BufReadPre", "BufNewFile" }, + after = function() + require("nvim-surround").setup() + end, + }, + { + "oil.nvim", + keys = { { "<leader>o", "<CMD>Oil<CR>", desc = "Open oil" } }, + for_cat = "core.general", + after = function() + require("oil").setup({ + default_file_explorer = true, + columns = { "icon", "permissions", "size" }, + keymaps = { + ["-"] = "actions.parent", + ["<CR>"] = "actions.select", + ["<C-v>"] = "actions.select_vsplit", + ["<C-s>"] = "actions.select_split", + }, + }) + end, + }, + { + "undotree", + for_cat = "core.general", + cmd = { "UndotreeToggle", "UndotreeHide", "UndotreeShow", "UndotreeFocus", "UndotreePersistUndo" }, + keys = { { "<leader>U", "<cmd>UndotreeToggle<CR>", mode = { "n" }, desc = "Undo Tree" } }, + before = function(_) + vim.g.undotree_WindowLayout = 1 + vim.g.undotree_SplitWidth = 40 + vim.g.undotree_WindowLayout = 3 + end, + }, + { + "lazydev.nvim", + ft = "lua", + after = function() + require("lazydev").setup({ + library = { + { path = "${3rd}/luv/library", words = { "vim%.uv" } }, + }, + + integrations = { + -- Fixes lspconfig's workspace management for LuaLS + -- Only create a new workspace if the buffer is not part + -- of an existing workspace or one of its libraries + lspconfig = true, + -- add the cmp source for completion of: + -- `require "modname"` + -- `---@module "modname"` + cmp = true, + -- same, but for Coq + coq = false, + }, + }) + end, + }, +} diff --git a/lua/plugins/git.lua b/lua/plugins/git.lua new file mode 100644 index 0000000..0e333f8 --- /dev/null +++ b/lua/plugins/git.lua @@ -0,0 +1,98 @@ +return { + { + "neogit", + for_cat = "core.git", + keys = { { "<leader>gg", "<CMD>Neogit<CR>", desc = "Open Neogit Ui" } }, + cmd = { "Neogit" }, + after = function() + require("neogit").setup({ + disable_hint = true, + kind = "split_above", + + commit_editor = { + kind = "tab", + show_staged_diff = true, + staged_diff_split_kind = "auto", + spell_check = true, + }, + }) + end, + }, + { + "gitsigns.nvim", + event = { "DeferredUIEnter" }, + for_cat = "core.git", + after = function(_) + require("gitsigns").setup({ + signs = { + add = { text = "+" }, + change = { text = "~" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + }, + + on_attach = function(bufnr) + local gs = package.loaded.gitsigns + + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + -- Navigation + map({ "n", "v" }, "]c", function() + if vim.wo.diff then + return "]c" + end + vim.schedule(function() + gs.next_hunk() + end) + return "<Ignore>" + end, { expr = true, desc = "Jump to next hunk" }) + + map({ "n", "v" }, "[c", function() + if vim.wo.diff then + return "[c" + end + vim.schedule(function() + gs.prev_hunk() + end) + return "<Ignore>" + end, { expr = true, desc = "Jump to previous hunk" }) + + -- Actions + -- visual mode + map("v", "<leader>hs", function() + gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) + end, { desc = "stage git hunk" }) + map("v", "<leader>hr", function() + gs.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) + end, { desc = "reset git hunk" }) + -- normal mode + map("n", "<leader>gs", gs.stage_hunk, { desc = "git stage hunk" }) + map("n", "<leader>gr", gs.reset_hunk, { desc = "git reset hunk" }) + map("n", "<leader>gS", gs.stage_buffer, { desc = "git Stage buffer" }) + map("n", "<leader>gu", gs.undo_stage_hunk, { desc = "undo stage hunk" }) + map("n", "<leader>gR", gs.reset_buffer, { desc = "git Reset buffer" }) + map("n", "<leader>gp", gs.preview_hunk, { desc = "preview git hunk" }) + map("n", "<leader>gb", function() + gs.blame_line({ full = false }) + end, { desc = "git blame line" }) + -- map('n', '<leader>gd', gs.diffthis, { desc = 'git diff against index' }) + map("n", "<leader>gD", function() + gs.diffthis("~") + end, { desc = "git diff against last commit" }) + + -- Toggles + map("n", "<leader>gtb", gs.toggle_current_line_blame, { desc = "toggle git blame line" }) + map("n", "<leader>gtd", gs.toggle_deleted, { desc = "toggle git show deleted" }) + + -- Text object + map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>", { desc = "select git hunk" }) + end, + }) + end, + }, +} diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua new file mode 100644 index 0000000..19e47d1 --- /dev/null +++ b/lua/plugins/init.lua @@ -0,0 +1,12 @@ +return { + { import = "plugins.ai" }, + { import = "plugins.general" }, + { import = "plugins.completion" }, + { import = "plugins.git" }, + { import = "plugins.formatter" }, + { import = "plugins.tsitter" }, + { import = "plugins.misc" }, + { import = "plugins.picker" }, + { import = "plugins.debug" }, + { import = "plugins.linter" }, +} diff --git a/lua/plugins/linter.lua b/lua/plugins/linter.lua new file mode 100644 index 0000000..c804d1c --- /dev/null +++ b/lua/plugins/linter.lua @@ -0,0 +1,40 @@ +return { + { + "nvim-lint", + event = { "BufReadPre", "BufNewFile" }, + for_cats = "core.general", + after = function() + local lint = require("lint") + + lint.linters_by_ft = { + python = { "ruff" }, + go = { "golangcilint" }, + rust = { "clippy" }, + c = { "clangtidy" }, + cpp = { "clangtidy" }, + java = { "checkstyle" }, + cmake = { "cmakelint" }, + javascript = { "eslint_d" }, + typescript = { "eslint_d" }, + } + + local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) + + vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost" }, { + group = lint_augroup, + callback = function() + lint.try_lint(nil, { ignore_errors = true }) + end, + }) + + vim.api.nvim_create_autocmd({ "InsertLeave" }, { + group = lint_augroup, + callback = function() + if vim.bo.filetype ~= "rust" then + lint.try_lint(nil, { ignore_errors = true }) + end + end, + }) + end, + }, +} diff --git a/lua/plugins/misc.lua b/lua/plugins/misc.lua new file mode 100644 index 0000000..37185ae --- /dev/null +++ b/lua/plugins/misc.lua @@ -0,0 +1,50 @@ +return { + { + "obsidian.nvim", + for_cats = "misc", + event = { + "BufReadPre " .. vim.fn.expand("~") .. "/Notes/**/*.md", + "BufNewFile " .. vim.fn.expand("~") .. "/Notes/**/*.md", + }, + after = function() + require("obsidian").setup({ + legacy_commands = false, + workspaces = { + { + name = "personal", + path = "~/Notes", + }, + }, + }) + end, + }, + { + "typst-preview.nvim", + ft = "typst", + for_cats = "misc", + after = function() + require("typst-preview").setup({ + debug = false, + open_cmd = nil, + port = nil, + invert_colors = "never", + follow_cursor = true, + dependencies_bin = { + tinymist = "tinymist", + websocat = "websocat", + }, + extra_args = nil, + get_root = function(path_of_main_file) + local root = os.getenv("TYPST_ROOT") + if root then + return root + end + return vim.fn.fnamemodify(path_of_main_file, ":p:h") + end, + get_main_file = function(path_of_buffer) + return path_of_buffer + end, + }) + end, + }, +} diff --git a/lua/plugins/picker.lua b/lua/plugins/picker.lua new file mode 100644 index 0000000..478a689 --- /dev/null +++ b/lua/plugins/picker.lua @@ -0,0 +1,142 @@ +local mini = function(key, action, desc) + return { + key, + "<cmd>Pick " .. action .. "<CR>", + mode = { "n" }, + desc = desc, + } +end + +local telescope_builtin = function(key, action, desc) + return { + key, + "<cmd>Telescope " .. action .. "<CR>", + mode = { "n" }, + desc = desc, + } +end + +return { + { + "mini.pick", + for_cat = "core.picker.mini", + event = "DeferredUIEnter", + keys = { + mini("<leader>ff", "files", "finde files"), + mini("<leader>fb", "buffers", "Find open buffers"), + mini("<leader>fh", "help", "Find help"), + mini("<leader>/", "grep_live", "Live grep"), + + -- MiniExtra + mini("<leader>fd", "diagnostic", "Diagnostics"), + mini("<leader>fgb", "git_branches", "Git branches"), + mini("<leader>fc", "git_commits", "Git commits"), + + -- LSP scopes + mini("<leader>fr", "lsp scope='references'", "LSP references"), + mini("<leader>ds", "lsp scope='document_symbol'", "Document symbols"), + mini("<leader>ws", "lsp scope='workspace_symbol'", "Workspace symbols"), + + mini("ld", "lsp scope='definition'", "Goto definition"), + mini("ltd", "lsp scope='type_definition'", "Goto type definition"), + mini("lD", "lsp scope='declaration'", "Goto declaration"), + mini("lr", "lsp scope='references'", "Goto references"), + mini("lI", "lsp scope='implementation'", "Goto implementation"), + }, + load = function(name) + require("lzextras").loaders.multi({ + name, + "mini.extra", + }) + end, + after = function() + require("mini.pick").setup() + end, + }, + { + "telescope.nvim", + event = "DeferredUIEnter", + for_cat = "core.picker.telescope", + keys = { + telescope_builtin("<leader>ff", "find_files", "Search files in cwd"), + telescope_builtin("<leader>fb", "buffers", "Search files in cwd"), + telescope_builtin("<leader>fo", "oldfiles", "Recent files"), + telescope_builtin("<leader>fr", "registers", "Registers"), + telescope_builtin("<leader>fj", "jumplist", "Jump list"), + telescope_builtin("<leader>fm", "marks", "Marks"), + + telescope_builtin("<leader>fq", "quickfix", "Quickfix list"), + telescope_builtin("<leader>fl", "loclist", "Location list"), + + telescope_builtin("<leader>st", "treesitter", "Treesitter symbols"), + + telescope_builtin("<leader>sc", "commands", "Commands"), + telescope_builtin("<leader>sp", "spell_suggest", "Spell suggestions"), + + telescope_builtin("<leader>sg", "live_grep", "Search by grep"), + telescope_builtin("<leader>ss", "grep_string", "Search string"), + telescope_builtin("<leader>sk", "keymaps", "Search keymaps"), + telescope_builtin("<leader>sh", "help_tags", "Search help tags"), + telescope_builtin("<leader>/", "current_buffer_fuzzy_find", "Search in current buffer"), + + telescope_builtin("<leader>gc", "git_commits", "Git commits"), + telescope_builtin("<leader>gB", "git_branches", "Git branches"), + telescope_builtin("<leader>gs", "git_status", "Git status"), + telescope_builtin("<leader>gS", "git_stash", "Git stash"), + + telescope_builtin("<leader>ls", "lsp_document_symbols", "Document symbols"), + telescope_builtin("<leader>lS", "lsp_workspace_symbols", "Workspace symbols"), + telescope_builtin("<leader>lds", "lsp_dynamic_workspace_symbols", "Workspace symbols"), + telescope_builtin("<leader>ld", "diagnostics", "Diagnostics"), + telescope_builtin("<leader>lD", "lsp_definitions", "LSP definitions"), + telescope_builtin("<leader>li", "lsp_incoming_calls", "LSP incoming calls"), + telescope_builtin("<leader>lo", "lsp_outgoing_calls", "LSP outgoing calls"), + telescope_builtin("<leader>lt", "lsp_type_definitions", "LSP type definitions"), + telescope_builtin("grr", "lsp_references", "LSP references"), + telescope_builtin("gri", "lsp_implementations", "LSP implementations"), + }, + load = function(name) + require("lzextras").loaders.multi({ + name, + "telescope-fzf-native.nvim", + "telescope-ui-select.nvim", + }) + end, + after = function() + require("telescope").setup({ + defaults = { + mappings = { + i = { + ["<M-Enter>"] = "to_fuzzy_refine", + }, + }, + }, + pickers = { + buffers = { + mappings = { + i = { + -- ["<C-d>"] = "delete_buffer", + }, + n = { + ["d"] = "delete_buffer", + }, + }, + }, + }, + extensions = { + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = "smart_case", + }, + ["ui-select"] = { + require("telescope.themes").get_dropdown({}), + }, + }, + }) + require("telescope").load_extension("fzf") + require("telescope").load_extension("ui-select") + end, + }, +} diff --git a/lua/plugins/tsitter.lua b/lua/plugins/tsitter.lua new file mode 100644 index 0000000..8bdb0ca --- /dev/null +++ b/lua/plugins/tsitter.lua @@ -0,0 +1,115 @@ +return { + { + "nvim-treesitter", + lazy = false, + after = function(plugin) + ---@param buf integer + ---@param language string + local function treesitter_try_attach(buf, language) + -- check if parser exists and load it + if not vim.treesitter.language.add(language) then + return false + end + -- enables syntax highlighting and other treesitter features + vim.treesitter.start(buf, language) + + -- enables treesitter based folds + vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" + + -- enables treesitter based indentation + vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + + return true + end + + local installable_parsers = require("nvim-treesitter").get_available() + vim.api.nvim_create_autocmd("FileType", { + callback = function(args) + local buf, filetype = args.buf, args.match + local language = vim.treesitter.language.get_lang(filetype) + if not language then + return + end + + if not treesitter_try_attach(buf, language) then + if vim.tbl_contains(installable_parsers, language) then + -- not already installed, so try to install them via nvim-treesitter if possible + require("nvim-treesitter").install(language):await(function() + treesitter_try_attach(buf, language) + end) + end + end + end, + }) + end, + }, + { + "nvim-treesitter-textobjects", + lazy = false, + before = function(plugin) + -- https://github.com/nvim-treesitter/nvim-treesitter-textobjects/tree/main?tab=readme-ov-file#using-a-package-manager + -- Disable entire built-in ftplugin mappings to avoid conflicts. + -- See https://github.com/neovim/neovim/tree/master/runtime/ftplugin for built-in ftplugins. + vim.g.no_plugin_maps = true + + -- Or, disable per filetype (add as you like) + -- vim.g.no_python_maps = true + -- vim.g.no_ruby_maps = true + -- vim.g.no_rust_maps = true + -- vim.g.no_go_maps = true + end, + after = function(plugin) + require("nvim-treesitter-textobjects").setup({ + select = { + -- Automatically jump forward to textobj, similar to targets.vim + lookahead = true, + -- You can choose the select mode (default is charwise 'v') + -- + -- Can also be a function which gets passed a table with the keys + -- * query_string: eg '@function.inner' + -- * method: eg 'v' or 'o' + -- and should return the mode ('v', 'V', or '<c-v>') or a table + -- mapping query_strings to modes. + selection_modes = { + ["@parameter.outer"] = "v", -- charwise + ["@function.outer"] = "V", -- linewise + -- ['@class.outer'] = '<c-v>', -- blockwise + }, + -- If you set this to `true` (default is `false`) then any textobject is + -- extended to include preceding or succeeding whitespace. Succeeding + -- whitespace has priority in order to act similarly to eg the built-in + -- `ap`. + -- + -- Can also be a function which gets passed a table with the keys + -- * query_string: eg '@function.inner' + -- * selection_mode: eg 'v' + -- and should return true of false + include_surrounding_whitespace = false, + }, + }) + + -- keymaps + -- You can use the capture groups defined in `textobjects.scm` + vim.keymap.set({ "x", "o" }, "am", function() + require("nvim-treesitter-textobjects.select").select_textobject("@function.outer", "textobjects") + end) + vim.keymap.set({ "x", "o" }, "im", function() + require("nvim-treesitter-textobjects.select").select_textobject("@function.inner", "textobjects") + end) + vim.keymap.set({ "x", "o" }, "ac", function() + require("nvim-treesitter-textobjects.select").select_textobject("@class.outer", "textobjects") + end) + vim.keymap.set({ "x", "o" }, "ic", function() + require("nvim-treesitter-textobjects.select").select_textobject("@class.inner", "textobjects") + end) + -- You can also use captures from other query groups like `locals.scm` + vim.keymap.set({ "x", "o" }, "as", function() + require("nvim-treesitter-textobjects.select").select_textobject("@local.scope", "locals") + end) + + -- NOTE: for more textobjects options, see the following link. + -- This template is using the new `main` branch of the repo. + -- https://github.com/nvim-treesitter/nvim-treesitter-textobjects/tree/main + end, + }, +} diff --git a/package.nix b/package.nix new file mode 100644 index 0000000..8a04224 --- /dev/null +++ b/package.nix @@ -0,0 +1,89 @@ +inputs: +let + inherit (inputs.nixCats) utils; + baseSettings = + { + pkgs, + name, + ... + }@misc: + { + suffix-path = true; + suffix-LD = true; + hosts.node.enable = false; + hosts.ruby.enable = false; + hosts.perl.enable = false; + hosts.python3.enable = false; + neovim-unwrapped = inputs.neovim-nightly-overlay.packages.${pkgs.stdenv.hostPlatform.system}.neovim; + wrapRc = true; + useBinaryWrapper = true; + aliases = [ + "vim" + "vi" + "nvim" + ]; + # neovim-unwrapped = inputs.neovim-nightly-overlay.packages.${pkgs.system}.neovim; + }; + baseCats = + { pkgs, ... }@misc: + { + ai = true; + theme = true; + rust = true; + toml = true; + nix = true; + general = true; + lua = true; + javascript = false; + java = false; + typst = false; + misc = false; + zig = false; + debug = false; + python = false; + markdown = false; + core = { + formatter = true; + git = true; + general = true; + completion = true; + picker.mini = false; + picker.telescope = true; + }; + tsitter = true; + }; + baseExtra = + { pkgs, ... }@misc: + { + colorscheme = "gruvbox-material"; + nixdExtras = { + nixpkgs = "import ${pkgs.path} {}"; + }; + }; +in +{ + beeVim = args: { + settings = baseSettings args; + categories = baseCats args; + extra = baseExtra args; + }; + mvim = args: { + settings = baseSettings args // { + suffix-path = false; + suffix-LD = false; + }; + categories = baseCats args // { + ai = false; + rust = false; + tsitter = false; + core = { + formatter = false; + git = true; + general = true; + picker.mini = true; + picker.telescope = false; + }; + }; + extra = baseExtra args; + }; +} diff --git a/stylua.toml b/stylua.toml new file mode 100644 index 0000000..6323d4c --- /dev/null +++ b/stylua.toml @@ -0,0 +1,11 @@ +column_width = 120 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 4 +quote_style = "AutoPreferDouble" +call_parentheses = "Always" +collapse_simple_statement = "Never" + +[sort_requires] +enabled = true + |
