diff --git a/.envrc b/.envrc deleted file mode 100644 index a1d3540..0000000 --- a/.envrc +++ /dev/null @@ -1 +0,0 @@ -use flake . -Lv diff --git a/.gitignore b/.gitignore index 7a8b6a5..cece139 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -result -.direnv +tags .luarc.json +/result diff --git a/.stylua.toml b/.stylua.toml index 49b29eb..139e939 100644 --- a/.stylua.toml +++ b/.stylua.toml @@ -1,10 +1,6 @@ -column_width = 80 +column_width = 160 line_endings = "Unix" indent_type = "Spaces" indent_width = 2 quote_style = "AutoPreferSingle" -call_parentheses = "Always" -collapse_simple_statement = "Never" - -[sort_requires] -enabled = true +call_parentheses = "None" diff --git a/Justfile b/Justfile deleted file mode 100644 index 5f083b6..0000000 --- a/Justfile +++ /dev/null @@ -1,23 +0,0 @@ -alias d := dev -dev: - nix develop - -alias t := test -test: - git aa && nix run . - -alias to := testone -testone: - git aa && nix run . -- flake.nix - -alias tt := testtwo -testtwo: - git aa && nix run . -- flake.nix .stylua.toml - -alias tl := testlua -testlua: - git aa && nix run . -- nvim/lua/autocmds.lua - -alias s := search -search this: - nh search {{this}} diff --git a/README.md b/README.md index 54fb994..44811d4 100644 --- a/README.md +++ b/README.md @@ -1,332 +1,5 @@ - -
-
- - kickstart-nix.nvim - - - - - - - - - - - - - - -

❄️

-

- - A dead simple Nix flake template repository
- for Neovim -
-

