Compare commits

...

10 commits

9 changed files with 236 additions and 75 deletions

72
.github/README.md vendored
View file

@ -48,7 +48,7 @@
[Documentation]: #documentation [Documentation]: #documentation
[Help]: #help [Help]: #help
[Contribute]: #contributing [Contribute]: #contributing
[FAQ]: #faq [FAQ]: #frequently-asked-questions
[Credits]: #credits [Credits]: #credits
**[<kbd><br>Features <br></kbd>][Features]** **[<kbd><br>Features <br></kbd>][Features]**
@ -56,7 +56,7 @@
**[<kbd><br>Documentation<br></kbd>][Documentation]** **[<kbd><br>Documentation<br></kbd>][Documentation]**
**[<kbd><br>Help<br></kbd>][Help]** **[<kbd><br>Help<br></kbd>][Help]**
**[<kbd><br>Contribute<br></kbd>][Contribute]** **[<kbd><br>Contribute<br></kbd>][Contribute]**
**[<kbd><br>FAQ<br></kbd>][Faq]** **[<kbd><br>Credits<br></kbd>][Credits]** **[<kbd><br>FAQ<br></kbd>][FAQ]** **[<kbd><br>Credits<br></kbd>][Credits]**
</p></div> </p></div>
@ -64,12 +64,21 @@
## Features ## Features
[standalone]: https://notashelf.github.io/nvf/index.xhtml#ch-standalone-installation
[NixOS module]: https://notashelf.github.io/nvf/index.xhtml#ch-standalone-nixos
[Home-Manager module]: https://notashelf.github.io/nvf/index.xhtml#ch-standalone-hm
- **Simple**: One language to rule them all! Use Nix to configure everything,
with additional Lua Support
- **Reproducible**: Your configuration will behave the same _anywhere_. No - **Reproducible**: Your configuration will behave the same _anywhere_. No
surprises, promise! surprises, promise!
- **Portable**: nvf depends _solely_ on your Nix store, and nothing else. No - **Portable**: nvf depends _solely_ on your Nix store, and nothing else. No
more global binaries! Works on all platforms, without hassle. more global binaries! Works on all platforms, without hassle.
- Options to install [standalone], [NixOS module] or [Home-Manager module].
- **Customizable**: There are _almost no defaults_ to annoy you. nvf is fully - **Customizable**: There are _almost no defaults_ to annoy you. nvf is fully
customizable through the Nix module system. customizable through the Nix module system.
- Not comfortable with a full-nix config or want to bring your Lua config? You
can do just that, no unnecessary restrictions.
- **Well-documented**: Documentation is priority. You will _never_ face - **Well-documented**: Documentation is priority. You will _never_ face
undocumented, obscure behaviour. undocumented, obscure behaviour.
- **Idiomatic**: nvf does things ✨ _the right way_ ✨ - the codebase is, and - **Idiomatic**: nvf does things ✨ _the right way_ ✨ - the codebase is, and
@ -120,7 +129,9 @@ instructions.
## Documentation ## Documentation
The _recommended_ way of installing **nvf** is using either the NixOS or the ### Installation
The _recommended_ way of installing nvf is using either the NixOS or the
Home-Manager module, though it is completely possible and no less supported to Home-Manager module, though it is completely possible and no less supported to
install **nvf** as a standalone package, or a flake output. install **nvf** as a standalone package, or a flake output.
@ -138,11 +149,13 @@ Please create an issue on the [issue tracker] if you find the documentation
lacking or confusing. Any improvements to the documentation through pull lacking or confusing. Any improvements to the documentation through pull
requests are also welcome, and appreciated. requests are also welcome, and appreciated.
## Help ## Getting Help
You can create an issue on the [issue tracker] to ask questions or report bugs. If you are confused, stuck or would like to ask a simple question; you may
I am not yet on spaces like matrix or IRC, so please use the issue tracker for create an issue on the [issue tracker] to ask questions or report bugs.
now.
We are not not yet on spaces like matrix or IRC, so please use the issue tracker
for now.
## Contributing ## Contributing
@ -152,7 +165,7 @@ submitting a pull request. You can also create an issue on the [issue tracker]
before submitting a pull request if you would like to discuss a feature or bug before submitting a pull request if you would like to discuss a feature or bug
fix. fix.
## FAQ ## Frequently Asked Questions
[appropriate issue template]: https://github.com/NotAShelf/nvf/issues/new/choose [appropriate issue template]: https://github.com/NotAShelf/nvf/issues/new/choose
[list of branches]: https://github.com/NotAShelf/nvf/branches [list of branches]: https://github.com/NotAShelf/nvf/branches
@ -160,13 +173,15 @@ fix.
**Q**: What platforms are supported? **Q**: What platforms are supported?
<br/> **A**: nvf actively supports Linux and Darwin platforms using standalone <br/> **A**: nvf actively supports Linux and Darwin platforms using standalone
Nix, NixOS or Home-Manager. Please take a look at the Nix, NixOS or Home-Manager. Please take a look at the [nvf manual] for available
installation instructions.
**Q**: Can you add _X_? **Q**: Can you add _X_?
<br/> **A**: Maybe! It is not one of our goals to support each and every Neovim <br/> **A**: Maybe! It is not one of our goals to support each and every Neovim
plugin, however, I am always open to new modules and plugin setup additions to plugin, however, I am always open to new modules and plugin setup additions to
**nvf**. Use the [appropriate issue template] and I will consider a module **nvf**. Use the [appropriate issue template] and I will consider a module
addition. As mentioned before, PRs adding new features are also welcome. addition. As mentioned before, pull requests to add new features are also
welcome.
**Q**: A plugin I need is not available in **nvf**. What to do? **Q**: A plugin I need is not available in **nvf**. What to do?
<br/> **A**: **nvf** exposes several APIs for you to be able to add your own <br/> **A**: **nvf** exposes several APIs for you to be able to add your own
@ -185,22 +200,26 @@ better prepare to breaking changes.
### Contributors ### Contributors
Special, heart-felt thanks to [mnw]: https://github.com/gerg-l/mnw
- [@fufexan](https://github.com/fufexan) - For the transition to flake-parts nvf would not be what it is today without the awesome people below. Special,
- [@FlafyDev](https://github.com/FlafyDev) - For getting the home-manager to heart-felt thanks to
work
- [@fufexan](https://github.com/fufexan) - For the transition to flake-parts and
invaluable Nix assistance.
- [@FlafyDev](https://github.com/FlafyDev) - For getting home-manager module to
work and Nix assistance.
- [@n3oney](https://github.com/n3oney) - For making custom keybinds finally - [@n3oney](https://github.com/n3oney) - For making custom keybinds finally
possible possible, and other module additions.
- [@horriblename](https://github.com/horriblename) - For actively implementing - [@horriblename](https://github.com/horriblename) - For actively implementing
planned features and quality of life updates planned features and quality of life updates.
- [@Yavko](https://github.com/Yavko) - For the amazing **nvf** logo - [@Yavko](https://github.com/Yavko) - For the amazing **nvf** logo
- [@FrothyMarrow](https://github.com/FrothyMarrow) - For seeing mistakes that I - [@FrothyMarrow](https://github.com/FrothyMarrow) - For seeing mistakes that I
could not could not.
- [@Diniamo](https://github.com/Diniamo) - For actively submitting PRs, pull - [@Diniamo](https://github.com/Diniamo) - For actively submitting pull
requests and overall assistence requests, issues and assistance with maintenance of nvf.
- [@Gerg-l](https://github.com/gerg-l) - For the modern Neovim wrapper, mnw and - [@Gerg-l](https://github.com/gerg-l) - For the modern Neovim wrapper, [mnw],
occasional code improvements and occasional code improvements.
and everyone who has submitted issues or pull requests! and everyone who has submitted issues or pull requests!
@ -214,7 +233,7 @@ including:
is originally based on. is originally based on.
- [@sioodmy's](https://github.com/sioodmy) - [@sioodmy's](https://github.com/sioodmy)
[dotfiles](https://github.com/sioodmy/dotfiles) that inspired the design [dotfiles](https://github.com/sioodmy/dotfiles) that inspired the design
choices. choices for UI and plugin defaults.
- [@wiltaylor's](https://github.com/wiltaylor) - [@wiltaylor's](https://github.com/wiltaylor)
[neovim-flake](https://github.com/wiltaylor/neovim-flake) for plugin and [neovim-flake](https://github.com/wiltaylor/neovim-flake) for plugin and
design ideas. design ideas.
@ -229,10 +248,11 @@ recommend checking their work out.
## License ## License
Following the license of the Following the license of the
[original neovim-flake](https://github.com/jordanisaacs/neovim-flake), **nvf** [original neovim-flake](https://github.com/jordanisaacs/neovim-flake), nvf has
has been made available under the [**MIT License**](LICENSE). However, all been made available under the [**MIT License**](LICENSE). However, all assets
assets and documentation are published under the and documentation are published under the
[**CC BY License**](https://github.com/NotAShelf/nvf/blob/main/.github/assets/LICENSE). [**CC BY License**](https://github.com/NotAShelf/nvf/blob/main/.github/assets/LICENSE)
under explicit permission by the artist.
<h6 align="center">Yes, this includes the logo work too. Stop taking artwork that is not yours!</h6> <h6 align="center">Yes, this includes the logo work too. Stop taking artwork that is not yours!</h6>

View file

@ -1,8 +1,9 @@
# Standalone Installation {#ch-standalone-installation} # Standalone Installation {#ch-standalone-installation}
It is possible to install **nvf** without depending on NixOS or home-manager as the parent It is possible to install nvf without depending on NixOS or Home-Manager as the
module system, using the `neovimConfiguration` function exposed by **nvf** extended library. parent module system, using the `neovimConfiguration` function exposed in the
It takes in the configuration as a module, and returns an attribute set as a result. extended library. This function will take `modules` and `extraSpecialArgs` as
arguments, and return the following schema as a result.
```nix ```nix
{ {
@ -13,6 +14,53 @@ It takes in the configuration as a module, and returns an attribute set as a res
} }
``` ```
An example flake that exposes your custom Neovim configuration might look like
```nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nvf.url = "github:notashelf/nvf";
};
outputs = {
self,
nixpkgs,
...
} @ inputs: {
packages."x86_64-linux" = let
neovimConfigured = (inputs.nvf.lib.neovimConfiguration {
inherit (nixpkgs.legacyPackages."x86_64-linux") pkgs;
modules = [{
config.vim = {
# Enable custom theming options
theme.enable = true;
# Enable Treesitter
tree-sitter.enable = true;
# Other options will go here. Refer to the config
# reference in Appendix B of the nvf manual.
# ...
};
}];
});
in {
# Set the default package to the wrapped instance of Neovim.
# This will allow running your Neovim configuration with
# `nix run` and in addition, sharing your configuration with
# other users in case your repository is public.
default = neovimConfigured.neovim;
};
};
}
```
<!-- TODO: mention the built-in flake template here when it is added -->
The next two chapters will detail specific usage of standalone nvf
configurations on NixOS and Home-Manager.
```{=include=} chapters ```{=include=} chapters
standalone/nixos.md standalone/nixos.md
standalone/home-manager.md standalone/home-manager.md

View file

@ -1,5 +1,9 @@
# Module Installation {#ch-module-installation} # Module Installation {#ch-module-installation}
The below chapters will describe installing nvf as NixOS and Home-Manager
modules. Note that those methods are mutually exclusive, and will likely cause
path collisions if used simultaneously.
```{=include=} chapters ```{=include=} chapters
modules/nixos.md modules/nixos.md
modules/home-manager.md modules/home-manager.md

View file

@ -1,6 +1,6 @@
# Standalone Installation on Home-Manager {#ch-standalone-hm} # Standalone Installation on Home-Manager {#ch-standalone-hm}
Your built Neoevim configuration can be exposed as a flake output to make it Your built Neovim configuration can be exposed as a flake output to make it
easier to share across machines, repositories and so on. Or it can be added to easier to share across machines, repositories and so on. Or it can be added to
your system packages to make it available across your system. your system packages to make it available across your system.

View file

@ -1,6 +1,6 @@
# Standalone Installation on NixOS {#ch-standalone-nixos} # Standalone Installation on NixOS {#ch-standalone-nixos}
Your built Neoevim configuration can be exposed as a flake output to make it Your built Neovim configuration can be exposed as a flake output to make it
easier to share across machines, repositories and so on. Or it can be added to easier to share across machines, repositories and so on. Or it can be added to
your system packages to make it available across your system. your system packages to make it available across your system.

View file

@ -185,6 +185,7 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to
default. default.
- Refactor of `nvim-cmp` and completion related modules - Refactor of `nvim-cmp` and completion related modules
- Remove `autocomplete.type` in favor of per-plugin enable options such as - Remove `autocomplete.type` in favor of per-plugin enable options such as
[](#opt-vim.autocomplete.nvim-cmp.enable). [](#opt-vim.autocomplete.nvim-cmp.enable).
- Deprecate legacy Vimsnip in favor of Luasnip, and integrate - Deprecate legacy Vimsnip in favor of Luasnip, and integrate
@ -277,9 +278,13 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to
configuration for [dashboard.nvim](https://github.com/nvimdev/dashboard-nvim) configuration for [dashboard.nvim](https://github.com/nvimdev/dashboard-nvim)
- Update `lualine.nvim` input and add missing themes: - Update `lualine.nvim` input and add missing themes:
- Adds `ayu`, `gruvbox_dark`, `iceberg`, `moonfly`, `onedark`, - Adds `ayu`, `gruvbox_dark`, `iceberg`, `moonfly`, `onedark`,
`powerline_dark` and `solarized_light` themes. `powerline_dark` and `solarized_light` themes.
- Add [](#opt-vim.spellcheck.extraSpellWords) to allow adding arbitrary
spellfiles to Neovim's runtime with ease.
[ppenguin](https://github.com/ppenguin): [ppenguin](https://github.com/ppenguin):
- Telescope: - Telescope:

View file

@ -30,29 +30,25 @@
}; };
homeManagerModules = { homeManagerModules = {
nvf = import ./flake/modules/home-manager.nix self.packages lib;
default = self.homeManagerModules.nvf;
neovim-flake = neovim-flake =
lib.warn '' lib.warn ''
homeManagerModules.neovim-flake has been deprecated. 'homeManagerModules.neovim-flake' has been deprecated, and will be removed
Plese use the homeManagerModules.nvf instead in a future release. Please use 'homeManagerModules.nvf' instead.
'' ''
self.homeManagerModules.nvf; self.homeManagerModules.nvf;
nvf = import ./flake/modules/home-manager.nix self.packages lib;
default = self.homeManagerModules.nvf;
}; };
nixosModules = { nixosModules = {
nvf = import ./flake/modules/nixos.nix self.packages lib;
default = self.nixosModules.nvf;
neovim-flake = neovim-flake =
lib.warn '' lib.warn ''
nixosModules.neovim-flake has been deprecated. 'nixosModules.neovim-flake' has been deprecated, and will be removed
Please use the nixosModules.nvf instead in a future release. Please use 'nixosModules.nvf' instead.
'' ''
self.nixosModules.nvf; self.nixosModules.nvf;
nvf = import ./flake/modules/nixos.nix self.packages lib;
default = self.nixosModules.nvf;
}; };
}; };

View file

@ -1,11 +1,14 @@
{ {
config, config,
pkgs,
lib, lib,
... ...
}: let }: let
inherit (lib.modules) mkIf mkRenamedOptionModule; inherit (lib.modules) mkIf mkRenamedOptionModule;
inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) listOf str; inherit (lib.strings) concatLines;
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.types) listOf str attrsOf;
inherit (lib.nvim.lua) listToLuaTable; inherit (lib.nvim.lua) listToLuaTable;
inherit (lib.nvim.dag) entryAfter; inherit (lib.nvim.dag) entryAfter;
@ -24,10 +27,48 @@ in {
description = '' description = ''
A list of languages that should be used for spellchecking. A list of languages that should be used for spellchecking.
To add your own language files, you may place your `spell` To add your own language files, you may place your `spell` directory in either
directory in either `~/.config/nvim` or the {file}`$XDG_CONFIG_HOME/nvf` or in a path that is included in the
[additionalRuntimePaths](#opt-vim.additionalRuntimePaths) [additionalRuntimePaths](#opt-vim.additionalRuntimePaths) list provided by nvf.
directory provided by **nvf**. '';
};
extraSpellWords = mkOption {
type = attrsOf (listOf str);
default = {};
example = literalExpression ''{"en.utf-8" = ["nvf" "word_you_want_to_add"];}'';
description = ''
Additional words to be used for spellchecking. The names of each key will be
used as the language code for the spell file. For example
```nix
"en.utf-8" = [ ... ];
```
will result in `en.utf-8.add.spl` being added to Neovim's runtime in the
{file}`spell` directory.
::: {.warning}
The attribute keys must be in `"<name>.<encoding>"` format for Neovim to
compile your spellfiles without mangling the resulting file names. Please
make sure that you enter the correct value, as nvf does not do any kind of
internal checking. Please see {command}`:help mkspell` for more details.
Example:
```nix
# "en" is the name, and "utf-8" is the encoding. For most use cases, utf-8
# will be enough, however, you may change it to any encoding format Neovim
# accepts, e.g., utf-16.
"en.utf-8" = ["nvf" "word_you_want_to_add"];
=> $out/spell/en-utf-8.add.spl
```
:::
Note that while adding a new language, you will still need to add the name of
the language (e.g. "en") to the {option}`vim.spellcheck.languages` list by name
in order to enable spellchecking for the language. By default only `"en"` is in
the list.
''; '';
}; };
@ -38,38 +79,75 @@ in {
description = '' description = ''
A list of filetypes for which spellchecking will be disabled. A list of filetypes for which spellchecking will be disabled.
You may use `echo &filetype` in Neovim to find out the ::: {.tip}
You may use {command}`:echo &filetype` in Neovim to find out the
filetype for a specific buffer. filetype for a specific buffer.
:::
''; '';
}; };
/*
# FIXME: This needs to be revisited. It tries to install
# the spellfile to an user directory, but it cannot do so
# as we sanitize runtime paths.
programmingWordlist.enable = mkEnableOption '' programmingWordlist.enable = mkEnableOption ''
vim-dirtytalk, a wordlist for programmers containing vim-dirtytalk, a wordlist for programmers containing
common programming terms. common programming terms.
Setting this value as `true` has the same effect ::: {.note}
as setting {option}`vim.spellCheck.enable` Enabling this option will unconditionally set
{option}`vim.spellcheck.enable` to true as vim-dirtytalk
depends on spellchecking having been set up.
:::
''; '';
*/
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.luaConfigRC.spellcheck = entryAfter ["basic"] '' vim = {
vim.opt.spell = true additionalRuntimePaths = let
vim.opt.spelllang = ${listToLuaTable cfg.languages} compileJoinedSpellfiles =
pkgs.runCommandLocal "nvf-compile-spellfiles" {
# Use the same version of Neovim as the user's configuration
nativeBuildInputs = [config.vim.package];
-- Disable spellchecking for certain filetypes spellfilesJoined = pkgs.symlinkJoin {
-- as configured by `vim.spellcheck.ignoredFiletypes` name = "nvf-spellfiles-joined";
vim.api.nvim_create_autocmd({ "FileType" }, { paths = mapAttrsToList (name: value: pkgs.writeTextDir "spell/${name}.add" (concatLines value)) cfg.extraSpellWords;
pattern = ${listToLuaTable cfg.ignoredFiletypes}, postBuild = "echo Spellfiles joined";
callback = function() };
vim.opt_local.spell = false } ''
end, # Fail on unset variables and non-zero exit codes
}) # this might be the only way to trace when `nvim --headless`
''; # fails in batch mode
set -eu
mkdir -p "$out/spell"
for spellfile in "$spellfilesJoined"/spell/*.add; do
name="$(basename "$spellfile" ".add")"
echo "Compiling spellfile: $spellfile"
nvim --headless --clean \
--cmd "mkspell $out/spell/$name.add.spl $spellfile" -Es -n
done
'';
in
mkIf (cfg.extraSpellWords != {}) [
# If .outPath is missing, additionalRuntimePaths receives the *function*
# instead of a path, causing errors.
compileJoinedSpellfiles.outPath
];
luaConfigRC.spellcheck = entryAfter ["basic"] ''
vim.opt.spell = true
vim.opt.spelllang = ${listToLuaTable cfg.languages}
-- Disable spellchecking for certain filetypes
-- as configured by `vim.spellcheck.ignoredFiletypes`
vim.api.nvim_create_augroup("nvf_autocmds", {clear = false})
vim.api.nvim_create_autocmd({ "FileType" }, {
group = "nvf_autocmds",
pattern = ${listToLuaTable cfg.ignoredFiletypes},
callback = function()
vim.opt_local.spell = false
end,
})
'';
};
}; };
} }

View file

@ -7,16 +7,26 @@
inherit (lib.nvim.dag) entryAfter; inherit (lib.nvim.dag) entryAfter;
cfg = config.vim.spellcheck; cfg = config.vim.spellcheck;
in { in {
config = mkIf (cfg.enable && cfg.programmingWordlist.enable) { config = mkIf cfg.programmingWordlist.enable {
vim = { vim = {
startPlugins = ["vim-dirtytalk"]; startPlugins = ["vim-dirtytalk"];
# vim-dirtytalk doesn't have any setup spellcheck.enable = true;
# but we would like to append programming to spelllang
# as soon as possible while the plugin is enabled # vim-dirtytalk doesn't have any setup but we would
pluginRC.vim-dirtytalk = entryAfter ["basic"] '' # like to append programming to spelllangs as soon as
-- append programming to spelllang # possible while the plugin is enabled and the state
vim.opt.spelllang:append("programming") # directory can be found.
pluginRC.vim-dirtytalk = entryAfter ["spellcheck"] ''
-- If Neovim can find (or access) the state directory
-- then append "programming" wordlist from vim-dirtytalk
-- to spelllang table. If path cannot be found, display
-- an error and avoid appending the programming words
if vim.fn.isdirectory(vim.fn.stdpath('state')) == 1 then
vim.opt.spelllang:append("programming")
else
vim.notify("State path does not exist: " .. state_path, vim.log.levels.ERROR)
end
''; '';
}; };
}; };