From ff2102be96ff3477e1537b98e192a24ba8ca7b9b Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 27 Sep 2023 16:06:12 +0300 Subject: [PATCH 01/14] docs/hacking: add contributing guidelines --- docs/default.nix | 21 ++- docs/man-configuration.xml | 5 +- docs/manual.xml | 10 +- docs/manual/hacking.adoc | 370 +++++++++++++++++++++++++++++++++++++ 4 files changed, 398 insertions(+), 8 deletions(-) create mode 100644 docs/manual/hacking.adoc diff --git a/docs/default.nix b/docs/default.nix index 683dc9c..211bf38 100644 --- a/docs/default.nix +++ b/docs/default.nix @@ -3,24 +3,41 @@ lib ? import ../lib/stdlib-extended.nix pkgs.lib, nmdSrc, }: let - nmd = import nmdSrc {inherit lib pkgs;}; + nmd = import nmdSrc { + inherit lib; + # The DocBook output of `nixos-render-docs` doesn't have the change + # `nmd` uses to work around the broken stylesheets in + # `docbook-xsl-ns`, so we restore the patched version here. + pkgs = + pkgs + // { + docbook-xsl-ns = + pkgs.docbook-xsl-ns.override {withManOptDedupPatch = true;}; + }; + }; + + # Make sure the used package is scrubbed to avoid actually + # instantiating derivations. scrubbedPkgsModule = { imports = [ { _module.args = { pkgs = lib.mkForce (nmd.scrubDerivations "pkgs" pkgs); + pkgs_i686 = lib.mkForce {}; }; } ]; }; + dontCheckDefinitions = {_module.check = false;}; + nvimModuleDocs = nmd.buildModulesDocs { modules = import ../modules/modules.nix { inherit pkgs lib; check = false; } - ++ [scrubbedPkgsModule]; + ++ [scrubbedPkgsModule dontCheckDefinitions]; moduleRootPaths = [./..]; mkModuleUrl = path: "https://github.com/notashelf/neovim-flake/blob/main/${path}#blob-path"; channelName = "neovim-flake"; diff --git a/docs/man-configuration.xml b/docs/man-configuration.xml index 498c0a0..01e7253 100644 --- a/docs/man-configuration.xml +++ b/docs/man-configuration.xml @@ -14,7 +14,8 @@ Description - Custom configuration is done with the neovim-flake.lib.neovimConfiguration function. It takes in the configuration as a module. + Custom configuration is done with the neovim-flake.lib.neovimConfiguration if home-manager module is not in use. + It takes in the configuration as a module. neovim-flake.lib.neovimConfiguration { inherit pkgs; @@ -31,6 +32,8 @@ neovim = "The built neovim package"; } + In case of the home-manager module, all options will be available under programs.neovim-flake once the module has + been imported from the flake inputs. Options diff --git a/docs/manual.xml b/docs/manual.xml index b16baa1..0464330 100644 --- a/docs/manual.xml +++ b/docs/manual.xml @@ -9,11 +9,10 @@ Preface - If your problem is caused by a bug in neovim-flake then it should be reported on the - neovim-flake issue tracker. - Alongside bug reports, feature requests are also welcome over - neovim-flake pull requests. - + If you believe your problem is caused by a bug in neovim-flake then please consider reporting it over + the neovim-flake issue tracker. + Bugfixes, feature additions and upstream changes are welcome over + the neovim-flake pull requests tab. @@ -23,6 +22,7 @@ + Configuration Options diff --git a/docs/manual/hacking.adoc b/docs/manual/hacking.adoc new file mode 100644 index 0000000..d9b5331 --- /dev/null +++ b/docs/manual/hacking.adoc @@ -0,0 +1,370 @@ +[[ch-hacking]] +== Hacking neovim-flake + +<<<<<<< HEAD +neovim-flake is designed for developers as much as it is for the end user. I would like any potential contributor +to be able to propagate their desired changes into the repository without the extra effort. As such, below are guides +(and guidelines) to streamline the contribution process and ensure that your valuable input seamlessly integrates +||||||| parent of c609a56 (among us) +neovim-flake is designed for developers as much as it is for the end user. I would like any potential contributor to +be able to propagate their desired changes into the repository without the extra effort. As such, below are guides +(and guidelines) to streamline the contribution process and ensure that your valuable input seamlessly integrates +======= +neovim-flake is designed for developers as much as it is for the end user. I would like any potential contributor to +be able to propagate their desired changes into the repository without the extra effort. As such, below are guides +(and guidelines) to streamline the contribution process and ensure that your valuable input seamlessly integrates +>>>>>>> c609a56 (among us) +into neovim-flake's development without leaving question marks in your head. + +:open-issues: https://github.com/notashelf/neovim-flake/issues +:new-issue: https://github.com/notashelf/neovim-flake/issues/new +:seven-rules: https://cbea.ms/git-commit/#seven-rules +:example-commit-message: https://github.com/nix-community/home-manager/commit/69f8e47e9e74c8d3d060ca22e18246b7f7d988ef + +This section is mainly directed towards those who wish to contribute code into neovim-flake. If you wish to instead +report a bug or discuss a potential feature implementation, first look among the already {open-issues}[open issues] and +if no matching issue exists you may open a {new-issue}[new issue] and describe your problem/request. While creating an +issue, please try to include as much information as you can, ideally also include relevant context in which an issue +occurs or a feature should be implemented. + +[[sec-contrib-getting-started]] +==== Getting started + +You naturally would like to start by forking the repository. If you are new to git, have a look at GitHub's +{fork-a-repo}[Fork a repo guide] for instructions on how you can do this. Once you have a fork of neovim-flake +you should create a branch starting at the most recent `main` branch. +Give your branch a reasonably descriptive name, suffixed by its type - i.e `feature/debugger` or `fix/pesky-bug`. + +Implement your changes and commit them to the newly created branch and when you are happy with the result and positive that it +fulfills <>. Once you are confident everything is in order, push the branch to GitHub and +{create-a-pull-request}[create a pull request], following the template that you will be prompted to fill. + +[[sec-guidelines]] +=== Guidelines +:assertions: https://nixos.org/manual/nixos/stable/index.html#sec-assertions +:discussions-tab: https://github.com/NotAShelf/neovim-flake/discussions + +If your contribution tightly follows the guidelines, then there is a good chance it will be merged without too much +trouble. Some of the guidelines will be strictly enforced, others will remain as gentle nudges towards the correct +direction. As we have no automated system enforcing those guidelines, please try to double check your changes before +making your pull request in order to avoid "faulty" code slipping by. + +If you are uncertain how these rules affect the change you would like to make then feel free to start a +discussion in the {discussions-tab}[discussions tab] ideally (but not necessarily) before you start developing. + +[[sec-documentation]] +==== Add adequate documentation +:nixpkgs-markdown: https://nixos.org/manual/nixpkgs/unstable/#sec-contributing-markup +:docbook: https://tdg.docbook.org/ +:asciidoc: https://asciidoc.org/ + +Most, if not all, changes warrant changes to the documentation. Module options should be documented with +{nixpkgs-markdown}[Nixpkgs-flavoured Markdown], albeit with exceptions. +neovim-flake is itself documented using a combination of {docbook}[DocBook] and {asciidoc}[AsciiDoc] conventions. + +The HTML version of this manual containing both the module option descriptions and the documentation of neovim-flake +(such as this page) can be generated and opened by typing the following in a shell within a clone of the +neovim-flake Git repository: + +[source,console] +---- +$ nix build .#docs-html +$ xdg-open ./result/share/doc/neovim-flake/index.html +---- + +[[sec-guidelines-code-style]] +==== Format your code + +Make sure your code is formatted as described in <>. To maintain consistency throughout the project +you are encouraged to browse through existing code and adopt its style also in new code. + +[[sec-guidelines-commit-message-style]] +==== Format your commit messages + +Similar to <> we encourage a consistent commit message format as described +in <>. + +[[sec-commit-style]] +==== Commits + +The commits in your pull request should be reasonably self-contained. Which means each and every commit in +a pull request should make sense both on its own and in general context. That is, a second commit should not resolve +an issue that is introduced in an earlier commit. In particular, you will be asked to amend any commit that +introduces syntax errors or similar problems even if they are fixed in a later commit. + +The commit messages should follow the {seven-rules}[seven rules], except for "Capitalize the subject line". +We also ask you to include the affected code component or module in the first line. +A commit message ideally, but not necessarily, follow the given template from home-manager's own documentation + +---- +{component}: {description} + +{long description} +---- + +where `{component}` refers to the code component (or module) your change affects, `{description}` is a very brief +description of your change, and `{long description}` is an optional clarifying description. As a rare exception, if +there is no clear component, or your change affects many components, then the `{component}` part is optional. +See <> for a commit message that fulfills these requirements. + +[[ex-commit-message]] +.Compliant commit message +=============================================================================== +The commit {example-commit-message}[69f8e47e9e74c8d3d060ca22e18246b7f7d988ef] contains the commit message + +---- +starship: allow running in Emacs if vterm is used + +The vterm buffer is backed by libvterm and can handle Starship prompts +without issues. +---- +=============================================================================== + +Long description can be ommitted if the change is too simple to warrant it. A minor fix in spelling or a formatting +change does not warrant long description, however, a module addition or removal does as you would like to provide the +relevant context for your changes. + +Finally, when adding a new module, say `modules/foo.nix`, we use the fixed commit format `foo: add module`. +You can, of course, still include a long description if you wish. + +In case of nested modules, i.e `modules/languages/java.nix` you are recommended to contain the parent as well - for +example `languages/java: some major change`. + + +[[sec-code-style]] +==== Code Style +:alejandra: https://github.com/kamadorueda/alejandra + +**Treewide** +Keep lines at a reasonable width, ideally 80 characters or less. This also applies to string literals and module +descriptions and documentation. + +**Nix** +neovim-flake is formatted by the {alejandra}[alejandra] tool and the formatting is checked in the pull +request and push workflows. Run the `nix fmt` command inside the project repository before submitting your +pull request. + +While Alejandra is mostly opinionated on how code looks after formatting, certain changes are done at the +user's discretion based on how the original code was structured. + +Please use one line code for attribute sets that contain only one subset. +For example: + +[source,nix] +---- +# parent modules should always be unfolded +module = { + value = mkEnableOption "some description" // { default = true; }; # merges can be done inline where possible + + # same as parent modules, unfold submodules + subModule = { + # this is an option that contains more than one nested value + someOtherValue = mkOption { + type = lib.types.bool; + description = "Some other description" + default = true; + }; + }; +} +---- + +If you move a line down after the merge operator, Alejandra will automatically unfold the whole merged attrset +for you, which we **do not** want. + +[source,nix] +---- +module = { + key = mkEnableOption "some description" // { + default = true; # we want this to be inline + }; + # ... +} +---- + +For lists, it is mostly up to your own discretion how you want to format them, but please try to unfold lists if +they contain multiple items and especially if they are to include comments. + +[source,nix] +---- +# this is ok +acceptableList = [ + item1 # comment + item2 + item3 # some other comment + item4 +]; + +# this is not ok +listToBeAvoided = [item1 item2 /* comment */ item3 item4]; + +# this is ok +singleItemList = [item1]; +---- + +[[sec-keybinds]] +=== Keybinds +As of 0.4, there exists an API for writing your own keybinds and a couple of useful utility functions are available in +the https://github.com/NotAShelf/neovim-flake/tree/main/lib[extended standard library]. The following section contains +a general overview to how you may utilize said functions. + +[[sec-custom-key-mappings]] +=== Custom Key Mappings Support for a Plugin + +:maps: https://notashelf.github.io/neovim-flake/options.html#opt-vim.maps.command._name_.action + +To set a mapping, you should define it in `vim.maps.<>`. +The available modes are: + +* normal +* insert +* select +* visual +* terminal +* normalVisualOp +* visualOnly +* operator +* insertCommand +* lang +* command + +An example, simple keybinding, can look like this: + +[source,nix] +---- +{ + vim.maps.normal = { + "wq" = { + action = ":wq"; + silent = true; + desc = "Save file and quit"; + }; + }; +} +---- + +There are many settings available in the options. Please refer to the {maps}[documentation] to see a list of them. + +`neovim-flake` provides a list of helper commands, so that you don't have to write the mapping attribute sets every +time: + +* `mkBinding = key: action: desc:` - makes a basic binding, with `silent` set to true. +* `mkExprBinding = key: action: desc:` - makes an expression binding, with `lua`, `silent`, and `expr` set to true. +* `mkLuaBinding = key: action: desc:` - makes an expression binding, with `lua`, and `silent` set to true. + +Note that the Lua in these bindings is actual Lua, not pasted into a `:lua` command. +Therefore, you either pass in a function like `require('someplugin').some_function`, without actually calling it, +or you define your own function, like `function() require('someplugin').some_function() end`. + +Additionally, to not have to repeat the descriptions, there's another utility function with its own set of functions: + +[source,nix] +---- +# Utility function that takes two attrsets: +# { someKey = "some_value" } and +# { someKey = { description = "Some Description"; }; } +# and merges them into +# { someKey = { value = "some_value"; description = "Some Description"; }; } + +addDescriptionsToMappings = actualMappings: mappingDefinitions: +---- + +This function can be used in combination with the same `mkBinding` functions as above, except they only take two +arguments - `binding` and `action`, and have different names: + +* `mkSetBinding = binding: action:` - makes a basic binding, with `silent` set to true. +* `mkSetExprBinding = binding: action:` - makes an expression binding, with `lua`, `silent`, and `expr` set to true. +* `mkSetLuaBinding = binding: action:` - makes an expression binding, with `lua`, and `silent` set to true. + +You can read the source code of some modules to see them in action, but their usage should look something like this: + +[source,nix] +---- +# plugindefinition.nix +{lib, ...}: +with lib; { + options.vim.plugin = { + enable = mkEnableOption "Enable plugin"; + + # Mappings should always be inside an attrset called mappings + mappings = { + # mkMappingOption is a helper function from lib, + # that takes a description (which will also appear in which-key), + # and a default mapping (which can be null) + toggleCurrentLine = mkMappingOption "Toggle current line comment" "gcc"; + toggleCurrentBlock = mkMappingOption "Toggle current block comment" "gbc"; + + toggleOpLeaderLine = mkMappingOption "Toggle line comment" "gc"; + toggleOpLeaderBlock = mkMappingOption "Toggle block comment" "gb"; + + toggleSelectedLine = mkMappingOption "Toggle selected comment" "gc"; + toggleSelectedBlock = mkMappingOption "Toggle selected block" "gb"; + }; + }; +} +---- + +[source,nix] +---- +# config.nix +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.plugin; + self = import ./plugindefinition.nix {inherit lib;}; + mappingDefinitions = self.options.vim.plugin; + + # addDescriptionsToMappings is a helper function from lib, + # that merges mapping values and their descriptions + # into one nice attribute set + mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; +in { + config = mkIf (cfg.enable) { + # ... + + vim.maps.normal = mkMerge [ + # mkSetBinding is another helper function from lib, + # that actually adds the mapping with a description. + (mkSetBinding mappings.findFiles " Telescope find_files") + (mkSetBinding mappings.liveGrep " Telescope live_grep") + (mkSetBinding mappings.buffers " Telescope buffers") + (mkSetBinding mappings.helpTags " Telescope help_tags") + (mkSetBinding mappings.open " Telescope") + + (mkSetBinding mappings.gitCommits " Telescope git_commits") + (mkSetBinding mappings.gitBufferCommits " Telescope git_bcommits") + (mkSetBinding mappings.gitBranches " Telescope git_branches") + (mkSetBinding mappings.gitStatus " Telescope git_status") + (mkSetBinding mappings.gitStash " Telescope git_stash") + + (mkIf config.vim.lsp.enable (mkMerge [ + (mkSetBinding mappings.lspDocumentSymbols " Telescope lsp_document_symbols") + (mkSetBinding mappings.lspWorkspaceSymbols " Telescope lsp_workspace_symbols") + + (mkSetBinding mappings.lspReferences " Telescope lsp_references") + (mkSetBinding mappings.lspImplementations " Telescope lsp_implementations") + (mkSetBinding mappings.lspDefinitions " Telescope lsp_definitions") + (mkSetBinding mappings.lspTypeDefinitions " Telescope lsp_type_definitions") + (mkSetBinding mappings.diagnostics " Telescope diagnostics") + ])) + + ( + mkIf config.vim.treesitter.enable + (mkSetBinding mappings.treesitter " Telescope treesitter") + ) + ]; + + # ... + }; +} +---- + +[NOTE] +==== +If you have come across a plugin that has an API that doesn't seem to easily allow custom keybindings, +don't be scared to implement a draft PR. We'll help you get it done. +==== From e1e4922aa5a0491602c45c35b11950cc482aa586 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 1 Oct 2023 16:07:44 +0300 Subject: [PATCH 02/14] docs/release-notes: minor styling changes --- docs/release-notes/release-notes.adoc | 1 + docs/release-notes/rl-0.4.adoc | 1 - docs/release-notes/rl-0.5.adoc | 3 +-- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/release-notes/release-notes.adoc b/docs/release-notes/release-notes.adoc index 15118f7..1cd4b68 100644 --- a/docs/release-notes/release-notes.adoc +++ b/docs/release-notes/release-notes.adoc @@ -10,3 +10,4 @@ include::rl-0.1.adoc[] include::rl-0.2.adoc[] include::rl-0.3.adoc[] include::rl-0.4.adoc[] +include::rl-0.5.adoc[] diff --git a/docs/release-notes/rl-0.4.adoc b/docs/release-notes/rl-0.4.adoc index 0f65fea..ce96e1e 100644 --- a/docs/release-notes/rl-0.4.adoc +++ b/docs/release-notes/rl-0.4.adoc @@ -8,7 +8,6 @@ Alongside customizable keybinds, there are a few quality of life updates, such a [[sec-release-0.4-changelog]] === Changelog - https://github.com/n3oney[n3oney]: * Streamlined keybind adding process towards new functions in extended stdlib. diff --git a/docs/release-notes/rl-0.5.adoc b/docs/release-notes/rl-0.5.adoc index 6e7b7db..15c5d91 100644 --- a/docs/release-notes/rl-0.5.adoc +++ b/docs/release-notes/rl-0.5.adoc @@ -5,7 +5,6 @@ [[sec-release-0.5-changelog]] === Changelog - https://github.com/horriblename[horriblename]: * Added transparency support for tokyonight theme. @@ -30,7 +29,7 @@ https://github.com/yavko[yavko]: * Added support for multiple languages <>, and added vim-dirtytalk <> -https://github.com/FrothyMarrow[frothymarrow]: +https://github.com/FrothyMarrow[frothymarrow]: * Renamed `vim.visuals.cursorWordline` to <>. From 714dadd2c2784cbf479f2940242375601565b7a7 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 1 Oct 2023 16:09:01 +0300 Subject: [PATCH 03/14] docs/README: add stars tracker --- .github/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/README.md b/.github/README.md index 5773502..71c09f8 100644 --- a/.github/README.md +++ b/.github/README.md @@ -23,11 +23,11 @@ Repo Size

- + +

+ +

+
A highly modular, configurable, extensible and easy to use Neovim configuration wrapper written in Nix. Designed for flexibility and ease of use, this flake allows you to easily configure your Neovim instance with a few lines of Nix code. From 9873d2bc98242dea07912cb92dfb3de87c0a1d6d Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 1 Oct 2023 16:09:41 +0300 Subject: [PATCH 04/14] docs/contributing: move guidelines to docs webpage --- .github/CONTRIBUTING.md | 222 ++-------------------------------------- 1 file changed, 6 insertions(+), 216 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 10371c9..436a68e 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -8,7 +8,7 @@ ## Welcome -I'm glad you are thinking about contributing to neovim-flake! If you're unsure about anything, just ask -- or submit the issue or pull request anyway. The worst that can happen is you'll be politely asked to change something. Friendly contributions are always welcome. +I'm glad you are thinking about contributing to neovim-flake! If you're unsure about anything, just ask - or submit the issue or pull request anyway. The worst that can happen is you'll be politely asked to change something. Friendly contributions are always welcome. Before you contribute, I encourage you to read this project's CONTRIBUTING policy (you are here), its [LICENSE](LICENSE.md), and its [README](README.md). @@ -18,223 +18,13 @@ If you have any questions regarding those files, feel free to open an issue or [ The contribution process is mostly documented in the [pull request template](.github/pull_request_template.md). You will find a checklist of items to complete before submitting a pull request. Please make sure you complete it before submitting a pull request. If you are unsure about any of the items, please ask. -### Code of Conduct - -This project does not quite have a code of conduct yet. And to be honest, I'm not sure if I want one. I'm not expecting this project to be a hotbed of activity, but I do want to make sure that everyone who does contribute feels welcome and safe. As such, I will do my best to make sure that those who distrupt the project are dealt with swiftly and appropriately. - -If you feel that you are not being treated with respect, please contact me directly. - ### Guidelines -Here are the overall boundaries I would like you to follow while contributing to neovim-flake. +We provide instructions on a healthy contribution to neovim-flake - including styling, commit formats, how-to guides for adding new modules and options. +You are very well recommended to read the contributing guideliner over at [the documentation](https://notashelf.github.io/neovim-flake#hacking) -#### Documentation +### Code of Conduct -If you are making a pull request to add a +This project does not quite have a code of conduct yet. And to be honest, I'm not sure if I want one or if it will ever have one. I'm not expecting this project to be a hotbed of activity, but I do want to make sure that everyone who does contribute feels welcome and safe. As such, I will do my best to make sure that those who distrupt the project are dealt with swiftly and appropriately. -#### Style - -**Nix** -We use Alejandra for formatting nix code, which can be invoked directly by running `nix fmt` in the repository. - -While Alejandra is mostly opinionated on how code looks after formatting, certain formattings are done at the user's discretion. - -Please use one line code for attribute sets that contain only one subset. -For example: - -```nix -# parent modules should always be unfolded -module = { - value = mkEnableOption "some description" // { default = true; }; - # same as parent modules, unfold submodules - subModule = { - # this is an option that contains more than one nested value - someOtherValue = mkOption { - type = lib.types.bool; - description = "Some other description" - default = true; - }; - }; -} -``` - -If you move a line down after the merge operator, Alejandra will automatically unfold the whole merged attrset for you, which we do not want. - -```nix -module = { - key = mkEnableOption "some description" // { - default = true; # we want this to be inline - }; - # ... -} -``` - -For lists, it's up mostly to your discretion but please try to avoid unfolded lists if there is only one item in the list. - -```nix - -# ok -acceptableList = [ - item1 - item2 - item3 - item4 -]; - -# not ok -listToBeAvoided = [item1 item2 item3 item4]; -``` - -_This will be moved elsewhere, disregard unless you are adding a new plugin with keybinds_ - -#### Keybinds - -##### Custom key mappings support for a plugin - -To add custom keymappings to a plugin, a couple of helper functions are available in the project. - -To set a mapping, you should define it on `vim.maps.`. -The available modes are: - -- normal -- insert -- select -- visual -- terminal -- normalVisualOp -- visualOnly -- operator -- insertCommand -- lang -- command - -An example, simple keybinding, can look like this: - -```nix - -{ - vim.maps.normal = { - "wq" = { - action = ":wq"; - silent = true; - desc = "Save file and quit"; - }; - }; -} -``` - -There are many settings available in the options. Please refer to [the documentation](https://notashelf.github.io/neovim-flake/options.html#opt-vim.maps.command._name_.action) to see a list of them. - -neovim-flake provides a list of helper commands, so that you don't have to write the mapping attribute sets every time: - -`mkBinding = key: action: desc:` - makes a basic binding, with `silent` set to true. -`mkExprBinding = key: action: desc:` - makes an expression binding, with `lua`, `silent`, and `expr` set to true. -`mkLuaBinding = key: action: desc:` - makes an expression binding, with `lua`, and `silent` set to true. -Note - the lua in these bindings is _actual_ lua, not pasted into a `:lua`. -Therefore, you either pass in a function like `require('someplugin').some_function`, without actually calling it, -or you define your own function, like `function() require('someplugin').some_function() end`. - -Additionally, to not have to repeat the descriptions, there's another utility function with its own set of functions: - -```nix -# Utility function that takes two attrsets: -# { someKey = "some_value" } and -# { someKey = { description = "Some Description"; }; } -# and merges them into -# { someKey = { value = "some_value"; description = "Some Description"; }; } - -addDescriptionsToMappings = actualMappings: mappingDefinitions: -``` - -This function can be used in combination with the same mkBinding functions as above, except they only take two arguments - `binding` and `action`, and have different names. -`mkSetBinding = binding: action:` - makes a basic binding, with `silent` set to true. -`mkSetExprBinding = binding: action:` - makes an expression binding, with `lua`, `silent`, and `expr` set to true. -`mkSetLuaBinding = binding: action:` - makes an expression binding, with `lua`, and `silent` set to true. - -You can read the source code of some modules to see them in action, but their usage should look something like this: - -```nix -# plugindefinition.nix -{lib, ...}: -with lib; { - options.vim.plugin = { - enable = mkEnableOption "Enable plugin"; - - # Mappings should always be inside an attrset called mappings - mappings = { - # mkMappingOption is a helper function from lib, - # that takes a description (which will also appear in which-key), - # and a default mapping (which can be null) - toggleCurrentLine = mkMappingOption "Toggle current line comment" "gcc"; - toggleCurrentBlock = mkMappingOption "Toggle current block comment" "gbc"; - - toggleOpLeaderLine = mkMappingOption "Toggle line comment" "gc"; - toggleOpLeaderBlock = mkMappingOption "Toggle block comment" "gb"; - - toggleSelectedLine = mkMappingOption "Toggle selected comment" "gc"; - toggleSelectedBlock = mkMappingOption "Toggle selected block" "gb"; - }; - }; -} -``` - -```nix -# config.nix -{ - pkgs, - config, - lib, - ... -}: -with lib; -with builtins; let - cfg = config.vim.plugin; - self = import ./plugindefinition.nix {inherit lib;}; - mappingDefinitions = self.options.vim.plugin; - - # addDescriptionsToMappings is a helper function from lib, - # that merges mapping values and their descriptions - # into one nice attribute set - mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; -in { - config = mkIf (cfg.enable) { - # ... - - vim.maps.normal = mkMerge [ - # mkSetBinding is another helper function from lib, - # that actually adds the mapping with a description. - (mkSetBinding mappings.findFiles " Telescope find_files") - (mkSetBinding mappings.liveGrep " Telescope live_grep") - (mkSetBinding mappings.buffers " Telescope buffers") - (mkSetBinding mappings.helpTags " Telescope help_tags") - (mkSetBinding mappings.open " Telescope") - - (mkSetBinding mappings.gitCommits " Telescope git_commits") - (mkSetBinding mappings.gitBufferCommits " Telescope git_bcommits") - (mkSetBinding mappings.gitBranches " Telescope git_branches") - (mkSetBinding mappings.gitStatus " Telescope git_status") - (mkSetBinding mappings.gitStash " Telescope git_stash") - - (mkIf config.vim.lsp.enable (mkMerge [ - (mkSetBinding mappings.lspDocumentSymbols " Telescope lsp_document_symbols") - (mkSetBinding mappings.lspWorkspaceSymbols " Telescope lsp_workspace_symbols") - - (mkSetBinding mappings.lspReferences " Telescope lsp_references") - (mkSetBinding mappings.lspImplementations " Telescope lsp_implementations") - (mkSetBinding mappings.lspDefinitions " Telescope lsp_definitions") - (mkSetBinding mappings.lspTypeDefinitions " Telescope lsp_type_definitions") - (mkSetBinding mappings.diagnostics " Telescope diagnostics") - ])) - - ( - mkIf config.vim.treesitter.enable - (mkSetBinding mappings.treesitter " Telescope treesitter") - ) - ]; - - # ... - }; -} -``` - -If you have come across a plugin that has an API that doesn't seem to easily allow custom keybindings, don't be scared to implement a draft PR. We'll help you get it done. +If you feel that you are not being treated with respect, please contact me directly. From e5df60172a54bf9d44bf2ccf223116bc0287ac50 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 1 Oct 2023 16:17:48 +0300 Subject: [PATCH 05/14] CI: cleanup --- .github/workflows/cachix.yml | 9 +++++++++ .github/workflows/check-docs.yml | 20 ++++++++++++-------- .github/workflows/manual.yml | 5 ++++- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cachix.yml b/.github/workflows/cachix.yml index c217234..8651732 100644 --- a/.github/workflows/cachix.yml +++ b/.github/workflows/cachix.yml @@ -23,12 +23,17 @@ jobs: - maximal steps: - uses: easimon/maximize-build-space@v6 + name: Maximize build space with: overprovision-lvm: true remove-android: true remove-dotnet: true remove-haskell: true + remove-codeql: true + - uses: actions/checkout@v3 + name: Checkout + - uses: cachix/install-nix-action@v20 with: extra_nix_config: | @@ -36,14 +41,18 @@ jobs: auto-optimise-store = true experimental-features = nix-command flakes nix_path: nixpkgs=channel:nixos-unstable + - uses: cachix/cachix-action@v12 with: authToken: ${{ secrets.CACHIX_TOKEN }} extraPullNames: nix-community name: neovim-flake + - name: Set default git branch (to reduce log spam) run: git config --global init.defaultBranch main + - name: Validate Flakes run: nix flake check + - name: Build neovim-flake with default settings run: nix build .#${{ matrix.package }} --print-build-logs diff --git a/.github/workflows/check-docs.yml b/.github/workflows/check-docs.yml index ae29751..009f4e5 100644 --- a/.github/workflows/check-docs.yml +++ b/.github/workflows/check-docs.yml @@ -14,10 +14,10 @@ jobs: strategy: matrix: package: - - docs - - docs-html - - docs-manpages - - docs-json + - docs + - docs-html + - docs-manpages + - docs-json steps: - uses: easimon/maximize-build-space@v6 with: @@ -25,25 +25,29 @@ jobs: remove-android: true remove-dotnet: true remove-haskell: true + - uses: cachix/install-nix-action@v20 with: - extra_nix_config: | + extra_nix_config: | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} auto-optimise-store = true experimental-features = nix-command flakes nix_path: nixpkgs=channel:nixos-unstable - uses: actions/checkout@v3 + name: Checkout + - name: Set default git branch (to reduce log spam) run: git config --global init.defaultBranch main - - name: Validate Flakes + + - name: Validate Flake run: nix flake check + - name: Build neovim-flake with default settings run: nix build .#${{ matrix.package }} --print-build-logs + - name: Upload doc artifacts uses: actions/upload-artifact@v3 with: name: doc path: result/share/doc/neovim-flake/ - - diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml index 5a2a50f..321d23e 100644 --- a/.github/workflows/manual.yml +++ b/.github/workflows/manual.yml @@ -4,7 +4,7 @@ on: push: branches: - main - paths: + paths: # build the manuals only when docs directory is updated - docs/** @@ -25,12 +25,15 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + - name: Install Nix uses: cachix/install-nix-action@v18 + - name: Build run: | nix build '.#docs' cp -r result/share/doc/neovim-flake public + - name: Deploy uses: peaceiris/actions-gh-pages@v3 with: From 1463d2444a3ed5c6048c89575750645e7382ecce Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 1 Oct 2023 16:27:53 +0300 Subject: [PATCH 06/14] docs/hacking: add testing section --- docs/manual/hacking.adoc | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/docs/manual/hacking.adoc b/docs/manual/hacking.adoc index d9b5331..66a5270 100644 --- a/docs/manual/hacking.adoc +++ b/docs/manual/hacking.adoc @@ -1,9 +1,17 @@ [[ch-hacking]] == Hacking neovim-flake +<<<<<<< HEAD <<<<<<< HEAD neovim-flake is designed for developers as much as it is for the end user. I would like any potential contributor to be able to propagate their desired changes into the repository without the extra effort. As such, below are guides +||||||| parent of 33dd7b0 (docs/hacking: add testing section) +neovim-flake is designed for developers as much as it is for the end user. I would like any potential contributor +to be able to propagate their desired changes into the repository without the extra effort. As such, below are guides +======= +neovim-flake is designed for developers as much as it is for the end user. I would like any potential contributor to +be able to propagate their desired changes into the repository without the extra effort. As such, below are guides +>>>>>>> 33dd7b0 (docs/hacking: add testing section) (and guidelines) to streamline the contribution process and ensure that your valuable input seamlessly integrates ||||||| parent of c609a56 (among us) neovim-flake is designed for developers as much as it is for the end user. I would like any potential contributor to @@ -35,8 +43,8 @@ You naturally would like to start by forking the repository. If you are new to g you should create a branch starting at the most recent `main` branch. Give your branch a reasonably descriptive name, suffixed by its type - i.e `feature/debugger` or `fix/pesky-bug`. -Implement your changes and commit them to the newly created branch and when you are happy with the result and positive that it -fulfills <>. Once you are confident everything is in order, push the branch to GitHub and +Implement your changes and commit them to the newly created branch and when you are happy with the result and positive +that it fulfills <>. Once you are confident everything is in order, push the branch to GitHub and {create-a-pull-request}[create a pull request], following the template that you will be prompted to fill. [[sec-guidelines]] @@ -201,8 +209,22 @@ listToBeAvoided = [item1 item2 /* comment */ item3 item4]; singleItemList = [item1]; ---- +[[sec-testing]] +=== Testing Your Changes + +Once you have made your changes, you will need to test them throughly. If it is a module, add your module option to +`configuration.nix` (located in the root of this project) inside `neovimConfiguration`. Enable it, and then run the +maximal configuration with `nix run .#maximal -Lv` to check for build errors. If neovim opens in the current directory +without any error messages (you can check the output of `:messages` inside neovim to see if there are any errors), then +your changes are good to go. Open your pull request, and it will be reviewed as soon as posssible. + +If it is not a new module, but a change to an existing one, then make sure the module you have changed is enabled in the +maximal configuration by editing configuration.nix, and then run it with `nix run .#maximal -Lv`. Same procedure as +adding a new module will apply here. + [[sec-keybinds]] === Keybinds + As of 0.4, there exists an API for writing your own keybinds and a couple of useful utility functions are available in the https://github.com/NotAShelf/neovim-flake/tree/main/lib[extended standard library]. The following section contains a general overview to how you may utilize said functions. From f432a364f13cd5b6cd778c643256898f04a28254 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 1 Oct 2023 16:28:11 +0300 Subject: [PATCH 07/14] docs/release-notes: fix invalid option reference --- docs/release-notes/rl-0.5.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/release-notes/rl-0.5.adoc b/docs/release-notes/rl-0.5.adoc index 15c5d91..3854602 100644 --- a/docs/release-notes/rl-0.5.adoc +++ b/docs/release-notes/rl-0.5.adoc @@ -33,7 +33,7 @@ https://github.com/FrothyMarrow[frothymarrow]: * Renamed `vim.visuals.cursorWordline` to <>. -* Added <> to display cursorline only in the presence of line numbers. +* Added <> to display cursorline only in the presence of line numbers. https://github.com/notashelf[notashelf]: From c223d49274bf14ffe6501cf5e2df8b54a161eaba Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 1 Oct 2023 16:58:05 +0300 Subject: [PATCH 08/14] docs: fix build failures --- docs/man-configuration.xml | 17 +++++++++++------ docs/manual.xml | 10 +++++----- docs/release-notes/rl-0.5.adoc | 8 ++++---- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/docs/man-configuration.xml b/docs/man-configuration.xml index 01e7253..84e914e 100644 --- a/docs/man-configuration.xml +++ b/docs/man-configuration.xml @@ -14,26 +14,31 @@ Description - Custom configuration is done with the neovim-flake.lib.neovimConfiguration if home-manager module is not in use. - It takes in the configuration as a module. + Custom configuration is done with the neovim-flake.lib.neovimConfiguration if home-manager module is not in use. + It takes in the configuration as a module. + neovim-flake.lib.neovimConfiguration { inherit pkgs; modules = [{config = xxx;}]; }; + The output of the configuration function is an attrset. - + + In case of the home-manager module, all options will be available under programs.neovim-flake once the module has + been imported from the flake inputs. + + { options = "The options that were available to configure"; config = "The outputted configuration"; pkgs = "The package set used to evaluate the module"; neovim = "The built neovim package"; } - - In case of the home-manager module, all options will be available under programs.neovim-flake once the module has - been imported from the flake inputs. + + Options diff --git a/docs/manual.xml b/docs/manual.xml index 0464330..07875fc 100644 --- a/docs/manual.xml +++ b/docs/manual.xml @@ -7,12 +7,12 @@ neovim-flake Manual - Preface + Preface - If you believe your problem is caused by a bug in neovim-flake then please consider reporting it over - the neovim-flake issue tracker. - Bugfixes, feature additions and upstream changes are welcome over - the neovim-flake pull requests tab. + If you believe your problem is caused by a bug in neovim-flake then please consider reporting it over + the neovim-flake issue tracker. + Bugfixes, feature additions and upstream changes are welcome over + the neovim-flake pull requests tab. diff --git a/docs/release-notes/rl-0.5.adoc b/docs/release-notes/rl-0.5.adoc index 3854602..6c38c3c 100644 --- a/docs/release-notes/rl-0.5.adoc +++ b/docs/release-notes/rl-0.5.adoc @@ -31,17 +31,17 @@ https://github.com/yavko[yavko]: https://github.com/FrothyMarrow[frothymarrow]: -* Renamed `vim.visuals.cursorWordline` to <>. +* Renamed `vim.visuals.cursorWordline` to <>. * Added <> to display cursorline only in the presence of line numbers. https://github.com/notashelf[notashelf]: -* Added GitHub Copilot to completion sources. +* Added GitHub Copilot to nvim-cmp completion sources. -* Added <> for global and individual plugin border configuration. +* Added <> for global and individual plugin border configuration. -* LSP integrated breadcrumbs with <> through nvim-navic +* LSP integrated breadcrumbs with <> through nvim-navic * LSP navigation helper with nvim-navbuddy, depends on nvim-navic (automatically enabled) From 90d172ae9d440e84f2fbf095288d3e8e3e24dd54 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 1 Oct 2023 17:44:05 +0300 Subject: [PATCH 09/14] docs/hacking: add missing URL macro --- docs/manual/hacking.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/manual/hacking.adoc b/docs/manual/hacking.adoc index 66a5270..3aa7035 100644 --- a/docs/manual/hacking.adoc +++ b/docs/manual/hacking.adoc @@ -24,6 +24,7 @@ be able to propagate their desired changes into the repository without the extra >>>>>>> c609a56 (among us) into neovim-flake's development without leaving question marks in your head. +:fork-a-repo: https://help.github.com/articles/fork-a-repo/ :open-issues: https://github.com/notashelf/neovim-flake/issues :new-issue: https://github.com/notashelf/neovim-flake/issues/new :seven-rules: https://cbea.ms/git-commit/#seven-rules From 96c568f99b008ed6b7167bdd5fea1cd0cc50cf6d Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 1 Oct 2023 18:35:52 +0300 Subject: [PATCH 10/14] docs: fix rebase errors --- docs/manual/hacking.adoc | 58 ++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/docs/manual/hacking.adoc b/docs/manual/hacking.adoc index 3aa7035..33ed8e0 100644 --- a/docs/manual/hacking.adoc +++ b/docs/manual/hacking.adoc @@ -1,27 +1,9 @@ [[ch-hacking]] == Hacking neovim-flake -<<<<<<< HEAD -<<<<<<< HEAD neovim-flake is designed for developers as much as it is for the end user. I would like any potential contributor to be able to propagate their desired changes into the repository without the extra effort. As such, below are guides -||||||| parent of 33dd7b0 (docs/hacking: add testing section) -neovim-flake is designed for developers as much as it is for the end user. I would like any potential contributor -to be able to propagate their desired changes into the repository without the extra effort. As such, below are guides -======= -neovim-flake is designed for developers as much as it is for the end user. I would like any potential contributor to -be able to propagate their desired changes into the repository without the extra effort. As such, below are guides ->>>>>>> 33dd7b0 (docs/hacking: add testing section) -(and guidelines) to streamline the contribution process and ensure that your valuable input seamlessly integrates -||||||| parent of c609a56 (among us) -neovim-flake is designed for developers as much as it is for the end user. I would like any potential contributor to -be able to propagate their desired changes into the repository without the extra effort. As such, below are guides -(and guidelines) to streamline the contribution process and ensure that your valuable input seamlessly integrates -======= -neovim-flake is designed for developers as much as it is for the end user. I would like any potential contributor to -be able to propagate their desired changes into the repository without the extra effort. As such, below are guides (and guidelines) to streamline the contribution process and ensure that your valuable input seamlessly integrates ->>>>>>> c609a56 (among us) into neovim-flake's development without leaving question marks in your head. :fork-a-repo: https://help.github.com/articles/fork-a-repo/ @@ -37,7 +19,7 @@ issue, please try to include as much information as you can, ideally also includ occurs or a feature should be implemented. [[sec-contrib-getting-started]] -==== Getting started +=== Getting started You naturally would like to start by forking the repository. If you are new to git, have a look at GitHub's {fork-a-repo}[Fork a repo guide] for instructions on how you can do this. Once you have a fork of neovim-flake @@ -231,7 +213,7 @@ the https://github.com/NotAShelf/neovim-flake/tree/main/lib[extended standard li a general overview to how you may utilize said functions. [[sec-custom-key-mappings]] -=== Custom Key Mappings Support for a Plugin +==== Custom Key Mappings Support for a Plugin :maps: https://notashelf.github.io/neovim-flake/options.html#opt-vim.maps.command._name_.action @@ -391,3 +373,39 @@ in { If you have come across a plugin that has an API that doesn't seem to easily allow custom keybindings, don't be scared to implement a draft PR. We'll help you get it done. ==== + +[[sec-additional-plugins]] +=== Adding Plugins + +To add a new neovim plugin, first add the source url in the inputs section of `flake.nix` + +[source,nix] +---- +{ + inputs = { + # ... + neodev-nvim = { + url = "github:folke/neodev.nvim"; + flake = false; + }; + }; +} +---- + +Then add the name of the plugin into the `availablePlugins` variable in `lib/types/plugins.nix`: + +[source,nix] +---- +# ... +availablePlugins = [ + # ... + "neodev-nvim" +]; +---- + +You can now reference this plugin using its string name: + +[source,nix] +---- +config.vim.startPlugins = ["neodev-nvim"]; +---- From 0c848869cf6874d2c121a198b7c70231d5d6f23a Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 3 Oct 2023 22:06:26 +0300 Subject: [PATCH 11/14] docs/manual: add more details to existing documentation pages --- docs/default.nix | 2 +- docs/manual.xml | 2 +- docs/manual/custom-configs.adoc | 23 +++++++++++++- docs/manual/custom-plugins.adoc | 21 +++++++++---- docs/manual/home-manager.adoc | 49 ++++++++++++++++++++++++++--- docs/manual/languages.adoc | 18 ++++++----- docs/manual/try-it-out.adoc | 55 ++++++++++++++++++++++----------- 7 files changed, 131 insertions(+), 39 deletions(-) diff --git a/docs/default.nix b/docs/default.nix index 211bf38..07274d8 100644 --- a/docs/default.nix +++ b/docs/default.nix @@ -1,6 +1,6 @@ { pkgs, - lib ? import ../lib/stdlib-extended.nix pkgs.lib, + lib, nmdSrc, }: let nmd = import nmdSrc { diff --git a/docs/manual.xml b/docs/manual.xml index 07875fc..0584b9c 100644 --- a/docs/manual.xml +++ b/docs/manual.xml @@ -18,8 +18,8 @@ - + diff --git a/docs/manual/custom-configs.adoc b/docs/manual/custom-configs.adoc index 7f90b00..5d8cd75 100644 --- a/docs/manual/custom-configs.adoc +++ b/docs/manual/custom-configs.adoc @@ -1,7 +1,8 @@ [[ch-custom-configuration]] == Custom Configuration -Custom configuration is done with the `neovimConfiguration` function. It takes in the configuration as a module. The output of the configuration function is an attrset. +Custom configuration is done with the `neovimConfiguration` while using the flake as a standalone package. +It takes in the configuration as a module. The output of the configuration function is an attrset. [source,nix] ---- @@ -40,8 +41,28 @@ The following is an example of a barebones vim configuration with the default th inherit pkgs; }; in { + # this will make the package available as a flake input packages.${system}.neovim = customNeovim.neovim; + + # this is an example nixosConfiguration using the built neovim package + nixosConfigurations = { + yourHostName = nixpkgs.lib.nixosSystem { + # ... + modules = [ + ./configuration.nix # or whatever your configuration is + + # this will make wrapped neovim available in your system packages + {environment.systemPackages = [customNeovim.neovim];} + ]; + # ... + }; + }; }; } ---- +Your built neovim configuration can be exposed as a flake output, or be added to your system packages to make +it available across your system. You may also consider passing the flake output to home-manager to make it available +to a specific user *without* using the home-manager module. + + diff --git a/docs/manual/custom-plugins.adoc b/docs/manual/custom-plugins.adoc index 6f6da92..e53f193 100644 --- a/docs/manual/custom-plugins.adoc +++ b/docs/manual/custom-plugins.adoc @@ -4,7 +4,7 @@ You can use custom plugins, before they are implemented in the flake. To add a plugin, you need to add it to your config's `config.vim.startPlugins` array. - +[[sec-new-method]] === New Method As of version 0.5, we have a more extensive API for configuring plugins, under `vim.extraPlugins`. @@ -22,7 +22,7 @@ Instead of using DAGs exposed by the library, you may use the extra plugin modul } ''; }; - + harpoon = { package = harpoon; setup = "require('harpoon').setup {}"; @@ -32,8 +32,10 @@ Instead of using DAGs exposed by the library, you may use the extra plugin modul } ---- +[[sec-old-method]] === Old Method -Users who have not yet updated to 0.5, or prefer a more hands-on approach may use the old method where the load orderof the plugins is determined by DAGs. +Users who have not yet updated to 0.5, or prefer a more hands-on approach may use the old method where the load order +of the plugins is determined by DAGs. [source,nix] ---- @@ -50,16 +52,23 @@ Users who have not yet updated to 0.5, or prefer a more hands-on approach may us } ---- -However, just making the plugin available might not be enough. In that case, you can write custom vimscript or lua config, using `config.vim.configRC` or `config.vim.luaConfigRC` respectively. +However, just making the plugin available might not be enough. In that case, you can write custom vimscript +or lua config, using `config.vim.configRC` or `config.vim.luaConfigRC` respectively. These options are attribute sets, and you need to give the configuration you're adding some name, like this: [source,nix] ---- { + # this will create an "aquarium" section in your init.vim with the contents of your custom config + # which will be *appended* to the rest of your configuration, inside your init.vim config.vim.configRC.aquarium = "colorscheme aquiarum"; } ---- -Note: If your configuration needs to be put in a specific place in the config, you can use functions from `inputs.neovim-flake.lib.nvim.dag` to order it. Refer to https://github.com/nix-community/home-manager/blob/master/modules/lib/dag.nix. +Note: If your configuration needs to be put in a specific place in the config, you can use functions from +`inputs.neovim-flake.lib.nvim.dag` to order it. +Refer to https://github.com/nix-community/home-manager/blob/master/modules/lib/dag.nix to find out more about +the DAG system. -Also, if you successfully made your plugin work, please make a PR to add it to the flake, or open an issue with your findings so that we can make it available for everyone easily. +Also, if you successfully made your plugin work, please make a PR to add it to the flake, or open an issue +with your findings so that we can make it available for everyone easily. diff --git a/docs/manual/home-manager.adoc b/docs/manual/home-manager.adoc index df60652..b48f262 100644 --- a/docs/manual/home-manager.adoc +++ b/docs/manual/home-manager.adoc @@ -1,7 +1,10 @@ [[ch-hm-module]] == Home Manager -The Home Manager module allows us to customize the different `vim` options. To use it, we first add the input flake. +The Home Manager module allows us to customize the different `vim` options from inside the home-manager configuration +and it is the preferred way of configuring neovim-flake, both on NixOS and non-NixOS systems. + +To use it, we first add the input flake. [source,nix] ---- @@ -10,20 +13,49 @@ The Home Manager module allows us to customize the different `vim` options. To u url = github:notashelf/neovim-flake; # you can override input nixpkgs inputs.nixpkgs.follows = "nixpkgs"; + # you can also override individual plugins + # i.e inputs.obsidian-nvim.follows = "obsidian-nvim"; # <- obsidian nvim needs to be in your inputs }; } ---- -Followed by importing the HM module. +Followed by importing the home-manager module somewhere in your configuration. [source,nix] ---- { - imports = [ neovim-flake.homeManagerModules.default ]; + # assuming neovim-flake is in your inputs and inputs is in the argset + imports = [ inputs.neovim-flake.homeManagerModules.default ]; } ---- -Then we should be able to use the given module. E.g. +An example installation for standalone home-manager would look like this: + +[source,nix] +---- +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + home-manager.url = "github:nix-community/home-manager"; + stylix.url = "github:notashelf/neovim-flake"; + }; + + outputs = { nixpkgs, home-manager, neovim-flake ... }: let + system = "x86_64-linux"; in { + # ↓ this is the home-manager output in the flake schema + homeConfigurations."yourUsername»" = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.x86_64-linux; + modules = [ + neovim-flake.homeManagerModules.default # <- this imports the home-manager module that provides the options + ./home.nix # your home-manager configuration, probably where you will want to add programs.neovim-flake options + ]; + }; + }; +} +---- + +Once the module is imported, we will be able to define the following options (and much more) from inside the +home-manager configuration. [source,nix] ---- @@ -31,7 +63,8 @@ Then we should be able to use the given module. E.g. programs.neovim-flake = { enable = true; - # your settings need to go into the settings attrset + # your settings need to go into the settings attribute set + # most settings are documented in the appendix settings = { vim.viAlias = false; vim.vimAlias = true; @@ -43,4 +76,10 @@ Then we should be able to use the given module. E.g. } ---- +[NOTE] +==== +You may find all avaliable options in the https://notashelf.github.io/neovim-flake/options[appendix] +==== + + diff --git a/docs/manual/languages.adoc b/docs/manual/languages.adoc index e6c9cbe..4b97aea 100644 --- a/docs/manual/languages.adoc +++ b/docs/manual/languages.adoc @@ -15,21 +15,25 @@ Language specific support means there is a combination of language specific plug * SQL: <> * Dart: <> * Go: <> +* Lua: <> -Adding support for more languages, and improving support for existing ones are great places where you can contribute with a PR. +Adding support for more languages, and improving support for existing ones are great places +where you can contribute with a PR. === LSP Custom Packages/Command -In any of the `opt.languages..lsp.package` options you can provide your own LSP package, or provide the command to launch the language server, as a list of strings. +In any of the `opt.languages..lsp.package` options you can provide your own LSP package, or provide +the command to launch the language server, as a list of strings. -You can use this to skip automatic installation of a language server, and instead use the one found in your `$PATH` during runtime, for example: +You can use this to skip automatic installation of a language server, and instead +use the one found in your `$PATH` during runtime, for example: [source,nix] ---- vim.languages.java = { - lsp = { - enable = true; - package = ["jdt-language-server" "-data" "~/.cache/jdtls/workspace"]; - }; + lsp = { + enable = true; + package = ["jdt-language-server" "-data" "~/.cache/jdtls/workspace"]; + }; } ---- diff --git a/docs/manual/try-it-out.adoc b/docs/manual/try-it-out.adoc index fb8198f..f186de1 100644 --- a/docs/manual/try-it-out.adoc +++ b/docs/manual/try-it-out.adoc @@ -1,34 +1,53 @@ [[ch-try-it-out]] == Try it out +Thanks to the portability of Nix, you can try out neovim-flake without actually installing it to your machine. +Below are the commands you may run to try out different configurations provided by this flake. As of v0.5, three +configurations are provided: + +* Nix +* Tidal +* Maximal + +You may try out any of the provided configurations using the `nix run` command on a system where Nix is installed. + [source,console] ---- $ cachix use neovim-flake # Optional: it'll save you CPU resources and time -$ nix run github:notashelf/neovim-flake # will run the default configuration +$ nix run github:notashelf/neovim-flake#nix # will run the default minimal configuration ---- +Do keep in mind that this is **susceptible to garbage collection** meaning it will be removed from your Nix store +once you garbage collect. If you wish to install neovim-flake, please take a look at +<> or <> sections for installation +instructions. -=== Nix - -By default LSP support for Nix is enabled alongside all complementary Neovim plugins. By running `nix run .`, which is the default package, -you will build Neovim with this config. - -=== Tidal - -Tidal is an alternative config that adds vim-tidal on top of the plugins from the Nix configuration. - -=== Maximal - -Maximal is the ultimate configuration that will enable basically everything. Keep in mind, however, that this will pull a lot of dependencies. - -You are strongly recommended to use the binary cache if you would like to try the Maximal configuration. - - +[[sec-using-prebuild-configs]] === Using Prebuilt Configs [source,console] ---- -$ nix run github:notashelf/neovim-flake#nix +$ nix run github:notashelf/neovim-flake#nix $ nix run github:notashelf/neovim-flake#tidal $ nix run github:notashelf/neovim-flake#maximal ---- + + +[[sec-available-configs]] +=== Available Configs + +==== Nix + +`Nix` configuration by default provides LSP/diagnostic support for Nix alongisde a set of visual and functional plugins. +By running `nix run .`, which is the default package, you will build Neovim with this config. + +==== Tidal + +Tidal is an alternative config that adds vim-tidal on top of the plugins from the Nix configuration. + +==== Maximal + +`Maximal` is the ultimate configuration that will enable support for more commonly used language as well as additional +complementary plugins. Keep in mind, however, that this will pull a lot of dependencies. + +You are *strongly* recommended to use the binary cache if you would like to try the Maximal configuration. From 8506a5ecee657c2ee0279d1d254721cdbd25ec91 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 3 Oct 2023 22:08:02 +0300 Subject: [PATCH 12/14] flake: drop zig overlay --- flake.lock | 76 +++------------------------------------- flake.nix | 11 +++--- flake/legacyPackages.nix | 2 -- flake/overlays.nix | 4 +-- flake/packages.nix | 7 ++++ 5 files changed, 18 insertions(+), 82 deletions(-) diff --git a/flake.lock b/flake.lock index f939c12..2f2330a 100644 --- a/flake.lock +++ b/flake.lock @@ -402,22 +402,6 @@ "type": "github" } }, - "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1673956053, - "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -454,21 +438,6 @@ "type": "github" } }, - "flake-utils_2": { - "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "flutter-tools": { "flake": false, "locked": { @@ -804,11 +773,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1690630721, - "narHash": "sha256-Y04onHyBQT4Erfr2fc82dbJTfXGYrf4V0ysLUYnPOP8=", + "lastModified": 1696261572, + "narHash": "sha256-s8TtSYJ1LBpuITXjbPLUPyxzAKw35LhETcajJjCS5f0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "d2b52322f35597c62abf56de91b0236746b2a03d", + "rev": "0c7ffbc66e6d78c50c38e717ec91a2a14e0622fb", "type": "github" }, "original": { @@ -868,22 +837,6 @@ "type": "github" } }, - "nixpkgs_4": { - "locked": { - "lastModified": 1689088367, - "narHash": "sha256-Y2tl2TlKCWEHrOeM9ivjCLlRAKH3qoPUE/emhZECU14=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "5c9ddb86679c400d6b7360797b8a22167c2053f8", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "release-23.05", - "repo": "nixpkgs", - "type": "github" - } - }, "nmd": { "flake": false, "locked": { @@ -1514,8 +1467,7 @@ "vim-repeat": "vim-repeat", "vim-startify": "vim-startify", "vim-vsnip": "vim-vsnip", - "which-key": "which-key", - "zig": "zig" + "which-key": "which-key" } }, "rust-overlay": { @@ -1951,26 +1903,6 @@ "repo": "which-key.nvim", "type": "github" } - }, - "zig": { - "inputs": { - "flake-compat": "flake-compat", - "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs_4" - }, - "locked": { - "lastModified": 1690718829, - "narHash": "sha256-GN19SrCqWxIJN+rnbv+pIkF/yynh6FG2y7jY6PZRiYw=", - "owner": "mitchellh", - "repo": "zig-overlay", - "rev": "92e485cc7887f57be4d2921ed077f467912b7d33", - "type": "github" - }, - "original": { - "owner": "mitchellh", - "repo": "zig-overlay", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 48a280f..149078a 100644 --- a/flake.nix +++ b/flake.nix @@ -62,13 +62,8 @@ flake = false; }; - # TODO: get zig from the zig overlay instead of nixpkgs - zig.url = "github:mitchellh/zig-overlay"; - # LSP plugins nvim-lspconfig = { - # url = "github:neovim/nvim-lspconfig?ref=v0.1.3"; - # Use master for nil_ls url = "github:neovim/nvim-lspconfig"; flake = false; }; @@ -167,6 +162,7 @@ # Langauge server (use master instead of nixpkgs) rnix-lsp.url = "github:nix-community/rnix-lsp"; + nil = { url = "github:oxalica/nil"; inputs.nixpkgs.follows = "nixpkgs"; @@ -212,22 +208,27 @@ url = "github:hrsh7th/nvim-cmp"; flake = false; }; + cmp-buffer = { url = "github:hrsh7th/cmp-buffer"; flake = false; }; + cmp-nvim-lsp = { url = "github:hrsh7th/cmp-nvim-lsp"; flake = false; }; + cmp-vsnip = { url = "github:hrsh7th/cmp-vsnip"; flake = false; }; + cmp-path = { url = "github:hrsh7th/cmp-path"; flake = false; }; + cmp-treesitter = { url = "github:ray-x/cmp-treesitter"; flake = false; diff --git a/flake/legacyPackages.nix b/flake/legacyPackages.nix index c98d626..d6fb73c 100644 --- a/flake/legacyPackages.nix +++ b/flake/legacyPackages.nix @@ -9,11 +9,9 @@ overlays = [ inputs.tidalcycles.overlays.default inputs.self.overlays.default - inputs.zig.overlays.default (_: _: { rnix-lsp = inputs'.rnix-lsp.defaultPackage; nil = inputs'.nil.packages.default; - zig = inputs'.zig.packages.default; }) ]; }; diff --git a/flake/overlays.nix b/flake/overlays.nix index 7a0469c..c73f2c0 100644 --- a/flake/overlays.nix +++ b/flake/overlays.nix @@ -5,9 +5,7 @@ }: let inherit (import ../configuration.nix inputs) neovimConfiguration mainConfig; - buildPkg = pkgs: modules: - (neovimConfiguration {inherit pkgs modules;}) - .neovim; + buildPkg = pkgs: modules: (neovimConfiguration {inherit pkgs modules;}).neovim; nixConfig = mainConfig false; maximalConfig = mainConfig true; diff --git a/flake/packages.nix b/flake/packages.nix index a87c8a2..a9937b8 100644 --- a/flake/packages.nix +++ b/flake/packages.nix @@ -1,5 +1,6 @@ {inputs, ...}: { perSystem = { + self', system, config, pkgs, @@ -18,6 +19,12 @@ docs-manpages = docs.manPages; docs-json = docs.options.json; + docs-html-wrapped = pkgs.writeScriptBin "docs-html-wrapped" '' + #!${pkgs.stdenv.shell} + # use xdg-open to open the docs in the browser + ${pkgs.xdg_utils}/bin/xdg-open ${docs.manual.html} + ''; + # nvim configs nix = config.legacyPackages.neovim-nix; maximal = config.legacyPackages.neovim-maximal; From b7f722252c6d9d9c7fb9ba8220592c81b683bdbc Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 3 Oct 2023 22:08:35 +0300 Subject: [PATCH 13/14] docs/README: update logo alt --- .github/README.md | 2 +- docs/default.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/README.md b/.github/README.md index 71c09f8..ca5bfb5 100644 --- a/.github/README.md +++ b/.github/README.md @@ -1,5 +1,5 @@
- Logo + neovim-flake Logo

❄️ neovim-flake

diff --git a/docs/default.nix b/docs/default.nix index 07274d8..211bf38 100644 --- a/docs/default.nix +++ b/docs/default.nix @@ -1,6 +1,6 @@ { pkgs, - lib, + lib ? import ../lib/stdlib-extended.nix pkgs.lib, nmdSrc, }: let nmd = import nmdSrc { From 2600fba72900d5493c9d030e428ef4806a3fc681 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 4 Oct 2023 00:24:55 +0300 Subject: [PATCH 14/14] revert `8506a5e (flake: drop zig overlay)` --- flake.lock | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++--- flake.nix | 11 ++++---- 2 files changed, 77 insertions(+), 10 deletions(-) diff --git a/flake.lock b/flake.lock index 2f2330a..f939c12 100644 --- a/flake.lock +++ b/flake.lock @@ -402,6 +402,22 @@ "type": "github" } }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -438,6 +454,21 @@ "type": "github" } }, + "flake-utils_2": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "flutter-tools": { "flake": false, "locked": { @@ -773,11 +804,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1696261572, - "narHash": "sha256-s8TtSYJ1LBpuITXjbPLUPyxzAKw35LhETcajJjCS5f0=", + "lastModified": 1690630721, + "narHash": "sha256-Y04onHyBQT4Erfr2fc82dbJTfXGYrf4V0ysLUYnPOP8=", "owner": "nixos", "repo": "nixpkgs", - "rev": "0c7ffbc66e6d78c50c38e717ec91a2a14e0622fb", + "rev": "d2b52322f35597c62abf56de91b0236746b2a03d", "type": "github" }, "original": { @@ -837,6 +868,22 @@ "type": "github" } }, + "nixpkgs_4": { + "locked": { + "lastModified": 1689088367, + "narHash": "sha256-Y2tl2TlKCWEHrOeM9ivjCLlRAKH3qoPUE/emhZECU14=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5c9ddb86679c400d6b7360797b8a22167c2053f8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, "nmd": { "flake": false, "locked": { @@ -1467,7 +1514,8 @@ "vim-repeat": "vim-repeat", "vim-startify": "vim-startify", "vim-vsnip": "vim-vsnip", - "which-key": "which-key" + "which-key": "which-key", + "zig": "zig" } }, "rust-overlay": { @@ -1903,6 +1951,26 @@ "repo": "which-key.nvim", "type": "github" } + }, + "zig": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_4" + }, + "locked": { + "lastModified": 1690718829, + "narHash": "sha256-GN19SrCqWxIJN+rnbv+pIkF/yynh6FG2y7jY6PZRiYw=", + "owner": "mitchellh", + "repo": "zig-overlay", + "rev": "92e485cc7887f57be4d2921ed077f467912b7d33", + "type": "github" + }, + "original": { + "owner": "mitchellh", + "repo": "zig-overlay", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 149078a..48a280f 100644 --- a/flake.nix +++ b/flake.nix @@ -62,8 +62,13 @@ flake = false; }; + # TODO: get zig from the zig overlay instead of nixpkgs + zig.url = "github:mitchellh/zig-overlay"; + # LSP plugins nvim-lspconfig = { + # url = "github:neovim/nvim-lspconfig?ref=v0.1.3"; + # Use master for nil_ls url = "github:neovim/nvim-lspconfig"; flake = false; }; @@ -162,7 +167,6 @@ # Langauge server (use master instead of nixpkgs) rnix-lsp.url = "github:nix-community/rnix-lsp"; - nil = { url = "github:oxalica/nil"; inputs.nixpkgs.follows = "nixpkgs"; @@ -208,27 +212,22 @@ url = "github:hrsh7th/nvim-cmp"; flake = false; }; - cmp-buffer = { url = "github:hrsh7th/cmp-buffer"; flake = false; }; - cmp-nvim-lsp = { url = "github:hrsh7th/cmp-nvim-lsp"; flake = false; }; - cmp-vsnip = { url = "github:hrsh7th/cmp-vsnip"; flake = false; }; - cmp-path = { url = "github:hrsh7th/cmp-path"; flake = false; }; - cmp-treesitter = { url = "github:ray-x/cmp-treesitter"; flake = false;