+# LazyVim distribution -[![Neovim][neovim-shield]][neovim-url] -[![Nix][nix-shield]][nix-url] -[![Lua][lua-shield]][lua-url] +How to get the [LazyVim](http://www.lazyvim.org/) distribution up and running -[![GPL2 License][license-shield]][license-url] -[![Issues][issues-shield]][issues-url] -
- - -![](https://github.com/nix-community/kickstart-nix.nvim/assets/12857160/84faa268-82de-4401-acf3-efddc26dd58a) - -## :grey_question: Why kickstart-nix.nvim - -If Nix and Neovim have one thing in common, -it's that many new users don't know where to get started. -Most Nix-based Neovim setups assume deep expertise in both realms, -abstracting away Neovim's core functionalities -as well as the Nix internals used to build a Neovim config. -Frameworks and module-based DSLs are opinionated and difficult to diverge from -with one's own modifications. - -`kickstart-nix.nvim` is different: -It's geared for users of all levels, -making the migration of Neovim configurations to Nix straightforward. -This project aims to be as simple as possible, while allowing -for maximum flexibility. - -> [!NOTE] -> -> Similar to [`kickstart.nvim`](https://github.com/nvim-lua/kickstart.nvim), -> this repository is meant to be used by **you** to begin your -> **Nix**/Neovim journey; remove the things you don't use and add what you miss. - -## :milky_way: Philosophy - -- KISS principle with sane defaults. -- Manage plugins + external dependencies using Nix - (managing plugins shouldn't be the responsibility of a plugin). -- Configuration entirely in Lua[^1] (Vimscript is also possible). - This makes it easy to migrate from non-nix dotfiles. -- Use Neovim's built-in loading mechanisms. See: - - [`:h initialization`](https://neovim.io/doc/user/starting.html#initialization) - - [`:h runtimepath`](https://neovim.io/doc/user/options.html#'runtimepath') - - [`:h packadd`](https://neovim.io/doc/user/repeat.html#%3Apackadd) -- Use Neovim's built-in LSP client, with Nix managing language servers. - -[^1]: The absence of a Nix module DSL for Neovim configuration is deliberate. - If you were to copy the `nvim` directory to `$XDG_CONFIG_HOME`, - and install the plugins, it would work out of the box. - -## :star2: Features - -- Use either nixpkgs or flake inputs as plugin sources. -- Usable on any device with Neovim and Nix installed. -- Create multiple derivations with different sets of plugins, - and simple regex filters to exclude config files. -- Uses Nix to generate a `.luarc.json` in the devShell's `shellHook`. - This sets up lua-language-server to recognize all plugins - and the Neovim API. - -## :bicyclist: Test drive - -If you have Nix installed (with [flakes](https://wiki.nixos.org/wiki/Flakes) enabled), -you can test drive this by running: - -```console -nix run "github:nix-community/kickstart-nix.nvim" -``` - -## :books: Usage - -1. Click on [Use this template](https://github.com/nix-community/kickstart-nix.nvim/generate) -to start a repo based on this template. **Do _not_ fork it**. -1. Add/remove plugins to/from the [Neovim overlay](./nix/neovim-overlay.nix). -1. Add/remove plugin configs to/from the `nvim/plugin` directory. -1. Modify as you wish (you will probably want to add a color theme, ...). - See: [Design](#robot-design). -1. You can create more than one package using the `mkNeovim` function by - - Passing different plugin lists. - - Adding `ignoreConfigRegexes` (e.g. `= [ "^ftplugin/.*.lua" ]`). - -> [!TIP] -> -> The nix and lua files contain comments explaining -> what everything does in detail. - -## :zap: Installation - -### :snowflake: NixOS (with flakes) - -1. Add your flake to you NixOS flake inputs. -1. Add the overlay provided by this flake. - -```nix -nixpkgs.overlays = [ - # replace with the name you chose - .overlays.default -]; -``` - -You can then add the overlay's output(s) to the `systemPackages`: - -```nix -environment.systemPackages = with pkgs; [ - nvim-pkg # The default package added by the overlay -]; -``` - -> [!IMPORTANT] -> -> This flake uses `nixpkgs.wrapNeovimUnstable`, which has an -> unstable signature. If you set `nixpkgs.follows = "nixpkgs";` -> when importing this into your flake.nix, it may break. -> Especially if your nixpkgs input pins a different branch. - -### :penguin: Non-NixOS - -With Nix installed (flakes enabled), from the repo root: - -```console -nix profile install .#nvim -``` - -## :robot: Design - -Directory structure: - -```sh -── flake.nix -── nvim # Neovim configs (lua), equivalent to ~/.config/nvim -── nix # Nix configs -``` - -### :open_file_folder: Neovim configs - -- Set options in `init.lua`. -- Source autocommands, user commands, keymaps, - and configure plugins in individual files within the `plugin` directory. -- Filetype-specific scripts (e.g. start LSP clients) in the `ftplugin` directory. -- Library modules in the `lua/user` directory. - -Directory structure: - -```sh -── nvim - ├── ftplugin # Sourced when opening a file type - │ └── .lua - ├── init.lua # Always sourced - ├── lua # Shared library modules - │ └── user - │ └── .lua - ├── plugin # Automatically sourced at startup - │ ├── autocommands.lua - │ ├── commands.lua - │ ├── keymaps.lua - │ ├── plugins.lua # Plugins that require a `setup` call - │ └── .lua # Plugin configurations - └── after # Empty in this template - ├── plugin # Sourced at the very end of startup (rarely needed) - └── ftplugin # Sourced when opening a filetype, after sourcing ftplugin scripts -``` - -> [!IMPORTANT] -> -> - Configuration variables (e.g. `vim.g.`) should go in `nvim/init.lua` -> or a module that is `require`d in `init.lua`. -> - Configurations for plugins that require explicit initialization -> (e.g. via a call to a `setup()` function) should go in `nvim/plugin/.lua` -> or `nvim/plugin/plugins.lua`. -> - See [Initialization order](#initialization-order) for details. - -### :open_file_folder: Nix - -You can declare Neovim derivations in `nix/neovim-overlay.nix`. - -There are two ways to add plugins: - -- The traditional way, using `nixpkgs` as the source. -- By adding plugins as flake inputs (if you like living on the bleeding-edge). - Plugins added as flake inputs must be built in `nix/plugin-overlay.nix`. - -Directory structure: - -```sh -── flake.nix -── nix - ├── mkNeovim.nix # Function for creating the Neovim derivation - └── neovim-overlay.nix # Overlay that adds Neovim derivation -``` - -### :mag: Initialization order - -This derivation creates an `init.lua` as follows: - -1. Add `nvim/lua` to the `runtimepath`. -1. Add the content of `nvim/init.lua`. -1. Add `nvim/*` to the `runtimepath`. -1. Add `nvim/after` to the `runtimepath`. - -This means that modules in `nvim/lua` can be `require`d in `init.lua` and `nvim/*/*.lua`. - -Modules in `nvim/plugin/` are sourced automatically, as if they were plugins. -Because they are added to the runtime path at the end of the resulting `init.lua`, -Neovim sources them _after_ loading plugins. - -## :electric_plug: Pre-configured plugins - -This configuration comes with [a few plugins pre-configured](./nix/neovim-overlay.nix). - -You can add or remove plugins by - -- Adding/Removing them in the [Nix list](./nix/neovim-overlay.nix). -- Adding/Removing the config in `nvim/plugin/.lua`. - -## :anchor: Syncing updates - -If you have used this template and would like to fetch updates -that were added later... - -Add this template as a remote: - -```console -git remote add upstream git@github.com:nix-community/kickstart-nix.nvim.git -``` - -Fetch and merge changes: - -```console -git fetch upstream -git merge upstream/main --allow-unrelated-histories -``` - -## :pencil: Editing your config - -When your neovim setup is a nix derivation, editing your config -demands a different workflow than you are used to without nix. -Here is how I usually do it: - -- Perform modifications and stage any new files[^2]. -- Run `nix run /path/to/neovim/#nvim` - or `nix run /path/to/neovim/#nvim -- ` - -[^2]: When adding new files, nix flakes won't pick them up unless they - have been committed or staged. - -This requires a rebuild of the `nvim` derivation, but has the advantage -that if anything breaks, it's only broken during your test run. - -If you want an impure, but faster feedback loop, -you can use `$XDG_CONFIG_HOME/$NVIM_APPNAME`[^3], where `$NVIM_APPNAME` -defaults to `nvim` if the `appName` attribute is not set -in the `mkNeovim` function. - -[^3]: Assuming Linux. Refer to `:h initialization` for Darwin. - -This has one caveat: The wrapper which nix generates for the derivation -calls `nvim` with `-u /nix/store/path/to/generated-init.lua`. -So it won't source a local `init.lua` file. -To work around this, you can put scripts in the `plugin` or `after/plugin` directory. - -> [!TIP] -> -> If you are starting out, and want to test things without having to -> stage or commit new files for changes to take effect, -> you can remove the `.git` directory and re-initialize it (`git init`) -> when you are done. - -## :link: Alternative / similar projects - -- [`kickstart.nvim`](https://github.com/nvim-lua/kickstart.nvim): - Single-file Neovim configuration template with a similar philosophy to this project. - Does not use Nix to manage plugins. -- [`neovim-flake`](https://github.com/jordanisaacs/neovim-flake): - Configured using a Nix module DSL. -- [`NixVim`](https://github.com/nix-community/nixvim): - A module system for Neovim, with a focus on plugin configs. -- [`nixCats-nvim`](https://github.com/BirdeeHub/nixCats-nvim): - A project that organises plugins into categories. - It also separates lua and nix configuration. -- [`lz.n`](https://github.com/nvim-neorocks/lz.n): - A plugin-manager agnostic Lua library for lazy-loading plugins. - Can be used with Nix. - -> [!NOTE] -> -> When comparing with projects in the "non-Nix world", this -> repository would be more comparable to `kickstart.nvim` (hence the name), -> while the philosophies of `neovim-flake` and `NixVim` are more in line with -> a Neovim distribution like [`LunarVim`](https://www.lunarvim.org/) -> or [`LazyVim`](https://www.lazyvim.org/) -> (though they are far more minimal by default). - - -[neovim-shield]: https://img.shields.io/badge/NeoVim-%2357A143.svg?&style=for-the-badge&logo=neovim&logoColor=white -[neovim-url]: https://neovim.io/ -[nix-shield]: https://img.shields.io/badge/nix-0175C2?style=for-the-badge&logo=NixOS&logoColor=white -[nix-url]: https://nixos.org/ -[lua-shield]: https://img.shields.io/badge/lua-%232C2D72.svg?style=for-the-badge&logo=lua&logoColor=white -[lua-url]: https://www.lua.org/ -[license-shield]: https://img.shields.io/github/license/nix-community/kickstart-nix.nvim.svg?style=for-the-badge -[license-url]: https://github.com/nix-community/kickstart-nix.nvim/blob/master/LICENSE -[issues-shield]: https://img.shields.io/github/issues/nix-community/kickstart-nix.nvim.svg?style=for-the-badge -[issues-url]: https://github.com/nix-community/kickstart-nix.nvim/issues -[license-shield]: https://img.shields.io/github/license/nix-community/kickstart-nix.nvim.svg?style=for-the-badge -[license-url]: https://github.com/nix-community/kickstart-nix.nvim/blob/master/LICENSE +see the [kickstart-nvim template](../kickstart-nvim) for more info on the lazy wrapper or other utilities used. diff --git a/flake.lock b/flake.lock index 87db72f..1ed5b86 100644 --- a/flake.lock +++ b/flake.lock @@ -1,476 +1,40 @@ { "nodes": { - "flake-compat": { - "flake": false, + "nixCats": { "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "lastModified": 1740730062, + "narHash": "sha256-tqIpClZGNV/CgY+V9fVOdWwpc2eeEj2rcisCwD0MUzw=", + "owner": "BirdeeHub", + "repo": "nixCats-nvim", + "rev": "4f193d7298ff1184d2f28a98acb1ce7a2a6bc3f7", "type": "github" }, "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-compat_2": { - "flake": false, - "locked": { - "lastModified": 1733328505, - "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-compat_3": { - "flake": false, - "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-parts": { - "inputs": { - "nixpkgs-lib": "nixpkgs-lib" - }, - "locked": { - "lastModified": 1717285511, - "narHash": "sha256-iKzJcpdXih14qYVcZ9QC9XuZYnPc6T8YImb6dX166kw=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, - "flake-parts_2": { - "inputs": { - "nixpkgs-lib": [ - "neovim-nightly", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1736143030, - "narHash": "sha256-+hu54pAoLDEZT9pjHlqL9DNzWz0NbUn8NEAHP7PQPzU=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "b905f6fc23a9051a6e1b741e1438dbfc0634c6de", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, - "flake-parts_3": { - "inputs": { - "nixpkgs-lib": [ - "neovim-nightly", - "hercules-ci-effects", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1733312601, - "narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9", - "type": "github" - }, - "original": { - "id": "flake-parts", - "type": "indirect" - } - }, - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "gen-luarc": { - "inputs": { - "flake-parts": "flake-parts", - "git-hooks": "git-hooks", - "luvit-meta": "luvit-meta", - "nixpkgs": "nixpkgs" - }, - "locked": { - "lastModified": 1735608918, - "narHash": "sha256-/TAukZv6LiqIrA/7mq1fxP5pb3Iavik7BTYqrnLO/JE=", - "ref": "refs/heads/main", - "rev": "24c726151769c2f2ee493ce45c8027860ddbcbcd", - "revCount": 21, - "type": "git", - "url": "https://codewith.babesonthe.net/punkfairie/nix-gen-luarc-json.git" - }, - "original": { - "type": "git", - "url": "https://codewith.babesonthe.net/punkfairie/nix-gen-luarc-json.git" - } - }, - "git-hooks": { - "inputs": { - "flake-compat": "flake-compat", - "gitignore": "gitignore", - "nixpkgs": [ - "gen-luarc", - "nixpkgs" - ], - "nixpkgs-stable": "nixpkgs-stable" - }, - "locked": { - "lastModified": 1723803910, - "narHash": "sha256-yezvUuFiEnCFbGuwj/bQcqg7RykIEqudOy/RBrId0pc=", - "owner": "cachix", - "repo": "git-hooks.nix", - "rev": "bfef0ada09e2c8ac55bbcd0831bd0c9d42e651ba", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "git-hooks.nix", - "type": "github" - } - }, - "git-hooks_2": { - "inputs": { - "flake-compat": "flake-compat_3", - "gitignore": "gitignore_2", - "nixpkgs": [ - "neovim-nightly", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1735882644, - "narHash": "sha256-3FZAG+pGt3OElQjesCAWeMkQ7C/nB1oTHLRQ8ceP110=", - "owner": "cachix", - "repo": "git-hooks.nix", - "rev": "a5a961387e75ae44cc20f0a57ae463da5e959656", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "git-hooks.nix", - "type": "github" - } - }, - "gitignore": { - "inputs": { - "nixpkgs": [ - "gen-luarc", - "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" - } - }, - "gitignore_2": { - "inputs": { - "nixpkgs": [ - "neovim-nightly", - "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" - } - }, - "hercules-ci-effects": { - "inputs": { - "flake-parts": "flake-parts_3", - "nixpkgs": [ - "neovim-nightly", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1735695978, - "narHash": "sha256-cwk53OX1S1bCFY09zydubZNmmwcx9l5XEba8mVYuNE4=", - "owner": "hercules-ci", - "repo": "hercules-ci-effects", - "rev": "f6233b5cfbada692d93a73d6ed35bdbfd0fdb9c4", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "hercules-ci-effects", - "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" - } - }, - "neotab-nvim": { - "flake": false, - "locked": { - "lastModified": 1733176083, - "narHash": "sha256-5IJQwZxDGDMM6KBWKU/EZwa5wciHeTXOZgHPCRmlxJk=", - "owner": "kawre", - "repo": "neotab.nvim", - "rev": "f6ed1ef49f32586f5db95edae5d6f264c8180d85", - "type": "github" - }, - "original": { - "owner": "kawre", - "repo": "neotab.nvim", - "type": "github" - } - }, - "neovim-nightly": { - "inputs": { - "flake-compat": "flake-compat_2", - "flake-parts": "flake-parts_2", - "git-hooks": "git-hooks_2", - "hercules-ci-effects": "hercules-ci-effects", - "neovim-src": "neovim-src", - "nixpkgs": [ - "nixpkgs" - ], - "treefmt-nix": "treefmt-nix" - }, - "locked": { - "lastModified": 1736753650, - "narHash": "sha256-qSbPnZ2utGL39UD6lKi+K/7sWyZVl/kGZfOoy+xJEjA=", - "owner": "nix-community", - "repo": "neovim-nightly-overlay", - "rev": "9e2c41b7c12adc3ca17b1b50589f5234bcc0bbac", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "neovim-nightly-overlay", - "type": "github" - } - }, - "neovim-src": { - "flake": false, - "locked": { - "lastModified": 1736752727, - "narHash": "sha256-sFD18EfXyQrN51ru6uzCt20C3DT4qBipJ1PbP9hnw80=", - "owner": "neovim", - "repo": "neovim", - "rev": "2c16c849986794682a4776ff4ec100d00eeba5ca", - "type": "github" - }, - "original": { - "owner": "neovim", - "repo": "neovim", - "type": "github" - } - }, - "nerdy-nvim": { - "flake": false, - "locked": { - "lastModified": 1733092208, - "narHash": "sha256-ALghRgNavAeGZk0+JbSdjSkTvtDgzD8zAguCl00R0yw=", - "owner": "2kabhishek", - "repo": "nerdy.nvim", - "rev": "719ed52244b34ea9de08f074e0d22fd67d615640", - "type": "github" - }, - "original": { - "owner": "2kabhishek", - "repo": "nerdy.nvim", + "owner": "BirdeeHub", + "repo": "nixCats-nvim", "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1718714799, - "narHash": "sha256-FUZpz9rg3gL8NVPKbqU8ei1VkPLsTIfAJ2fdAf5qjak=", + "lastModified": 1740762151, + "narHash": "sha256-Rn0j0gP6po1m46RsW/4jrn7938TZGR+wRZ0+MSZThBg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "c00d587b1a1afbf200b1d8f0b0e4ba9deb1c7f0e", + "rev": "5954d3359cc7178623da6c7fd23dc7f7504d7187", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-unstable", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } }, - "nixpkgs-lib": { - "locked": { - "lastModified": 1717284937, - "narHash": "sha256-lIbdfCsf8LMFloheeE6N31+BMIeixqyQWbSr2vk79EQ=", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz" - } - }, - "nixpkgs-stable": { - "locked": { - "lastModified": 1720386169, - "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "194846768975b7ad2c4988bdb82572c00222c0d7", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-24.05", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1736701207, - "narHash": "sha256-jG/+MvjVY7SlTakzZ2fJ5dC3V1PrKKrUEOEE30jrOKA=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "ed4a395ea001367c1f13d34b1e01aa10290f67d6", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nvim-emmet": { - "flake": false, - "locked": { - "lastModified": 1717158539, - "narHash": "sha256-LgKASQ1xBL8ugxK1g4R3BLQ3ha05cFtZaSYvd2Hy73c=", - "owner": "olrtg", - "repo": "nvim-emmet", - "rev": "cde4fb2968704aae5c18b7f8a9bc2508767bb78d", - "type": "github" - }, - "original": { - "owner": "olrtg", - "repo": "nvim-emmet", - "type": "github" - } - }, "root": { "inputs": { - "flake-utils": "flake-utils", - "gen-luarc": "gen-luarc", - "neotab-nvim": "neotab-nvim", - "neovim-nightly": "neovim-nightly", - "nerdy-nvim": "nerdy-nvim", - "nixpkgs": "nixpkgs_2", - "nvim-emmet": "nvim-emmet" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "treefmt-nix": { - "inputs": { - "nixpkgs": [ - "neovim-nightly", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1736154270, - "narHash": "sha256-p2r8xhQZ3TYIEKBoiEhllKWQqWNJNoT9v64Vmg4q8Zw=", - "owner": "numtide", - "repo": "treefmt-nix", - "rev": "13c913f5deb3a5c08bb810efd89dc8cb24dd968b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "treefmt-nix", - "type": "github" + "nixCats": "nixCats", + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index 92aff38..62cb184 100644 --- a/flake.nix +++ b/flake.nix @@ -1,89 +1,328 @@ +# Copyright (c) 2023 BirdeeHub +# Licensed under the MIT license { - description = "Neovim derivation"; + description = "A Lua-natic's neovim flake, with extra cats! nixCats!"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - gen-luarc.url = "git+https://codewith.babesonthe.net/punkfairie/nix-gen-luarc-json.git"; + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + nixCats.url = "github:BirdeeHub/nixCats-nvim"; - neovim-nightly = { - url = "github:nix-community/neovim-nightly-overlay"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + # neovim-nightly-overlay = { + # url = "github:nix-community/neovim-nightly-overlay"; + # }; - neotab-nvim = { - url = "github:kawre/neotab.nvim"; - flake = false; - }; + # see :help nixCats.flake.inputs + # If you want your plugin to be loaded by the standard overlay, + # i.e. if it wasnt on nixpkgs, but doesnt have an extra build step. + # Then you should name it "plugins-something" + # If you wish to define a custom build step not handled by nixpkgs, + # then you should name it in a different format, and deal with that in the + # overlay defined for custom builds in the overlays directory. + # for specific tags, branches and commits, see: + # https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake.html#examples - nerdy-nvim = { - url = "github:2kabhishek/nerdy.nvim"; - flake = false; - }; - - nvim-emmet = { - url = "github:olrtg/nvim-emmet"; - flake = false; - }; - - # nixd.url = "github:nix-community/nixd"; }; - outputs = inputs @ { - self, - nixpkgs, - flake-utils, - gen-luarc, - ... - }: let - supportedSystems = [ - "x86_64-linux" - "aarch64-linux" - "x86_64-darwin" - "aarch64-darwin" + # see :help nixCats.flake.outputs + outputs = { self, nixpkgs, nixCats, ... }@inputs: let + inherit (nixCats) utils; + luaPath = "${./.}"; + forEachSystem = utils.eachSystem nixpkgs.lib.platforms.all; + # the following extra_pkg_config contains any values + # which you want to pass to the config set of nixpkgs + # import nixpkgs { config = extra_pkg_config; inherit system; } + # will not apply to module imports + # as that will have your system values + extra_pkg_config = { + # allowUnfree = true; + }; + # management of the system variable is one of the harder parts of using flakes. + + # so I have done it here in an interesting way to keep it out of the way. + # It gets resolved within the builder itself, and then passed to your + # categoryDefinitions and packageDefinitions. + + # this allows you to use ${pkgs.system} whenever you want in those sections + # without fear. + + # sometimes our overlays require a ${system} to access the overlay. + # Your dependencyOverlays can either be lists + # in a set of ${system}, or simply a list. + # the nixCats builder function will accept either. + # see :help nixCats.flake.outputs.overlays + dependencyOverlays = /* (import ./overlays inputs) ++ */ [ + # This overlay grabs all the inputs named in the format + # `plugins-` + # Once we add this overlay to our nixpkgs, we are able to + # use `pkgs.neovimPlugins`, which is a set of our plugins. + (utils.standardPluginOverlay inputs) + # add any other flake overlays here. + + # when other people mess up their overlays by wrapping them with system, + # you may instead call this function on their overlay. + # it will check if it has the system in the set, and if so return the desired overlay + # (utils.fixSystemizedOverlay inputs.codeium.overlays + # (system: inputs.codeium.overlays.${system}.default) + # ) ]; - # This is where the Neovim derivation is built. - neovim-overlay = import ./nix/neovim-overlay.nix {inherit inputs;}; - in - flake-utils.lib.eachSystem supportedSystems (system: let - pkgs = import nixpkgs { - inherit system; - overlays = [ - # Import the overlay, so that the final Neovim derivation(s) can be accessed via pkgs. - neovim-overlay + # see :help nixCats.flake.outputs.categories + # and + # :help nixCats.flake.outputs.categoryDefinitions.scheme + categoryDefinitions = { pkgs, settings, categories, extra, name, mkNvimPlugin, ... }@packageDef: { + # to define and use a new category, simply add a new list to a set here, + # and later, you will include categoryname = true; in the set you + # provide when you build the package using this builder function. + # see :help nixCats.flake.outputs.packageDefinitions for info on that section. - # This adds a function can be used to generate a .luarc.json - # containing the Neovim API all plugins in the workspace directory. - # The generated file can be symlinked in the devShell's shellHook. - gen-luarc.overlays.default + # lspsAndRuntimeDeps: + # this section is for dependencies that should be available + # at RUN TIME for plugins. Will be available to PATH within neovim terminal + # this includes LSPs + lspsAndRuntimeDeps = with pkgs; { + general = [ + universal-ctags + curl + lazygit + ripgrep + fd + stdenv.cc.cc + lua-language-server + nil # I would go for nixd but lazy chooses this one idk + stylua ]; }; - shell = pkgs.mkShell { - name = "nvim-devShell"; - buildInputs = with pkgs; [ - fish - just - ]; - shellHook = '' - # symlink the .luarc.json generated in the overlay - ln -fs ${pkgs.nvim-luarc-json} .luarc.json - # use fish - exec fish + # NOTE: lazy doesnt care if these are in startupPlugins or optionalPlugins + # also you dont have to download everything via nix if you dont want. + # but you have the option, and that is demonstrated here. + startupPlugins = with pkgs.vimPlugins; { + general = [ + # LazyVim + lazy-nvim + LazyVim + bufferline-nvim + lazydev-nvim + cmp-buffer + cmp-nvim-lsp + cmp-path + cmp_luasnip + conform-nvim + dashboard-nvim + dressing-nvim + flash-nvim + friendly-snippets + gitsigns-nvim + indent-blankline-nvim + lualine-nvim + neo-tree-nvim + neoconf-nvim + neodev-nvim + noice-nvim + nui-nvim + nvim-cmp + nvim-lint + nvim-lspconfig + nvim-notify + nvim-spectre + nvim-treesitter-context + nvim-treesitter-textobjects + nvim-ts-autotag + nvim-ts-context-commentstring + nvim-web-devicons + persistence-nvim + plenary-nvim + telescope-fzf-native-nvim + telescope-nvim + todo-comments-nvim + tokyonight-nvim + trouble-nvim + vim-illuminate + vim-startuptime + which-key-nvim + snacks-nvim + nvim-treesitter-textobjects + nvim-treesitter.withAllGrammars + # This is for if you only want some of the grammars + # (nvim-treesitter.withPlugins ( + # plugins: with plugins; [ + # nix + # lua + # ] + # )) + + # sometimes you have to fix some names + { plugin = luasnip; name = "LuaSnip"; } + { plugin = catppuccin-nvim; name = "catppuccin"; } + { plugin = mini-ai; name = "mini.ai"; } + { plugin = mini-icons; name = "mini.icons"; } + { plugin = mini-bufremove; name = "mini.bufremove"; } + { plugin = mini-comment; name = "mini.comment"; } + { plugin = mini-indentscope; name = "mini.indentscope"; } + { plugin = mini-pairs; name = "mini.pairs"; } + { plugin = mini-surround; name = "mini.surround"; } + # you could do this within the lazy spec instead if you wanted + # and get the new names from `:NixCats pawsible` debug command + ]; + }; + + # not loaded automatically at startup. + # use with packadd and an autocommand in config to achieve lazy loading + # NOTE: this template is using lazy.nvim so, which list you put them in is irrelevant. + # startupPlugins or optionalPlugins, it doesnt matter, lazy.nvim does the loading. + # I just put them all in startupPlugins. I could have put them all in here instead. + optionalPlugins = {}; + + # shared libraries to be added to LD_LIBRARY_PATH + # variable available to nvim runtime + sharedLibraries = { + general = with pkgs; [ + # libgit2 + ]; + }; + + # environmentVariables: + # this section is for environmentVariables that should be available + # at RUN TIME for plugins. Will be available to path within neovim terminal + environmentVariables = { + test = { + CATTESTVAR = "It worked!"; + }; + }; + + # If you know what these are, you can provide custom ones by category here. + # If you dont, check this link out: + # https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/setup-hooks/make-wrapper.sh + extraWrapperArgs = { + test = [ + '' --set CATTESTVAR2 "It worked again!"'' + ]; + }; + + # lists of the functions you would have passed to + # python.withPackages or lua.withPackages + + # get the path to this python environment + # in your lua config via + # vim.g.python3_host_prog + # or run from nvim terminal via :!-python3 + extraPython3Packages = { + test = [ (_:[]) ]; + }; + # populates $LUA_PATH and $LUA_CPATH + extraLuaPackages = { + test = [ (_:[]) ]; + }; + }; + + + + # And then build a package with specific categories from above here: + # All categories you wish to include must be marked true, + # but false may be omitted. + # This entire set is also passed to nixCats for querying within the lua. + + # see :help nixCats.flake.outputs.packageDefinitions + packageDefinitions = { + # These are the names of your packages + # you can include as many as you wish. + nvim = { pkgs, mkNvimPlugin, ... }: { + # they contain a settings set defined above + # see :help nixCats.flake.outputs.settings + settings = { + wrapRc = true; + # IMPORTANT: + # your alias may not conflict with your other packages. + # aliases = [ "vim" ]; + # neovim-unwrapped = inputs.neovim-nightly-overlay.packages.${pkgs.system}.neovim; + }; + # and a set of categories that you want + # (and other information to pass to lua) + categories = { + general = true; + test = false; + }; + extra = {}; + }; + # an extra test package with normal lua reload for fast edits + # nix doesnt provide the config in this package, allowing you free reign to edit it. + # then you can swap back to the normal pure package when done. + testnvim = { pkgs, mkNvimPlugin, ... }: { + settings = { + wrapRc = false; + unwrappedCfgPath = "/absolute/path/to/config"; + }; + categories = { + general = true; + test = false; + }; + extra = {}; + }; + }; + # In this section, the main thing you will need to do is change the default package name + # to the name of the packageDefinitions entry you wish to use as the default. + defaultPackageName = "nvim"; + in + + + # see :help nixCats.flake.outputs.exports + forEachSystem (system: let + # the builder function that makes it all work + nixCatsBuilder = utils.baseBuilder luaPath { + inherit nixpkgs system dependencyOverlays extra_pkg_config; + } categoryDefinitions packageDefinitions; + defaultPackage = nixCatsBuilder defaultPackageName; + # this is just for using utils such as pkgs.mkShell + # The one used to build neovim is resolved inside the builder + # and is passed to our categoryDefinitions and packageDefinitions + pkgs = import nixpkgs { inherit system; }; + in + { + # these outputs will be wrapped with ${system} by utils.eachSystem + + # this will make a package out of each of the packageDefinitions defined above + # and set the default package to the one passed in here. + packages = utils.mkAllWithDefault defaultPackage; + + # choose your package for devShell + # and add whatever else you want in it. + devShells = { + default = pkgs.mkShell { + name = defaultPackageName; + packages = [ defaultPackage ]; + inputsFrom = [ ]; + shellHook = '' ''; }; - in { - packages = rec { - default = nvim; - nvim = pkgs.nvim-pkg; - }; - devShells = { - default = shell; - }; - }) - // { - # You can add this overlay to your NixOS configuration - overlays.default = neovim-overlay; }; + + }) // (let + # we also export a nixos module to allow reconfiguration from configuration.nix + nixosModule = utils.mkNixosModules { + moduleNamespace = [ defaultPackageName ]; + inherit defaultPackageName dependencyOverlays luaPath + categoryDefinitions packageDefinitions extra_pkg_config nixpkgs; + }; + # and the same for home manager + homeModule = utils.mkHomeModules { + moduleNamespace = [ defaultPackageName ]; + inherit defaultPackageName dependencyOverlays luaPath + categoryDefinitions packageDefinitions extra_pkg_config nixpkgs; + }; + in { + + # these outputs will be NOT wrapped with ${system} + + # this will make an overlay out of each of the packageDefinitions defined above + # and set the default overlay to the one named here. + 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/init.lua b/init.lua new file mode 100644 index 0000000..8b1b7c3 --- /dev/null +++ b/init.lua @@ -0,0 +1,53 @@ +-- NOTE: this just gives nixCats global command a default value +-- so that it doesnt throw an error if you didnt install via nix. +-- usage of both this setup and the nixCats command is optional, +-- but it is very useful for passing info from nix to lua so you will likely use it at least once. +require('nixCatsUtils').setup { + non_nix_value = true, +} + +-- NOTE: You might want to move the lazy-lock.json file +local function getlockfilepath() + if require('nixCatsUtils').isNixCats and type(nixCats.settings.unwrappedCfgPath) == 'string' then + return nixCats.settings.unwrappedCfgPath .. '/lazy-lock.json' + else + return vim.fn.stdpath 'config' .. '/lazy-lock.json' + end +end +local lazyOptions = { + lockfile = getlockfilepath(), +} + +-- NOTE: this the lazy wrapper. Use it like require('lazy').setup() but with an extra +-- argument, the path to lazy.nvim as downloaded by nix, or nil, before the normal arguments. +require('nixCatsUtils.lazyCat').setup(nixCats.pawsible { 'allPlugins', 'start', 'lazy.nvim' }, { + { 'LazyVim/LazyVim', import = 'lazyvim.plugins' }, + -- The following configs are needed for fixing lazyvim on nix + -- force enable telescope-fzf-native.nvim + { 'nvim-telescope/telescope-fzf-native.nvim', enabled = require('nixCatsUtils').lazyAdd(true, false) }, + -- disable mason.nvim while using nix + -- precompiled binaries do not agree with nixos, and we can just make nix install this stuff for us. + { 'williamboman/mason-lspconfig.nvim', enabled = require('nixCatsUtils').lazyAdd(true, false) }, + { 'williamboman/mason.nvim', enabled = require('nixCatsUtils').lazyAdd(true, false) }, + { + 'nvim-treesitter/nvim-treesitter', + build = require('nixCatsUtils').lazyAdd ':TSUpdate', + opts_extend = require('nixCatsUtils').lazyAdd(nil, false), + opts = { + -- nix already ensured they were installed, and we would need to change the parser_install_dir if we wanted to use it instead. + -- so we just disable install and do it via nix. + ensure_installed = require('nixCatsUtils').lazyAdd({ 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc' }, false), + auto_install = require('nixCatsUtils').lazyAdd(true, false), + }, + }, + { 'folke/lazydev.nvim', ft = "lua", + opts = { + library = { + -- adds type hints for nixCats global, but LazyDev is just nice in general + { path = (nixCats.nixCatsPath or "") .. '/lua', words = { "nixCats" } }, + }, + } + }, + -- import/override with your plugins + { import = 'plugins' }, +}, lazyOptions) diff --git a/lua/nixCatsUtils/init.lua b/lua/nixCatsUtils/init.lua new file mode 100644 index 0000000..b6a6128 --- /dev/null +++ b/lua/nixCatsUtils/init.lua @@ -0,0 +1,129 @@ +--[[ + 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 = {} + +--[[ + This file is for making your config still work WITHOUT nixCats. + When you don't use nixCats to load your config, + you wont have the nixCats plugin. + + The setup function defined here defines a mock nixCats plugin when nixCats wasnt used to load the config. + This will help avoid indexing errors when the nixCats plugin doesnt exist. + + NOTE: If you only ever use nixCats to load your config, you don't need this file. +--]] + +---@type boolean +M.isNixCats = vim.g[ [[nixCats-special-rtp-entry-nixCats]] ] ~= nil + +---@class nixCatsSetupOpts +---@field non_nix_value boolean|nil + +---This function will setup a mock nixCats plugin when not using nix +---It will help prevent you from running into indexing errors without a nixCats plugin from nix. +---If you loaded the config via nix, it does nothing +---non_nix_value defaults to true if not provided or is not a boolean. +---@param v nixCatsSetupOpts +function M.setup(v) + if not M.isNixCats then + local nixCats_default_value + if type(v) == "table" and type(v.non_nix_value) == "boolean" then + nixCats_default_value = v.non_nix_value + else + nixCats_default_value = true + end + local mk_with_meta = function (tbl) + return setmetatable(tbl, { + __call = function(_, attrpath) + local strtable = {} + if type(attrpath) == "table" then + strtable = attrpath + elseif type(attrpath) == "string" then + for key in attrpath:gmatch("([^%.]+)") do + table.insert(strtable, key) + end + else + print("function requires a table of strings or a dot separated string") + return + end + return vim.tbl_get(tbl, unpack(strtable)); + end + }) + end + package.preload['nixCats'] = function () + local ncsub = { + get = function(_) return nixCats_default_value end, + cats = mk_with_meta({ + nixCats_config_location = vim.fn.stdpath('config'), + wrapRc = false, + }), + settings = mk_with_meta({ + nixCats_config_location = vim.fn.stdpath('config'), + configDirName = os.getenv("NVIM_APPNAME") or "nvim", + wrapRc = false, + }), + petShop = mk_with_meta({}), + extra = mk_with_meta({}), + pawsible = mk_with_meta({ + allPlugins = { + start = {}, + opt = {}, + }, + }), + configDir = vim.fn.stdpath('config'), + packageBinPath = os.getenv('NVIM_WRAPPER_PATH_NIX') or vim.v.progpath + } + return setmetatable(ncsub, {__call = function(_, cat) return ncsub.get(cat) end}) + end + _G.nixCats = require('nixCats') + end +end + +---allows you to guarantee a boolean is returned, and also declare a different +---default value than specified in setup when not using nix to load the config +---@overload fun(v: string|string[]): boolean +---@overload fun(v: string|string[], default: boolean): boolean +function M.enableForCategory(v, default) + if M.isNixCats or default == nil then + if nixCats(v) then + return true + else + return false + end + else + return default + end +end + +---if nix, return value of nixCats(v) else return default +---Exists to specify a different non_nix_value than the one in setup() +---@param v string|string[] +---@param default any +---@return any +function M.getCatOrDefault(v, default) + if M.isNixCats then + return nixCats(v) + else + return default + end +end + +---for conditionally disabling build steps on nix, as they are done via nix +---I should probably have named it dontAddIfCats or something. +---@overload fun(v: any): any|nil +---Will return the second value if nix, otherwise the first +---@overload fun(v: any, o: any): any +function M.lazyAdd(v, o) + if M.isNixCats then + return o + else + return v + end +end + +return M diff --git a/lua/nixCatsUtils/lazyCat.lua b/lua/nixCatsUtils/lazyCat.lua new file mode 100644 index 0000000..6d8fd7f --- /dev/null +++ b/lua/nixCatsUtils/lazyCat.lua @@ -0,0 +1,119 @@ +--[[ + 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 = {} +-- NOTE: If you don't use lazy.nvim, you don't need this file. + +---lazy.nvim wrapper +---@overload fun(nixLazyPath: string|nil, lazySpec: any, opts: table) +---@overload fun(nixLazyPath: string|nil, opts: table) +function M.setup(nixLazyPath, lazySpec, opts) + local lazySpecs = nil + local lazyCFG = nil + if opts == nil and type(lazySpec) == "table" and lazySpec.spec then + lazyCFG = lazySpec + else + lazySpecs = lazySpec + lazyCFG = opts + end + + local function regularLazyDownload() + local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" + if not vim.loop.fs_stat(lazypath) then + vim.fn.system { + 'git', + 'clone', + '--filter=blob:none', + 'https://github.com/folke/lazy.nvim.git', + '--branch=stable', -- latest stable release + lazypath, + } + end + return lazypath + end + + local isNixCats = vim.g[ [[nixCats-special-rtp-entry-nixCats]] ] ~= nil + local lazypath + if not isNixCats then + -- No nixCats? Not nix. Do it normally + lazypath = regularLazyDownload() + vim.opt.rtp:prepend(lazypath) + else + local nixCats = require('nixCats') + -- Else, its nix, so we wrap lazy with a few extra config options + lazypath = nixLazyPath + -- and also we probably dont have to download lazy either + if lazypath == nil then + lazypath = regularLazyDownload() + end + + local oldPath + local lazypatterns + local fallback + if type(lazyCFG) == "table" and type(lazyCFG.dev) == "table" then + lazypatterns = lazyCFG.dev.patterns + fallback = lazyCFG.dev.fallback + oldPath = lazyCFG.dev.path + end + + local myNeovimPackages = nixCats.vimPackDir .. "/pack/myNeovimPackages" + + local newLazyOpts = { + performance = { + rtp = { + reset = false, + }, + }, + dev = { + path = function(plugin) + local path = nil + if type(oldPath) == "string" and vim.fn.isdirectory(oldPath .. "/" .. plugin.name) == 1 then + path = oldPath .. "/" .. plugin.name + elseif type(oldPath) == "function" then + path = oldPath(plugin) + if type(path) ~= "string" then + path = nil + end + end + if path == nil then + if vim.fn.isdirectory(myNeovimPackages .. "/start/" .. plugin.name) == 1 then + path = myNeovimPackages .. "/start/" .. plugin.name + elseif vim.fn.isdirectory(myNeovimPackages .. "/opt/" .. plugin.name) == 1 then + path = myNeovimPackages .. "/opt/" .. plugin.name + else + path = "~/projects/" .. plugin.name + end + end + return path + end, + patterns = lazypatterns or { "" }, + fallback = fallback == nil and true or fallback, + } + } + lazyCFG = vim.tbl_deep_extend("force", lazyCFG or {}, newLazyOpts) + -- do the reset we disabled without removing important stuff + local cfgdir = nixCats.configDir + vim.opt.rtp = { + cfgdir, + nixCats.nixCatsPath, + nixCats.pawsible.allPlugins.ts_grammar_path, + vim.fn.stdpath("data") .. "/site", + lazypath, + vim.env.VIMRUNTIME, + vim.fn.fnamemodify(vim.v.progpath, ":p:h:h") .. "/lib/nvim", + cfgdir .. "/after", + } + end + + if lazySpecs then + require('lazy').setup(lazySpecs, lazyCFG) + else + require('lazy').setup(lazyCFG) + end +end + +return M diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/lua/plugins/init.lua @@ -0,0 +1 @@ +return {} diff --git a/nix/mkNeovim.nix b/nix/mkNeovim.nix deleted file mode 100644 index cf03df6..0000000 --- a/nix/mkNeovim.nix +++ /dev/null @@ -1,219 +0,0 @@ -# Function for creating a Neovim derivation -{ - pkgs, - lib, - stdenv, - # - # Set by the overlay to ensure we use a compatible version of `wrapNeovimUnstable` - pkgs-wrapNeovim ? pkgs, -}: -with lib; - { - # NVIM_APPNAME - Defaults to 'nvim' if not set. - # If set to something else, this will also rename the binary. - appName ? null, - # - # The Neovim package to wrap - neovim-unwrapped ? pkgs-wrapNeovim.neovim-unwrapped, - # - # List of plugins - plugins ? [], - # - # List of dev plugins (will be bootstrapped) - useful for plugin developers - # { name = ; url = ; } - devPlugins ? [], - # - # Regexes for config files to ignore, relative to the nvim directory. - # e.g. [ "^plugin/neogit.lua" "^ftplugin/.*.lua" ] - ignoreConfigRegexes ? [], - # - # Extra runtime dependencies (e.g. ripgrep, ...) - extraPackages ? [], - # - # - # The below arguments can typically be left as their defaults - # - # Additional lua packages (not plugins), e.g. from luarocks.org. - # e.g. p: [p.jsregexp] - extraLuaPackages ? p: [], - # - # Additional python 3 packages - extraPython3Packages ? p: [], - # - withPython3 ? true, # Build Neovim with Python 3 support? - withRuby ? false, # Build Neovim with Ruby support? - withNodeJs ? false, # Build Neovim with NodeJS support? - withSqlite ? true, # Add sqlite? This is a dependency for some plugins - # - # You probably don't want to create vi or vim aliases - # if the appName is something different than "nvim" - # - # Add a "vi" binary to the build output as an alias? - viAlias ? appName == null || appName == "nvim", - # - # Add a "vim" binary to the build output as an alias? - vimAlias ? appName == null || appName == "nvim", - }: let - externalPackages = extraPackages ++ (optionals withSqlite [pkgs.sqlite]); - - # Map all plugins to an attrset { plugin = ; config = ; optional = ; ... } - normalizedPlugins = - map ( - x: - if x ? plugin - then x - else {plugin = x;} - ) - plugins; - - # This nixpkgs util function creates an attrset - # that pkgs.wrapNeovimUnstable uses to configure the Neovim build. - neovimConfig = pkgs-wrapNeovim.neovimUtils.makeNeovimConfig { - inherit extraPython3Packages withPython3 withRuby withNodeJs viAlias vimAlias; - plugins = normalizedPlugins; - }; - - # This uses the ignoreConfigRegexes list to filter - # the nvim directory - nvimRtpSrc = let - src = ../nvim; - in - lib.cleanSourceWith { - inherit src; - name = "nvim-rtp-src"; - filter = path: tyoe: let - srcPrefix = toString src + "/"; - relPath = lib.removePrefix srcPrefix (toString path); - in - lib.all (regex: builtins.match regex relPath == null) ignoreConfigRegexes; - }; - - # Split runtimepath into 3 directories: - # - lua, to be prepended to the rtp at the beginning of init.lua - # - nvim, containing plugin, ftplugin, ... subdirectories - # - after, to be sourced last in the startup initialization - # See also: https://neovim.io/doc/user/starting.html - nvimRtp = stdenv.mkDerivation { - name = "nvim-rtp"; - src = nvimRtpSrc; - - buildPhase = '' - mkdir -p $out/nvim - mkdir -p $out/lua - rm init.lua - ''; - - installPhase = '' - cp -r lua $out/lua - rm -r lua - # Copy nvim/after only if it exists - if [ -d "after" ]; then - cp -r after $out/after - rm -r after - fi - # Copy rest of nvim/ subdirectories only if they exist - if [ ! -z "$(ls -A)" ]; then - cp -r -- * $out/nvim - fi - ''; - }; - - # The final init.lua content that we pass to the Neovim wrapper. - # It wraps the user init.lua, prepends the lua lib directory to the RTP - # and prepends the nvim and after directory to the RTP - # It also adds logic for bootstrapping dev plugins (for plugin developers) - initLua = - '' - vim.loader.enable() - -- prepend lua directory - vim.opt.rtp:prepend('${nvimRtp}/lua') - '' - # Wrap init.lua - + (builtins.readFile ../nvim/init.lua) - # Bootstrap/load dev plugins - + optionalString (devPlugins != []) ( - '' - local dev_pack_path = vim.fn.stdpath('data') .. '/site/pack/dev' - local dev_plugins_dir = dev_pack_path .. '/opt' - local dev_plugin_path - '' - + strings.concatMapStringsSep - "\n" - (plugin: '' - dev_plugin_path = dev_plugins_dir .. '/${plugin.name}' - if vim.fn.empty(vim.fn.glob(dev_plugin_path)) > 0 then - vim.notify('Bootstrapping dev plugin ${plugin.name} ...', vim.log.levels.INFO) - vim.cmd('!${pkgs.git}/bin/git clone ${plugin.url} ' .. dev_plugin_path) - end - vim.cmd('packadd! ${plugin.name}') - '') - devPlugins - ) - # Prepend nvim and after directories to the runtimepath - # NOTE: This is done after init.lua, - # because of a bug in Neovim that can cause filetype plugins - # to be sourced prematurely, see https://github.com/neovim/neovim/issues/19008 - # We prepend to ensure that user ftplugins are sourced before builtin ftplugins. - + '' - vim.opt.rtp:prepend('${nvimRtp}/nvim') - vim.opt.rtp:prepend('${nvimRtp}/after') - ''; - - # Add arguments to the Neovim wrapper script - extraMakeWrapperArgs = builtins.concatStringsSep " " ( - # Set the NVIM_APPNAME environment variable - (optional (appName != "nvim" && appName != null && appName != "") - ''--set NVIM_APPNAME "${appName}"'') - # Add external packages to the PATH - ++ (optional (externalPackages != []) - ''--prefix PATH : "${makeBinPath externalPackages}"'') - # Set the LIBSQLITE_CLIB_PATH if sqlite is enabled - ++ (optional withSqlite - ''--set LIBSQLITE_CLIB_PATH "${pkgs.sqlite.out}/lib/libsqlite3.so"'') - # Set the LIBSQLITE environment variable if sqlite is enabled - ++ (optional withSqlite - ''--set LIBSQLITE "${pkgs.sqlite.out}/lib/libsqlite3.so"'') - ); - - luaPackages = neovim-unwrapped.lua.pkgs; - resolvedExtraLuaPackages = extraLuaPackages luaPackages; - - # Native Lua libraries - extraMakeWrapperLuaCArgs = - optionalString (resolvedExtraLuaPackages != []) - ''--suffix LUA_CPATH ";" "${concatMapStringsSep ";" luaPackages.getLuaCPath resolvedExtraLuaPackages}"''; - - # Lua libraries - extraMakeWrapperLuaArgs = - optionalString (resolvedExtraLuaPackages != []) - ''--suffix LUA_PATH ";" "${concatMapStringsSep ";" luaPackages.getLuaPath resolvedExtraLuaPackages}"''; - - # wrapNeovimUnstable is the nixpkgs utility function for building a Neovim derivation. - neovim-wrapped = pkgs-wrapNeovim.wrapNeovimUnstable neovim-unwrapped (neovimConfig - // { - luaRcContent = initLua; - wrapperArgs = - escapeShellArgs neovimConfig.wrapperArgs - + " " - + extraMakeWrapperArgs - + " " - + extraMakeWrapperLuaCArgs - + " " - + extraMakeWrapperLuaArgs; - wrapRc = true; - }); - - isCustomAppName = appName != null && appName != "nvim"; - in - neovim-wrapped.overrideAttrs (oa: { - buildPhase = - oa.buildPhase - # If a custom NVIM_APPNAME has been set, rename the `nvim` binary - + lib.optionalString isCustomAppName '' - mv $out/bin/nvim $out/bin/${lib.escapeShellArg appName} - ''; - meta.mainProgram = - if isCustomAppName - then appName - else oa.meta.mainProgram; - }) diff --git a/nix/neovim-overlay.nix b/nix/neovim-overlay.nix deleted file mode 100644 index 233eb5c..0000000 --- a/nix/neovim-overlay.nix +++ /dev/null @@ -1,208 +0,0 @@ -# This overlay, when applied to nixpkgs, adds the final neovim derivation to nixpkgs. -{inputs}: final: prev: -with final.pkgs.lib; let - pkgs = final; - - # Use this to create a plugin from a flake input - mkNvimPlugin = src: pname: - pkgs.vimUtils.buildVimPlugin { - inherit pname src; - version = src.lastModifiedDate; - }; - - # Make sure we use the pinned nixpkgs instance for wrapNeovimUnstable, - # otherwise it could have an incompatible signature when applying this overlay. - pkgs-wrapNeovim = inputs.nixpkgs.legacyPackages.${pkgs.system}; - - # This is the helper function that builds the Neovim derivation. - mkNeovim = pkgs.callPackage ./mkNeovim.nix {inherit pkgs-wrapNeovim;}; - - # A plugin can either be a package or an attrset, such as - # { plugin = ; # the package, e.g. pkgs.vimPlugins.nvim-cmp - # config = ; # String; a config that will be loaded with the plugin - # # Boolean; Whether to automatically load the plugin as a 'start' plugin, - # # or as an 'opt' plugin, that can be loaded with `:packadd!` - # optional = ; # Default: false - # ... - # } - all-plugins = with pkgs.vimPlugins; [ - # Base - lz-n - snacks-nvim - - # Util - plenary-nvim - nui-nvim - persistence-nvim - mini-hipatterns - project-nvim - (mkNvimPlugin inputs.nerdy-nvim "nerdy.nvim") - - # Colorscheme - rose-pine - - # UI - mini-icons - alpha-nvim - bufferline-nvim - lualine-nvim - noice-nvim - indent-blankline-nvim - mini-animate - nvim-treesitter-context - diffview-nvim - no-neck-pain-nvim - - # Editor - neo-tree-nvim - grug-far-nvim - flash-nvim - which-key-nvim - gitsigns-nvim - trouble-nvim - todo-comments-nvim - aerial-nvim - fzf-lua - refactoring-nvim - (mkNvimPlugin inputs.nvim-emmet "nvim-emmet") - - # Treesitter - nvim-treesitter-textobjects - nvim-ts-autotag - (nvim-treesitter.withPlugins ( - plugins: - with plugins; [ - bash - comment - css - diff - fish - git_config - gitignore - html - hyprlang - ini - javascript - jsdoc - json - jsonc - just - lua - luadoc - markdown - markdown_inline - nix - just - phpdoc - php_only - printf - python - query - rasi - regex - scss - ssh_config - toml - tsx - typescript - vim - vimdoc - xml - yaml - ] - )) - - # Coding - blink-cmp - luasnip - friendly-snippets - lexima-vim - (mkNvimPlugin inputs.neotab-nvim "neotab.nvim") - ts-comments-nvim - mini-comment - mini-ai - mini-surround - yanky-nvim - - # Formatting - conform-nvim - - # Linting - nvim-lint - - # Test - nvim-nio - neotest - - # Languages - vim-caddyfile - ]; - - extraPackages = with pkgs; [ - # System packages - ripgrep - lazygit # snacks.nvim - fzf # fzf-lua - fd # fzf-lua - bat # fzf-lua - delta # fzf-lua - chafa # fzf-lua - - # Language servers - bash-language-server - emmet-language-server - lua-language-server - nil - # inputs.nixd.packages.${pkgs.system}.nixd - phpactor - stylelint-lsp - taplo - vscode-langservers-extracted # html, css, json, eslint - - # Linters - biome - shellcheck - statix - yamllint - - # Formatters - alejandra - blade-formatter - fish - php84Packages.php-cs-fixer - nodePackages.prettier - rustywind - shfmt - stylelint - stylua - ]; -in { - # This is the neovim derivation returned by the overlay. - nvim-pkg = mkNeovim { - plugins = all-plugins; - neovim-unwrapped = inputs.neovim-nightly.packages.${pkgs.system}.default; - inherit extraPackages; - }; - - # This can be symlinked in the devShell's shellHook. - nvim-luarc-json = final.mk-luarc-json { - plugins = all-plugins; - globals = ["MarleyVim"]; - runtimePath = ["nvim/lua/?.lua" "nvim/lua/?/init.lua"]; - }; - - # You can add as many derivations as you like. - # Use `ignoreConfigRegexes` to filter out config - # files you would not like to include. - # - # For example: - # - # nvim-pkg-no-telescope = mkNeovim { - # plugins = []; - # ignoreConfigRegexes = [ - # "^plugin/telescope.lua" - # "^ftplugin/.*.lua" - # ]; - # inherit extraPackages; - # }; -} diff --git a/nvim-nix.svg b/nvim-nix.svg deleted file mode 100644 index 882567a..0000000 --- a/nvim-nix.svg +++ /dev/null @@ -1,317 +0,0 @@ - - - - neovim-mark@2x - Created with Sketch (http://www.bohemiancoding.com/sketch) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - neovim-mark@2x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nvim/init.lua b/nvim/init.lua deleted file mode 100644 index 4c18dd7..0000000 --- a/nvim/init.lua +++ /dev/null @@ -1,19 +0,0 @@ --- Native plugins -vim.cmd.filetype('plugin', 'indent', 'on') - --- let sqlite.lua (which some plugins depend on) know where to find sqlite ----@diagnostic disable-next-line:missing-parameter -vim.g.sqlite_clib_path = require('luv').os_getenv('LIBSQLITE') - -_G.MarleyVim = require('lib') - -require('options') -require('keymaps') -require('autocmds') - -require('snacks-nvim') -require('lsp') - -require('lz.n').load('plugins') - -vim.cmd('colorscheme rose-pine') diff --git a/nvim/lsp/bash-language-server.lua b/nvim/lsp/bash-language-server.lua deleted file mode 100644 index 534a8af..0000000 --- a/nvim/lsp/bash-language-server.lua +++ /dev/null @@ -1,11 +0,0 @@ -return { - filetypes = { 'bash', 'sh' }, - cmd = { 'bash-language-server', 'start' }, - root_markers = { '.git' }, - - settings = { - bashIde = { - globPattern = vim.env.GLOB_PATTERN or '*@(.sh|.inc|.bash|.command)', - }, - }, -} diff --git a/nvim/lsp/emmet-language-server.lua b/nvim/lsp/emmet-language-server.lua deleted file mode 100644 index 3b33a2d..0000000 --- a/nvim/lsp/emmet-language-server.lua +++ /dev/null @@ -1,20 +0,0 @@ -return { - cmd = { 'emmet-language-server', '--stdio' }, - filetypes = { - 'blade', - 'css', - 'eruby', - 'html', - 'htmlangular', - 'htmldjango', - 'javascriptreact', - 'less', - 'liquid', - 'pug', - 'sass', - 'scss', - 'typescriptreact', - 'vue', - }, - root_markers = { '.git' }, -} diff --git a/nvim/lsp/lua-language-server.lua b/nvim/lsp/lua-language-server.lua deleted file mode 100644 index a9106e7..0000000 --- a/nvim/lsp/lua-language-server.lua +++ /dev/null @@ -1,39 +0,0 @@ -return { - cmd = { 'lua-language-server' }, - filetypes = { 'lua' }, - root_markers = { - '.luarc.json', - '.luarc.jsonc', - '.luacheckrc', - '.stylua.toml', - 'stylua.toml', - 'selene.toml', - 'selene.yml', - '.git', - }, - - settings = { - Lua = { - workspace = { - checkThirdParty = false, - }, - codeLens = { - enable = true, - }, - completion = { - callSnippet = 'Replace', - }, - doc = { - privateName = { '^_' }, - }, - hint = { - enable = true, - setType = false, - paramType = true, - paramName = 'Disable', - semicolon = 'Disable', - arrayIndex = 'Disable', - }, - }, - }, -} diff --git a/nvim/lsp/nil.lua b/nvim/lsp/nil.lua deleted file mode 100644 index ee0ce92..0000000 --- a/nvim/lsp/nil.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - cmd = { 'nil' }, - filetypes = { 'nix' }, - root_markers = { 'flake.nix', '.git' }, - - settings = { - ['nil'] = { - flake = { - autoArchive = true, - autoEvalInputs = true, - }, - }, - }, -} diff --git a/nvim/lsp/nixd.lua b/nvim/lsp/nixd.lua deleted file mode 100644 index 178f28c..0000000 --- a/nvim/lsp/nixd.lua +++ /dev/null @@ -1,24 +0,0 @@ -return { - cmd = { 'nixd' }, - filetypes = { 'nix' }, - root_markers = { 'flake.nix', '.git' }, - - settings = { - nixd = { - formatting = { - command = { 'alejandra' }, - }, - options = { - nixos = { - expr = '(builtins.getFlake "/home/marley/marleyos").nixosConfigurations.nyx.options', - }, - ['home-manager'] = { - expr = '(builtins.getFlake "/home/marley/marleyos").homeConfigurations."marley@nyx".options', - }, - ['nix-darwin'] = { - expr = '(builtins.getFlake "/home/marley/marleyos").darwinConfigurations.mairley.options', - }, - }, - }, - }, -} diff --git a/nvim/lsp/phpactor.lua b/nvim/lsp/phpactor.lua deleted file mode 100644 index 65ddafd..0000000 --- a/nvim/lsp/phpactor.lua +++ /dev/null @@ -1,10 +0,0 @@ -return { - cmd = { 'phpactor', 'language-server' }, - filetypes = { 'php', 'blade' }, - root_markers = { - 'composer.json', - '.git', - '.phpactor.json', - '.phpactor.yml', - }, -} diff --git a/nvim/lsp/stylelint-lsp.lua b/nvim/lsp/stylelint-lsp.lua deleted file mode 100644 index cd59152..0000000 --- a/nvim/lsp/stylelint-lsp.lua +++ /dev/null @@ -1,29 +0,0 @@ -return { - cmd = { 'stylelint-lsp', '--stdio' }, - filetypes = { - 'css', - 'less', - 'scss', - 'sugarss', - 'vue', - 'wxss', - }, - root_markers = { - '.stylelintrc', - '.stylelintrc.cjs', - '.stylelintrc.js', - '.stylelintrc.json', - '.stylelintrc.yaml', - '.stylelintrc.yml', - 'stylelint.config.cjs', - 'stylelint.config.js', - }, - - settings = { - stylelintplus = { - autoFixOnFormat = true, - validateOnSave = true, - validateOnType = false, - }, - }, -} diff --git a/nvim/lsp/taplo.lua b/nvim/lsp/taplo.lua deleted file mode 100644 index d1a3757..0000000 --- a/nvim/lsp/taplo.lua +++ /dev/null @@ -1,5 +0,0 @@ -return { - cmd = { 'taplo', 'lsp', 'stdio' }, - filetypes = { 'toml' }, - root_markers = { '.git' }, -} diff --git a/nvim/lsp/vscode-css-language-server.lua b/nvim/lsp/vscode-css-language-server.lua deleted file mode 100644 index 054e6ec..0000000 --- a/nvim/lsp/vscode-css-language-server.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - cmd = { 'vscode-css-language-server', '--stdio' }, - filetypes = { 'css', 'scss', 'less' }, - root_markers = { 'package.json', '.git' }, - - init_options = { provideFormatter = true }, - settings = { - css = { validate = true }, - scss = { validate = true }, - less = { validate = true }, - }, -} diff --git a/nvim/lsp/vscode-html-language-server.lua b/nvim/lsp/vscode-html-language-server.lua deleted file mode 100644 index 09c5a32..0000000 --- a/nvim/lsp/vscode-html-language-server.lua +++ /dev/null @@ -1,11 +0,0 @@ -return { - cmd = { 'vscode-html-language-server', '--stdio' }, - filetypes = { 'html', 'templ', 'liquid' }, - root_markers = { 'package.json', '.git' }, - - init_options = { - provideFormatter = true, - embeddedLanguages = { css = true, javascript = true }, - configurationSection = { 'html', 'css', 'javascript' }, - }, -} diff --git a/nvim/lua/autocmds.lua b/nvim/lua/autocmds.lua deleted file mode 100644 index 43a04b6..0000000 --- a/nvim/lua/autocmds.lua +++ /dev/null @@ -1,139 +0,0 @@ -local function augroup(name) - return vim.api.nvim_create_augroup('marleyvim_' .. name, { clear = true }) -end - -local autocmd = vim.api.nvim_create_autocmd - -autocmd({ 'FocusGained', 'TermClose', 'TermLeave' }, { - desc = 'Reload file when changed if needed', - group = augroup('checktime'), - callback = function() - if vim.o.buftype ~= 'nofile' then - vim.cmd('checktime') - end - end, -}) - -autocmd({ 'TextYankPost' }, { - desc = 'Highlight on yank', - group = augroup('highlight_yank'), - callback = function() - (vim.hl or vim.highlight).on_yank() - end, -}) - -autocmd({ 'VimResized' }, { - desc = 'Resize splits on window resize', - group = augroup('resize_splits'), - callback = function() - local current_tab = vim.fn.tabpagenr() - - vim.cmd('tabdo wincmd =') - vim.cmd('tabnext ' .. current_tab) - end, -}) - -autocmd({ 'BufReadPost' }, { - desc = 'Go to last location when opening a buffer', - group = augroup('last_loc'), - callback = function(event) - local exclude = { 'gitcommit' } - local buf = event.buf - - if - vim.tbl_contains(exclude, vim.bo[buf].filetype) - or vim.b[buf].marleyvim_last_loc - then - return - end - - vim.b[buf].marleyvim_last_loc = true - - local mark = vim.api.nvim_buf_get_mark(buf, '"') - local lcount = vim.api.nvim_buf_line_count(buf) - - if mark[1] > 0 and mark[1] <= lcount then - pcall(vim.api.nvim_win_set_cursor, 0, mark) - end - end, -}) - -autocmd({ 'FileType' }, { - desc = 'Close some filetypes with ', - group = augroup('close_with_q'), - pattern = { - 'PlenaryTestPopup', - 'checkhealth', - 'dbout', - 'gitsigns-blame', - 'grug-far', - 'help', - 'lspinfo', - 'neotest-output', - 'neotest-output-panel', - 'neotest-summary', - 'notify', - 'qf', - 'snacks_win', - 'spectre_panel', - 'startuptime', - 'tsplayground', - }, - callback = function(event) - vim.bo[event.buf].buflisted = false - - vim.schedule(function() - vim.keymap.set({ 'n' }, 'q', function() - vim.cmd('close') - pcall(vim.api.nvim_buf_delete, event.buf, { force = true }) - end, { - desc = 'Quit buffer', - buffer = event.buf, - silent = true, - }) - end) - end, -}) - -autocmd({ 'FileType' }, { - desc = 'Make it easier to close man-files', - group = augroup('man_unlisted'), - pattern = { 'man' }, - callback = function(event) - vim.bo[event.buf].buflisted = false - end, -}) - -autocmd({ 'FileType' }, { - desc = 'Fix conceallevel for JSON files', - group = augroup('json_conceal'), - pattern = { 'json', 'jsonc', 'json5' }, - callback = function() - vim.opt_local.conceallevel = 0 - end, -}) - -autocmd({ 'BufWritePre' }, { - desc = 'Auto create missing directories when saving a file', - group = augroup('auto_create_dir'), - callback = function(event) - if event.match:match('^%w%w+:[\\/][\\/') then - return - end - - local file = vim.uv.fs_realpath(event.match) or event.match - - vim.fn.mkdir(vim.fn.fnamemodify(file, ':p:h'), 'p') - end, -}) - -autocmd({ 'BufWinEnter' }, { - desc = 'Open help files in vertical split to the right', - group = augroup('help_window_right'), - pattern = { '*.txt' }, - callback = function() - if vim.o.filetype == 'help' then - vim.cmd.wincmd('L') - end - end, -}) diff --git a/nvim/lua/colors.lua b/nvim/lua/colors.lua deleted file mode 100644 index 0a39f22..0000000 --- a/nvim/lua/colors.lua +++ /dev/null @@ -1,381 +0,0 @@ ----@class colors ----@field tailwind colors.tailwind ----@field [string] colorNames -local M = {} - ----@alias colorNames "azure" | "blue" | "cyan" | "green" | "grey" | "orange" | "purple" | "red" | "yellow" - ----@type {[string]:colorNames} -M.colors = { - around = 'purple', - buffers = 'cyan', - change = 'cyan', - delete = 'red', - diagnostics = 'green', - explorer = 'yellow', - fold = 'purple', - format = 'purple', - git = 'orange', - go_to = 'cyan', - inner = 'purple', - notifications = 'orange', - replace = 'blue', - search = 'green', - sessions = 'azure', - spell = 'red', - surround = 'purple', - ui = 'green', - visual = 'purple', - window = 'blue', - yank = 'yellow', -} - ----@class colorSteps ----@field [50] string ----@field [100] string ----@field [200] string ----@field [300] string ----@field [400] string ----@field [500] string ----@field [600] string ----@field [700] string ----@field [800] string ----@field [900] string ----@field [950] string - ----@class colors.tailwind ----@field slate colorSteps ----@field gray colorSteps ----@field zinc colorSteps ----@field neutral colorSteps ----@field stone colorSteps ----@field red colorSteps ----@field orange colorSteps ----@field amber colorSteps ----@field yellow colorSteps ----@field lime colorSteps ----@field green colorSteps ----@field emerald colorSteps ----@field teal colorSteps ----@field cyan colorSteps ----@field sky colorSteps ----@field blue colorSteps ----@field indigo colorSteps ----@field violet colorSteps ----@field purple colorSteps ----@field fuchsia colorSteps ----@field pink colorSteps ----@field rose colorSteps - ----@type colors.tailwind -M.tailwind = { - slate = { - [50] = 'f8fafc', - [100] = 'f1f5f9', - [200] = 'e2e8f0', - [300] = 'cbd5e1', - [400] = '94a3b8', - [500] = '64748b', - [600] = '475569', - [700] = '334155', - [800] = '1e293b', - [900] = '0f172a', - [950] = '020617', - }, - - gray = { - [50] = 'f9fafb', - [100] = 'f3f4f6', - [200] = 'e5e7eb', - [300] = 'd1d5db', - [400] = '9ca3af', - [500] = '6b7280', - [600] = '4b5563', - [700] = '374151', - [800] = '1f2937', - [900] = '111827', - [950] = '030712', - }, - - zinc = { - [50] = 'fafafa', - [100] = 'f4f4f5', - [200] = 'e4e4e7', - [300] = 'd4d4d8', - [400] = 'a1a1aa', - [500] = '71717a', - [600] = '52525b', - [700] = '3f3f46', - [800] = '27272a', - [900] = '18181b', - [950] = '09090B', - }, - - neutral = { - [50] = 'fafafa', - [100] = 'f5f5f5', - [200] = 'e5e5e5', - [300] = 'd4d4d4', - [400] = 'a3a3a3', - [500] = '737373', - [600] = '525252', - [700] = '404040', - [800] = '262626', - [900] = '171717', - [950] = '0a0a0a', - }, - - stone = { - [50] = 'fafaf9', - [100] = 'f5f5f4', - [200] = 'e7e5e4', - [300] = 'd6d3d1', - [400] = 'a8a29e', - [500] = '78716c', - [600] = '57534e', - [700] = '44403c', - [800] = '292524', - [900] = '1c1917', - [950] = '0a0a0a', - }, - - red = { - [50] = 'fef2f2', - [100] = 'fee2e2', - [200] = 'fecaca', - [300] = 'fca5a5', - [400] = 'f87171', - [500] = 'ef4444', - [600] = 'dc2626', - [700] = 'b91c1c', - [800] = '991b1b', - [900] = '7f1d1d', - [950] = '450a0a', - }, - - orange = { - [50] = 'fff7ed', - [100] = 'ffedd5', - [200] = 'fed7aa', - [300] = 'fdba74', - [400] = 'fb923c', - [500] = 'f97316', - [600] = 'ea580c', - [700] = 'c2410c', - [800] = '9a3412', - [900] = '7c2d12', - [950] = '431407', - }, - - amber = { - [50] = 'fffbeb', - [100] = 'fef3c7', - [200] = 'fde68a', - [300] = 'fcd34d', - [400] = 'fbbf24', - [500] = 'f59e0b', - [600] = 'd97706', - [700] = 'b45309', - [800] = '92400e', - [900] = '78350f', - [950] = '451a03', - }, - - yellow = { - [50] = 'fefce8', - [100] = 'fef9c3', - [200] = 'fef08a', - [300] = 'fde047', - [400] = 'facc15', - [500] = 'eab308', - [600] = 'ca8a04', - [700] = 'a16207', - [800] = '854d0e', - [900] = '713f12', - [950] = '422006', - }, - - lime = { - [50] = 'f7fee7', - [100] = 'ecfccb', - [200] = 'd9f99d', - [300] = 'bef264', - [400] = 'a3e635', - [500] = '84cc16', - [600] = '65a30d', - [700] = '4d7c0f', - [800] = '3f6212', - [900] = '365314', - [950] = '1a2e05', - }, - - green = { - [50] = 'f0fdf4', - [100] = 'dcfce7', - [200] = 'bbf7d0', - [300] = '86efac', - [400] = '4ade80', - [500] = '22c55e', - [600] = '16a34a', - [700] = '15803d', - [800] = '166534', - [900] = '14532d', - [950] = '052e16', - }, - - emerald = { - [50] = 'ecfdf5', - [100] = 'd1fae5', - [200] = 'a7f3d0', - [300] = '6ee7b7', - [400] = '34d399', - [500] = '10b981', - [600] = '059669', - [700] = '047857', - [800] = '065f46', - [900] = '064e3b', - [950] = '022c22', - }, - - teal = { - [50] = 'f0fdfa', - [100] = 'ccfbf1', - [200] = '99f6e4', - [300] = '5eead4', - [400] = '2dd4bf', - [500] = '14b8a6', - [600] = '0d9488', - [700] = '0f766e', - [800] = '115e59', - [900] = '134e4a', - [950] = '042f2e', - }, - - cyan = { - [50] = 'ecfeff', - [100] = 'cffafe', - [200] = 'a5f3fc', - [300] = '67e8f9', - [400] = '22d3ee', - [500] = '06b6d4', - [600] = '0891b2', - [700] = '0e7490', - [800] = '155e75', - [900] = '164e63', - [950] = '083344', - }, - - sky = { - [50] = 'f0f9ff', - [100] = 'e0f2fe', - [200] = 'bae6fd', - [300] = '7dd3fc', - [400] = '38bdf8', - [500] = '0ea5e9', - [600] = '0284c7', - [700] = '0369a1', - [800] = '075985', - [900] = '0c4a6e', - [950] = '082f49', - }, - - blue = { - [50] = 'eff6ff', - [100] = 'dbeafe', - [200] = 'bfdbfe', - [300] = '93c5fd', - [400] = '60a5fa', - [500] = '3b82f6', - [600] = '2563eb', - [700] = '1d4ed8', - [800] = '1e40af', - [900] = '1e3a8a', - [950] = '172554', - }, - - indigo = { - [50] = 'eef2ff', - [100] = 'e0e7ff', - [200] = 'c7d2fe', - [300] = 'a5b4fc', - [400] = '818cf8', - [500] = '6366f1', - [600] = '4f46e5', - [700] = '4338ca', - [800] = '3730a3', - [900] = '312e81', - [950] = '1e1b4b', - }, - - violet = { - [50] = 'f5f3ff', - [100] = 'ede9fe', - [200] = 'ddd6fe', - [300] = 'c4b5fd', - [400] = 'a78bfa', - [500] = '8b5cf6', - [600] = '7c3aed', - [700] = '6d28d9', - [800] = '5b21b6', - [900] = '4c1d95', - [950] = '2e1065', - }, - - purple = { - [50] = 'faf5ff', - [100] = 'f3e8ff', - [200] = 'e9d5ff', - [300] = 'd8b4fe', - [400] = 'c084fc', - [500] = 'a855f7', - [600] = '9333ea', - [700] = '7e22ce', - [800] = '6b21a8', - [900] = '581c87', - [950] = '3b0764', - }, - - fuchsia = { - [50] = 'fdf4ff', - [100] = 'fae8ff', - [200] = 'f5d0fe', - [300] = 'f0abfc', - [400] = 'e879f9', - [500] = 'd946ef', - [600] = 'c026d3', - [700] = 'a21caf', - [800] = '86198f', - [900] = '701a75', - [950] = '4a044e', - }, - - pink = { - [50] = 'fdf2f8', - [100] = 'fce7f3', - [200] = 'fbcfe8', - [300] = 'f9a8d4', - [400] = 'f472b6', - [500] = 'ec4899', - [600] = 'db2777', - [700] = 'be185d', - [800] = '9d174d', - [900] = '831843', - [950] = '500724', - }, - - rose = { - [50] = 'fff1f2', - [100] = 'ffe4e6', - [200] = 'fecdd3', - [300] = 'fda4af', - [400] = 'fb7185', - [500] = 'f43f5e', - [600] = 'e11d48', - [700] = 'be123c', - [800] = '9f1239', - [900] = '881337', - [950] = '4c0519', - }, -} - -return M diff --git a/nvim/lua/icons.lua b/nvim/lua/icons.lua deleted file mode 100644 index cb7f6cc..0000000 --- a/nvim/lua/icons.lua +++ /dev/null @@ -1,95 +0,0 @@ -return { - around = '󰅪', - bottom = '', - center = '󰘢', - change = '', - char = '󰾹', - comment = '', - dashboard = { - quit = '', - mru = '', - project = '', - }, - delete = '󰆴', - diagnostics = { - Error = '', - Warn = '', - Hint = '', - Info = '', - }, - explorer = '󰙅', - first = '󰘀', - fold = '', - format = '󰉼', - git = { - added = ' ', - modified = ' ', - removed = ' ', - unstaged = '󰄱', - staged = '󰱒', - diff = '󰫙', - }, - go_to = '', - indent = { - left = '󰉵', - decrease = '󰉵', - right = '󰉶', - increase = '󰉶', - }, - inner = '󰅩', - last = '󰘁', - lazygit = '', - left = '', - lsp = { - Array = '', - Boolean = '◩', - Class = '', - Color = '', - Control = '', - Constant = '󰏿', - Constructor = '', - Enum = '', - EnumMember = '', - Event = '', - Field = '', - File = '', - Folder = '', - Function = '󰊕', - Interface = '', - Key = '󰌋', - Keyword = '', - Method = '󰊕', - Module = '', - Namespace = '󰌗', - Null = '', - Number = '󰎠', - Object = '', - Operator = '󰆕', - Package = '', - Property = '', - Reference = '', - Snippet = '󱄽', - String = '', - Struct = '', - Text = '', - TypeParameter = '', - Unit = '', - Value = '', - Variable = '', - }, - next = '', - notifications = '󰈸', - prev = '', - registers = '󰅍', - replace = '', - right = '', - sessions = '', - spell = '', - search = '', - top = '', - ui = '󰙵', - undo = '', - visual = '', - word = '', - yank = '', -} diff --git a/nvim/lua/keymaps.lua b/nvim/lua/keymaps.lua deleted file mode 100644 index ab1cae5..0000000 --- a/nvim/lua/keymaps.lua +++ /dev/null @@ -1,207 +0,0 @@ -local g = vim.g -local set = vim.keymap.set -local f = string.format - -g.mapleader = ' ' -g.maplocalleader = '\\' - --- Disable arrow key movement -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -for _, key in ipairs({ '', '', '', '' }) do - set({ 'n', 'i' }, key, '') -end - --- Better up/down -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -for dir, key in pairs({ Down = 'j', Up = 'k' }) do - set( - { 'n', 'x' }, - key, - f("v:count == 0 ? 'g%s' : '%s'", key, key), - { desc = dir, expr = true, silent = true } - ) -end - --- Resize windows -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -for key, dir in pairs({ - Up = 'increase', - Down = 'decrease', - Left = 'decrease', - Right = 'increase', -}) do - local sign = (dir == 'increase') and '+' or '-' - - set( - { 'n' }, - f('', key), - f('resize %s4', sign), - { desc = f('%s window height', dir) } - ) -end - --- Buffers -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -for key, dir in pairs({ - [''] = 'previous', - [''] = 'next', - ['[b'] = 'previous', - [']b'] = 'next', -}) do - -- previous -> prev - local prettyDir = dir:sub(1, 4) - - set( - { 'n' }, - key, - f('b%s', dir), - { desc = f('%s buffer', prettyDir) } - ) -end - -set({ 'n' }, 'bD', 'bd', { desc = 'delete buffer and window' }) - --- Clear search & refresh -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -set( - { 'n', 'i' }, - '', - 'noh', - { desc = 'escape and clear hlsearch' } -) - -set( - { 'n' }, - 'ur', - 'nohlsearchdiffupdatenormal! ', - { desc = 'redraw / clear hlsearch / diff update' } -) - --- Better n & N -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -for _, mode in ipairs({ 'n', 'x', 'o' }) do - local zv = (mode == 'n') and ".'zv'" or '' - - set( - { mode }, - 'n', - f("'Nn'[v:searchforward]%s", zv), - { desc = 'next search result', expr = true } - ) - - set( - { mode }, - 'N', - f("'nN'[v:searchforward]%s", zv), - { desc = 'previous search result', expr = true } - ) -end - --- Undo break-points -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -for _, char in ipairs({ ',', '.', ';' }) do - set({ 'i' }, char, f('%su', char)) -end - --- Search docs (keywordprog) -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --- https://til.codeinthehole.com/posts/about-how-to-use-keywordprg-effectively/ -set( - { 'n' }, - 'K', - 'norm! K', - { desc = 'search for word' } -) - --- Better indenting -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -for _, char in ipairs({ '<', '>' }) do - local desc = 'indent ' .. (char == '<' and 'left' or 'right') - - set({ 'v' }, char, f('%sgv', char), { desc = desc }) -end - --- Commenting -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -for key, dir in pairs({ o = 'below', O = 'above' }) do - set( - { 'n' }, - f('gc%s', key), - f('%sVcxnormal gccfxa', key), - { desc = f('add comment %s', dir) } - ) -end - --- New files -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -set({ 'n' }, 'fn', 'enew', { desc = 'new file' }) - --- Locations/quickfixes -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -set({ 'n' }, 'xl', 'lopen', { desc = 'location list' }) -set({ 'n' }, 'xq', 'copen', { desc = 'quickfix list' }) - -for key, dir in pairs({ ['['] = 'previous', [']'] = 'next' }) do - -- previous -> prev - local cmd = dir:sub(1, 4) - - set( - { 'n' }, - f('%sq', key), - f('c%s', cmd), - { desc = f('%s quickfix', dir) } - ) -end - --- Diagnostics -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -set({ 'n' }, 'cd', function() - vim.diagnostic.open_float() -end, { desc = 'line diagnostics' }) - -local function goto_diagnostic(next, severity) - local go = next and vim.diagnostic.goto_next or vim.diagnostic.goto_prev - severity = severity and vim.diagnostic.severity[severity] or nil - return function() - go({ severity = severity }) - end -end - -for key, sev in pairs({ - d = { nil, 'diagnostic' }, - e = { 'ERROR', 'error' }, - w = { 'WARN', 'warning' }, -}) do - set( - { 'n' }, - f(']%s', key), - goto_diagnostic(true, sev[1]), - { desc = f('next %s', sev[2]) } - ) - - set( - { 'n' }, - f('[%s', key), - goto_diagnostic(false, sev[1]), - { desc = f('previous %s', sev[2]) } - ) -end - --- Quit -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -set({ 'n' }, 'qq', 'qa', { desc = 'quit all' }) - --- Inspect -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -set({ 'n' }, 'ui', vim.show_pos, { desc = 'inspect position' }) - --- Window management -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -set({ 'n' }, 'w', '', { desc = 'windows', remap = true }) -set({ 'n' }, '-', 's', { desc = 'split below', remap = true }) -set({ 'n' }, '|', 'v', { desc = 'split right', remap = true }) -set({ 'n' }, 'wd', 'c', { desc = 'delete window', remap = true }) - --- Tab management -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -for key, act in pairs({ - l = 'last', - o = 'only', - f = 'first', - [''] = 'new', - [']'] = 'next', - d = 'close', - ['['] = 'previous', -}) do - local desc = (act == 'only') and 'close other tabs' or f('%s tab', act) - - set( - { 'n' }, - f('%s', key), - f('tab%s', act:lower()), - { desc = desc } - ) -end diff --git a/nvim/lua/lib/init.lua b/nvim/lua/lib/init.lua deleted file mode 100644 index 164a9ba..0000000 --- a/nvim/lua/lib/init.lua +++ /dev/null @@ -1,53 +0,0 @@ ----@class lib -local M = {} - -M.lsp = require('lib.lsp') -M.prettier = require('lib.prettier') - ----Find the root of a project based on `vim.g.root_spec`. Defaults to ----`{ '.git' }` if unset. ----@return string? -function M.root() - local root_spec = vim.g.root_spec or { '.git' } - - return vim.fs.root(0, root_spec) -end - ----Require a file relative to the given prefix, to avoid repetition. ----@param prefix string The string to prefix to all req calls. -function M.local_require(prefix) - ---@param mod string The module to require. - return function(mod) - return require(prefix .. '.' .. mod) - end -end - ----Get and format the foreground of a highlight group. ----@param name string The highlight group name to fetch from. ----@return {fg:string}? -function M.fg(name) - local hl = vim.api.nvim_get_hl(0, { name = name, link = false }) - - return hl and { fg = string.format('#%06x', hl.fg) } or nil -end - ----Generates a function that can be used to create which-key mappings. ----@param color string The color to use for the icon. ----@return function -function M.wkSpec(color) - ---@param lhs string - ---@param rhs string | fun() - ---@param icon string | wk.Icon - ---@param opts? wk.Spec - return function(lhs, rhs, icon, opts) - if type(icon) == 'string' then - icon = { icon = icon, color = color } - else - icon = vim.tbl_deep_extend('force', icon, { color = color }) - end - - return vim.tbl_deep_extend('force', { lhs, rhs, icon = icon }, (opts or {})) - end -end - -return M diff --git a/nvim/lua/lib/lsp.lua b/nvim/lua/lib/lsp.lua deleted file mode 100644 index ead14c1..0000000 --- a/nvim/lua/lib/lsp.lua +++ /dev/null @@ -1,20 +0,0 @@ ----@class lib.lsp -local M = {} - ----Boilerplate to create an autocommand to do something on LspAttach. ----@param callback fun(client:vim.lsp.Client, buffer:number) ----@param name? string -function M.on_attach(callback, name) - return vim.api.nvim_create_autocmd('LspAttach', { - callback = function(args) - local buffer = args.buf ---@type number - local client = vim.lsp.get_client_by_id(args.data.client_id) - - if client and (not name or client.name == name) then - return callback(client, buffer) - end - end, - }) -end - -return M diff --git a/nvim/lua/lib/prettier.lua b/nvim/lua/lib/prettier.lua deleted file mode 100644 index ee7eb53..0000000 --- a/nvim/lua/lib/prettier.lua +++ /dev/null @@ -1,54 +0,0 @@ ----@class lib.prettier -local M = {} - ----@alias ConformCtx {buf: number, filename: string, dirname: string} - -M.supported = { - 'css', - 'graphql', - 'handlebars', - 'html', - 'javascript', - 'javascriptreact', - 'json', - 'jsonc', - 'less', - 'markdown', - 'markdown.mdx', - 'scss', - 'typescript', - 'typescriptreact', - 'vue', - 'yaml', -} - ----Check if a parser exists for the given context. ----@param ctx ConformCtx -function M.has_parser(ctx) - local ft = vim.bo[ctx.buf].filetype --[[@as string]] - - -- Default filetypes are always supported. - if vim.tbl_contains(M.supported, ft) then - return true - end - - -- Otherwise, check if a parser can be inferred. - local inferred = vim.fn.system({ 'prettier', '--file-info', ctx.filename }) - - ---@type boolean, string? - local ok, parser = pcall(function() - return vim.fn.json_decode(inferred).inferredParser - end) - - return ok and parser and parser ~= vim.NIL -end - ----Check if a Prettier config file exists in the current context. ----@param ctx ConformCtx -function M.has_config(ctx) - vim.fn.system({ 'prettier', '--find-config-path', ctx.filename }) - - return vim.v.shell_error == 0 -end - -return M diff --git a/nvim/lua/lsp.lua b/nvim/lua/lsp.lua deleted file mode 100644 index 040c6a0..0000000 --- a/nvim/lua/lsp.lua +++ /dev/null @@ -1,181 +0,0 @@ -local i = require('icons') - --- Diagnostics -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ----@type vim.diagnostic.Opts -local diagnosticConfig = { - underline = true, - update_in_insert = true, - virtual_text = { - spacing = 4, - source = 'if_many', - prefix = function(diagnostic) - for d, icon in pairs(i.diagnostics) do - if diagnostic.severity == vim.diagnostic.severity[d:upper()] then - return icon - end - end - - return '' - end, - }, - severity_sort = true, - signs = { - text = { - [vim.diagnostic.severity.ERROR] = i.diagnostics.Error, - [vim.diagnostic.severity.WARN] = i.diagnostics.Warn, - [vim.diagnostic.severity.HINT] = i.diagnostics.Hint, - [vim.diagnostic.severity.INFO] = i.diagnostics.Info, - }, - }, -} - -for severity, icon in pairs(diagnosticConfig.signs.text) do - local name = - vim.diagnostic.severity[severity]:lower():gsub('^%l', string.upper) - name = 'DiagnosticSign' .. name - - vim.fn.sign_define(name, { text = icon, texthl = name, numhl = '' }) -end - -vim.diagnostic.config(diagnosticConfig) - --- Codelens -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -vim.api.nvim_create_autocmd('User', { - pattern = 'LspSupportsMethod', - callback = function(args) - local client = vim.lsp.get_client_by_id(args.data.client_id) - local buffer = args.data.buffer - - if client and args.data.method == 'textDocument/codeLens' then - vim.lsp.codelens.refresh() - - vim.api.nvim_create_autocmd({ 'BufEnter', 'CursorHold', 'InsertLeave' }, { - buffer = buffer, - callback = vim.lsp.codelens.refresh, - }) - end - end, -}) - --- Server Setup -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -local has_blink, blink = pcall(require, 'blink.cmp') -local capabilities = vim.tbl_deep_extend( - 'force', - {}, - vim.lsp.protocol.make_client_capabilities(), - has_blink and blink.get_lsp_capabilities() or {}, - { - workspace = { - fileOperations = { - didRename = true, - willRename = true, - }, - }, - } -) - -vim.lsp.config('*', { - root_markers = { '.git' }, - capabilities = capabilities, -}) - -vim.lsp.enable({ - 'bash-language-server', - 'emmet-language-server', - 'lua-language-server', - 'nil', - -- 'nixd', - 'phpactor', - 'stylelint-lsp', - 'taplo', - 'vscode-css-language-server', - 'vscode-html-language-server', -}) - --- Keymaps -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -MarleyVim.lsp.on_attach(function(client) - local set = vim.keymap.set - - set('n', 'gD', vim.lsp.buf.declaration, { desc = 'declaration' }) - set('n', 'gI', vim.lsp.buf.implementation, { desc = 'implementation' }) - - set('n', 'gr', vim.lsp.buf.references, { desc = 'references', nowait = true }) - - set('n', 'gy', vim.lsp.buf.type_definition, { desc = 'type definition' }) - - set('n', 'K', function() - return vim.lsp.buf.hover() - end, { desc = 'hover' }) - - if client.supports_method('textDocument/codeAction') then - set( - { 'n', 'v' }, - 'ca', - vim.lsp.buf.code_action, - { desc = 'code action' } - ) - end - - if client.supports_method('textDocument/codeLens') then - set( - { 'n', 'v' }, - 'cc', - vim.lsp.codelens.run, - { desc = 'run codelens' } - ) - - set( - 'n', - 'cC', - vim.lsp.codelens.refresh, - { desc = 'refresh & display codelens' } - ) - end - - if client.supports_method('textDocument/definition') then - set('n', 'gd', vim.lsp.buf.definition, { desc = 'definition' }) - end - - if client.supports_method('textDocument/documentHighlight') then - if Snacks.words.is_enabled() then - set('n', '', function() - Snacks.words.jump(vim.v.count1, true) - end, { desc = 'next reference' }) - - set('n', '', function() - Snacks.words.jump(-vim.v.count1, true) - end, { desc = 'prev reference' }) - - set('n', ']]', function() - Snacks.words.jump(vim.v.count1) - end, { desc = 'next reference' }) - - set('n', '[[', function() - Snacks.words.jump(-vim.v.count1) - end, { desc = 'prev reference' }) - end - end - - if client.supports_method('textDocument/rename') then - set('n', 'cr', vim.lsp.buf.rename, { desc = 'rename' }) - end - - if client.supports_method('textDocument/signatureHelp') then - set('i', '', function() - return vim.lsp.buf.signature_help() - end, { desc = 'signature help' }) - - set('n', 'gK', function() - vim.lsp.buf.signature_help() - end, { desc = 'signature help' }) - end - - if - client.supports_method('workspace/didRenameFiles') - or client.supports_method('workspace/willRenameFiles') - then - set('n', 'cR', function() - Snacks.rename.rename_file() - end, { desc = 'rename file' }) - end -end) diff --git a/nvim/lua/options.lua b/nvim/lua/options.lua deleted file mode 100644 index dfea37a..0000000 --- a/nvim/lua/options.lua +++ /dev/null @@ -1,135 +0,0 @@ -local g = vim.g -local opt = vim.opt - --- Root dir detection options. --- Each entry can be a pattern `.git` or `package.json` -g.root_spec = { '.git', 'package.json' } - --- Only set clipboard if not in SSH, to make sure the OSC 52 integration works --- automatically. Requires Neovim >= 0.10.0. --- `unnamedplus` is the system clipboard. -opt.clipboard = vim.env.SSH_TTY and '' or 'unnamedplus' - --- Relative line numbers. -opt.number = true -opt.relativenumber = true - --- Set to 2 spaces. -opt.expandtab = true -opt.shiftwidth = 2 -opt.tabstop = 2 - --- Smart/auto indenting. -opt.shiftround = true -opt.smartindent = true -opt.breakindent = true - --- Show matches in real time while searching. -opt.hlsearch = true -opt.incsearch = true - --- Disable text wrap. -opt.wrap = false - --- Better splitting. -opt.splitbelow = true -opt.splitright = true - --- Enable mouse mode. -opt.mouse = 'a' - --- Smart handling of case when searching. -opt.ignorecase = true -opt.smartcase = true - --- Use Ripgrep for searching. -opt.grepprg = 'rg --vimgrep' -opt.grepformat = '%f:%l:%c:%m' - --- More frequent swap file saving. -opt.updatetime = 200 - --- Completion options. -opt.completeopt = { 'menu', 'menuone', 'noselect', 'noinsert' } - --- Persistant & bigger undo history. -opt.undofile = true -opt.undolevels = 10000 - --- Enable 24-bit colors. -opt.termguicolors = true - --- Always show the signcolumn to keep the text from jumping. -opt.signcolumn = 'yes' - --- Highlight the current line. -opt.cursorline = true - --- Fold settings. -opt.foldcolumn = '1' -opt.foldlevel = 99 -opt.foldenable = true -opt.foldmethod = 'expr' -opt.foldexpr = 'nvim_treesitter#foldexpr()' -opt.foldtext = '' - --- Always keep 4 lines above/below cursor. -opt.scrolloff = 4 - --- Max width. -opt.textwidth = 80 -opt.colorcolumn = '+1' - --- Show some invisible chars. -opt.list = true -opt.listchars = { tab = '->', trail = '·' } - --- Only show a single statusline instead of one for each window. -opt.laststatus = 3 - --- Preview subsitutions as you type. -opt.inccommand = 'split' - --- Ask to save changes before exiting modified buffer. -opt.confirm = true - --- I don't understand this but LazyVim sets it and it seems like a good idea. -opt.jumpoptions = 'view' - --- Enable a little transparency for pop-ups. -opt.pumblend = 10 - --- Disable default line/col numbers in statusline. -opt.ruler = false - --- What to save when calling :mksession. -opt.sessionoptions = { - 'buffers', - 'curdir', - 'tabpages', - 'winsize', - 'help', - 'globals', - 'skiprtp', - 'folds', -} - --- Scrolling. -opt.smoothscroll = true -opt.sidescroll = 1 -opt.sidescrolloff = 8 - --- Spelling suggestions language. -opt.spelllang = { 'en' } - --- Allow cursor to move where there is no text in visual block mode. -opt.virtualedit = 'block' - --- Command mode completion mode. -opt.wildmode = { 'longest:full', 'full' } - --- Min window width when splitting. -opt.winminwidth = 5 - --- Disable some messages. -opt.shortmess:append({ W = true, I = true, c = true, C = true }) diff --git a/nvim/lua/plugins/coding/blink-cmp.lua b/nvim/lua/plugins/coding/blink-cmp.lua deleted file mode 100644 index c34e384..0000000 --- a/nvim/lua/plugins/coding/blink-cmp.lua +++ /dev/null @@ -1,84 +0,0 @@ -return { - 'blink.cmp', - event = 'InsertEnter', - before = function() - require('lz.n').trigger_load({ - 'mini.icons', - 'luasnip', - }) - end, - after = function() - ---@module 'blink.cmp' - ---@type blink.cmp.Config - local opts = { - appearance = { - use_nvim_cmp_as_default = false, - nerd_font_variant = 'mono', - }, - completion = { - accept = { - auto_brackets = { - enabled = true, - }, - }, - menu = { - draw = { - treesitter = { 'lsp' }, - components = { - kind_icon = { - ellipsis = false, - text = function(ctx) - local icon, _, _ = require('mini.icons').get('lsp', ctx.kind) - return icon - end, - highlight = function(ctx) - local _, hl, _ = require('mini.icons').get('lsp', ctx.kind) - return hl - end, - }, - }, - }, - }, - documentation = { - auto_show = true, - auto_show_delay_ms = 200, - }, - ghost_text = { - enabled = false, - }, - list = { - selection = { preselect = true, auto_insert = false }, - }, - }, - - snippets = { - preset = 'luasnip', - expand = function(snippet) - require('luasnip').lsp_expand(snippet) - end, - - active = function(filter) - if filter and filter.direction then - return require('luasnip').jumpable(filter.direction) - end - - return require('luasnip').in_snippet() - end, - - jump = function(direction) - require('luasnip').jump(direction) - end, - }, - - sources = { - default = { 'lsp', 'path', 'snippets', 'buffer' }, - }, - - keymap = { - preset = 'super-tab', - }, - } - - require('blink.cmp').setup(opts) - end, -} diff --git a/nvim/lua/plugins/coding/friendly-snippets.lua b/nvim/lua/plugins/coding/friendly-snippets.lua deleted file mode 100644 index afaa69c..0000000 --- a/nvim/lua/plugins/coding/friendly-snippets.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - 'friendly-snippets', - lazy = true, -} diff --git a/nvim/lua/plugins/coding/init.lua b/nvim/lua/plugins/coding/init.lua deleted file mode 100644 index 27f6238..0000000 --- a/nvim/lua/plugins/coding/init.lua +++ /dev/null @@ -1,14 +0,0 @@ -local req = MarleyVim.local_require('plugins.coding') - -return { - req('blink-cmp'), - req('friendly-snippets'), - req('lexima-vim'), - req('luasnip'), - req('mini-ai'), - req('mini-comment'), - req('mini-surround'), - req('neotab-nvim'), - req('ts-comments-nvim'), - req('yanky-nvim'), -} diff --git a/nvim/lua/plugins/coding/lexima-vim.lua b/nvim/lua/plugins/coding/lexima-vim.lua deleted file mode 100644 index b0e6bb3..0000000 --- a/nvim/lua/plugins/coding/lexima-vim.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - 'lexima.vim', - event = 'DeferredUIEnter', -} diff --git a/nvim/lua/plugins/coding/luasnip.lua b/nvim/lua/plugins/coding/luasnip.lua deleted file mode 100644 index 97ab788..0000000 --- a/nvim/lua/plugins/coding/luasnip.lua +++ /dev/null @@ -1,32 +0,0 @@ -return { - 'luasnip', - lazy = true, - before = function() - require('lz.n').trigger_load({ - 'friendly-snippets', - }) - end, - after = function() - require('luasnip').setup({ - history = true, - delete_check_events = 'TextChanged', - store_selection_keys = '', - update_events = 'TextChanged,TextChangedI', - }) - - -- friendly-snippets - require('luasnip.loaders.from_vscode').lazy_load() - - -- Personal snippets. - local snippets = {} - - local paths = vim.api.nvim_get_runtime_file('lua/snippets', true) - for _, path in ipairs(paths) do - if string.find(path, '%/nix%/store%/.+') then - table.insert(snippets, path) - end - end - - require('luasnip.loaders.from_lua').load({ paths = snippets }) - end, -} diff --git a/nvim/lua/plugins/coding/mini-ai.lua b/nvim/lua/plugins/coding/mini-ai.lua deleted file mode 100644 index da00562..0000000 --- a/nvim/lua/plugins/coding/mini-ai.lua +++ /dev/null @@ -1,124 +0,0 @@ -return { - 'mini.ai', - event = 'DeferredUIEnter', - before = function() - require('lz.n').trigger_load('which-key.nvim') - end, - after = function() - local ai = require('mini.ai') - - ai.setup({ - n_lines = 500, - custom_textobjects = { - -- code blOck - o = ai.gen_spec.treesitter({ - a = { '@block.outer', '@conditional.outer', '@loop.outer' }, - i = { '@block.inner', '@conditional.inner', '@loop.inner' }, - }), - - -- Class - c = ai.gen_spec.treesitter({ - a = '@class.outer', - i = '@class.inner', - }), - - -- Usage (fn call) - u = ai.gen_spec.function_call(), - - -- Usage (to last .) - U = ai.gen_spec.function_call({ name_pattern = '[%w_]' }), - - -- Digit - d = { '%f[%d]%d+' }, - - -- word within casE (snake_case, CamelCase, etc) - e = { - { - '%u[%l%d]+%f[^%l%d]', - '%f[%S][%l%d]+%f[^%l%d]', - '%f[%P][%l%d]+%f[^%l%d]', - '^[%l%d]+%f[^%l%d]', - }, - '^().*()$', - }, - - -- buffer - g = { - from = { line = 1, col = 1 }, - to = { - line = vim.fn.line('$'), - col = math.max(vim.fn.getline('$'):len(), 1), - }, - }, - }, - }) - - local i = require('icons') - local c = require('colors') - local mkA = MarleyVim.wkSpec(c.around) - local mkI = MarleyVim.wkSpec(c.inner) - - ---@param lhs string - ---@param icon string - ---@param opts table - local function mkKey(lhs, icon, opts) - if lhs:sub(1, 1) == 'a' then - return mkA(lhs, nil, icon, opts) - else - return mkI(lhs, nil, icon, opts) - end - end - - local groups = { - around = { 'a', i.around }, - around_last = { 'al', i.around }, - around_next = { 'an', i.around }, - inner = { 'i', i.inner }, - inner_last = { 'il', i.inner }, - inner_next = { 'in', i.inner }, - } - - local mappings = { - { '', '', 'whitespace' }, - { '"', '', 'double quotes' }, - { "'", '', 'single quotes' }, - { '`', '', 'backticks' }, - { '(', '󰅲', '()' }, - { ')', '󰅲', '() with ws' }, - { '[', '󰅪', '[] block' }, - { ']', '󰅪', '[] block with ws' }, - { '{', '󰅩', '{} block' }, - { '}', '󰅩', '{} block with ws' }, - { '<', '󰅴', '<>' }, - { '>', '󰅴', '<> with ws' }, - { '_', '󱁐', 'underscores' }, - { '?', '󰘎', 'user prompt' }, - { 'a', i.lsp.Variable, 'argument' }, - { 'b', '󰅲', ')]} block' }, - { 'c', i.lsp.Class, 'class' }, - { 'd', i.lsp.Number, 'numbers' }, - { 'e', i.lsp.Variable, 'word within case' }, - { 'f', i.lsp.Function, 'function' }, - { 'g', i.lsp.File, 'entire buffer' }, - { 'o', i.lsp.Control, 'block, conditional, loop' }, - { 'q', i.lsp.String, 'quotes/backticks' }, - { 't', '󰅴', 'tags' }, - { 'u', i.lsp.Method, 'use/call' }, - { 'U', i.lsp.Method, 'use/call without dot' }, - } - - local spec = { mode = { 'o', 'x' } } - - for name, data in pairs(groups) do - name = name:gsub('^around_', ''):gsub('^insude_', '') - - spec[#spec + 1] = mkKey(data[1], data[2], { group = name }) - - for _, item in ipairs(mappings) do - spec[#spec + 1] = mkKey(data[1] .. item[1], item[2], { desc = item[3] }) - end - end - - require('which-key').add({ spec }) - end, -} diff --git a/nvim/lua/plugins/coding/mini-comment.lua b/nvim/lua/plugins/coding/mini-comment.lua deleted file mode 100644 index f581764..0000000 --- a/nvim/lua/plugins/coding/mini-comment.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - 'mini.comment', - event = 'DeferredUIEnter', - after = function() - require('mini.comment').setup({}) - end, -} diff --git a/nvim/lua/plugins/coding/mini-surround.lua b/nvim/lua/plugins/coding/mini-surround.lua deleted file mode 100644 index a03a922..0000000 --- a/nvim/lua/plugins/coding/mini-surround.lua +++ /dev/null @@ -1,26 +0,0 @@ -local keys = { - add = 'gsa', - delete = 'gsd', - find = 'gsf', - find_left = 'gsF', - highlight = 'gsh', - replace = 'gsr', - update_n_lines = 'gsn', -} -return { - 'mini.surround', - keys = { - { keys.add, desc = 'add surrounding', mode = { 'n', 'v' } }, - { keys.delete, desc = 'delete surrounding' }, - { keys.find, desc = 'find right surrounding' }, - { keys.find_left, desc = 'find left surrounding' }, - { keys.highlight, desc = 'highlight surrounding' }, - { keys.replace, desc = 'replace surrounding' }, - { keys.update_n_lines, desc = 'update n_lines' }, - }, - after = function() - require('mini.surround').setup({ - mappings = keys, - }) - end, -} diff --git a/nvim/lua/plugins/coding/neotab-nvim.lua b/nvim/lua/plugins/coding/neotab-nvim.lua deleted file mode 100644 index 36ae6fa..0000000 --- a/nvim/lua/plugins/coding/neotab-nvim.lua +++ /dev/null @@ -1,36 +0,0 @@ -return { - 'neotab.nvim', - event = 'InsertEnter', - after = function() - require('neotab').setup({ - behavior = 'closing', - smart_punctuators = { - enabled = true, - semicolon = { - enabled = true, - ft = { 'javascript', 'typescript', 'php', 'nix' }, - }, - escape = { - enabled = true, - triggers = { - [','] = { - pairs = { - { open = "'", close = "'" }, - { open = '"', close = '"' }, - }, - format = '%s ', -- ", " - }, - ['='] = { - pairs = { - { open = '(', close = ')' }, - }, - ft = { 'javascript', 'typescript' }, - format = ' %s> ', -- ` => ` - cond = '^$', -- match only pairs with empty content - }, - }, - }, - }, - }) - end, -} diff --git a/nvim/lua/plugins/coding/ts-comments-nvim.lua b/nvim/lua/plugins/coding/ts-comments-nvim.lua deleted file mode 100644 index 06e73cb..0000000 --- a/nvim/lua/plugins/coding/ts-comments-nvim.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - 'ts-comments.nvim', - event = 'DeferredUIEnter', - after = function() - require('ts-comments').setup({}) - end, -} diff --git a/nvim/lua/plugins/coding/yanky-nvim.lua b/nvim/lua/plugins/coding/yanky-nvim.lua deleted file mode 100644 index 6cb7217..0000000 --- a/nvim/lua/plugins/coding/yanky-nvim.lua +++ /dev/null @@ -1,104 +0,0 @@ -return { - 'yanky.nvim', - event = { 'BufReadPost', 'BufWritePost', 'BufNewFile' }, - keys = { - { - 'gp', - '(YankyGPutAfter)', - mode = { 'n', 'x' }, - desc = 'put text after selection', - }, - { - 'gP', - '(YankyGPutBefore', - mode = { 'n', 'x' }, - desc = 'put text before selection', - }, - { - 'p', - '(YankyPutAfter)', - mode = { 'n', 'x' }, - desc = 'put text after cursor', - }, - { - 'P', - '(YankyPutBefore)', - mode = { 'n', 'x' }, - desc = 'put text before cursor', - }, - { 'y', '(YankyYank)', mode = { 'n', 'x' }, desc = 'yank text' }, - { - 'p', - function() - vim.cmd([[YankyRingHistory]]) - end, - mode = { 'n', 'x' }, - desc = 'open yank history', - }, - { - '[p', - '(YankyPutIndentBeforeLinewise)', - desc = 'put indented before cursor (linewise)', - }, - { - '[P', - '(YankyPutIndentBeforeLinewise)', - desc = 'put indented before cursor (linewise)', - }, - { - ']p', - '(YankyPutIndentAfterLinewise)', - desc = 'put indented after cursor (linewise)', - }, - { - ']P', - '(YankyPutIndentAfterLinewise)', - desc = 'put indented after cursor (linewise)', - }, - { - '[y', - '(YankyCycleForward)', - desc = 'cycle forward through yank history', - }, - { - ']y', - '(YankyCycleBackward)', - desc = 'cycle backword through yank history', - }, - { - '(YankyPutIndentAfterShiftLeft)', - desc = 'put and indent left', - }, - { - '(YankyPutIndentBeforeShiftLeft)', - desc = 'put and indent left', - }, - { - '>p', - '(YankyPutIndentAfterShiftRight)', - desc = 'put and indent right', - }, - { - '>P', - '(YankyPutIndentBeforeShiftRight)', - desc = 'put and indent right', - }, - { - '=p', - '(YankyPutAfterFilter)', - desc = 'put after applying a filter', - }, - { - '=P', - '(YankyPutBeforeFilter)', - desc = 'put before applying a filter', - }, - }, - after = function() - require('yanky').setup({ - highlight = { timer = 150 }, - }) - end, -} diff --git a/nvim/lua/plugins/colorscheme/init.lua b/nvim/lua/plugins/colorscheme/init.lua deleted file mode 100644 index e102eb7..0000000 --- a/nvim/lua/plugins/colorscheme/init.lua +++ /dev/null @@ -1,5 +0,0 @@ -local req = MarleyVim.local_require('plugins.colorscheme') - -return { - req('rose-pine'), -} diff --git a/nvim/lua/plugins/colorscheme/rose-pine.lua b/nvim/lua/plugins/colorscheme/rose-pine.lua deleted file mode 100644 index 5b42c7e..0000000 --- a/nvim/lua/plugins/colorscheme/rose-pine.lua +++ /dev/null @@ -1,17 +0,0 @@ -return { - 'rose-pine', - colorscheme = { - 'rose-pine', - 'rose-pine-main', - 'rose-pine-moon', - 'rose-pine-dawn', - }, - after = function() - require('rose-pine').setup({ - variant = 'main', - }) - - -- Reload the colorscheme once opts are set. - vim.cmd('colorscheme rose-pine') - end, -} diff --git a/nvim/lua/plugins/editor/aerial-nvim.lua b/nvim/lua/plugins/editor/aerial-nvim.lua deleted file mode 100644 index 913c574..0000000 --- a/nvim/lua/plugins/editor/aerial-nvim.lua +++ /dev/null @@ -1,32 +0,0 @@ -return { - 'aerial.nvim', - event = { 'BufReadPost', 'BufWritePost', 'BufNewFile' }, - keys = { - { 'cs', 'AerialToggle', desc = 'toggle aerial' }, - }, - before = function() - require('lz.n').trigger_load({ 'mini.icons' }) - end, - after = function() - require('aerial').setup({ - attach_mode = 'global', - backends = { 'lsp', 'treesitter', 'markdown', 'man' }, - show_guides = true, - layout = { - resize_to_content = false, - placement = 'edge', - win_opts = { - winhl = 'Normal:NormalFloat,FloatBorder:NormalFloat,SignColumn:SignColumnSB', - signcolumn = 'yes', - statuscolumn = ' ', - }, - }, - guides = { - mid_item = '├╴', - last_item = '└╴', - nested_top = '│ ', - whitespace = ' ', - }, - }) - end, -} diff --git a/nvim/lua/plugins/editor/flash-nvim.lua b/nvim/lua/plugins/editor/flash-nvim.lua deleted file mode 100644 index f9d9775..0000000 --- a/nvim/lua/plugins/editor/flash-nvim.lua +++ /dev/null @@ -1,61 +0,0 @@ -return { - 'flash.nvim', - event = 'DeferredUIEnter', - keys = { - { - 's', - function() - require('flash').jump() - end, - mode = { 'n', 'x', 'o' }, - desc = 'flash', - }, - { - 'S', - function() - require('flash').treesitter() - end, - mode = { 'n', 'x', 'o' }, - desc = 'flash (treesitter)', - }, - { - 'r', - function() - require('flash').remote() - end, - mode = { 'o' }, - desc = 'remote flash', - }, - { - 'R', - function() - require('flash').treesitter_search() - end, - mode = { 'x', 'o' }, - desc = 'treesitter search', - }, - { - '', - function() - require('flash').toggle() - end, - mode = { 'c' }, - desc = 'toggle flash search', - }, - }, - before = function() - require('lz.n').trigger_load('which-key.nvim') - end, - after = function() - require('flash').setup({}) - - local mkKey = MarleyVim.wkSpec(require('colors').search) - require('which-key').add({ - mkKey('s', nil, '', { mode = { 'n', 'x', 'o' } }), - mkKey('S', nil, '', { mode = { 'n', 'x', 'o' } }), - mkKey('r', nil, '', { mode = { 'o' } }), - mkKey('r', nil, '󰊕', { mode = { 'x', 'o' } }), - mkKey('', nil, '󰥖', { mode = { 'c' } }), - }) - end, -} diff --git a/nvim/lua/plugins/editor/fzf-lua.lua b/nvim/lua/plugins/editor/fzf-lua.lua deleted file mode 100644 index 4836a75..0000000 --- a/nvim/lua/plugins/editor/fzf-lua.lua +++ /dev/null @@ -1,370 +0,0 @@ ----@param picker string ----@param opts? table -local function pick(picker, opts) - opts = opts or {} - - return function() - require('fzf-lua')[picker](opts) - end -end - -local projectPick = nil - -projectPick = function() - local has_project, _ = pcall(require, 'project_nvim') - if not has_project then - return - end - - local fzf_lua = require('fzf-lua') - local project = require('project_nvim.project') - local history = require('project_nvim.utils.history') - local results = history.get_recent_projects() - local utils = require('fzf-lua.utils') - - local function hl_validate(hl) - return not utils.is_hl_cleared(hl) and hl or nil - end - - local function ansi_from_hl(hl, s) - return utils.ansi_from_hl(hl_validate(hl), s) - end - - local opts = { - fzf_opts = { - ['--header'] = string.format( - ':: <%s> to %s | <%s> to %s | <%s> to %s | <%s> to %s | <%s> to %s', - ansi_from_hl('FzfLuaHeaderBind', 'ctrl-t'), - ansi_from_hl('FzfLuaHeaderText', 'tabedit'), - ansi_from_hl('FzfLuaHeaderBind', 'ctrl-s'), - ansi_from_hl('FzfLuaHeaderText', 'live_grep'), - ansi_from_hl('FzfLuaHeaderBind', 'ctrl-r'), - ansi_from_hl('FzfLuaHeaderText', 'oldfiles'), - ansi_from_hl('FzfLuaHeaderBind', 'ctrl-w'), - ansi_from_hl('FzfLuaHeaderText', 'change_dir'), - ansi_from_hl('FzfLuaHeaderBind', 'ctrl-d'), - ansi_from_hl('FzfLuaHeaderText', 'delete') - ), - }, - fzf_colors = true, - actions = { - ['default'] = { - function(selected) - fzf_lua.files({ cwd = selected[1] }) - end, - }, - ['ctrl-t'] = { - function(selected) - vim.cmd('tabedit') - fzf_lua.files({ cwd = selected[1] }) - end, - }, - ['ctrl-s'] = { - function(selected) - fzf_lua.live_grep({ cwd = selected[1] }) - end, - }, - ['ctrl-r'] = { - function(selected) - fzf_lua.oldfiles({ cwd = selected[1] }) - end, - }, - ['ctrl-w'] = { - function(selected) - local path = selected[1] - local ok = project.set_pwd(path) - if ok then - vim.api.nvim_win_close(0, false) - vim.notify('Change project dir to ' .. path, 'info') - end - end, - }, - ['ctrl-d'] = function(selected) - local path = selected[1] - local choice = - vim.fn.confirm("Delete '" .. path .. "' project? ", '&Yes\n&No') - if choice == 1 then - history.delete_project({ value = path }) - end - ---@diagnostic disable-next-line:need-check-nil - projectPick() - end, - }, - } - - fzf_lua.fzf_exec(results, opts) -end - -return { - 'fzf-lua', - event = { 'DeferredUIEnter' }, - cmd = { 'FzfLua' }, - keys = { - -- Find. - { - 'fb', - pick('buffers', { sort_mru = true, sort_lastused = true }), - desc = 'buffers', - }, - { 'ff', pick('files'), desc = 'find files (root dir)' }, - { - 'fF', - pick('files', { root = false }), - desc = 'find files (cwd)', - }, - { 'fg', pick('git_files'), desc = 'find files (git)' }, - { 'fp', projectPick, desc = 'projects' }, - { 'fr', pick('oldfiles'), desc = 'recent' }, - { - 'fR', - pick('oldfiles', { cwd = vim.uv.cwd() }), - desc = 'recent (cwd)', - }, - - -- Git. - { 'gc', pick('git_commits'), desc = 'commits' }, - { 'gs', pick('git_status'), desc = 'status' }, - - -- Search. - { 'sa', pick('autocmds'), desc = 'auto-commands' }, - { 'sb', pick('grep_curbuf'), desc = 'buffer' }, - { 'sc', pick('command_history'), desc = 'command history' }, - { 'sC', pick('commands'), desc = 'commands' }, - { - 'sd', - pick('diagnostics_document'), - desc = 'document diagnostics', - }, - { - 'sD', - pick('diagnostics_workspace'), - desc = 'workspace diagnostics', - }, - { 'sg', pick('live_grep'), desc = 'grep (root dir)' }, - { 'sG', pick('live_grep', { root = false }), desc = 'grep (cwd)' }, - { 'sh', pick('help_tags'), desc = 'help pages' }, - { 'sH', pick('highlights'), desc = 'search highlight groups' }, - { 'sj', pick('jumps'), desc = 'jumplist' }, - { 'sk', pick('keymaps'), desc = 'keymaps' }, - { 'sl', pick('loclist'), desc = 'location list' }, - { 'sm', pick('marks'), desc = 'jump to mark' }, - { 'sM', pick('man_pages'), desc = 'man pages' }, - { 'sq', pick('quickfix'), desc = 'quickfix list' }, - { 'sR', pick('resume'), desc = 'resume last picker' }, - { 'sw', pick('grep_cword'), desc = 'word under cursor (root dir)' }, - { - 'sw', - pick('grep_visual'), - mode = 'v', - desc = 'selection (root dir)', - }, - { - 'sW', - pick('grep_cword', { root = false }), - desc = 'word under cursor (cwd)', - }, - { - 'sW', - pick('grep_visual', { root = false }), - mode = 'v', - desc = 'selection (cwd)', - }, - { 's"', pick('registers'), desc = 'registers' }, - - -- Misc. - { 'uC', pick('colorschemes'), desc = 'colorschemes' }, - { '', pick('files'), desc = 'find files (root dir)' }, - { - ',', - pick('buffers', { sort_mru = true, sort_lastused = true }), - desc = 'switch buffer', - }, - { '/', pick('live_grep'), desc = 'grep (root dir)' }, - { ':', pick('command_history'), desc = 'command history' }, - }, - after = function() - local config = require('fzf-lua.config') - local actions = require('fzf-lua.actions') - - -- quickfix - config.defaults.keymap.fzf['ctrl-q'] = 'select-all+accept' - config.defaults.keymap.fzf['ctrl-u'] = 'half-page-up' - config.defaults.keymap.fzf['ctrl-d'] = 'half-page-down' - config.defaults.keymap.fzf['ctrl-x'] = 'jump' - config.defaults.keymap.fzf['ctrl-f'] = 'preview-page-down' - config.defaults.keymap.fzf['ctrl-b'] = 'preview-page-up' - config.defaults.keymap.builtin[''] = 'preview-page-down' - config.defaults.keymap.builtin[''] = 'preview-page-up' - - -- trouble.nvim - local has_trouble, _ = pcall(require, 'trouble') - if has_trouble then - config.defaults.actions.files['ctrl-t'] = - require('trouble.sources.fzf').actions.open - end - - local img_previewer = { 'chafa', '{file}', '--format=symbols' } - - local opts = { - -- Base profile. - 'default-title', - - fzf_colors = true, - fzf_opts = { - ['--no-scrollbar'] = true, - }, - - defaults = { - formatter = 'path.dirname_first', - }, - - previewers = { - builtin = { - extensions = { - ['png'] = img_previewer, - ['jpg'] = img_previewer, - ['jpeg'] = img_previewer, - ['gif'] = img_previewer, - ['webp'] = img_previewer, - }, - }, - }, - - winopts = { - width = 0.8, - height = 0.8, - row = 0.5, - col = 0.5, - preview = { - scrollchars = { '┃', '' }, - }, - }, - - files = { - cwd_prompt = false, - actions = { - ['alt-i'] = { actions.toggle_ignore }, - ['alt-h'] = { actions.toggle_hidden }, - }, - }, - - grep = { - actions = { - ['alt-i'] = { actions.toggle_ignore }, - ['alt-h'] = { actions.toggle_hidden }, - }, - }, - - lsp = { - symbols = { - symbol_hl = function(s) - return 'TroubleIcon' .. s - end, - symbol_fmt = function(s) - return s:lower() .. '\t' - end, - child_prefix = false, - }, - code_actions = { - previewer = 'codeaction_native', - }, - }, - } - - -- Use the same prompt for all pickers for profile 'default-title'. - local function fix(table) - table.prompt = table.prompt ~= nil and ' ' or nil - - -- Recurse into subtables. - for _, value in pairs(table) do - if type(value) == 'table' then - fix(value) - end - end - - return table - end - - opts = vim.tbl_deep_extend( - 'force', - fix(require('fzf-lua.profiles.default-title')), - opts - ) - - -- Don't let fzf-lua apply the profile as we've already done so above. - opts[1] = nil - - require('fzf-lua').setup(opts) - require('fzf-lua').register_ui_select(function(fzf_opts, items) - return vim.tbl_deep_extend('force', fzf_opts, { - prompt = ' ', - winopts = { - title = ' ' - .. vim.trim((fzf_opts.prompt or 'Select'):gsub('%s*:%s*$', '')) - .. ' ', - title_pos = 'center', - }, - }, fzf_opts.kind == 'codeaction' and { - winopts = { - layout = 'vertical', - height = math.floor( - math.min(vim.o.lines * 0.8 - 16, #items + 2) + 0.5 - ) + 16, - preview = not vim.tbl_isempty( - vim.lsp.get_clients({ bufnr = 0, name = 'vtsls' }) - ) - and { - layout = 'vertical', - vertical = 'down:15,border-top', - hidden = 'hidden', - } - or { - layout = 'vertical', - vertical = 'down:15,border-top', - }, - }, - } or { - winopts = { - width = 0.5, - height = math.floor(math.min(vim.o.lines * 0.8, #items + 2) + 0.5), - }, - }) - end) - - -- LSP keybinds. - MarleyVim.lsp.on_attach(function(client) - local set = vim.keymap.set - - local pickOpts = - { jump_to_single_result = true, ignore_current_line = true } - - set( - 'n', - 'gI', - pick('lsp_implementations', pickOpts), - { desc = 'implementation' } - ) - set( - 'n', - 'gr', - pick('lsp_references', pickOpts), - { desc = 'references', nowait = true } - ) - set( - 'n', - 'gy', - pick('lsp_typedefs', pickOpts), - { desc = 't[y]pe definition' } - ) - - if client.supports_method('textDocument/definition') then - set( - 'n', - 'gd', - pick('lsp_definitions', pickOpts), - { desc = 'definition' } - ) - end - end) - end, -} diff --git a/nvim/lua/plugins/editor/gitsigns-nvim.lua b/nvim/lua/plugins/editor/gitsigns-nvim.lua deleted file mode 100644 index ef13329..0000000 --- a/nvim/lua/plugins/editor/gitsigns-nvim.lua +++ /dev/null @@ -1,133 +0,0 @@ -return { - 'gitsigns.nvim', - event = { 'BufReadPost', 'BufWritePost', 'BufNewFile' }, - before = function() - require('lz.n').trigger_load('which-key.nvim') - end, - after = function() - require('gitsigns').setup({ - signs = { - add = { text = '▎' }, - change = { text = '▎' }, - delete = { text = '' }, - topdelete = { text = '' }, - changedelete = { text = '▎' }, - untracked = { text = '▎' }, - }, - signs_staged = { - add = { text = '▎' }, - change = { text = '▎' }, - delete = { text = '' }, - topdelete = { text = '' }, - changedelete = { text = '▎' }, - }, - on_attach = function(buf) - local gitsigns = package.loaded.gitsigns - - local icons = require('icons') - local mkKey = MarleyVim.wkSpec(require('colors').git) - require('which-key').add({ - { - buffer = buf, - mkKey(']h', function() - if vim.wo.diff then - vim.cmd.normal({ ']c', bang = true }) - else - gitsigns.nav_hunk('next') - end - end, icons.next, { desc = 'next hunk' }), - - mkKey('[h', function() - if vim.wo.diff then - vim.cmd.normal({ '[c', bang = true }) - else - gitsigns.nav_hunk('prev') - end - end, icons.prev, { desc = 'previous hunk' }), - - mkKey(']H', function() - gitsigns.nav_hunk('last') - end, icons.last, { desc = 'last hunk' }), - - mkKey('[H', function() - gitsigns.nav_hunk('first') - end, icons.first, { desc = 'first hunk' }), - - mkKey( - 'ghs', - 'Gitsigns stage_hunk', - icons.git.staged, - { mode = { 'n', 'v' }, desc = 'stage hunk' } - ), - - mkKey( - 'ghr', - 'Gitsigns reset_hunk', - icons.git.unstaged, - { mode = { 'n', 'v' }, desc = 'reset hunk' } - ), - - mkKey( - 'ghS', - gitsigns.stage_buffer, - icons.git.staged, - { desc = 'stage buffer' } - ), - - mkKey( - 'ghu', - gitsigns.undo_stage_hunk, - icons.undo, - { desc = 'undo stage hunk' } - ), - - mkKey( - 'ghR', - gitsigns.reset_buffer, - icons.git.unstaged, - { desc = 'reset buffer' } - ), - - mkKey( - 'ghp', - gitsigns.preview_hunk_inline, - '', - { desc = 'preview hunk inline' } - ), - - mkKey('ghb', function() - gitsigns.blame_line({ full = true }) - end, { cat = 'filetype', name = 'git' }, { - desc = 'blame line', - }), - - mkKey( - 'ghB', - gitsigns.blame, - { cat = 'filetype', name = 'git' }, - { desc = 'blame buffer' } - ), - - mkKey( - 'ghd', - gitsigns.diffthis, - icons.git.diff, - { desc = 'diff file' } - ), - - mkKey('ghD', function() - gitsigns.diffthis('~') - end, icons.git.diff, { desc = 'diff file from ~' }), - - mkKey( - 'ih', - 'Gitsigns select_hunk', - '󰿚', - { mode = { 'o', 'x' }, desc = 'select hunk' } - ), - }, - }) - end, - }) - end, -} diff --git a/nvim/lua/plugins/editor/grug-far-nvim.lua b/nvim/lua/plugins/editor/grug-far-nvim.lua deleted file mode 100644 index c142e9c..0000000 --- a/nvim/lua/plugins/editor/grug-far-nvim.lua +++ /dev/null @@ -1,25 +0,0 @@ -return { - 'grug-far.nvim', - cmd = 'GrugFar', - keys = { - { - 'sr', - function() - local grug = require('grug-far') - local ext = vim.bo.buftype == '' and vim.fn.expand('%:e') - - grug.open({ - transient = true, - prefills = { - filesFilter = ext and ext ~= '' and '*.' .. ext or nil, - }, - }) - end, - mode = { 'n', 'v' }, - desc = 'search and replace', - }, - }, - after = function() - require('grug-far').setup({ headerMaxWidth = 80 }) - end, -} diff --git a/nvim/lua/plugins/editor/init.lua b/nvim/lua/plugins/editor/init.lua deleted file mode 100644 index 1f03fc9..0000000 --- a/nvim/lua/plugins/editor/init.lua +++ /dev/null @@ -1,15 +0,0 @@ -local req = MarleyVim.local_require('plugins.editor') - -return { - req('aerial-nvim'), - req('flash-nvim'), - req('fzf-lua'), - req('gitsigns-nvim'), - req('grug-far-nvim'), - req('neo-tree-nvim'), - req('nvim-emmet'), - req('refactoring-nvim'), - req('todo-comments-nvim'), - req('trouble-nvim'), - req('which-key-nvim'), -} diff --git a/nvim/lua/plugins/editor/neo-tree-nvim.lua b/nvim/lua/plugins/editor/neo-tree-nvim.lua deleted file mode 100644 index 26304d7..0000000 --- a/nvim/lua/plugins/editor/neo-tree-nvim.lua +++ /dev/null @@ -1,140 +0,0 @@ ----@param root? boolean ----@param grouped? boolean -local function make_toggle_mapping(root, grouped) - root = root or false - grouped = grouped or false - - local lhs = grouped and 'fe' or 'e' - lhs = root and lhs or (lhs:gsub('%l$', string.upper)) - - return { - lhs, - function() - require('neo-tree.command').execute({ - toggle = true, - dir = root and (MarleyVim.root()) or (vim.uv.cwd()), - }) - end, - desc = 'explorer (' .. (root and 'root' or 'cwd') .. ')', - } -end - -return { - 'neo-tree.nvim', - cmd = 'Neotree', - keys = { - make_toggle_mapping(true, true), -- root / grouped - make_toggle_mapping(false, true), -- cwd / grouped - make_toggle_mapping(true, false), -- root / non-grouped - make_toggle_mapping(false, false), -- cwd / non-grouped - { - 'ge', - function() - require('neo-tree.command').execute({ - source = 'git_status', - toggle = true, - }) - end, - desc = 'git explorer', - }, - { - 'be', - function() - require('neo-tree.command').execute({ - source = 'buffers', - toggle = true, - }) - end, - desc = 'buffer explorer', - }, - }, - before = function() - require('lz.n').trigger_load({ - 'plenary.nvim', - 'mini.icons', - 'nui.nvim', - 'which-key.nvim', - }) - end, - after = function() - local icons = require('icons') - local events = require('neo-tree.events') - - for _, type in ipairs({ 'Error', 'Warn', 'Info', 'Hint' }) do - vim.fn.sign_define('DiagnosticSign' .. type, { - text = icons.diagnostics[type] .. ' ', - texthl = 'DiagnosticSign' .. type, - }) - end - - local function on_move(data) - Snacks.rename.on_rename_file(data.source, data.destination) - end - - require('neo-tree').setup({ - close_if_last_window = true, - sources = { 'filesystem', 'buffers', 'git_status' }, - open_files_do_not_replace_types = { - 'terminal', - 'Trouble', - 'trouble', - 'qf', - 'Outline', - }, - - filesystem = { - bind_to_cwd = false, - follow_current_file = { enabled = true }, - use_libuv_file_watcher = true, - filtered_items = { - visible = true, - hide_dotfiles = false, - hide_gitignored = false, - hide_hidden = false, - }, - }, - - window = { - width = 30, - mappings = { - ['l'] = 'open', - ['h'] = 'close_node', - [''] = 'none', - ['Y'] = { - function(state) - local node = state.tree:get_node() - local path = node:get_id() - vim.fn.setreg('+', path, 'c') - end, - desc = 'copy path to clipboard', - }, - ['P'] = { 'toggle_preview', config = { use_float = false } }, - }, - }, - default_component_configs = { - indent = { - with_expanders = true, - expanders_collapsed = '', - expander_expanded = '', - expander_highlight = 'NeoTreeExpander', - }, - git_status = { - symbols = { - unstaged = icons.git.unstaged, - staged = icons.git.staged, - }, - }, - }, - event_handlers = { - { event = events.FILE_MOVED, handler = on_move }, - { event = events.FILE_RENAMED, handler = on_move }, - }, - }) - - local colors = require('colors') - require('which-key').add({ - { 'ge', icon = { icon = '', color = colors.git } }, - { 'be', icon = { icon = '', color = colors.buffer } }, - }) - end, -} diff --git a/nvim/lua/plugins/editor/nvim-emmet.lua b/nvim/lua/plugins/editor/nvim-emmet.lua deleted file mode 100644 index 5bb31dc..0000000 --- a/nvim/lua/plugins/editor/nvim-emmet.lua +++ /dev/null @@ -1,11 +0,0 @@ -return { - 'nvim-emmet', - keys = { - { - 'xe', - require('nvim-emmet').wrap_with_abbreviation, - mode = { 'n', 'v' }, - desc = 'wrap with emmet abbr', - }, - }, -} diff --git a/nvim/lua/plugins/editor/refactoring-nvim.lua b/nvim/lua/plugins/editor/refactoring-nvim.lua deleted file mode 100644 index 0a446cb..0000000 --- a/nvim/lua/plugins/editor/refactoring-nvim.lua +++ /dev/null @@ -1,126 +0,0 @@ -return { - 'refactoring.nvim', - event = { 'BufReadPre', 'BufNewFile' }, - keys = { - { 'r', '', desc = '+refactor', mode = { 'n', 'v' } }, - { - 'rb', - function() - require('refactoring').refactor('Extract Block') - end, - desc = 'extract block', - }, - { - 'rc', - function() - require('refactoring').debug.cleanup({}) - end, - desc = 'debug cleanup', - }, - { - 'rf', - function() - require('refactoring').refactor('Extract Block To File') - end, - desc = 'extract block to file', - }, - { - 'rf', - function() - require('refactoring').refactor('Extract Function') - end, - mode = 'v', - desc = 'extract function', - }, - { - 'rF', - function() - require('refactoring').refactor('Extract Function To File') - end, - mode = 'v', - desc = 'extract function to file', - }, - { - 'ri', - function() - require('refactoring').refactor('Inline Variable') - end, - mode = { 'n', 'v' }, - desc = 'inline variable', - }, - { - 'rp', - function() - require('refactoring').debug.print_var({ normal = true }) - end, - desc = 'debug print variable', - }, - { - 'rp', - function() - require('refactoring').debug.print_var() - end, - mode = 'v', - desc = 'debug print variable', - }, - { - 'rP', - function() - require('refactoring').debug.printf({ below = false }) - end, - desc = 'debug print', - }, - { - 'rs', - function() - require('fzf-lua').fzf_exec(require('refactoring').get_refactors(), { - fzf_opts = {}, - fzf_colors = true, - actions = { - ['default'] = function(selected) - require('refactoring').refactor(selected[1]) - end, - }, - }) - end, - mode = 'v', - desc = 'refactor', - }, - { - 'rx', - function() - require('refactoring').refactor('Extract Variable') - end, - mode = 'v', - desc = 'extract variable', - }, - }, - before = function() - require('lz.n').trigger_load({ 'plenary.nvim', 'nvim-treesitter' }) - end, - after = function() - require('refactoring').setup({ - prompt_func_param_type = { - go = false, - java = false, - cpp = false, - c = false, - h = false, - hpp = false, - cxx = false, - }, - prompt_func_return_type = { - go = false, - java = false, - cpp = false, - c = false, - h = false, - hpp = false, - cxx = false, - }, - printf_statements = {}, - print_var_statements = {}, - show_success_message = false, - }) - end, -} diff --git a/nvim/lua/plugins/editor/todo-comments-nvim.lua b/nvim/lua/plugins/editor/todo-comments-nvim.lua deleted file mode 100644 index 51ffc7c..0000000 --- a/nvim/lua/plugins/editor/todo-comments-nvim.lua +++ /dev/null @@ -1,49 +0,0 @@ -return { - 'todo-comments.nvim', - event = { 'BufReadPost', 'BufWritePost', 'BufNewFile' }, - cmd = { 'TodoTrouble', 'TodoTelescope' }, - keys = { - { - 'st', - function() - require('todo-comments.fzf').todo() - end, - desc = 'todo search', - }, - { - 'sT', - function() - require('todo-comments.fzf').todo({ - keywords = { 'TODO', 'FIX', 'FIXME' }, - }) - end, - desc = 'todo/fix/fixme search', - }, - { 'xt', 'Trouble todo toggle', desc = 'todo' }, - { - 'xT', - 'Trouble todo toggle filter = {tag = {TODO,FIX,FIXME}}', - desc = 'todo/fix/fixme', - }, - { - ']t', - function() - require('todo-comments').jump_prev() - end, - desc = 'previous todo', - }, - { - ']t', - function() - require('todo-comments').jump_next() - end, - desc = 'next todo', - }, - }, - before = function() - require('lz.n').trigger_load({ 'trouble.nvim', 'fzf-lua' }) - end, - after = function() - require('todo-comments').setup({}) - end, -} diff --git a/nvim/lua/plugins/editor/trouble-nvim.lua b/nvim/lua/plugins/editor/trouble-nvim.lua deleted file mode 100644 index b5f7b7a..0000000 --- a/nvim/lua/plugins/editor/trouble-nvim.lua +++ /dev/null @@ -1,55 +0,0 @@ -return { - 'trouble.nvim', - cmd = { 'Trouble' }, - keys = { - { - 'xQ', - 'Trouble qflist toggle', - desc = 'quickfix list (trouble)', - }, - { - 'xx', - 'Trouble diagnostics toggle', - desc = 'diagnostics', - }, - { - 'xX', - 'Trouble diagnostics toggle filter.buf=0', - desc = 'buffer diagnostics', - }, - { - '[q', - function() - if require('trouble').is_open() then - require('trouble').prev({ skip_groups = true, jump = true }) - else - local ok, err = pcall(vim.cmd.cprev) - - if not ok then - vim.notify(err, vim.log.levels.ERROR) - end - end - end, - desc = 'previous trouble/quickfix item', - }, - { - ']q', - function() - if require('trouble').is_open() then - require('trouble').next({ skip_groups = true, jump = true }) - else - local ok, err = pcall(vim.cmd.cnext) - - if not ok then - vim.notify(err, vim.log.levels.ERROR) - end - end - end, - }, - }, - after = function() - require('trouble').setup({ - modes = { lsp = { win = { position = 'right' } } }, - }) - end, -} diff --git a/nvim/lua/plugins/editor/which-key-nvim.lua b/nvim/lua/plugins/editor/which-key-nvim.lua deleted file mode 100644 index 17cd877..0000000 --- a/nvim/lua/plugins/editor/which-key-nvim.lua +++ /dev/null @@ -1,240 +0,0 @@ -return { - 'which-key.nvim', - event = 'DeferredUIEnter', - keys = { - { - '?', - function() - require('which-key').show({ global = false }) - end, - desc = 'buffer keymaps (which key)', - }, - { - '', - function() - require('which-key').show({ keys = '', loop = true }) - end, - desc = 'window hydra mode (which key)', - }, - }, - before = function() - require('lz.n').trigger_load('mini.icons') - end, - after = function() - local i = require('icons') - local c = require('colors') - - require('which-key').setup({ - preset = 'modern', - spec = { - { - mode = { 'n', 'v' }, - { - '', - group = 'leader', - icon = { icon = '', color = 'green' }, - }, - { '', group = 'tabs' }, - { - 'b', - group = 'buffer', - expand = function() - return require('which-key.extras').expand.buf() - end, - }, - { 'c', group = 'code' }, - { 'f', group = 'file/find' }, - { 'g', group = 'git' }, - { 'gh', group = 'hunks' }, - { 'n', group = 'notifications' }, - { 'q', group = 'quit/session' }, - { 's', group = 'search' }, - { 'u', group = 'ui', icon = { icon = i.ui, color = c.ui } }, - { 'ur', icon = { icon = '', color = c.ui } }, - { - 'w', - group = 'windows', - expand = function() - return require('which-key.extras').expand.win() - end, - }, - { - 'x', - group = 'diagnostics/quickfix', - icon = { icon = '󱖫 ', color = c.diagnostics }, - }, - { '|', icon = '' }, - { '-', icon = '' }, - - { '0', desc = 'start of line', icon = i.first }, - { 'b', desc = 'previous word', icon = i.word }, - { 'B', desc = 'previous WORD', icon = i.word }, - { 'c', desc = 'change' }, - { 'd', desc = 'delete' }, - { 'e', desc = 'next end of word', icon = i.word }, - { 'E', desc = 'next end of WORD', icon = i.word }, - { 'f', desc = 'find next char' }, - { 'F', desc = 'find previous char' }, - - { 'g', group = 'goto', icon = { icon = i.go_to, color = c.go_to } }, - { 'gc', group = 'toggle comment' }, - { 'ge', desc = 'previous end of word', icon = i.word }, - { 'gf', desc = 'file under cursor' }, - { 'gg', desc = 'first line', icon = i.first }, - { 'gi', desc = 'last insert' }, - { 'gn', desc = 'search forward & select' }, - { 'gN', desc = 'search backward & select' }, - { 'gO', desc = 'document symbols', icon = '󰊕' }, - { 'gt', desc = 'next tab page' }, - { 'gT', desc = 'previous tab page' }, - { 'gu', desc = 'make lowercase', icon = '󰬵' }, - { 'gU', desc = 'make uppercase', icon = '󰬶' }, - { 'gv', desc = 'last visual selection' }, - { 'w', desc = 'format' }, - { - 'gs', - group = 'surround', - icon = { icon = '󰅲', color = c.surround }, - }, - { 'gx', desc = 'open with system app', icon = '󰏋' }, - { 'g%', desc = 'cycle backward through results' }, - { 'g~', desc = 'toggle case' }, - - { 'G', desc = 'last line', icon = i.last }, - - { 'M', desc = 'middle line of window', icon = i.center }, - { 'r', desc = 'replace' }, - { 't', desc = 'find before next char' }, - { 'T', desc = 'find before previous char' }, - { 'v', desc = 'visual' }, - { 'V', desc = 'visual line' }, - { 'w', desc = 'next word', icon = i.word }, - { 'W', desc = 'next WORD', icon = i.word }, - { 'y', desc = 'yank' }, - { 'Y', desc = 'yank to end of line' }, - - { 'z', group = 'fold/scroll/spell', icon = '' }, - { 'za', desc = 'toggle fold under cursor' }, - { 'zA', desc = 'toggle all folds under cursor' }, - { 'zb', desc = 'bottom this line', icon = i.bottom }, - { 'zc', desc = 'close fold under cursor' }, - { 'zC', desc = 'close all fold under cursor' }, - { 'zd', desc = 'delete fold under cursor' }, - { 'zD', desc = 'delete all folds under cursor' }, - { 'ze', desc = 'right this line', icon = i.right }, - { 'zE', desc = 'delete all folds in file' }, - { 'zf', desc = 'create fold' }, - { 'zg', desc = 'mark word as correctly spelled' }, - { 'zH', desc = 'half screen to the left', icon = i.left }, - { 'zi', desc = 'toggle folding' }, - { 'zL', desc = 'half screen to the right', icon = i.right }, - { 'zm', desc = 'fold more' }, - { 'zM', desc = 'close all folds' }, - { 'zo', desc = 'open fold under cursor' }, - { 'zO', desc = 'open all folds under cursor' }, - { 'zr', desc = 'fold less' }, - { 'zR', desc = 'open all folds' }, - { 'zs', desc = 'left this line', icon = i.left }, - { 'zt', desc = 'top this line', icon = i.top }, - { 'zv', desc = 'show cursor line' }, - { 'zw', desc = 'mark word as mispelled' }, - { 'zx', desc = 'update folds' }, - { 'zz', desc = 'center this line', icon = i.center }, - { 'z', desc = 'top this line', icon = i.top }, - { 'z=', group = 'spelling suggestions' }, - - { '[', group = 'previous', icon = i.prev }, - { ']', group = 'next', icon = i.next }, - { '!', desc = 'run program', icon = '' }, - { '$', desc = 'end of line', icon = i.last }, - { '%', desc = 'matching (){}[]', icon = '󰅪' }, - { '&', desc = 'repeat last subsitute' }, - { ',', desc = 'repeat last char search (backwards)' }, - { '/', desc = 'search forward' }, - { ';', desc = 'repeat last char search' }, - { '<', desc = 'indent decrease', icon = i.indent.decrease }, - { '>', desc = 'indent increase', icon = i.indent.increase }, - { '?', desc = 'search backwards' }, - { '^', desc = 'first char of line', icon = i.first }, - { '_', desc = 'first char of line', icon = i.first }, - { '{', desc = 'previous empty line', icon = i.prev }, - { '}', desc = 'next empty line', icon = i.next }, - { '~', desc = 'toggle case' }, - - { - '', - desc = 'clear & redraw', - icon = { icon = '', color = 'red' }, - }, - }, - { - mode = { 'n', 'i' }, - hidden = true, - { '' }, - { '' }, - { '' }, - { '' }, - }, - { - mode = { 'n', 'x' }, - hidden = true, - { 'j' }, - { 'k' }, - { 'h' }, - { 'l' }, - { '' }, - }, - }, - icons = { - rules = { - { pattern = 'fold', icon = i.fold, color = c.fold }, - - { pattern = 'buffer', color = c.buffer }, - { pattern = 'change', icon = i.change, color = c.change }, - { pattern = 'comment', icon = i.comment }, - { pattern = 'delete', icon = i.delete, color = c.delete }, - { - pattern = 'diagnostic', - icon = i.diagnostics.Info, - hl = 'DiagnosticInfo', - }, - { - pattern = 'error', - icon = i.diagnostics.Error, - hl = 'DiagnosticError', - }, - { - pattern = 'explorer', - icon = i.explorer, - color = c.explorer, - }, - { pattern = 'format', icon = i.format, color = c.format }, - { pattern = 'hunk', color = c.git }, - { pattern = 'lazygit', icon = i.git, color = c.git }, - { - pattern = 'message', - icon = i.notifications, - color = c.notifications, - }, - { - pattern = 'notification', - icon = i.notifications, - color = c.notifications, - }, - { pattern = 'registers', icon = i.registers, color = c.yank }, - { pattern = 'replace', icon = i.replace, colors = c.replace }, - { pattern = 'session', icon = i.sessions, color = c.sessions }, - { pattern = 'spell', icon = i.spell, color = c.spell }, - { pattern = 'subsitute', icon = i.search, color = c.search }, - { pattern = 'visual', icon = i.visual, color = c.visual }, - { - pattern = ' warning', - icon = i.diagnostics.Warning, - hl = 'DiagnosticWarn', - }, - { pattern = 'yank', icon = i.yank, color = c.yank }, - }, - }, - }) - end, -} diff --git a/nvim/lua/plugins/formatting/conform-nvim.lua b/nvim/lua/plugins/formatting/conform-nvim.lua deleted file mode 100644 index cfbf7db..0000000 --- a/nvim/lua/plugins/formatting/conform-nvim.lua +++ /dev/null @@ -1,96 +0,0 @@ -return { - 'conform.nvim', - event = { 'BufWritePre' }, - cmd = { 'ConformInfo' }, - keys = { - { - 'cf', - function() - require('conform').format() - end, - desc = 'format', - }, - { - 'cF', - function() - require('conform').format({ - formatters = { 'injected' }, - timeout_ms = 3000, - }) - end, - mode = { 'n', 'v' }, - desc = 'format injected langs', - }, - }, - after = function() - require('conform').setup({ - format_on_save = function(buf) - if (vim.g.autoformat == false) or (vim.b[buf].autoformat == false) then - return - end - - return { timeout_ms = 3000, lsp_format = 'fallback' } - end, - - -- Prettier is last but only activated if there is a config available, - -- thereby giving it priority only when it is wanted. - formatters_by_ft = { - blade = { 'blade-formatter', 'rustywind' }, - css = { 'stylelint', 'biome', 'prettier' }, - fish = { 'fish_indent' }, - graphql = { 'biome', 'prettier' }, - handlebars = { 'prettier' }, - html = { 'prettier' }, - javascript = { 'biome', 'prettier' }, - javascriptreact = { 'biome', 'prettier' }, - json = { 'biome', 'prettier' }, - jsonc = { 'biome', 'prettier' }, - liquid = { 'prettier' }, - lua = { 'stylua' }, - less = { 'prettier' }, - markdown = { 'prettier' }, - ['markdown.mdx'] = { 'prettier' }, - nix = { 'alejandra' }, - php = { 'pint', 'php_cs_fixer', stop_after_first = true }, - ruby = { 'prettier' }, - scss = { 'stylelint', 'prettier' }, - sh = { 'shfmt' }, - toml = { 'taplo' }, - typescript = { 'biome', 'prettier' }, - typescriptreact = { 'biome', 'prettier' }, - vue = { 'biome', 'prettier' }, - yaml = { 'prettier' }, - }, - - formatters = { - biome = { - require_cwd = true, - }, - pint = { - meta = { url = 'https://github.com/laravel/pint' }, - command = require('conform.util').find_executable({ - 'vendor/bin/pint', - }, 'pint'), - args = { '$FILENAME' }, - stdin = false, - }, - prettier = { - condition = function(_, ctx) - return MarleyVim.prettier.has_parser(ctx) - and MarleyVim.prettier.has_config(ctx) - end, - }, - shfmt = { - prepend_args = { - '--indent=2', - '--case-indent', - '--binary-next-line', - '--func-next-line', - }, - }, - }, - }) - - vim.o.formatexpr = "v:lua.require'conform'.formatexpr()" - end, -} diff --git a/nvim/lua/plugins/formatting/init.lua b/nvim/lua/plugins/formatting/init.lua deleted file mode 100644 index 4b2a62b..0000000 --- a/nvim/lua/plugins/formatting/init.lua +++ /dev/null @@ -1,5 +0,0 @@ -local req = MarleyVim.local_require('plugins.formatting') - -return { - req('conform-nvim'), -} diff --git a/nvim/lua/plugins/languages/init.lua b/nvim/lua/plugins/languages/init.lua deleted file mode 100644 index f8bfa4a..0000000 --- a/nvim/lua/plugins/languages/init.lua +++ /dev/null @@ -1,5 +0,0 @@ -local req = MarleyVim.local_require('plugins.languages') - -return { - req('vim-caddyfile'), -} diff --git a/nvim/lua/plugins/languages/vim-caddyfile.lua b/nvim/lua/plugins/languages/vim-caddyfile.lua deleted file mode 100644 index f897ef5..0000000 --- a/nvim/lua/plugins/languages/vim-caddyfile.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - 'vim-caddyfile', - lazy = false, -} diff --git a/nvim/lua/plugins/linting/init.lua b/nvim/lua/plugins/linting/init.lua deleted file mode 100644 index e396bd7..0000000 --- a/nvim/lua/plugins/linting/init.lua +++ /dev/null @@ -1,5 +0,0 @@ -local req = MarleyVim.local_require('plugins.linting') - -return { - req('nvim-lint'), -} diff --git a/nvim/lua/plugins/linting/nvim-lint.lua b/nvim/lua/plugins/linting/nvim-lint.lua deleted file mode 100644 index 90d01fd..0000000 --- a/nvim/lua/plugins/linting/nvim-lint.lua +++ /dev/null @@ -1,48 +0,0 @@ -return { - 'nvim-lint', - event = { 'BufReadPost', 'BufWritePost', 'BufNewFile' }, - after = function() - local lint = require('lint') - - lint.linters_by_ft = { - bash = { 'shellcheck' }, - fish = { 'fish' }, - nix = { 'statix' }, - scss = { 'stylelint' }, - sh = { 'shellcheck' }, - yaml = { 'yamllint' }, - } - - local linters = { - shellcheck = { - args = { - '-x', - }, - }, - } - - for name, linter in pairs(linters) do - if type(linter) == 'table' and type(lint.linters[name]) == 'table' then - lint.linters[name] = - vim.tbl_deep_extend('force', lint.linters[name], linter) - - if type(linter.prepend_args) == 'table' then - lint.linters[name].args = lint.linters[name].args or {} - vim.list_extend(lint.linters[name].args, linter.prepend_args) - end - else - lint.linters[name] = linter - end - end - - vim.api.nvim_create_autocmd( - { 'BufWritePost', 'BufReadPost', 'InsertLeave' }, - { - group = vim.api.nvim_create_augroup('nvim-lint', { clear = true }), - callback = function() - require('lint').try_lint() - end, - } - ) - end, -} diff --git a/nvim/lua/plugins/test/init.lua b/nvim/lua/plugins/test/init.lua deleted file mode 100644 index a8ee21c..0000000 --- a/nvim/lua/plugins/test/init.lua +++ /dev/null @@ -1,6 +0,0 @@ -local req = MarleyVim.local_require('plugins.test') - -return { - req('neotest'), - req('nvim-nio'), -} diff --git a/nvim/lua/plugins/test/neotest.lua b/nvim/lua/plugins/test/neotest.lua deleted file mode 100644 index 979b098..0000000 --- a/nvim/lua/plugins/test/neotest.lua +++ /dev/null @@ -1,146 +0,0 @@ -return { - 'neotest', - keys = { - { 't', '', desc = '+test' }, - { - 'tl', - function() - require('neotest').run.run_last() - end, - desc = 'run last', - }, - { - 'to', - function() - require('neotest').output.open({ enter = true, auto_close = true }) - end, - desc = 'show output', - }, - { - 'tO', - function() - require('neotest').output_panel.toggle() - end, - desc = 'toggle output panel', - }, - { - 'tr', - function() - require('neotest').run.run() - end, - desc = 'run nearest', - }, - { - 'ts', - function() - require('neotest').summary.toggle() - end, - desc = 'toggle summary', - }, - { - 'tS', - function() - require('neotest').run.stop() - end, - desc = 'stop tests', - }, - { - 'tt', - function() - require('neotest').run.run(vim.fn.expand('%')) - end, - desc = 'run file tests', - }, - { - 'tT', - function() - require('neotest').run.run(vim.uv.cwd()) - end, - desc = 'run all tests', - }, - { - 'tw', - function() - require('neotest').watch.toggle(vim.fn.expand('%')) - end, - desc = 'toggle watch', - }, - }, - before = function() - require('lz.n').trigger_load({ - 'nvim-nio', - 'plenary.nvim', - 'nvim-treesitter', - }) - end, - after = function() - local neotest_ns = vim.api.nvim_create_namespace('neotest') - vim.diagnostic.config({ - virtual_text = { - format = function(diagnostic) - -- Replace newline/tab chars with spaces. - return diagnostic.message - :gsub('\n', ' ') - :gsub('\t', ' ') - :gsub('%s+', ' ') - :gsub('^%s+', ' ') - end, - }, - }, neotest_ns) - - local consumers = {} - -- Refresh and auto-close trouble after running tests. - local has_trouble, _ = pcall(require, 'trouble') - if has_trouble then - ---@type neotest.Consumer - consumers.trouble = function(client) - client.listeners.results = function(adapter_id, results, partial) - if partial then - return - end - - local tree = - assert(client:get_position(nil, { adapter = adapter_id })) - - local failed = 0 - for pos_id, result in pairs(results) do - if result.status == 'failed' and tree:get_key(pos_id) then - failed = failed + 1 - end - end - - vim.schedule(function() - local trouble = require('trouble') - - if trouble.is_open() then - trouble.refresh() - - if failed == 0 then - trouble.close() - end - end - end) - end - - return {} - end - end - - require('neotest').setup({ - status = { virtual_text = true }, - output = { virtual_text = true }, - - quickfix = { - open = function() - if has_trouble then - require('trouble').open({ mode = 'quickfix', focus = false }) - else - vim.cmd('copen') - end - end, - }, - - consumers = consumers, - }) - end, -} diff --git a/nvim/lua/plugins/test/nvim-nio.lua b/nvim/lua/plugins/test/nvim-nio.lua deleted file mode 100644 index 3c3cb59..0000000 --- a/nvim/lua/plugins/test/nvim-nio.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - 'nvim-nio', - lazy = true, -} diff --git a/nvim/lua/plugins/treesitter/init.lua b/nvim/lua/plugins/treesitter/init.lua deleted file mode 100644 index d87817b..0000000 --- a/nvim/lua/plugins/treesitter/init.lua +++ /dev/null @@ -1,7 +0,0 @@ -local req = MarleyVim.local_require('plugins.treesitter') - -return { - req('nvim-treesitter-textobjects'), - req('nvim-treesitter'), - req('nvim-ts-autotag'), -} diff --git a/nvim/lua/plugins/treesitter/nvim-treesitter-textobjects.lua b/nvim/lua/plugins/treesitter/nvim-treesitter-textobjects.lua deleted file mode 100644 index 8deffdf..0000000 --- a/nvim/lua/plugins/treesitter/nvim-treesitter-textobjects.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - 'nvim-treesitter-textobjects', - event = 'DeferredUIEnter', - before = function() - require('lz.n').trigger_load('nvim-treesitter') - end, -} diff --git a/nvim/lua/plugins/treesitter/nvim-treesitter.lua b/nvim/lua/plugins/treesitter/nvim-treesitter.lua deleted file mode 100644 index dbe94ec..0000000 --- a/nvim/lua/plugins/treesitter/nvim-treesitter.lua +++ /dev/null @@ -1,73 +0,0 @@ -return { - 'nvim-treesitter', - event = { 'BufReadPost', 'BufWritePost', 'BufNewFile', 'DeferredUIEnter' }, - keys = { - { '', desc = 'increment selection' }, - { '', desc = 'decrement selection', mode = 'x' }, - }, - before = function() - require('lz.n').trigger_load('which-key.nvim') - end, - after = function() - vim.filetype.add({ - extension = { rasi = 'rasi', rofi = 'rasi', wofi = 'rasi', env = 'conf' }, - filename = { ['.env'] = 'conf' }, - pattern = { - ['.*/waybar/config'] = 'jsonc', - ['.*/mako/config'] = 'dosini', - ['.*/kitty/.+%.conf'] = 'kitty', - ['.*/hypr/.+*.conf'] = 'hyprlang', - ['%.env%.[%w_.-]+'] = 'conf', - }, - }) - - -- Use the bash parser for kitty files. - vim.treesitter.language.register('bash', 'kitty') - - ---@diagnostic disable-next-line: missing-fields - require('nvim-treesitter.configs').setup({ - auto_install = false, - highlight = { enable = true }, - indent = { enable = true }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = '', - node_incremental = '', - scope_incremental = false, - node_decremental = '', - }, - }, - textobjects = { - move = { - enable = true, - goto_next_start = { - [']f'] = '@function.outer', - [']c'] = '@class.outer', - [']a'] = '@parameter.inner', - }, - goto_next_end = { - [']F'] = '@function.outer', - [']C'] = '@class.outer', - [']A'] = '@parameter.inner', - }, - goto_previous_start = { - ['[f'] = '@function.outer', - ['[c'] = '@class.outer', - ['[a'] = '@parameter.inner', - }, - goto_previous_end = { - ['[F'] = '@function.outer', - ['[C'] = '@class.outer', - ['[A'] = '@parameter.inner', - }, - }, - }, - }) - - require('which-key').add({ - { '', desc = 'decrement selection', mode = 'x' }, - { '', desc = 'increment selection', mode = { 'x', 'n' } }, - }) - end, -} diff --git a/nvim/lua/plugins/treesitter/nvim-ts-autotag.lua b/nvim/lua/plugins/treesitter/nvim-ts-autotag.lua deleted file mode 100644 index d663d8b..0000000 --- a/nvim/lua/plugins/treesitter/nvim-ts-autotag.lua +++ /dev/null @@ -1,11 +0,0 @@ -return { - 'nvim-ts-autotag', - event = { 'BufReadPost', 'BufWritePost', 'BufNewFile' }, - after = function() - require('nvim-ts-autotag').setup({ - opts = { - enable_close_on_slash = true, - }, - }) - end, -} diff --git a/nvim/lua/plugins/ui/alpha-nvim.lua b/nvim/lua/plugins/ui/alpha-nvim.lua deleted file mode 100644 index 19bd4a0..0000000 --- a/nvim/lua/plugins/ui/alpha-nvim.lua +++ /dev/null @@ -1,53 +0,0 @@ -return { - 'alpha-nvim', - before = function() - require('lz.n').trigger_load('plenary.nvim') - require('lz.n').trigger_load('mini.icons') - end, - after = function() - local theta = require('alpha.themes.theta') - - local header = [[ -███╗ ███╗ █████╗ ██████╗ ██╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ -████╗ ████║██╔══██╗██╔══██╗██║ ██╔════╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ -██╔████╔██║███████║██████╔╝██║ █████╗ ╚████╔╝ ██║ ██║██║██╔████╔██║ -██║╚██╔╝██║██╔══██║██╔══██╗██║ ██╔══╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ -██║ ╚═╝ ██║██║ ██║██║ ██║███████╗███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║ -╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ - ]] - - theta.header.val = vim.split(header, '\n') - - local button = require('alpha.themes.dashboard').button - theta.buttons.val = { - { - type = 'text', - val = 'Shortcuts', - opts = { hl = 'SpecialComment', position = 'center' }, - }, - { type = 'padding', val = 1 }, - - button( - 'f', - '󰈞 Find file', - 'lua require("lz.n").trigger_load("fzf-lua"); require("fzf-lua").files()' - ), - - button( - 'g', - ' Live grep', - 'lua require("lz.n").trigger_load("fzf-lua"); require("fzf-lua").live_grep()' - ), - - button( - 's', - ' Restore session', - 'lua require("lz.n").trigger_load("persistence.nvim"); require("persistence").load()' - ), - - button('q', ' Quit', 'qa'), - } - - require('alpha').setup(theta.config) - end, -} diff --git a/nvim/lua/plugins/ui/bufferline-nvim.lua b/nvim/lua/plugins/ui/bufferline-nvim.lua deleted file mode 100644 index 91526b4..0000000 --- a/nvim/lua/plugins/ui/bufferline-nvim.lua +++ /dev/null @@ -1,109 +0,0 @@ -return { - 'bufferline.nvim', - event = 'DeferredUIEnter', - keys = { - { - 'bp', - 'BufferLineTogglePin', - desc = 'toggle buffer pin', - }, - { - 'bP', - 'BufferLineGroupClose ungrouped', - desc = 'delete non-pinned buffers', - }, - { - 'br', - 'BufferLineCloseRight', - desc = 'delete buffers to the right', - }, - { - 'bl', - 'BufferLineCloseLeft', - desc = 'delete buffers to the left', - }, - { '', 'BufferLineCyclePrev', desc = 'previous buffer' }, - { '', 'BufferLineCycleNext', desc = 'next buffer' }, - { '[b', 'BufferLineCyclePrev', desc = 'previous buffer' }, - { ']b', 'BufferLineCycleNext', desc = 'next buffer' }, - { '[B', 'BufferLineMovePrev', desc = 'move buffer left' }, - { ']B', 'BufferLineMoveNext', desc = 'move buffer right' }, - }, - before = function() - require('lz.n').trigger_load({ 'mini.icons', 'which-key.nvim' }) - - if vim.g.colors_name == 'rose-pine' then - require('lz.n').trigger_load('rose-pine') - end - end, - after = function() - local opts = { - options = { - always_show_bufferline = true, - - close_command = function(n) - Snacks.bufdelete(n) - end, - right_mouse_command = function(n) - Snacks.bufdelete(n) - end, - - diagnostics = 'nvim_lsp', - diagnostics_indicator = function(_, _, diag) - local icons = require('icons').diagnostics - local ret = (diag.error and icons.Error .. diag.error .. ' ' or '') - .. (diag.warning and icons.Warn .. diag.warning or '') - - return vim.trim(ret) - end, - - offsets = { - { - filetype = 'neo-tree', - text = 'Explorer', - highlight = 'Directory', - text_align = 'center', - }, - }, - - get_element_icon = function(elem) - local icon, hl, _ = - require('mini.icons').get('filetype', elem.filetype) - - return icon, hl - end, - }, - } - - if vim.g.colors_name == 'rose-pine' then - opts.highlights = require('rose-pine.plugins.bufferline') - end - - require('bufferline').setup(opts) - - vim.api.nvim_create_autocmd({ 'BufAdd', 'BufDelete' }, { - desc = 'Fix bufferline when restoring a session', - callback = function() - vim.schedule(function() - pcall(nvim_bufferline) - end) - end, - }) - - local colors = require('colors') - local mkKey = MarleyVim.wkSpec(colors.buffers) - - require('which-key').add({ - mkKey('bp', nil, ''), - mkKey('bP', nil, '󰐄'), - mkKey('br', nil, ''), - mkKey('bl', nil, ''), - mkKey('', nil, ''), - mkKey('', nil, ''), - mkKey('[b', nil, ''), - mkKey(']b', nil, ''), - mkKey('[B', nil, ''), - mkKey(']B', nil, ''), - }) - end, -} diff --git a/nvim/lua/plugins/ui/diffview-nvim.lua b/nvim/lua/plugins/ui/diffview-nvim.lua deleted file mode 100644 index d8cceb7..0000000 --- a/nvim/lua/plugins/ui/diffview-nvim.lua +++ /dev/null @@ -1,17 +0,0 @@ -return { - 'diffview.nvim', - cmd = { - 'DiffviewOpen', - 'DiffviewClose', - 'DiffviewToggleFiles', - 'DiffviewFocusFiles', - 'DiffviewRefresh', - 'DiffviewFileHistory', - }, - before = function() - require('lz.n').trigger_load({ 'mini.icons' }) - end, - after = function() - require('diffview').setup({}) - end, -} diff --git a/nvim/lua/plugins/ui/indent-blankline-nvim.lua b/nvim/lua/plugins/ui/indent-blankline-nvim.lua deleted file mode 100644 index 039961a..0000000 --- a/nvim/lua/plugins/ui/indent-blankline-nvim.lua +++ /dev/null @@ -1,41 +0,0 @@ -return { - 'indent-blankline.nvim', - event = { 'BufReadPost', 'BufWritePost', 'BufNewFile' }, - after = function() - require('ibl').setup({ - indent = { - char = '│', - tab_char = '│', - }, - scope = { show_start = false, show_end = false }, - exclude = { - filetypes = { - 'Trouble', - 'alpha', - 'dashboard', - 'help', - 'lazy', - 'mason', - 'neo-tree', - 'notify', - 'snacks_dashboard', - 'snacks_notif', - 'snacks_terminal', - 'snacks_win', - 'toggleterm', - 'trouble', - }, - }, - }) - - Snacks.toggle({ - name = 'Indent guides', - get = function() - return require('ibl.config').get_config(0).enabled - end, - set = function(state) - require('ibl').setup_buffer(0, { enabled = state }) - end, - }):map('ug') - end, -} diff --git a/nvim/lua/plugins/ui/init.lua b/nvim/lua/plugins/ui/init.lua deleted file mode 100644 index d0cf2e0..0000000 --- a/nvim/lua/plugins/ui/init.lua +++ /dev/null @@ -1,14 +0,0 @@ -local req = MarleyVim.local_require('plugins.ui') - -return { - req('alpha-nvim'), - req('bufferline-nvim'), - req('diffview-nvim'), - req('indent-blankline-nvim'), - req('lualine-nvim'), - req('mini-animate'), - req('mini-icons'), - req('no-neck-pain-nvim'), - req('noice-nvim'), - req('nvim-treesitter-context'), -} diff --git a/nvim/lua/plugins/ui/lualine-nvim.lua b/nvim/lua/plugins/ui/lualine-nvim.lua deleted file mode 100644 index 99a67c8..0000000 --- a/nvim/lua/plugins/ui/lualine-nvim.lua +++ /dev/null @@ -1,146 +0,0 @@ -return { - 'lualine.nvim', - event = 'DeferredUIEnter', - beforeAll = function() - vim.g.lualine_laststatus = vim.o.laststatus - - if vim.fn.argc(-1) > 0 then - -- Set an empty statusline until lualine loads. - vim.o.statusline = ' ' - else - -- Hide the statusline on the starter page. - vim.o.laststatus = 0 - end - end, - before = function() - require('lz.n').trigger_load({ 'mini.icons', 'aerial.nvim' }) - - if vim.g.colors_name == 'rose-pine' then - require('lz.n').trigger_load('rose-pine') - end - end, - after = function() - local icons = require('icons') - - vim.o.laststatus = vim.g.lualine_laststatus - - require('lualine').setup({ - options = { - theme = 'auto', - globalstatus = vim.o.laststatus == 3, - disabled_filetypes = { - statusline = { - 'dashboard', - 'alpha', - 'ministarter', - 'snacks_dashboard', - }, - }, - sections = { - lualine_a = { 'mode' }, - lualine_b = { 'branch' }, - - lualine_c = { - { - 'diagnostics', - symbols = { - error = icons.diagnostics.Error, - warn = icons.diagnostics.Warn, - info = icons.diagnostics.Info, - hint = icons.diagnostics.Hint, - }, - }, - { - 'filetype', - icon_only = true, - separator = '', - padding = { left = 1, right = 0 }, - }, - { - 'filename', - path = 4, - symbols = { readonly = ' 󰌾 ', modified = '' }, - }, - { - 'aerial', - sep = ' ', - sep_icon = '', - depth = 5, - dense = false, - dense_sep = '.', - colored = true, - }, - }, - - lualine_x = { - { - function() - ---@alias NoiceStatusOv {has:(fun():boolean), get:(fun():string), get_hl:(fun():string)} - - return require('noice') - .api - .status - .command --[[@as NoiceStatusOv]] - .get() - end, - cond = function() - return package.loaded['noice'] - and require('noice') - .api - .status - .command --[[@as NoiceStatusOv]] - .has() - end, - color = function() - return MarleyVim.fg('Statement') - end, - }, - - { - function() - return ' ' .. require('dap').status() - end, - cond = function() - return package.loaded['dap'] and require('dap').status ~= '' - end, - color = function() - return MarleyVim.fg('debug') - end, - }, - - { - 'diff', - symbols = { - added = icons.git.added, - modified = icons.git.modified, - removed = icons.git.removed, - }, - source = function() - local gitsigns = vim.b.gitsigns_status_dict - - if gitsigns then - return { - added = gitsigns.added, - modified = gitsigns.changed, - removed = gitsigns.removed, - } - end - end, - }, - }, - - lualine_y = { - { 'progress', separator = ' ', padding = { left = 1, right = 0 } }, - { 'location', padding = { left = 0, right = 1 } }, - }, - lualine_z = { - function() - return ' ' .. os.date('%R') - end, - }, - }, - extensions = { 'neo-tree' }, - }, - }) - end, -} diff --git a/nvim/lua/plugins/ui/mini-animate.lua b/nvim/lua/plugins/ui/mini-animate.lua deleted file mode 100644 index b9dac3f..0000000 --- a/nvim/lua/plugins/ui/mini-animate.lua +++ /dev/null @@ -1,56 +0,0 @@ -return { - 'mini.animate', - enabled = vim.g.neovide == nil, - event = { 'DeferredUIEnter' }, - after = function() - local mouse_scrolled = false - for _, scroll in ipairs({ 'UP', 'DOWN' }) do - local key = '' - - vim.keymap.set({ '', 'i' }, key, function() - mouse_scrolled = true - return key - end, { expr = true }) - end - - vim.api.nvim_create_autocmd('FileType', { - pattern = 'grug-far', - callback = function() - vim.b.minianimate_disable = true - end, - }) - - Snacks.toggle({ - name = 'mini animate', - get = function() - return not vim.g.minianimate_disable - end, - set = function(state) - vim.g.minianimate_disable = not state - end, - }):map('ua') - - local animate = require('mini.animate') - - local opts = { - resize = { - timing = animate.gen_timing.linear({ duration = 50, unit = 'total' }), - }, - scroll = { - timing = animate.gen_timing.linear({ duration = 50, unit = 'total' }), - subscroll = animate.gen_subscroll.equal({ - predicate = function(total_scroll) - if mouse_scrolled then - mouse_scrolled = false - return false - end - - return total_scroll > 1 - end, - }), - }, - } - - animate.setup(opts) - end, -} diff --git a/nvim/lua/plugins/ui/mini-icons.lua b/nvim/lua/plugins/ui/mini-icons.lua deleted file mode 100644 index abe2b52..0000000 --- a/nvim/lua/plugins/ui/mini-icons.lua +++ /dev/null @@ -1,20 +0,0 @@ -return { - 'mini.icons', - after = function() - require('mini.icons').setup({ - file = { - ['.keep'] = { glyph = '󰊢', hl = 'MiniIconsGrey' }, - ['devcontainer.json'] = { glyph = '', hl = 'MiniIconsAzure' }, - }, - filetype = { - dotenv = { glyph = '󰌋', hl = 'MiniIconsYellow' }, - }, - }) - - package.preload['nvim-web-devicons'] = function() - require('mini.icons').mock_nvim_web_devicons() - - return package.loaded['nvim-web-devicons'] - end - end, -} diff --git a/nvim/lua/plugins/ui/no-neck-pain-nvim.lua b/nvim/lua/plugins/ui/no-neck-pain-nvim.lua deleted file mode 100644 index 569043c..0000000 --- a/nvim/lua/plugins/ui/no-neck-pain-nvim.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - 'no-neck-pain-nvim', - cmd = { - 'NoNeckPain', - 'NoNeckPainResize', - 'NoNeckPainToggleLeftSide', - 'NoNeckPainToggleRightSide', - 'NoNeckPainWidthUp', - 'NoNeckPainWidthDown', - 'NoNeckPainScratchPad', - }, -} diff --git a/nvim/lua/plugins/ui/noice-nvim.lua b/nvim/lua/plugins/ui/noice-nvim.lua deleted file mode 100644 index 6f621d4..0000000 --- a/nvim/lua/plugins/ui/noice-nvim.lua +++ /dev/null @@ -1,113 +0,0 @@ -return { - 'noice.nvim', - event = 'DeferredUIEnter', - keys = { - { 'n', '', desc = '+notifications' }, - { - '', - function() - require('noice').redirect(vim.fn.getcmdline()) - end, - mode = 'c', - desc = 'redirect cmdline', - }, - { - 'nl', - function() - require('noice').cmd('last') - end, - desc = 'last message', - }, - { - 'nh', - function() - require('noice').cmd('history') - end, - desc = 'message history', - }, - { - 'na', - function() - require('noice').cmd('all') - end, - desc = 'all messages', - }, - { - 'nd', - function() - require('noice').cmd('dismiss') - end, - desc = 'dismiss all', - }, - { - 'nt', - function() - require('noice').cmd('pick') - end, - desc = 'message picker', - }, - { - '', - function() - if not require('noice.lsp').scroll(4) then - return '' - end - end, - mode = { 'i', 'n', 's' }, - silent = true, - expr = true, - desc = 'scroll forward', - }, - { - '', - function() - if not require('noice.lsp').scroll(-4) then - return '' - end - end, - mode = { 'i', 'n', 's' }, - silent = true, - expr = true, - desc = 'scroll backward', - }, - }, - before = function() - require('lz.n').trigger_load({ 'nui.nvim', 'which-key.nvim' }) - end, - after = function() - require('noice').setup({ - lsp = { - override = { - ['vim.lsp.util.convert_input_to_markdown_lines'] = true, - ['vim.lsp.util.stylize_markdown'] = true, - ['cmp.entry.get_documentation'] = true, - }, - }, - routes = { - { - filter = { - event = 'msg_show', - any = { - { find = '%d+L, %d+B' }, - { find = '; after #%d+' }, - { find = '; before #%d+' }, - }, - }, - view = 'mini', - }, - }, - presets = { - command_palette = true, - long_message_to_split = true, - lsp_doc_border = true, - }, - }) - - local mkKey = MarleyVim.wkSpec(require('colors').notifications) - require('which-key').add({ - mkKey('', nil, '', { mode = 'c' }), - mkKey('', nil, '', { mode = { 'i', 'n', 's' } }), - mkKey('', nil, '', { mode = { 'i', 'n', 's' } }), - }) - end, -} diff --git a/nvim/lua/plugins/ui/nvim-treesitter-context.lua b/nvim/lua/plugins/ui/nvim-treesitter-context.lua deleted file mode 100644 index 19c7470..0000000 --- a/nvim/lua/plugins/ui/nvim-treesitter-context.lua +++ /dev/null @@ -1,24 +0,0 @@ -return { - 'nvim-treesitter-context', - event = { 'BufReadPost', 'BufWritePost', 'BufNewFile' }, - after = function() - local tsc = require('treesitter-context') - - Snacks.toggle({ - name = 'treesitter context', - get = tsc.enabled, - set = function(state) - if state then - tsc.enable() - else - tsc.disable() - end - end, - }):map('ut') - - tsc.setup({ - mode = 'cursor', - max_lines = 3, - }) - end, -} diff --git a/nvim/lua/plugins/util/init.lua b/nvim/lua/plugins/util/init.lua deleted file mode 100644 index bb8b65f..0000000 --- a/nvim/lua/plugins/util/init.lua +++ /dev/null @@ -1,10 +0,0 @@ -local req = MarleyVim.local_require('plugins.util') - -return { - req('mini-hipatterns'), - req('nerdy-nvim'), - req('nui-nvim'), - req('persistance-nvim'), - req('plenary'), - req('project-nvim'), -} diff --git a/nvim/lua/plugins/util/mini-hipatterns.lua b/nvim/lua/plugins/util/mini-hipatterns.lua deleted file mode 100644 index 6c8a19b..0000000 --- a/nvim/lua/plugins/util/mini-hipatterns.lua +++ /dev/null @@ -1,85 +0,0 @@ -return { - 'mini.hipatterns', - event = { 'BufReadPost', 'BufWritePost', 'BufNewFile' }, - after = function() - local hipatterns = require('mini.hipatterns') - - -- Tailwind CSS support. - local hls = {} - local tailwindFts = { - 'astro', - 'css', - 'heex', - 'html', - 'html-eex', - 'javascript', - 'javascriptreact', - 'rust', - 'svelte', - 'typescript', - 'typescriptreact', - 'vue', - } - - -- Reset hl groups when colorscheme changes. - vim.api.nvim_create_autocmd('ColorScheme', { - callback = function() - hls = {} - end, - }) - - hipatterns.setup({ - highlighters = { - hex_color = hipatterns.gen_highlighter.hex_color({ priority = 2000 }), - shorthand = { - pattern = '()#%x%x%x()%f[^%x%w]', - group = function(_, _, data) - ---@type string - local match = data.full_match - local r, g, b = match:sub(2, 2), match:sub(3, 3), match:sub(4, 4) - local hex_color = '#' .. r .. r .. g .. g .. b .. b - - return MiniHipatterns.compute_hex_color_group(hex_color, 'bg') - end, - extmark_opts = { priority = 2000 }, - }, - tailwind = { - pattern = function() - if not vim.tbl_contains(tailwindFts, vim.bo.filetype) then - return - end - - return '%f[%w:-]()[%w:-]+%-[a-z%-]+%-%d+()%f[^%w:-]' - end, - group = function(_, _, m) - ---@type string - local match = m.full_match - - ---@type string, number? - local color, shade = match:match('[%w-]+%-([a-z%-]+)%-(%d+)') - shade = tonumber(shade) - - local c = require('colors') - local bg = vim.tbl_get(c.tailwind, color, shade) - if bg then - local hl = 'MiniHipatternsTailwind' .. color .. shade - if not hls[hl] then - hls[hl] = true - - local bg_shade = shade == 500 and 950 - or shade < 500 and 900 - or 100 - local fg = vim.tbl_get(c.tailwind, color, bg_shade) - - vim.api.nvim_set_hl(0, hl, { bg = '#' .. bg, fg = '#' .. fg }) - end - - return hl - end - end, - extmark_opts = { priority = 2000 }, - }, - }, - }) - end, -} diff --git a/nvim/lua/plugins/util/nerdy-nvim.lua b/nvim/lua/plugins/util/nerdy-nvim.lua deleted file mode 100644 index 03f7d83..0000000 --- a/nvim/lua/plugins/util/nerdy-nvim.lua +++ /dev/null @@ -1,13 +0,0 @@ -return { - 'nerdy.nvim', - cmd = 'Nerdy', - keys = { - { - 'ci', - function() - require('nerdy').list() - end, - desc = 'pick nerd icon', - }, - }, -} diff --git a/nvim/lua/plugins/util/nui-nvim.lua b/nvim/lua/plugins/util/nui-nvim.lua deleted file mode 100644 index 0b09579..0000000 --- a/nvim/lua/plugins/util/nui-nvim.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - 'nui.nvim', - lazy = true, -} diff --git a/nvim/lua/plugins/util/persistance-nvim.lua b/nvim/lua/plugins/util/persistance-nvim.lua deleted file mode 100644 index e54f273..0000000 --- a/nvim/lua/plugins/util/persistance-nvim.lua +++ /dev/null @@ -1,37 +0,0 @@ -return { - 'persistence.nvim', - event = 'BufReadPre', - keys = { - { - 'qs', - function() - require('persistence').load() - end, - desc = 'Restore session', - }, - { - 'qS', - function() - require('persistence').select() - end, - desc = 'Select session', - }, - { - 'ql', - function() - require('persistence').load({ last = true }) - end, - desc = 'Restore last session', - }, - { - 'qd', - function() - require('persistence').stop() - end, - desc = "Don't save current session", - }, - }, - after = function() - require('persistence').setup({}) - end, -} diff --git a/nvim/lua/plugins/util/plenary.lua b/nvim/lua/plugins/util/plenary.lua deleted file mode 100644 index 5694110..0000000 --- a/nvim/lua/plugins/util/plenary.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - 'plenary.nvim', - lazy = true, -} diff --git a/nvim/lua/plugins/util/project-nvim.lua b/nvim/lua/plugins/util/project-nvim.lua deleted file mode 100644 index 4e42c80..0000000 --- a/nvim/lua/plugins/util/project-nvim.lua +++ /dev/null @@ -1,19 +0,0 @@ -return { - 'project.nvim', - event = { 'DeferredUIEnter' }, - after = function() - require('project_nvim').setup({ - manual_mode = true, - }) - - local history = require('project_nvim.utils.history') - history.delete_project = function(project) - for k, v in pairs(history.recent_projects) do - if v == project.value then - history.recent_projects[k] = nil - return - end - end - end - end, -} diff --git a/nvim/lua/snacks-nvim.lua b/nvim/lua/snacks-nvim.lua deleted file mode 100644 index 399fc8f..0000000 --- a/nvim/lua/snacks-nvim.lua +++ /dev/null @@ -1,135 +0,0 @@ --- Snacks needs to be loaded very early, so it gets its own special file. -local set = vim.keymap.set - -require('snacks').setup({ - bigfile = { enabled = true }, - notifier = { enabled = true }, - quickfile = { enabled = true }, - statuscolumn = { enabled = true }, - words = { enabled = true }, - scroll = { enabled = false }, -}) - --- Debuggers -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -_G.dd = function(...) - Snacks.debug.inspect(...) -end - -_G.bt = function() - Snacks.debug.backtrace() -end - -vim.print = _G.dd - --- Notifier -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -set({ 'n' }, 'un', function() - Snacks.notifier.hide() -end, { desc = 'dismiss all notifications' }) - --- Buffers -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -set({ 'n' }, 'bd', function() - Snacks.bufdelete() -end, { desc = 'delete buffer' }) - -set({ 'n' }, 'bo', function() - Snacks.bufdelete.other() -end, { desc = 'delete other buffers' }) - --- Toggles -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -local toggle = Snacks.toggle - -toggle.option('spell', { name = 'spelling' }):map('us') -toggle.option('wrap', { name = 'wrap' }):map('uw') - -toggle.option('relativenumber', { name = 'relative number' }):map('uL') -toggle.line_number():map('ul') - -toggle.diagnostics():map('ud') - -toggle - .option( - 'conceallevel', - { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 } - ) - :map('uc') - -toggle.treesitter():map('uT') - -if vim.lsp.inlay_hint then - toggle.inlay_hints():map('uh') -end - -toggle({ - name = 'auto format (global)', - get = function() - return vim.g.autoformat == nil or vim.g.autoformat - end, - set = function(enable) - vim.g.autoformat = (enable == nil and true) or enable - vim.b.autoformat = nil - end, -}):map('uf') - -toggle({ - name = 'auto format (buffer)', - get = function() - local buf = vim.api.nvim_get_current_buf() - - local gopt = vim.g.autoformat - local bopt = vim.b[buf].autoformat - - if bopt ~= nil then - return bopt - end - - return gopt == nil or gopt - end, - set = function(enable) - vim.b.autoformat = (enable == nil and true) or enable - end, -}):map('uF') - --- Git -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -set({ 'n' }, 'gb', function() - Snacks.git.blame_line() -end, { desc = 'git blame line' }) - -set({ 'n' }, 'gB', function() - Snacks.gitbrowse() -end, { desc = 'git browse (open)' }) - -set({ 'n' }, 'gY', function() - Snacks.gitbrowse({ - open = function(url) - vim.fn.setreg('+', url) - end, - }) -end, { desc = 'git browse (copy)' }) - --- LazyGit -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - -if vim.fn.executable('lazygit') == 1 then - set({ 'n' }, 'gg', function() - Snacks.lazygit({ cwd = MarleyVim.root() }) - end, { desc = 'lazygit (root dir)' }) - - -- set({ 'n' }, 'gG', function() - -- Snacks.lazygit() - -- end, { desc = 'Lazygit (cwd)' }) - - set({ 'n' }, 'gf', function() - Snacks.lazygit.log_file() - end, { desc = 'lazygit current file history' }) - - set({ 'n' }, 'gl', function() - Snacks.lazygit.log({ cwd = MarleyVim.root() }) - end, { desc = 'Lazygit log' }) - - -- set({ 'n' }, 'gL', function() - -- Snacks.lazygit.log() - -- end, { desc = 'Lazygit log (cwd)' }) -end diff --git a/nvim/lua/snippets/fish.lua b/nvim/lua/snippets/fish.lua deleted file mode 100644 index 911294f..0000000 --- a/nvim/lua/snippets/fish.lua +++ /dev/null @@ -1,107 +0,0 @@ -local ls = require("luasnip") -local s = ls.snippet -local t = ls.text_node -local i = ls.insert_node -local f = ls.function_node -local fmt = require("luasnip.extras.fmt").fmt -local fill = require("snippets.helpers").fill - -return { - s( - { trig = "dc", desc = "divider comment" }, - f(fill, {}, { user_args = { "#%- " } }) - ), - - s({ trig = "#!", desc = "shebang" }, t("#!/usr/bin/env fish")), - - s( - { trig = "if", desc = "if ... end" }, - fmt( - [[ - if {} - {} - end - ]], - { i(1), i(0) } - ) - ), - - s( - { trig = "elif", desc = "else if ..." }, - fmt( - [[ - else if {} - {} - ]], - { i(1), i(0) } - ) - ), - - s( - { trig = "fori", desc = "for ... in ... end" }, - fmt( - [[ - for {} in {} - {} - end - ]], - { i(1), i(2), i(0) } - ) - ), - - s( - { trig = "wh", desc = "while ... end" }, - fmt( - [[ - while {} - {} - end - ]], - { i(1), i(0) } - ) - ), - - s( - { trig = "wht", desc = "while true ... end" }, - fmt( - [[ - while true - {} - end - ]], - { i(0) } - ) - ), - - s( - { trig = "sw", desc = "switch ... case ... end" }, - fmt( - [[ - switch {} - case {} - {} - end - ]], - { i(1), i(2), i(0) } - ) - ), - - s( - { trig = "func", desc = "function ... end" }, - fmt( - [[ - function {} - {} - end - ]], - { i(1), i(0) } - ) - ), - - s({ trig = "dn", desc = "&>/dev/null" }, t("&>/dev/null")), - - s( - { trig = "abbr", desc = "abbr -a ... --position ..." }, - fmt('abbr -a {} --position {} "{}"', { i(1), i(2, "command"), i(3) }) - ), -} diff --git a/nvim/lua/snippets/gitconfig.lua b/nvim/lua/snippets/gitconfig.lua deleted file mode 100644 index 088e0ef..0000000 --- a/nvim/lua/snippets/gitconfig.lua +++ /dev/null @@ -1,8 +0,0 @@ -local ls = require("luasnip") -local s = ls.snippet -local f = ls.function_node -local helpers = require("snippets.helpers") - -return { - s({ trig = "dc", desc = "divider comment" }, f(helpers.fill, {}, { user_args = { "#%- " } })), -} diff --git a/nvim/lua/snippets/helpers.lua b/nvim/lua/snippets/helpers.lua deleted file mode 100644 index 0ae8842..0000000 --- a/nvim/lua/snippets/helpers.lua +++ /dev/null @@ -1,40 +0,0 @@ -local ls = require('luasnip') -local sn = ls.snippet_node -local i = ls.insert_node - -local M = {} - -M.fill = function(_, parent, args) - local title = '' - local chars = {} - - if type(parent.snippet.env.LS_SELECT_RAW) == 'table' then - for _, ele in ipairs(parent.snippet.env.LS_SELECT_RAW) do - title = title .. ele .. ' ' - end - end - - for str in string.gmatch(args, '([^%%]+)') do - table.insert(chars, str) - end - - local snip = chars[1] .. ' ' .. title - - local _, c = unpack(vim.api.nvim_win_get_cursor(0)) - - while #snip < (vim.bo.tw - c - 1) do - snip = snip .. chars[2] - end - - return snip -end - -M.get_visual = function(_, parent) - if #parent.snippet.env.LS_SELECT_RAW > 0 then - return sn(nil, i(1, parent.snippet.env.LS_SELECT_RAW)) - else -- If LS_SELECT_RAW is empty, return a blank insert node - return sn(nil, i(1)) - end -end - -return M diff --git a/nvim/lua/snippets/html.lua b/nvim/lua/snippets/html.lua deleted file mode 100644 index 5a34b0d..0000000 --- a/nvim/lua/snippets/html.lua +++ /dev/null @@ -1,29 +0,0 @@ -local ls = require("luasnip") -local s = ls.snippet -local i = ls.insert_node -local fmt = require("luasnip.extras.fmt").fmt - -return { - s( - { trig = "sd!", desc = "Saudade page" }, - fmt( - [[ - - - - - {} - - - - - - - {} - - - ]], - { i(1), i(0) } - ) - ), -} diff --git a/nvim/lua/snippets/lua.lua b/nvim/lua/snippets/lua.lua deleted file mode 100644 index 435711f..0000000 --- a/nvim/lua/snippets/lua.lua +++ /dev/null @@ -1,20 +0,0 @@ -local ls = require('luasnip') -local s = ls.snippet -local f = ls.function_node -local t = ls.text_node -local fill = require('snippets.helpers').fill - -return { - s( - { trig = 'dc', desc = 'divider comment' }, - f(fill, {}, { user_args = { '--%-- ' } }) - ), - s( - { trig = 'LazyFile', desc = 'LazyFile events for non-lazy.nvim setups' }, - t('event = { "BufReadPost", "BufWritePost", "BufNewFile" }') - ), - s( - { trig = 'VeryLazy', desc = 'VeryLazy events for non-lazy.nvim setups' }, - t('event = { "DeferredUIEnter" }') - ), -} diff --git a/nvim/lua/snippets/nix.lua b/nvim/lua/snippets/nix.lua deleted file mode 100644 index b9b89c9..0000000 --- a/nvim/lua/snippets/nix.lua +++ /dev/null @@ -1,148 +0,0 @@ -local ls = require("luasnip") -local s = ls.snippet -local i = ls.insert_node -local f = ls.function_node -local fmta = require("luasnip.extras.fmt").fmta -local rep = require("luasnip.extras").rep -local fill = require("snippets.helpers").fill - -return { - s( - { trig = "dc", desc = "divider comment" }, - f(fill, {}, { user_args = { "#%- " } }) - ), - - s( - { trig = "mexpr", desc = "Basic module expression" }, - fmta( - [[ - { <>... }: - { - <> - } - ]], - { i(1), i(0) } - ) - ), - - s( - { trig = "ovr", desc = "Override" }, - fmta( - [[ - <> = prev.<>.override { - <> - }; - ]], - { i(1, "pkg"), rep(1), i(0) } - ) - ), - - s( - { trig = "ovra", desc = "OverrideAttrs" }, - fmta( - [[ - <> = prev.<>.overrideAttrs (old: { - <> - }); - ]], - { i(1, "pkg"), rep(1), i(0) } - ) - ), - - s( - { trig = "hpkg", desc = "home.packages list" }, - fmta( - [[ - home.packages = with pkgs; [ - <> - ];<> - ]], - { i(1), i(0) } - ) - ), - - s( - { trig = "shm", desc = "Snowfall lib home module" }, - fmta( - [[ - { - lib, - config,<> - ... - }: - let - inherit (lib) mkEnableOption mkIf;<> - - cfg = config.marleyos.<>.<>;<> - in - { - options.marleyos.<>.<>.enable = mkEnableOption "<>"; - - config = mkIf cfg.enable { - <> - }; - } - ]], - { - i(1), -- extra args - i(2, { "", " inherit (lib.marleyos) enabled;" }), - i(3), -- group - i(4), -- mod - i(5, { "", " inherit (config.marleyos.theme) colors;" }), - rep(3), -- group - rep(4), -- mod - rep(4), -- mod - i(0), -- end - } - ) - ), - - s( - { trig = "ith", desc = "Inherit theme definition" }, - fmta( - [[ - inherit (config.marleyos.theme) colors;<> - ]], - { i(0) } - ) - ), - - s( - { trig = "erpth", desc = "Enable rose-pine theme module option" }, - fmta( - [[ - rose-pine = mkIf colors.isRosePine enabled;<> - ]], - { i(0) } - ) - ), - - s( - { trig = "sov", desc = "Snowfall lib overlay" }, - fmta( - [[ - <>: final: prev: { - <> - } - ]], - { i(1, "_"), i(0) } - ) - ), - - s( - { trig = "nvk", desc = "NixVim keymap attr set" }, - fmta( - [[ - { - mode = [ "<>"<> ]; - key = "<>"; - action = "<>"; - options = { - desc = "<>";<> - }; - }<> - ]], - { i(1), i(2), i(3), i(4), i(5), i(6), i(0) } - ) - ), -} diff --git a/nvim/queries/lua/highlights.scm b/nvim/queries/lua/highlights.scm deleted file mode 100644 index 7402260..0000000 --- a/nvim/queries/lua/highlights.scm +++ /dev/null @@ -1,7 +0,0 @@ -;; extends - -((identifier) @namespace.builtin - (#eq? @namespace.builtin "vim")) - -((identifier) @namespace.builtin - (#eq? @namespace.builtin "MarleyVim"))