mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-19 13:19:48 +01:00
commit
85d693540b
136 changed files with 3383 additions and 1206 deletions
218
.github/CONTRIBUTING.md
vendored
218
.github/CONTRIBUTING.md
vendored
|
@ -18,8 +18,224 @@ 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.
|
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
|
### 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.
|
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.
|
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.
|
||||||
|
|
||||||
|
#### Documentation
|
||||||
|
|
||||||
|
If you are making a pull request to add a
|
||||||
|
|
||||||
|
|
||||||
|
#### Style
|
||||||
|
|
||||||
|
**Nix**
|
||||||
|
We use Alejandra for formatting nix code, which can be invoked directly with `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.<mode>`.
|
||||||
|
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 = {
|
||||||
|
"<leader>wq" = {
|
||||||
|
action = ":wq<CR>";
|
||||||
|
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 "<cmd> Telescope find_files<CR>")
|
||||||
|
(mkSetBinding mappings.liveGrep "<cmd> Telescope live_grep<CR>")
|
||||||
|
(mkSetBinding mappings.buffers "<cmd> Telescope buffers<CR>")
|
||||||
|
(mkSetBinding mappings.helpTags "<cmd> Telescope help_tags<CR>")
|
||||||
|
(mkSetBinding mappings.open "<cmd> Telescope<CR>")
|
||||||
|
|
||||||
|
(mkSetBinding mappings.gitCommits "<cmd> Telescope git_commits<CR>")
|
||||||
|
(mkSetBinding mappings.gitBufferCommits "<cmd> Telescope git_bcommits<CR>")
|
||||||
|
(mkSetBinding mappings.gitBranches "<cmd> Telescope git_branches<CR>")
|
||||||
|
(mkSetBinding mappings.gitStatus "<cmd> Telescope git_status<CR>")
|
||||||
|
(mkSetBinding mappings.gitStash "<cmd> Telescope git_stash<CR>")
|
||||||
|
|
||||||
|
(mkIf config.vim.lsp.enable (mkMerge [
|
||||||
|
(mkSetBinding mappings.lspDocumentSymbols "<cmd> Telescope lsp_document_symbols<CR>")
|
||||||
|
(mkSetBinding mappings.lspWorkspaceSymbols "<cmd> Telescope lsp_workspace_symbols<CR>")
|
||||||
|
|
||||||
|
(mkSetBinding mappings.lspReferences "<cmd> Telescope lsp_references<CR>")
|
||||||
|
(mkSetBinding mappings.lspImplementations "<cmd> Telescope lsp_implementations<CR>")
|
||||||
|
(mkSetBinding mappings.lspDefinitions "<cmd> Telescope lsp_definitions<CR>")
|
||||||
|
(mkSetBinding mappings.lspTypeDefinitions "<cmd> Telescope lsp_type_definitions<CR>")
|
||||||
|
(mkSetBinding mappings.diagnostics "<cmd> Telescope diagnostics<CR>")
|
||||||
|
]))
|
||||||
|
|
||||||
|
(
|
||||||
|
mkIf config.vim.treesitter.enable
|
||||||
|
(mkSetBinding mappings.treesitter "<cmd> Telescope treesitter<CR>")
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
# ...
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
|
||||||
|
|
24
.github/README.md
vendored
24
.github/README.md
vendored
|
@ -41,10 +41,10 @@
|
||||||
<div align="center"><p>
|
<div align="center"><p>
|
||||||
|
|
||||||
**[<kbd> <br> Get Started <br> </kbd>][Get Started]**
|
**[<kbd> <br> Get Started <br> </kbd>][Get Started]**
|
||||||
**[<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> FAQ <br> </kbd>][Faq]**
|
||||||
**[<kbd> <br> Credits <br> </kbd>][Credits]**
|
**[<kbd> <br> Credits <br> </kbd>][Credits]**
|
||||||
|
|
||||||
</p></div>
|
</p></div>
|
||||||
|
@ -78,7 +78,7 @@ nix run github:notashelf/neovim-flake#tidal
|
||||||
|
|
||||||
Similar instructions will apply for `nix profile install`.
|
Similar instructions will apply for `nix profile install`.
|
||||||
|
|
||||||
P.S. The `maximal` configuration is *massive* and will take a while to build. To get a feel for the configuration, use the default `nix` or `tidal` configurations.
|
P.S. The `maximal` configuration is _massive_ and will take a while to build. To get a feel for the configuration, use the default `nix` or `tidal` configurations.
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
|
@ -103,8 +103,8 @@ I am always looking for new ways to help improve this flake. If you would like t
|
||||||
## Philosophy
|
## Philosophy
|
||||||
|
|
||||||
The philosophy behind this flake configuration is to create an easily configurable and reproducible Neovim environment. While it does sacrifice in size
|
The philosophy behind this flake configuration is to create an easily configurable and reproducible Neovim environment. While it does sacrifice in size
|
||||||
(which I know some users will find *disagreeable*), it offers a lot of flexibility and customizability in exchange for the large size of the flake inputs.
|
(which I know some users will find _disagreeable_), it offers a lot of flexibility and customizability in exchange for the large size of the flake inputs.
|
||||||
The KISS (Keep it simple, stupid) principle has been abandoned here, however, you *can* ultimately leverage the flexibility of this flake to declare a configuration that follows KISS principles, it is very easy to bring your own plugins and configurations from non-nix. What this flake is meant to be does eventually fall into your hands. Whether you are a developer, writer, or live coder (see tidal cycles below!), you can quickly craft a config that suits every project's need. Think of it like a distribution of Neovim that takes advantage of pinning vim plugins and
|
The KISS (Keep it simple, stupid) principle has been abandoned here, however, you _can_ ultimately leverage the flexibility of this flake to declare a configuration that follows KISS principles, it is very easy to bring your own plugins and configurations from non-nix. What this flake is meant to be does eventually fall into your hands. Whether you are a developer, writer, or live coder, you can quickly craft a config that suits every project's need. Think of it like a distribution of Neovim that takes advantage of pinning vim plugins and
|
||||||
third party dependencies (such as tree-sitter grammars, language servers, and more).
|
third party dependencies (such as tree-sitter grammars, language servers, and more).
|
||||||
|
|
||||||
One should never get a broken config when setting options. If setting multiple options results in a broken Neovim, file an issue! Each plugin knows when another plugin which allows for smart configuration of keybindings and automatic setup of things like completion sources and languages.
|
One should never get a broken config when setting options. If setting multiple options results in a broken Neovim, file an issue! Each plugin knows when another plugin which allows for smart configuration of keybindings and automatic setup of things like completion sources and languages.
|
||||||
|
@ -128,9 +128,9 @@ instead of the `maximal` output. This will reduce size by a lot, but you will lo
|
||||||
**A**: No. If you feel the need to ask that question, then you have missed the whole point of using nix and ultimately this flake. The whole reason we use nix is to be able to handle EVERYTHING declaratively, well including the LSP and plugin installations.
|
**A**: No. If you feel the need to ask that question, then you have missed the whole point of using nix and ultimately this flake. The whole reason we use nix is to be able to handle EVERYTHING declaratively, well including the LSP and plugin installations.
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
|
|
||||||
**Q**: Can you add *X*?
|
**Q**: Can you add _X_?
|
||||||
<br/>
|
<br/>
|
||||||
**A**: Maybe. Open an issue using the appropriate template and I will consider it. I do not intend to add *every plugin that is in existence*, but I will consider it, should it offer something useful to the flake.
|
**A**: Maybe. Open an issue using the appropriate template and I will consider it. I do not intend to add _every plugin that is in existence_, but I will consider it, should it offer something useful to the flake.
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
|
@ -139,7 +139,9 @@ instead of the `maximal` output. This will reduce size by a lot, but you will lo
|
||||||
Special thanks to
|
Special thanks to
|
||||||
|
|
||||||
- [@fufexan](https://github.com/fufexan) - For the transition to flake-parts
|
- [@fufexan](https://github.com/fufexan) - For the transition to flake-parts
|
||||||
- [@FlafyDev](https://github.com/FlafyDev) - For getting the home-manager to work
|
- [@FlafyDev](https://github.com/FlafyDev) - For getting the home-manager to work
|
||||||
|
- [@n3oney](https://github.com/n3oney) - For making custom keybinds finally possible
|
||||||
|
- [@horriblename](https://github.com/horriblename) - For actively implementing planned features and quality of life updates
|
||||||
|
|
||||||
and everyone who has submitted issues or pull requests!
|
and everyone who has submitted issues or pull requests!
|
||||||
|
|
||||||
|
@ -147,9 +149,9 @@ and everyone who has submitted issues or pull requests!
|
||||||
|
|
||||||
This configuration borrows from and is based on a few other configurations, including:
|
This configuration borrows from and is based on a few other configurations, including:
|
||||||
|
|
||||||
|
- [@jordanisaacs's](https://github.com/jordanisaacs) [neovim-flake](https://github.com/jordanisaacs/neovim-flake)
|
||||||
- [@sioodmy's](https://github.com/sioodmy) [dotfiles](https://github.com/sioodmy/dotfiles)
|
- [@sioodmy's](https://github.com/sioodmy) [dotfiles](https://github.com/sioodmy/dotfiles)
|
||||||
- [@wiltaylor's](https://github.com/wiltaylor) [neovim-flake](https://github.com/wiltaylor/neovim-flake)
|
- [@wiltaylor's](https://github.com/wiltaylor) [neovim-flake](https://github.com/wiltaylor/neovim-flake)
|
||||||
- [@jordanisaacs's](https://github.com/jordanisaacs) [neovim-flake](https://github.com/jordanisaacs/neovim-flake)
|
|
||||||
- [@gvolpe's](https://github.com/gvolpe) [neovim-flake](https://github.com/gvolpe/neovim-flake)
|
- [@gvolpe's](https://github.com/gvolpe) [neovim-flake](https://github.com/gvolpe/neovim-flake)
|
||||||
|
|
||||||
I am grateful for their previous work and inspiration.
|
I am grateful for their previous work and inspiration.
|
||||||
|
|
5
.github/workflows/check-docs.yml
vendored
5
.github/workflows/check-docs.yml
vendored
|
@ -40,5 +40,10 @@ jobs:
|
||||||
run: nix flake check
|
run: nix flake check
|
||||||
- name: Build neovim-flake with default settings
|
- name: Build neovim-flake with default settings
|
||||||
run: nix build .#${{ matrix.package }} --print-build-logs
|
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/
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,13 @@ inputs: let
|
||||||
lspSignature.enable = true;
|
lspSignature.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
vim.debugger = {
|
||||||
|
nvim-dap = {
|
||||||
|
enable = true;
|
||||||
|
ui.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
vim.languages = {
|
vim.languages = {
|
||||||
enableLSP = true;
|
enableLSP = true;
|
||||||
enableFormat = true;
|
enableFormat = true;
|
||||||
|
@ -54,6 +61,7 @@ inputs: let
|
||||||
crates.enable = true;
|
crates.enable = true;
|
||||||
};
|
};
|
||||||
ts.enable = isMaximal;
|
ts.enable = isMaximal;
|
||||||
|
svelte.enable = isMaximal;
|
||||||
go.enable = isMaximal;
|
go.enable = isMaximal;
|
||||||
zig.enable = isMaximal;
|
zig.enable = isMaximal;
|
||||||
python.enable = isMaximal;
|
python.enable = isMaximal;
|
||||||
|
@ -108,6 +116,7 @@ inputs: let
|
||||||
};
|
};
|
||||||
view = {
|
view = {
|
||||||
width = 25;
|
width = 25;
|
||||||
|
cursorline = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -133,12 +142,12 @@ inputs: let
|
||||||
|
|
||||||
vim.minimap = {
|
vim.minimap = {
|
||||||
minimap-vim.enable = false;
|
minimap-vim.enable = false;
|
||||||
codewindow.enable = true; # lighter, faster, and uses lua for configuration
|
codewindow.enable = isMaximal; # lighter, faster, and uses lua for configuration
|
||||||
};
|
};
|
||||||
|
|
||||||
vim.dashboard = {
|
vim.dashboard = {
|
||||||
dashboard-nvim.enable = false;
|
dashboard-nvim.enable = false;
|
||||||
alpha.enable = true;
|
alpha.enable = isMaximal;
|
||||||
};
|
};
|
||||||
|
|
||||||
vim.notify = {
|
vim.notify = {
|
||||||
|
@ -150,8 +159,10 @@ inputs: let
|
||||||
};
|
};
|
||||||
|
|
||||||
vim.utility = {
|
vim.utility = {
|
||||||
colorizer.enable = true;
|
ccc.enable = isMaximal;
|
||||||
icon-picker.enable = true;
|
vim-wakatime.enable = isMaximal;
|
||||||
|
icon-picker.enable = isMaximal;
|
||||||
|
surround.enable = isMaximal;
|
||||||
diffview-nvim.enable = true;
|
diffview-nvim.enable = true;
|
||||||
motion = {
|
motion = {
|
||||||
hop.enable = true;
|
hop.enable = true;
|
||||||
|
@ -175,16 +186,27 @@ inputs: let
|
||||||
|
|
||||||
vim.ui = {
|
vim.ui = {
|
||||||
noice.enable = true;
|
noice.enable = true;
|
||||||
smartcolumn.enable = true;
|
colorizer.enable = true;
|
||||||
|
modes-nvim.enable = false; # the theme looks terrible with catppuccin
|
||||||
|
illuminate.enable = true;
|
||||||
|
smartcolumn = {
|
||||||
|
enable = true;
|
||||||
|
columnAt.languages = {
|
||||||
|
# this is a freeform module, it's `buftype = int;` for configuring column position
|
||||||
|
nix = 110;
|
||||||
|
ruby = 120;
|
||||||
|
java = 130;
|
||||||
|
go = [90 130];
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
vim.assistant = {
|
vim.assistant = {
|
||||||
copilot.enable = isMaximal;
|
copilot.enable = isMaximal;
|
||||||
#tabnine.enable = false; # FIXME: this is not working because the plugin depends on an internal script to be ran by the package manager
|
|
||||||
};
|
};
|
||||||
|
|
||||||
vim.session = {
|
vim.session = {
|
||||||
nvim-session-manager.enable = true;
|
nvim-session-manager.enable = isMaximal;
|
||||||
};
|
};
|
||||||
|
|
||||||
vim.gestures = {
|
vim.gestures = {
|
||||||
|
@ -202,6 +224,7 @@ inputs: let
|
||||||
image_text = "The Superior Text Editor";
|
image_text = "The Superior Text Editor";
|
||||||
client_id = "793271441293967371";
|
client_id = "793271441293967371";
|
||||||
main_image = "neovim";
|
main_image = "neovim";
|
||||||
|
show_time = true;
|
||||||
rich_presence = {
|
rich_presence = {
|
||||||
editing_text = "Editing %s";
|
editing_text = "Editing %s";
|
||||||
};
|
};
|
|
@ -16,11 +16,12 @@
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
</preface>
|
</preface>
|
||||||
<xi:include href="try-it-out.xml"/>
|
<xi:include href="manual/try-it-out.xml"/>
|
||||||
<xi:include href="default-configs.xml"/>
|
<xi:include href="manual/default-configs.xml"/>
|
||||||
<xi:include href="custom-configs.xml"/>
|
<xi:include href="manual/custom-configs.xml"/>
|
||||||
<xi:include href="home-manager.xml"/>
|
<xi:include href="manual/custom-plugins.xml"/>
|
||||||
<xi:include href="languages.xml"/>
|
<xi:include href="manual/home-manager.xml"/>
|
||||||
|
<xi:include href="manual/languages.xml"/>
|
||||||
<appendix xml:id="ch-options">
|
<appendix xml:id="ch-options">
|
||||||
<title>Configuration Options</title>
|
<title>Configuration Options</title>
|
||||||
<xi:include href="./nmd-result/neovim-flake-options.xml" />
|
<xi:include href="./nmd-result/neovim-flake-options.xml" />
|
||||||
|
|
34
docs/manual/custom-plugins.adoc
Normal file
34
docs/manual/custom-plugins.adoc
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[[ch-custom-plugins]]
|
||||||
|
== Custom Plugins
|
||||||
|
|
||||||
|
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.
|
||||||
|
This is an example of adding the FrenzyExists/aquarium-vim plugin:
|
||||||
|
|
||||||
|
[source,nix]
|
||||||
|
----
|
||||||
|
{
|
||||||
|
config.vim.startPlugins = [
|
||||||
|
(pkgs.fetchFromGitHub {
|
||||||
|
owner = "FrenzyExists";
|
||||||
|
repo = "aquarium-vim";
|
||||||
|
rev = "d09b1feda1148797aa5ff0dbca8d8e3256d028d5";
|
||||||
|
sha256 = "CtyEhCcGxxok6xFQ09feWpdEBIYHH+GIFVOaNZx10Bs=";
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
|
----
|
||||||
|
|
||||||
|
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]
|
||||||
|
----
|
||||||
|
{
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
80
docs/manual/home-manager.adoc
Normal file
80
docs/manual/home-manager.adoc
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
[[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.
|
||||||
|
|
||||||
|
[source,nix]
|
||||||
|
----
|
||||||
|
{
|
||||||
|
neovim-flake = {
|
||||||
|
url = github:notashelf/neovim-flake;
|
||||||
|
# you can override input nixpkgs
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
----
|
||||||
|
|
||||||
|
Followed by importing the HM module.
|
||||||
|
|
||||||
|
[source,nix]
|
||||||
|
----
|
||||||
|
{
|
||||||
|
imports = [ neovim-flake.homeManagerModules.default ];
|
||||||
|
}
|
||||||
|
----
|
||||||
|
|
||||||
|
Then we should be able to use the given module. E.g.
|
||||||
|
|
||||||
|
[source,nix]
|
||||||
|
----
|
||||||
|
{
|
||||||
|
programs.neovim-flake = {
|
||||||
|
|
||||||
|
enable = true;
|
||||||
|
# your settings need to go into the settings attrset
|
||||||
|
settings = {
|
||||||
|
vim.viAlias = false;
|
||||||
|
vim.vimAlias = true;
|
||||||
|
vim.lsp = {
|
||||||
|
enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
----
|
||||||
|
|
||||||
|
=== Custom vim/neovim plugins
|
||||||
|
|
||||||
|
It is possible to add custom plugins to your configuration by using the `vim.startPlugins` option and the this flake's lua DAG library.
|
||||||
|
|
||||||
|
Start by adding it to startPlugins. This example uses nvim-surround, but the process will be similar for other plugins as well.
|
||||||
|
|
||||||
|
[source,nix]
|
||||||
|
----
|
||||||
|
{
|
||||||
|
programs.neovim-flake = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
vim.startPlugins = [ pkgs.vimPlugins.nvim-surround ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
----
|
||||||
|
|
||||||
|
Followed by requiring the plugin, should it need one, in the lua DAG. Please note that you're able to name the DAG to however you want, the name will add a `--SECTION <name>` in the init.vim, under which it will be initialized. `lib.nvim.dag.entryAfter ["name"]` could also be used to initialize a plugin only after a previous plugin has beeni initialize
|
||||||
|
Your final setup will likely look like this, where nvim-flake refers to your flake input or fetch.
|
||||||
|
|
||||||
|
[source,nix]
|
||||||
|
----
|
||||||
|
{
|
||||||
|
programs.neovim-flake = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
vim.startPlugins = [ pkgs.vimPlugins.nvim-surround ];
|
||||||
|
luaConfigRC.nvim-surround = nvim-flake.lib.nvim.dag.entryAnywhere '' # nvim-flake is a reference to the flake. Please change this accordingly to your config.
|
||||||
|
require("nvim-surround").setup()
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
----
|
|
@ -4,7 +4,7 @@
|
||||||
[source,console]
|
[source,console]
|
||||||
----
|
----
|
||||||
$ cachix use neovim-flake # Optional: it'll save you CPU resources and time
|
$ cachix use neovim-flake # Optional: it'll save you CPU resources and time
|
||||||
$ nix run github:notashelf/neovim-flake
|
$ nix run github:notashelf/neovim-flake # will run the default configuration
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|
|
@ -9,3 +9,4 @@ This section lists the release notes for tagged version of neovim-flake and curr
|
||||||
include::rl-0.1.adoc[]
|
include::rl-0.1.adoc[]
|
||||||
include::rl-0.2.adoc[]
|
include::rl-0.2.adoc[]
|
||||||
include::rl-0.3.adoc[]
|
include::rl-0.3.adoc[]
|
||||||
|
include::rl-0.4.adoc[]
|
||||||
|
|
|
@ -1,15 +1,73 @@
|
||||||
[[sec-release-0.4]]
|
[[sec-release-0.4]]
|
||||||
== Release 0.4
|
== Release 0.4
|
||||||
|
Following the release of v0.3, I have decided to release v0.4 with a massive new change: customizable keybinds. As of the 0.4 release, keybinds will no longer be hardcoded and instead provided by each module's own keybinds section. The old keybind system (`vim.keybinds = {}`) is now considered deprecated and the new lib functions are recommended to be used for adding keybinds for new plugins, or adding keybinds to existing plugins.
|
||||||
|
|
||||||
Release notes for release 0.4
|
Alongside customizable keybinds, there are a few quality of life updates, such as `lazygit` integration and the new experimental Lua loader of Neovim 0.9 thanks to our awesome contributors who made this update possible during my absence.
|
||||||
|
|
||||||
|
|
||||||
[[sec-release-0.4-changelog]]
|
[[sec-release-0.4-changelog]]
|
||||||
=== Changelog
|
=== Changelog
|
||||||
|
|
||||||
|
|
||||||
ttps://github.com/horriblename[horriblename]:
|
https://github.com/n3oney[n3oney]:
|
||||||
|
|
||||||
|
* Streamlined keybind adding process towards new functions in extended stdlib.
|
||||||
|
|
||||||
|
* Moved default keybinds into keybinds section of each module
|
||||||
|
|
||||||
|
* Simplified luaConfigRC and configRC setting - they can now just take strings
|
||||||
|
|
||||||
|
* Refactored the resolveDag function - you can just provide a string now, which will default to dag.entryAnywhere
|
||||||
|
|
||||||
|
* Fixed formatting sometimes removing parts of files
|
||||||
|
|
||||||
|
* Made formatting synchronous
|
||||||
|
|
||||||
|
* Gave null-ls priority over other formatters
|
||||||
|
|
||||||
|
https://github.com/horriblename[horriblename]:
|
||||||
|
|
||||||
* Added `clangd` as alternative lsp for C/++.
|
* Added `clangd` as alternative lsp for C/++.
|
||||||
|
|
||||||
* Added `toggleterm` integration for `lazygit`.
|
* Added `toggleterm` integration for `lazygit`.
|
||||||
|
|
||||||
|
* Added new option `enableluaLoader` to enable neovim's experimental module loader for faster startup time.
|
||||||
|
|
||||||
|
* Fixed bug where flutter-tools can't find `dart` LSP
|
||||||
|
|
||||||
|
* Added Debug Adapter (DAP) support for clang, rust, go, python and dart.
|
||||||
|
|
||||||
|
https://github.com/notashelf[notashelf]:
|
||||||
|
|
||||||
|
* Made Copilot's Node package configurable. It is recommended to keep as default, but providing a different NodeJS version is now possible.
|
||||||
|
|
||||||
|
* Added <<opt-vim.cursorlineOpt>> for configuring Neovim's cursorlineOpt.
|
||||||
|
|
||||||
|
* Added <<opt-vim.filetree.nvimTreeLua.view.cursorline>>, default false, to enable cursorline in nvimtre.
|
||||||
|
|
||||||
|
* Added Fidget.nvim support for the Catppuccin theme.
|
||||||
|
|
||||||
|
* Updated bundled NodeJS version used by `Copilot.lua`. v16 is now marked as insecure on Nixpkgs, and we updated to v18
|
||||||
|
|
||||||
|
* Enabled Catppuccin modules for plugins available by default.
|
||||||
|
|
||||||
|
* Added experimental Svelte support under `vim.languages`.
|
||||||
|
|
||||||
|
* Removed unnecessary scrollbar element from notifications and codeaction warning UI.
|
||||||
|
|
||||||
|
* `vim.utility.colorizer` has been renamed to `vim.utility.ccc` after the plugin it uses
|
||||||
|
|
||||||
|
* Color preview via `nvim-colorizer.lua`
|
||||||
|
|
||||||
|
* Updated Lualine statusline UI
|
||||||
|
|
||||||
|
* Added vim-illuminate for smart highlighting
|
||||||
|
|
||||||
|
* Added a module for enabling Neovim's spellchecker
|
||||||
|
|
||||||
|
* Added prettierd as an alternative formatter to prettier - currently defaults to prettier
|
||||||
|
|
||||||
|
* Fixed presence.nvim inheriting the wrong client id
|
||||||
|
|
||||||
|
* Cleaned up documentation
|
||||||
|
|
||||||
|
|
490
flake.lock
490
flake.lock
File diff suppressed because it is too large
Load diff
42
flake.nix
42
flake.nix
|
@ -10,11 +10,8 @@
|
||||||
systems = [
|
systems = [
|
||||||
"x86_64-linux"
|
"x86_64-linux"
|
||||||
"aarch64-linux"
|
"aarch64-linux"
|
||||||
|
"x86_64-darwin"
|
||||||
# FIXME: zig compiler - therefore the maximal version - is broken on darwin
|
"aarch64-darwin"
|
||||||
# see https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/compilers/zig/0.10.nix#L70
|
|
||||||
# "x86_64-darwin"
|
|
||||||
# "aarch64-darwin"
|
|
||||||
];
|
];
|
||||||
|
|
||||||
imports = [
|
imports = [
|
||||||
|
@ -29,7 +26,7 @@
|
||||||
flake = {
|
flake = {
|
||||||
lib = {
|
lib = {
|
||||||
inherit (import ./lib/stdlib-extended.nix nixpkgs.lib) nvim;
|
inherit (import ./lib/stdlib-extended.nix nixpkgs.lib) nvim;
|
||||||
inherit (import ./extra.nix inputs) neovimConfiguration;
|
inherit (import ./configuration.nix inputs) neovimConfiguration;
|
||||||
};
|
};
|
||||||
|
|
||||||
homeManagerModules = {
|
homeManagerModules = {
|
||||||
|
@ -49,6 +46,7 @@
|
||||||
...
|
...
|
||||||
}: {
|
}: {
|
||||||
devShells.default = pkgs.mkShell {nativeBuildInputs = [config.packages.nix];};
|
devShells.default = pkgs.mkShell {nativeBuildInputs = [config.packages.nix];};
|
||||||
|
formatter = pkgs.alejandra;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -164,6 +162,17 @@
|
||||||
inputs.flake-utils.follows = "flake-utils";
|
inputs.flake-utils.follows = "flake-utils";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Debuggers
|
||||||
|
nvim-dap = {
|
||||||
|
url = "github:mfussenegger/nvim-dap";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
nvim-dap-ui = {
|
||||||
|
url = "github:rcarriga/nvim-dap-ui";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
|
||||||
# Filetrees
|
# Filetrees
|
||||||
nvim-tree-lua = {
|
nvim-tree-lua = {
|
||||||
url = "github:nvim-tree/nvim-tree.lua";
|
url = "github:nvim-tree/nvim-tree.lua";
|
||||||
|
@ -330,7 +339,7 @@
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
nvim-web-devicons = {
|
nvim-web-devicons = {
|
||||||
url = "github:kyazdani42/nvim-web-devicons";
|
url = "github:nvim-tree/nvim-web-devicons";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
gitsigns-nvim = {
|
gitsigns-nvim = {
|
||||||
|
@ -339,7 +348,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
fidget-nvim = {
|
fidget-nvim = {
|
||||||
url = "github:j-hui/fidget.nvim";
|
url = "github:j-hui/fidget.nvim?ref=legacy";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -373,7 +382,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
# Utilities
|
# Utilities
|
||||||
colorizer = {
|
ccc = {
|
||||||
url = "github:uga-rosa/ccc.nvim";
|
url = "github:uga-rosa/ccc.nvim";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
@ -418,6 +427,11 @@
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
nvim-surround = {
|
||||||
|
url = "github:kylechui/nvim-surround";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
|
||||||
# Note-taking
|
# Note-taking
|
||||||
obsidian-nvim = {
|
obsidian-nvim = {
|
||||||
url = "github:epwalsh/obsidian.nvim";
|
url = "github:epwalsh/obsidian.nvim";
|
||||||
|
@ -451,6 +465,16 @@
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
nvim-colorizer-lua = {
|
||||||
|
url = "github:norcalli/nvim-colorizer.lua";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
vim-illuminate = {
|
||||||
|
url = "github:RRethy/vim-illuminate";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
|
||||||
# Assistant
|
# Assistant
|
||||||
copilot-lua = {
|
copilot-lua = {
|
||||||
url = "github:zbirenbaum/copilot.lua";
|
url = "github:zbirenbaum/copilot.lua";
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (import ../extra.nix inputs) neovimConfiguration mainConfig;
|
inherit (import ../configuration.nix inputs) neovimConfiguration mainConfig;
|
||||||
|
|
||||||
buildPkg = pkgs: modules:
|
buildPkg = pkgs: modules:
|
||||||
(neovimConfiguration {inherit pkgs modules;})
|
(neovimConfiguration {inherit pkgs modules;})
|
||||||
|
|
33
lib/lua.nix
33
lib/lua.nix
|
@ -1,12 +1,43 @@
|
||||||
# Helpers for converting values to lua
|
# Helpers for converting values to lua
|
||||||
{lib}: {
|
{lib}: rec {
|
||||||
|
# yes? no.
|
||||||
yesNo = value:
|
yesNo = value:
|
||||||
if value
|
if value
|
||||||
then "yes"
|
then "yes"
|
||||||
else "no";
|
else "no";
|
||||||
|
|
||||||
|
# Convert a null value to lua's nil
|
||||||
nullString = value:
|
nullString = value:
|
||||||
if value == null
|
if value == null
|
||||||
then "nil"
|
then "nil"
|
||||||
else "'${value}'";
|
else "'${value}'";
|
||||||
|
|
||||||
|
# convert an expression to lua
|
||||||
|
expToLua = exp:
|
||||||
|
if builtins.isList exp
|
||||||
|
then listToLuaTable exp
|
||||||
|
else if builtins.isAttrs exp
|
||||||
|
then attrsetToLuaTable exp
|
||||||
|
else ("\"" + builtins.toJSON exp + "\"");
|
||||||
|
|
||||||
|
# convert list to a lua table
|
||||||
|
listToLuaTable = list:
|
||||||
|
"{ " + (builtins.concatStringsSep ", " (map expToLua list)) + " }";
|
||||||
|
|
||||||
|
# convert attrset to a lua table
|
||||||
|
attrsetToLuaTable = attrset:
|
||||||
|
"{ "
|
||||||
|
+ (
|
||||||
|
builtins.concatStringsSep ", "
|
||||||
|
(
|
||||||
|
lib.mapAttrsToList (
|
||||||
|
name: value:
|
||||||
|
name
|
||||||
|
+ " = "
|
||||||
|
+ (expToLua value)
|
||||||
|
)
|
||||||
|
attrset
|
||||||
|
)
|
||||||
|
)
|
||||||
|
+ " }";
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,13 @@ packages: inputs: {
|
||||||
}:
|
}:
|
||||||
with lib; let
|
with lib; let
|
||||||
cfg = config.programs.neovim-flake;
|
cfg = config.programs.neovim-flake;
|
||||||
inherit (import ../../extra.nix inputs) neovimConfiguration;
|
inherit (import ../../configuration.nix inputs) neovimConfiguration;
|
||||||
set = neovimConfiguration {
|
set = neovimConfiguration {
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
modules = [cfg.settings];
|
modules = [cfg.settings];
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
meta.maintainers = [maintainers.notashelf];
|
meta.maintainers = with maintainers; [NotAShelf];
|
||||||
|
|
||||||
options.programs.neovim-flake = {
|
options.programs.neovim-flake = {
|
||||||
enable = mkEnableOption "A NeoVim IDE with a focus on configurability and extensibility.";
|
enable = mkEnableOption "A NeoVim IDE with a focus on configurability and extensibility.";
|
||||||
|
|
|
@ -4,9 +4,70 @@
|
||||||
nixpkgsLib: let
|
nixpkgsLib: let
|
||||||
mkNvimLib = import ./.;
|
mkNvimLib = import ./.;
|
||||||
in
|
in
|
||||||
nixpkgsLib.extend (self: super: {
|
nixpkgsLib.extend (self: super: rec {
|
||||||
nvim = mkNvimLib {lib = self;};
|
nvim = mkNvimLib {lib = self;};
|
||||||
|
|
||||||
|
mkLuaBinding = key: action: desc:
|
||||||
|
self.mkIf (key != null) {
|
||||||
|
"${key}" = {
|
||||||
|
inherit action desc;
|
||||||
|
lua = true;
|
||||||
|
silent = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mkExprBinding = key: action: desc:
|
||||||
|
self.mkIf (key != null) {
|
||||||
|
"${key}" = {
|
||||||
|
inherit action desc;
|
||||||
|
lua = true;
|
||||||
|
silent = true;
|
||||||
|
expr = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mkBinding = key: action: desc:
|
||||||
|
self.mkIf (key != null) {
|
||||||
|
"${key}" = {
|
||||||
|
inherit action desc;
|
||||||
|
silent = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mkMappingOption = description: default:
|
||||||
|
self.mkOption {
|
||||||
|
type = self.types.nullOr self.types.str;
|
||||||
|
inherit default description;
|
||||||
|
};
|
||||||
|
|
||||||
|
# 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:
|
||||||
|
self.attrsets.mapAttrs (name: value: let
|
||||||
|
isNested = self.isAttrs value;
|
||||||
|
returnedValue =
|
||||||
|
if isNested
|
||||||
|
then addDescriptionsToMappings actualMappings."${name}" mappingDefinitions."${name}"
|
||||||
|
else {
|
||||||
|
value = value;
|
||||||
|
description = mappingDefinitions."${name}".description;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
returnedValue)
|
||||||
|
actualMappings;
|
||||||
|
|
||||||
|
mkSetBinding = binding: action:
|
||||||
|
mkBinding binding.value action binding.description;
|
||||||
|
|
||||||
|
mkSetExprBinding = binding: action:
|
||||||
|
mkExprBinding binding.value action binding.description;
|
||||||
|
|
||||||
|
mkSetLuaBinding = binding: action:
|
||||||
|
mkLuaBinding binding.value action binding.description;
|
||||||
|
|
||||||
# For forward compatibility.
|
# For forward compatibility.
|
||||||
literalExpression = super.literalExpression or super.literalExample;
|
literalExpression = super.literalExpression or super.literalExample;
|
||||||
literalDocBook = super.literalDocBook or super.literalExample;
|
literalDocBook = super.literalDocBook or super.literalExample;
|
||||||
|
|
|
@ -50,7 +50,7 @@ with lib; let
|
||||||
"nvim-notify"
|
"nvim-notify"
|
||||||
"cinnamon-nvim"
|
"cinnamon-nvim"
|
||||||
"cheatsheet-nvim"
|
"cheatsheet-nvim"
|
||||||
"colorizer"
|
"ccc"
|
||||||
"cellular-automaton"
|
"cellular-automaton"
|
||||||
"presence-nvim"
|
"presence-nvim"
|
||||||
"icon-picker-nvim"
|
"icon-picker-nvim"
|
||||||
|
@ -73,6 +73,7 @@ with lib; let
|
||||||
"diffview-nvim"
|
"diffview-nvim"
|
||||||
"todo-comments"
|
"todo-comments"
|
||||||
"flutter-tools"
|
"flutter-tools"
|
||||||
|
"flutter-tools-patched"
|
||||||
"hop-nvim"
|
"hop-nvim"
|
||||||
"leap-nvim"
|
"leap-nvim"
|
||||||
"modes-nvim"
|
"modes-nvim"
|
||||||
|
@ -81,6 +82,11 @@ with lib; let
|
||||||
"project-nvim"
|
"project-nvim"
|
||||||
"elixir-ls"
|
"elixir-ls"
|
||||||
"elixir-tools"
|
"elixir-tools"
|
||||||
|
"nvim-colorizer-lua"
|
||||||
|
"vim-illuminate"
|
||||||
|
"nvim-surround"
|
||||||
|
"nvim-dap"
|
||||||
|
"nvim-dap-ui"
|
||||||
];
|
];
|
||||||
# You can either use the name of the plugin or a package.
|
# You can either use the name of the plugin or a package.
|
||||||
pluginsType = with types;
|
pluginsType = with types;
|
||||||
|
|
|
@ -6,16 +6,22 @@
|
||||||
with lib; let
|
with lib; let
|
||||||
cfg = config.vim;
|
cfg = config.vim;
|
||||||
in {
|
in {
|
||||||
assertions = mkMerge [
|
config = {
|
||||||
{
|
assertions = mkMerge [
|
||||||
assertion = cfg.kommentary.enable;
|
{
|
||||||
message = "Kommentary has been deprecated in favor of comments-nvim";
|
assertion = cfg.kommentary.enable;
|
||||||
}
|
message = "Kommentary has been deprecated in favor of comments-nvim";
|
||||||
mkIf
|
}
|
||||||
(config.programs.neovim-flake.enable)
|
{
|
||||||
{
|
assertion = cfg.utility.colorizer.enable;
|
||||||
assertion = !config.programs.neovim.enable;
|
message = "config.utility.colorizer has been renamed to config.utility.ccc";
|
||||||
message = "You cannot use `programs.neovim-flake.enable` with `programs.neovim.enable`";
|
}
|
||||||
}
|
mkIf
|
||||||
];
|
(config.programs.neovim-flake.enable)
|
||||||
|
{
|
||||||
|
assertion = !config.programs.neovim.enable;
|
||||||
|
message = "You cannot use `programs.neovim-flake.enable` with `programs.neovim.enable`";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,18 +7,73 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.assistant.copilot;
|
cfg = config.vim.assistant.copilot;
|
||||||
|
|
||||||
|
wrapPanelBinding = luaFunction: key: ''
|
||||||
|
function()
|
||||||
|
local s, _ = pcall(${luaFunction})
|
||||||
|
|
||||||
|
if not s then
|
||||||
|
local termcode = vim.api.nvim_replace_termcodes(${builtins.toJSON key}, true, false, true)
|
||||||
|
|
||||||
|
vim.fn.feedkeys(termcode, 'n')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
'';
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = [
|
vim.startPlugins = [
|
||||||
"copilot-lua"
|
"copilot-lua"
|
||||||
pkgs.nodejs-slim-16_x
|
cfg.copilotNodePackage
|
||||||
];
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.copilot = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.copilot = nvim.dag.entryAnywhere ''
|
||||||
require("copilot").setup({
|
require("copilot").setup({
|
||||||
-- available options: https://github.com/zbirenbaum/copilot.lua
|
-- available options: https://github.com/zbirenbaum/copilot.lua
|
||||||
copilot_node_command = "${cfg.copilot_node_command}",
|
copilot_node_command = "${cfg.copilot_node_command}",
|
||||||
|
panel = {
|
||||||
|
keymap = {
|
||||||
|
jump_prev = false,
|
||||||
|
jump_next = false,
|
||||||
|
accept = false,
|
||||||
|
refresh = false,
|
||||||
|
open = false,
|
||||||
|
},
|
||||||
|
layout = {
|
||||||
|
position = "${cfg.panel.position}",
|
||||||
|
ratio = ${toString cfg.panel.ratio},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
suggestion = {
|
||||||
|
keymap = {
|
||||||
|
accept = false,
|
||||||
|
accept_word = false,
|
||||||
|
accept_line = false,
|
||||||
|
next = false,
|
||||||
|
prev = false,
|
||||||
|
dismiss = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
vim.maps.normal = mkMerge [
|
||||||
|
(mkLuaBinding cfg.mappings.panel.jumpPrev (wrapPanelBinding "require(\"copilot.panel\").jump_prev" cfg.mappings.panel.jumpPrev) "[copilot] Accept suggestion")
|
||||||
|
(mkLuaBinding cfg.mappings.panel.jumpNext (wrapPanelBinding "require(\"copilot.panel\").jump_next" cfg.mappings.panel.jumpNext) "[copilot] Accept suggestion")
|
||||||
|
(mkLuaBinding cfg.mappings.panel.accept (wrapPanelBinding ''require("copilot.panel").accept'' cfg.mappings.panel.accept) "[copilot] Accept suggestion")
|
||||||
|
(mkLuaBinding cfg.mappings.panel.refresh (wrapPanelBinding "require(\"copilot.panel\").refresh" cfg.mappings.panel.refresh) "[copilot] Accept suggestion")
|
||||||
|
(mkLuaBinding cfg.mappings.panel.open (wrapPanelBinding ''
|
||||||
|
function() require("copilot.panel").open({ position = "${cfg.panel.position}", ratio = ${toString cfg.panel.ratio}, }) end
|
||||||
|
''
|
||||||
|
cfg.mappings.panel.open) "[copilot] Accept suggestion")
|
||||||
|
];
|
||||||
|
|
||||||
|
vim.maps.insert = mkMerge [
|
||||||
|
(mkLuaBinding cfg.mappings.suggestion.accept "require(\"copilot.suggestion\").accept" "[copilot] Accept suggestion")
|
||||||
|
(mkLuaBinding cfg.mappings.suggestion.acceptLine "require(\"copilot.suggestion\").accept_line" "[copilot] Accept suggestion (line)")
|
||||||
|
(mkLuaBinding cfg.mappings.suggestion.acceptWord "require(\"copilot.suggestion\").accept_word" "[copilot] Accept suggestion (word)")
|
||||||
|
(mkLuaBinding cfg.mappings.suggestion.next "require(\"copilot.suggestion\").next" "[copilot] next suggestion")
|
||||||
|
(mkLuaBinding cfg.mappings.suggestion.prev "require(\"copilot.suggestion\").prev" "[copilot] previous suggestion")
|
||||||
|
(mkLuaBinding cfg.mappings.suggestion.dismiss "require(\"copilot.suggestion\").dismiss" "[copilot] dismiss suggestion")
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,14 +5,102 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; {
|
with builtins; let
|
||||||
|
cfg = config.vim.assistant.copilot;
|
||||||
|
in {
|
||||||
options.vim.assistant.copilot = {
|
options.vim.assistant.copilot = {
|
||||||
enable = mkEnableOption "Enable GitHub Copilot";
|
enable = mkEnableOption "GitHub Copilot AI assistant";
|
||||||
|
|
||||||
|
panel = {
|
||||||
|
position = mkOption {
|
||||||
|
type = types.enum [
|
||||||
|
"bottom"
|
||||||
|
"top"
|
||||||
|
"left"
|
||||||
|
"right"
|
||||||
|
];
|
||||||
|
default = "bottom";
|
||||||
|
description = "Panel position";
|
||||||
|
};
|
||||||
|
ratio = mkOption {
|
||||||
|
type = types.float;
|
||||||
|
default = 0.4;
|
||||||
|
description = "Panel size";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
panel = {
|
||||||
|
jumpPrev = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "[[";
|
||||||
|
description = "Jump to previous suggestion";
|
||||||
|
};
|
||||||
|
jumpNext = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "]]";
|
||||||
|
description = "Jump to next suggestion";
|
||||||
|
};
|
||||||
|
accept = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<CR>";
|
||||||
|
description = "Accept suggestion";
|
||||||
|
};
|
||||||
|
refresh = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "gr";
|
||||||
|
description = "Refresh suggestions";
|
||||||
|
};
|
||||||
|
open = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<M-CR>";
|
||||||
|
description = "Open suggestions";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
suggestion = {
|
||||||
|
accept = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<M-l>";
|
||||||
|
description = "Accept suggetion";
|
||||||
|
};
|
||||||
|
acceptWord = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
description = "Accept next word";
|
||||||
|
};
|
||||||
|
acceptLine = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
description = "Accept next line";
|
||||||
|
};
|
||||||
|
prev = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<M-[>";
|
||||||
|
description = "Previous suggestion";
|
||||||
|
};
|
||||||
|
next = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<M-]>";
|
||||||
|
description = "Next suggestion";
|
||||||
|
};
|
||||||
|
dismiss = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<C-]>";
|
||||||
|
description = "Dismiss suggestion";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
copilot_node_command = mkOption {
|
copilot_node_command = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "${lib.getExe pkgs.nodejs-slim-16_x}";
|
default = "${lib.getExe cfg.copilotNodePackage}";
|
||||||
description = "Path to nodejs";
|
description = "Path to nodejs";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
copilotNodePackage = mkOption {
|
||||||
|
type = with types; nullOr package; # TODO - maybe accept a path as well? imperative users might want to use something like nvm
|
||||||
|
default = pkgs.nodejs-slim; # this will likely need to be downgraded because Copilot does not stay up to date with NodeJS
|
||||||
|
description = "The package that will be used for Copilot. NodeJS v18 is recommended.";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,43 @@ in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = ["tabnine-nvim"];
|
vim.startPlugins = ["tabnine-nvim"];
|
||||||
|
|
||||||
|
vim.maps.insert = mkMerge [
|
||||||
|
(mkExprBinding cfg.mappings.accept ''
|
||||||
|
function()
|
||||||
|
local state = require("tabnine.state")
|
||||||
|
local completion = require("tabnine.completion")
|
||||||
|
|
||||||
|
if not state.completions_cache then
|
||||||
|
return "${builtins.toJSON cfg.mappings.accept}"
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.schedule(completion.accept)
|
||||||
|
end
|
||||||
|
'' "orzel")
|
||||||
|
(mkExprBinding cfg.mappings.dismiss ''
|
||||||
|
function()
|
||||||
|
local state = require("tabnine.state")
|
||||||
|
local completion = require("tabnine.completion")
|
||||||
|
|
||||||
|
if not state.completions_cache then
|
||||||
|
return "${builtins.toJSON cfg.mappings.dismiss}"
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.schedule(function()
|
||||||
|
completion.clear()
|
||||||
|
state.completions_cache = nil
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
'' "orzel")
|
||||||
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.tabnine-nvim = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.tabnine-nvim = nvim.dag.entryAnywhere ''
|
||||||
require('tabnine').setup({
|
require('tabnine').setup({
|
||||||
disable_auto_comment = ${boolToString cfg.disable_auto_comment},
|
disable_auto_comment = ${boolToString cfg.disable_auto_comment},
|
||||||
accept_keymap = ${cfg.accept_keymap},
|
accept_keymap = null,
|
||||||
dismiss_keymap = ${cfg.dismiss_keymap},
|
dismiss_keymap = null,
|
||||||
debounce_ms = ${cfg.debounce_ms},
|
debounce_ms = ${cfg.debounce_ms},
|
||||||
execlude_filetypes = ${cfg.execlude_filetypes},
|
exclude_filetypes = ${cfg.exclude_filetypes},
|
||||||
})
|
})
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
{
|
{lib, ...}:
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim.assistant.tabnine = {
|
options.vim.assistant.tabnine = {
|
||||||
enable = mkEnableOption "Enable TabNine assistant";
|
enable = mkEnableOption "Tabnine assistant";
|
||||||
|
|
||||||
disable_auto_comment = mkOption {
|
disable_auto_comment = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
|
@ -14,16 +10,9 @@ with builtins; {
|
||||||
description = "Disable auto comment";
|
description = "Disable auto comment";
|
||||||
};
|
};
|
||||||
|
|
||||||
accept_keymap = mkOption {
|
mappings = {
|
||||||
type = types.str;
|
accept = mkMappingOption "Accept [Tabnine]" "<Tab>";
|
||||||
default = "<Tab>";
|
dismiss = mkMappingOption "Dismiss [Tabnine]" "<C-]>";
|
||||||
description = "Accept keymap";
|
|
||||||
};
|
|
||||||
|
|
||||||
dismiss_keymap = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "<C-]>";
|
|
||||||
description = "Dismiss keymap";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
debounce_ms = mkOption {
|
debounce_ms = mkOption {
|
||||||
|
@ -32,10 +21,10 @@ with builtins; {
|
||||||
description = "Debounce ms";
|
description = "Debounce ms";
|
||||||
};
|
};
|
||||||
|
|
||||||
execlude_filetypes = mkOption {
|
exclude_filetypes = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = ["TelescopePrompt" "NvimTree" "alpha"];
|
default = ["TelescopePrompt" "NvimTree" "alpha"];
|
||||||
description = "Execlude filetypes";
|
description = "Exclude filetypes";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,9 @@
|
||||||
{
|
{lib, ...}:
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim = {
|
options.vim = {
|
||||||
autopairs = {
|
autopairs = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "autopairs" // {default = false;};
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Enable autopairs";
|
|
||||||
};
|
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
type = types.enum ["nvim-autopairs"];
|
type = types.enum ["nvim-autopairs"];
|
||||||
|
|
|
@ -10,21 +10,51 @@ in {
|
||||||
config = {
|
config = {
|
||||||
vim.startPlugins = ["plenary-nvim"];
|
vim.startPlugins = ["plenary-nvim"];
|
||||||
|
|
||||||
vim.nmap = mkIf cfg.disableArrows {
|
vim.maps.normal =
|
||||||
"<up>" = "<nop>";
|
mkIf cfg.disableArrows {
|
||||||
"<down>" = "<nop>";
|
"<up>" = {
|
||||||
"<left>" = "<nop>";
|
action = "<nop>";
|
||||||
"<right>" = "<nop>";
|
|
||||||
};
|
|
||||||
|
|
||||||
vim.imap = mkIf cfg.disableArrows {
|
noremap = false;
|
||||||
"<up>" = "<nop>";
|
};
|
||||||
"<down>" = "<nop>";
|
"<down>" = {
|
||||||
"<left>" = "<nop>";
|
action = "<nop>";
|
||||||
"<right>" = "<nop>";
|
|
||||||
};
|
|
||||||
|
|
||||||
vim.nnoremap = mkIf cfg.mapLeaderSpace {"<space>" = "<nop>";};
|
noremap = false;
|
||||||
|
};
|
||||||
|
"<left>" = {
|
||||||
|
action = "<nop>";
|
||||||
|
noremap = false;
|
||||||
|
};
|
||||||
|
"<right>" = {
|
||||||
|
action = "<nop>";
|
||||||
|
noremap = false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// mkIf cfg.mapLeaderSpace {
|
||||||
|
"<space>" = {
|
||||||
|
action = "<nop>";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
vim.maps.insert = mkIf cfg.disableArrows {
|
||||||
|
"<up>" = {
|
||||||
|
action = "<nop>";
|
||||||
|
noremap = false;
|
||||||
|
};
|
||||||
|
"<down>" = {
|
||||||
|
action = "<nop>";
|
||||||
|
noremap = false;
|
||||||
|
};
|
||||||
|
"<left>" = {
|
||||||
|
action = "<nop>";
|
||||||
|
noremap = false;
|
||||||
|
};
|
||||||
|
"<right>" = {
|
||||||
|
action = "<nop>";
|
||||||
|
noremap = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
vim.configRC.basic = nvim.dag.entryAfter ["globalsScript"] ''
|
vim.configRC.basic = nvim.dag.entryAfter ["globalsScript"] ''
|
||||||
" Debug mode settings
|
" Debug mode settings
|
||||||
|
@ -45,6 +75,8 @@ in {
|
||||||
set shortmess+=c
|
set shortmess+=c
|
||||||
set tm=${toString cfg.mapTimeout}
|
set tm=${toString cfg.mapTimeout}
|
||||||
set hidden
|
set hidden
|
||||||
|
set cursorlineopt=${toString cfg.cursorlineOpt}
|
||||||
|
|
||||||
${optionalString cfg.splitBelow ''
|
${optionalString cfg.splitBelow ''
|
||||||
set splitbelow
|
set splitbelow
|
||||||
''}
|
''}
|
||||||
|
@ -106,6 +138,10 @@ in {
|
||||||
${optionalString (!cfg.enableEditorconfig) ''
|
${optionalString (!cfg.enableEditorconfig) ''
|
||||||
let g:editorconfig = v:false
|
let g:editorconfig = v:false
|
||||||
''}
|
''}
|
||||||
|
${optionalString (cfg.spellChecking.enable) ''
|
||||||
|
set spell
|
||||||
|
set spelllang=${toString cfg.spellChecking.language}
|
||||||
|
''}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,13 @@ with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim = {
|
options.vim = {
|
||||||
debugMode = {
|
debugMode = {
|
||||||
enable = mkEnableOption "Enable debug mode";
|
enable = mkEnableOption "debug mode";
|
||||||
level = mkOption {
|
level = mkOption {
|
||||||
type = types.int;
|
type = types.int;
|
||||||
default = 20;
|
default = 20;
|
||||||
description = "Set the debug level";
|
description = "Set the debug level";
|
||||||
};
|
};
|
||||||
|
|
||||||
logFile = mkOption {
|
logFile = mkOption {
|
||||||
type = types.path;
|
type = types.path;
|
||||||
default = "/tmp/nvim.log";
|
default = "/tmp/nvim.log";
|
||||||
|
@ -20,6 +21,16 @@ with builtins; {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
spellChecking = {
|
||||||
|
enable = mkEnableOption "neovim's built-in spellchecking";
|
||||||
|
language = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "The language to be used for spellchecking";
|
||||||
|
default = "en_US";
|
||||||
|
example = "de";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
colourTerm = mkOption {
|
colourTerm = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
|
@ -144,5 +155,13 @@ with builtins; {
|
||||||
default = true;
|
default = true;
|
||||||
description = "Follow editorconfig rules in current directory";
|
description = "Follow editorconfig rules in current directory";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
cursorlineOpt = mkOption {
|
||||||
|
type = types.enum ["line" "screenline" "number" "both"];
|
||||||
|
default = "line";
|
||||||
|
description = "Highlight the text line of the cursor with CursorLine hl-CursorLine";
|
||||||
|
};
|
||||||
|
|
||||||
|
enableLuaLoader = mkEnableOption "experimental Lua module loader to speed up the start up process";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,18 @@
|
||||||
{
|
{lib, ...}:
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim.comments.comment-nvim = {
|
options.vim.comments.comment-nvim = {
|
||||||
enable = mkEnableOption "Enable comment-nvim";
|
enable = mkEnableOption "smart and powerful comment plugin for neovim comment-nvim";
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
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";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,14 +6,45 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.comments.comment-nvim;
|
cfg = config.vim.comments.comment-nvim;
|
||||||
|
self = import ./comment-nvim.nix {
|
||||||
|
inherit lib;
|
||||||
|
};
|
||||||
|
mappings = self.options.vim.comments.comment-nvim.mappings;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = [
|
vim.startPlugins = [
|
||||||
"comment-nvim"
|
"comment-nvim"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
vim.maps.normal = mkMerge [
|
||||||
|
(mkBinding cfg.mappings.toggleOpLeaderLine "<Plug>(comment_toggle_linewise)" mappings.toggleOpLeaderLine.description)
|
||||||
|
(mkBinding cfg.mappings.toggleOpLeaderBlock "<Plug>(comment_toggle_blockwise)" mappings.toggleOpLeaderBlock.description)
|
||||||
|
|
||||||
|
(mkExprBinding cfg.mappings.toggleCurrentLine ''
|
||||||
|
function()
|
||||||
|
return vim.api.nvim_get_vvar('count') == 0 and '<Plug>(comment_toggle_linewise_current)'
|
||||||
|
or '<Plug>(comment_toggle_linewise_count)'
|
||||||
|
end
|
||||||
|
''
|
||||||
|
mappings.toggleCurrentLine.description)
|
||||||
|
(mkExprBinding cfg.mappings.toggleCurrentBlock ''
|
||||||
|
function()
|
||||||
|
return vim.api.nvim_get_vvar('count') == 0 and '<Plug>(comment_toggle_blockwise_current)'
|
||||||
|
or '<Plug>(comment_toggle_blockwise_count)'
|
||||||
|
end
|
||||||
|
''
|
||||||
|
mappings.toggleCurrentBlock.description)
|
||||||
|
];
|
||||||
|
|
||||||
|
vim.maps.visualOnly = mkMerge [
|
||||||
|
(mkBinding cfg.mappings.toggleSelectedLine "<Plug>(comment_toggle_linewise_visual)" mappings.toggleSelectedLine.description)
|
||||||
|
(mkBinding cfg.mappings.toggleSelectedBlock "<Plug>(comment_toggle_blockwise_visual)" mappings.toggleSelectedBlock.description)
|
||||||
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.comment-nvim = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.comment-nvim = nvim.dag.entryAnywhere ''
|
||||||
require('Comment').setup()
|
require('Comment').setup({
|
||||||
|
mappings = { basic = false, extra = false, },
|
||||||
|
})
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{
|
{
|
||||||
pkgs,
|
|
||||||
lib,
|
lib,
|
||||||
config,
|
config,
|
||||||
...
|
...
|
||||||
|
@ -8,6 +7,12 @@ with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.autocomplete;
|
cfg = config.vim.autocomplete;
|
||||||
lspkindEnabled = config.vim.lsp.enable && config.vim.lsp.lspkind.enable;
|
lspkindEnabled = config.vim.lsp.enable && config.vim.lsp.lspkind.enable;
|
||||||
|
|
||||||
|
self = import ./nvim-cmp.nix {inherit lib;};
|
||||||
|
mappingDefinitions = self.options.vim.autocomplete.mappings;
|
||||||
|
|
||||||
|
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||||
|
|
||||||
builtSources =
|
builtSources =
|
||||||
concatMapStringsSep
|
concatMapStringsSep
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -46,6 +51,139 @@ in {
|
||||||
"path" = "[Path]";
|
"path" = "[Path]";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
vim.maps.insert = mkMerge [
|
||||||
|
(mkSetLuaBinding mappings.complete ''
|
||||||
|
require('cmp').complete
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.confirm ''
|
||||||
|
function()
|
||||||
|
if not require('cmp').confirm({ select = true }) then
|
||||||
|
local termcode = vim.api.nvim_replace_termcodes(${builtins.toJSON mappings.confirm.value}, true, false, true)
|
||||||
|
|
||||||
|
vim.fn.feedkeys(termcode, 'n')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.next ''
|
||||||
|
function()
|
||||||
|
local has_words_before = function()
|
||||||
|
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||||
|
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local cmp = require('cmp')
|
||||||
|
|
||||||
|
local feedkey = function(key, mode)
|
||||||
|
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
elseif vim.fn['vsnip#available'](1) == 1 then
|
||||||
|
feedkey("<Plug>(vsnip-expand-or-jump)", "")
|
||||||
|
elseif has_words_before() then
|
||||||
|
cmp.complete()
|
||||||
|
else
|
||||||
|
local termcode = vim.api.nvim_replace_termcodes(${builtins.toJSON mappings.next.value}, true, false, true)
|
||||||
|
|
||||||
|
vim.fn.feedkeys(termcode, 'n')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.previous ''
|
||||||
|
function()
|
||||||
|
local cmp = require('cmp')
|
||||||
|
|
||||||
|
local feedkey = function(key, mode)
|
||||||
|
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
elseif vim.fn['vsnip#available'](-1) == 1 then
|
||||||
|
feedkeys("<Plug>(vsnip-jump-prev)", "")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.close ''
|
||||||
|
require('cmp').mapping.abort
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.scrollDocsUp ''
|
||||||
|
function()
|
||||||
|
require('cmp').mapping.scroll_docs(-4)
|
||||||
|
end
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.scrollDocsDown ''
|
||||||
|
function()
|
||||||
|
require('cmp').mapping.scroll_docs(4)
|
||||||
|
end
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
|
||||||
|
vim.maps.command = mkMerge [
|
||||||
|
(mkSetLuaBinding mappings.complete ''
|
||||||
|
require('cmp').complete
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.close ''
|
||||||
|
require('cmp').mapping.close
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.scrollDocsUp ''
|
||||||
|
function()
|
||||||
|
require('cmp').mapping.scroll_docs(-4)
|
||||||
|
end
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.scrollDocsDown ''
|
||||||
|
function()
|
||||||
|
require('cmp').mapping.scroll_docs(4)
|
||||||
|
end
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
|
||||||
|
vim.maps.select = mkMerge [
|
||||||
|
(mkSetLuaBinding mappings.next ''
|
||||||
|
function()
|
||||||
|
local cmp = require('cmp')
|
||||||
|
local has_words_before = function()
|
||||||
|
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||||
|
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local feedkey = function(key, mode)
|
||||||
|
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
elseif vim.fn['vsnip#available'](1) == 1 then
|
||||||
|
feedkey("<Plug>(vsnip-expand-or-jump)", "")
|
||||||
|
elseif has_words_before() then
|
||||||
|
cmp.complete()
|
||||||
|
else
|
||||||
|
local termcode = vim.api.nvim_replace_termcodes(${builtins.toJSON mappings.next.value}, true, false, true)
|
||||||
|
|
||||||
|
vim.fn.feedkeys(termcode, 'n')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.previous ''
|
||||||
|
function()
|
||||||
|
local cmp = require('cmp')
|
||||||
|
|
||||||
|
local feedkey = function(key, mode)
|
||||||
|
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
elseif vim.fn['vsnip#available'](-1) == 1 then
|
||||||
|
feedkeys("<Plug>(vsnip-jump-prev)", "")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
|
||||||
|
# TODO: alternative snippet engines to vsnip
|
||||||
|
# https://github.com/hrsh7th/nvim-cmp/blob/main/doc/cmp.txt#L82
|
||||||
vim.luaConfigRC.completion = mkIf (cfg.type == "nvim-cmp") (dagPlacement ''
|
vim.luaConfigRC.completion = mkIf (cfg.type == "nvim-cmp") (dagPlacement ''
|
||||||
local nvim_cmp_menu_map = function(entry, vim_item)
|
local nvim_cmp_menu_map = function(entry, vim_item)
|
||||||
-- name for each source
|
-- name for each source
|
||||||
|
@ -60,59 +198,29 @@ in {
|
||||||
lspkind_opts.before = ${cfg.formatting.format}
|
lspkind_opts.before = ${cfg.formatting.format}
|
||||||
''}
|
''}
|
||||||
|
|
||||||
local has_words_before = function()
|
|
||||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
|
||||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local feedkey = function(key, mode)
|
|
||||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
local cmp = require'cmp'
|
local cmp = require'cmp'
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
|
window = {
|
||||||
|
-- TODO: at some point, those need to be optional
|
||||||
|
-- but first nvim cmp module needs to be detached from "cfg.autocomplete"
|
||||||
|
completion = cmp.config.window.bordered(),
|
||||||
|
documentation = cmp.config.window.bordered(),
|
||||||
|
},
|
||||||
|
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
vim.fn["vsnip#anonymous"](args.body)
|
vim.fn["vsnip#anonymous"](args.body)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
sources = {
|
sources = {
|
||||||
${builtSources}
|
${builtSources}
|
||||||
},
|
},
|
||||||
mapping = {
|
|
||||||
['<C-d>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
|
|
||||||
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c'}),
|
|
||||||
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c'}),
|
|
||||||
['<C-y>'] = cmp.config.disable,
|
|
||||||
['<C-e>'] = cmp.mapping({
|
|
||||||
i = cmp.mapping.abort(),
|
|
||||||
c = cmp.mapping.close(),
|
|
||||||
}),
|
|
||||||
['<CR>'] = cmp.mapping.confirm({
|
|
||||||
select = true,
|
|
||||||
}),
|
|
||||||
['<Tab>'] = cmp.mapping(function (fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_next_item()
|
|
||||||
elseif vim.fn['vsnip#available'](1) == 1 then
|
|
||||||
feedkey("<Plug>(vsnip-expand-or-jump)", "")
|
|
||||||
elseif has_words_before() then
|
|
||||||
cmp.complete()
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { 'i', 's' }),
|
|
||||||
['<S-Tab>'] = cmp.mapping(function (fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_prev_item()
|
|
||||||
elseif vim.fn['vsnip#available'](-1) == 1 then
|
|
||||||
feedkeys("<Plug>(vsnip-jump-prev)", "")
|
|
||||||
end
|
|
||||||
end, { 'i', 's' })
|
|
||||||
},
|
|
||||||
completion = {
|
completion = {
|
||||||
completeopt = 'menu,menuone,noinsert',
|
completeopt = 'menu,menuone,noinsert',
|
||||||
},
|
},
|
||||||
|
|
||||||
formatting = {
|
formatting = {
|
||||||
format =
|
format =
|
||||||
${
|
${
|
||||||
|
|
|
@ -1,40 +1,18 @@
|
||||||
{
|
{lib, ...}:
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; {
|
||||||
cfg = config.vim.autocomplete;
|
|
||||||
lspkindEnabled = config.vim.lsp.enable && config.vim.lsp.lspkind.enable;
|
|
||||||
builtSources =
|
|
||||||
concatMapStringsSep
|
|
||||||
"\n"
|
|
||||||
(n: "{ name = '${n}'},")
|
|
||||||
(attrNames cfg.sources);
|
|
||||||
|
|
||||||
builtMaps =
|
|
||||||
concatStringsSep
|
|
||||||
"\n"
|
|
||||||
(mapAttrsToList
|
|
||||||
(n: v:
|
|
||||||
if v == null
|
|
||||||
then ""
|
|
||||||
else "${n} = '${v}',")
|
|
||||||
cfg.sources);
|
|
||||||
|
|
||||||
dagPlacement =
|
|
||||||
if lspkindEnabled
|
|
||||||
then nvim.dag.entryAfter ["lspkind"]
|
|
||||||
else nvim.dag.entryAnywhere;
|
|
||||||
in {
|
|
||||||
options.vim = {
|
options.vim = {
|
||||||
autocomplete = {
|
autocomplete = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "enable autocomplete" // {default = false;};
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
mappings = {
|
||||||
description = "enable autocomplete";
|
complete = mkMappingOption "Complete [nvim-cmp]" "<C-Space>";
|
||||||
|
confirm = mkMappingOption "Confirm [nvim-cmp]" "<CR>";
|
||||||
|
next = mkMappingOption "Next item [nvim-cmp]" "<Tab>";
|
||||||
|
previous = mkMappingOption "Previous item [nvim-cmp]" "<S-Tab>";
|
||||||
|
close = mkMappingOption "Close [nvim-cmp]" "<C-e>";
|
||||||
|
scrollDocsUp = mkMappingOption "Scroll docs up [nvim-cmp]" "<C-d>";
|
||||||
|
scrollDocsDown = mkMappingOption "Scroll docs down [nvim-cmp]" "<C-f>";
|
||||||
};
|
};
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
|
|
|
@ -9,16 +9,113 @@ with builtins; let
|
||||||
|
|
||||||
wrapLuaConfig = luaConfig: ''
|
wrapLuaConfig = luaConfig: ''
|
||||||
lua << EOF
|
lua << EOF
|
||||||
|
${optionalString cfg.enableLuaLoader ''
|
||||||
|
vim.loader.enable()
|
||||||
|
''}
|
||||||
${luaConfig}
|
${luaConfig}
|
||||||
EOF
|
EOF
|
||||||
'';
|
'';
|
||||||
|
|
||||||
mkMappingOption = it:
|
mkBool = value: description:
|
||||||
mkOption ({
|
mkOption {
|
||||||
default = {};
|
type = types.bool;
|
||||||
type = with types; attrsOf (nullOr str);
|
default = value;
|
||||||
}
|
description = description;
|
||||||
// it);
|
};
|
||||||
|
|
||||||
|
# Most of the keybindings code is highly inspired by pta2002/nixvim. Thank you!
|
||||||
|
mapConfigOptions = {
|
||||||
|
silent =
|
||||||
|
mkBool false
|
||||||
|
(nvim.nmd.asciiDoc "Whether this mapping should be silent. Equivalent to adding <silent> to a map.");
|
||||||
|
|
||||||
|
nowait =
|
||||||
|
mkBool false
|
||||||
|
(nvim.nmd.asciiDoc "Whether to wait for extra input on ambiguous mappings. Equivalent to adding <nowait> to a map.");
|
||||||
|
|
||||||
|
script =
|
||||||
|
mkBool false
|
||||||
|
(nvim.nmd.asciiDoc "Equivalent to adding <script> to a map.");
|
||||||
|
|
||||||
|
expr =
|
||||||
|
mkBool false
|
||||||
|
(nvim.nmd.asciiDoc "Means that the action is actually an expression. Equivalent to adding <expr> to a map.");
|
||||||
|
|
||||||
|
unique =
|
||||||
|
mkBool false
|
||||||
|
(nvim.nmd.asciiDoc "Whether to fail if the map is already defined. Equivalent to adding <unique> to a map.");
|
||||||
|
|
||||||
|
noremap =
|
||||||
|
mkBool true
|
||||||
|
"Whether to use the 'noremap' variant of the command, ignoring any custom mappings on the defined action. It is highly advised to keep this on, which is the default.";
|
||||||
|
|
||||||
|
desc = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
description = "A description of this keybind, to be shown in which-key, if you have it enabled.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
genMaps = mode: maps: let
|
||||||
|
/*
|
||||||
|
Take a user-defined action (string or attrs) and return the following attribute set:
|
||||||
|
{
|
||||||
|
action = (string) the actual action to map to this key
|
||||||
|
config = (attrs) the configuration options for this mapping (noremap, silent...)
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
normalizeAction = action: let
|
||||||
|
# Extract the values of the config options that have been explicitly set by the user
|
||||||
|
config =
|
||||||
|
filterAttrs (n: v: v != null)
|
||||||
|
(getAttrs (attrNames mapConfigOptions) action);
|
||||||
|
in {
|
||||||
|
config =
|
||||||
|
if config == {}
|
||||||
|
then {"__empty" = null;}
|
||||||
|
else config;
|
||||||
|
action =
|
||||||
|
if action.lua
|
||||||
|
then {"__raw" = action.action;}
|
||||||
|
else action.action;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
builtins.attrValues (builtins.mapAttrs
|
||||||
|
(key: action: let
|
||||||
|
normalizedAction = normalizeAction action;
|
||||||
|
in {
|
||||||
|
inherit (normalizedAction) action config;
|
||||||
|
key = key;
|
||||||
|
mode = mode;
|
||||||
|
})
|
||||||
|
maps);
|
||||||
|
|
||||||
|
mapOption = types.submodule {
|
||||||
|
options =
|
||||||
|
mapConfigOptions
|
||||||
|
// {
|
||||||
|
action = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "The action to execute.";
|
||||||
|
};
|
||||||
|
|
||||||
|
lua = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
description = ''
|
||||||
|
If true, `action` is considered to be lua code.
|
||||||
|
Thus, it will not be wrapped in `""`.
|
||||||
|
'';
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mapOptions = mode:
|
||||||
|
mkOption {
|
||||||
|
description = "Mappings for ${mode} mode";
|
||||||
|
type = types.attrsOf mapOption;
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
in {
|
in {
|
||||||
options.vim = {
|
options.vim = {
|
||||||
viAlias = mkOption {
|
viAlias = mkOption {
|
||||||
|
@ -35,13 +132,13 @@ in {
|
||||||
|
|
||||||
configRC = mkOption {
|
configRC = mkOption {
|
||||||
description = "vimrc contents";
|
description = "vimrc contents";
|
||||||
type = nvim.types.dagOf types.lines;
|
type = types.oneOf [(nvim.types.dagOf types.lines) types.str];
|
||||||
default = {};
|
default = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
luaConfigRC = mkOption {
|
luaConfigRC = mkOption {
|
||||||
description = "vim lua config";
|
description = "vim lua config";
|
||||||
type = nvim.types.dagOf types.lines;
|
type = types.oneOf [(nvim.types.dagOf types.lines) types.str];
|
||||||
default = {};
|
default = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -67,64 +164,38 @@ in {
|
||||||
type = types.attrs;
|
type = types.attrs;
|
||||||
};
|
};
|
||||||
|
|
||||||
nnoremap =
|
maps = mkOption {
|
||||||
mkMappingOption {description = "Defines 'Normal mode' mappings";};
|
type = types.submodule {
|
||||||
|
options = {
|
||||||
|
normal = mapOptions "normal";
|
||||||
|
insert = mapOptions "insert";
|
||||||
|
select = mapOptions "select";
|
||||||
|
visual = mapOptions "visual and select";
|
||||||
|
terminal = mapOptions "terminal";
|
||||||
|
normalVisualOp = mapOptions "normal, visual, select and operator-pending (same as plain 'map')";
|
||||||
|
|
||||||
inoremap = mkMappingOption {
|
visualOnly = mapOptions "visual only";
|
||||||
description = "Defines 'Insert and Replace mode' mappings";
|
operator = mapOptions "operator-pending";
|
||||||
};
|
insertCommand = mapOptions "insert and command-line";
|
||||||
|
lang = mapOptions "insert, command-line and lang-arg";
|
||||||
|
command = mapOptions "command-line";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
default = {};
|
||||||
|
description = ''
|
||||||
|
Custom keybindings for any mode.
|
||||||
|
|
||||||
vnoremap = mkMappingOption {
|
For plain maps (e.g. just 'map' or 'remap') use maps.normalVisualOp.
|
||||||
description = "Defines 'Visual and Select mode' mappings";
|
'';
|
||||||
};
|
|
||||||
|
|
||||||
xnoremap =
|
example = ''
|
||||||
mkMappingOption {description = "Defines 'Visual mode' mappings";};
|
maps = {
|
||||||
|
normal."<leader>m" = {
|
||||||
snoremap =
|
silent = true;
|
||||||
mkMappingOption {description = "Defines 'Select mode' mappings";};
|
action = "<cmd>make<CR>";
|
||||||
|
}; # Same as nnoremap <leader>m <silent> <cmd>make<CR>
|
||||||
cnoremap =
|
};
|
||||||
mkMappingOption {description = "Defines 'Command-line mode' mappings";};
|
'';
|
||||||
|
|
||||||
onoremap = mkMappingOption {
|
|
||||||
description = "Defines 'Operator pending mode' mappings";
|
|
||||||
};
|
|
||||||
|
|
||||||
tnoremap = mkMappingOption {
|
|
||||||
description = "Defines 'Terminal mode' mappings";
|
|
||||||
};
|
|
||||||
|
|
||||||
nmap = mkMappingOption {
|
|
||||||
description = "Defines 'Normal mode' mappings";
|
|
||||||
};
|
|
||||||
|
|
||||||
imap = mkMappingOption {
|
|
||||||
description = "Defines 'Insert and Replace mode' mappings";
|
|
||||||
};
|
|
||||||
|
|
||||||
vmap = mkMappingOption {
|
|
||||||
description = "Defines 'Visual and Select mode' mappings";
|
|
||||||
};
|
|
||||||
|
|
||||||
xmap = mkMappingOption {
|
|
||||||
description = "Defines 'Visual mode' mappings";
|
|
||||||
};
|
|
||||||
|
|
||||||
smap = mkMappingOption {
|
|
||||||
description = "Defines 'Select mode' mappings";
|
|
||||||
};
|
|
||||||
|
|
||||||
cmap = mkMappingOption {
|
|
||||||
description = "Defines 'Command-line mode' mappings";
|
|
||||||
};
|
|
||||||
|
|
||||||
omap = mkMappingOption {
|
|
||||||
description = "Defines 'Operator pending mode' mappings";
|
|
||||||
};
|
|
||||||
|
|
||||||
tmap = mkMappingOption {
|
|
||||||
description = "Defines 'Terminal mode' mappings";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -148,41 +219,76 @@ in {
|
||||||
mapAttrsFlatten (name: value: "let g:${name}=${valToVim value}")
|
mapAttrsFlatten (name: value: "let g:${name}=${valToVim value}")
|
||||||
(filterNonNull cfg.globals);
|
(filterNonNull cfg.globals);
|
||||||
|
|
||||||
matchCtrl = it: match "Ctrl-(.)(.*)" it;
|
toLuaObject = args:
|
||||||
mapKeyBinding = it: let
|
if builtins.isAttrs args
|
||||||
groups = matchCtrl it;
|
then
|
||||||
in
|
if hasAttr "__raw" args
|
||||||
if groups == null
|
then args.__raw
|
||||||
then it
|
else if hasAttr "__empty" args
|
||||||
else "<C-${toUpper (head groups)}>${head (tail groups)}";
|
then "{ }"
|
||||||
mapVimBinding = prefix: mappings:
|
else
|
||||||
mapAttrsFlatten (name: value: "${prefix} ${mapKeyBinding name} ${value}")
|
"{"
|
||||||
(filterNonNull mappings);
|
+ (concatStringsSep ","
|
||||||
|
(mapAttrsToList
|
||||||
|
(n: v:
|
||||||
|
if head (stringToCharacters n) == "@"
|
||||||
|
then toLuaObject v
|
||||||
|
else "[${toLuaObject n}] = " + (toLuaObject v))
|
||||||
|
(filterAttrs
|
||||||
|
(
|
||||||
|
n: v:
|
||||||
|
!isNull v && (toLuaObject v != "{}")
|
||||||
|
)
|
||||||
|
args)))
|
||||||
|
+ "}"
|
||||||
|
else if builtins.isList args
|
||||||
|
then "{" + concatMapStringsSep "," toLuaObject args + "}"
|
||||||
|
else if builtins.isString args
|
||||||
|
then
|
||||||
|
# This should be enough!
|
||||||
|
builtins.toJSON args
|
||||||
|
else if builtins.isPath args
|
||||||
|
then builtins.toJSON (toString args)
|
||||||
|
else if builtins.isBool args
|
||||||
|
then "${boolToString args}"
|
||||||
|
else if builtins.isFloat args
|
||||||
|
then "${toString args}"
|
||||||
|
else if builtins.isInt args
|
||||||
|
then "${toString args}"
|
||||||
|
else if isNull args
|
||||||
|
then "nil"
|
||||||
|
else "";
|
||||||
|
|
||||||
nmap = mapVimBinding "nmap" config.vim.nmap;
|
toLuaBindings = mode: maps:
|
||||||
imap = mapVimBinding "imap" config.vim.imap;
|
builtins.map (value: ''
|
||||||
vmap = mapVimBinding "vmap" config.vim.vmap;
|
vim.keymap.set(${toLuaObject mode}, ${toLuaObject value.key}, ${toLuaObject value.action}, ${toLuaObject value.config})
|
||||||
xmap = mapVimBinding "xmap" config.vim.xmap;
|
'') (genMaps mode maps);
|
||||||
smap = mapVimBinding "smap" config.vim.smap;
|
|
||||||
cmap = mapVimBinding "cmap" config.vim.cmap;
|
|
||||||
omap = mapVimBinding "omap" config.vim.omap;
|
|
||||||
tmap = mapVimBinding "tmap" config.vim.tmap;
|
|
||||||
|
|
||||||
nnoremap = mapVimBinding "nnoremap" config.vim.nnoremap;
|
# I'm not sure if every one of these will work.
|
||||||
inoremap = mapVimBinding "inoremap" config.vim.inoremap;
|
allmap = toLuaBindings "" config.vim.maps.normalVisualOp;
|
||||||
vnoremap = mapVimBinding "vnoremap" config.vim.vnoremap;
|
nmap = toLuaBindings "n" config.vim.maps.normal;
|
||||||
xnoremap = mapVimBinding "xnoremap" config.vim.xnoremap;
|
vmap = toLuaBindings "v" config.vim.maps.visual;
|
||||||
snoremap = mapVimBinding "snoremap" config.vim.snoremap;
|
xmap = toLuaBindings "x" config.vim.maps.visualOnly;
|
||||||
cnoremap = mapVimBinding "cnoremap" config.vim.cnoremap;
|
smap = toLuaBindings "s" config.vim.maps.select;
|
||||||
onoremap = mapVimBinding "onoremap" config.vim.onoremap;
|
imap = toLuaBindings "i" config.vim.maps.insert;
|
||||||
tnoremap = mapVimBinding "tnoremap" config.vim.tnoremap;
|
cmap = toLuaBindings "c" config.vim.maps.command;
|
||||||
|
tmap = toLuaBindings "t" config.vim.maps.terminal;
|
||||||
|
lmap = toLuaBindings "l" config.vim.maps.lang;
|
||||||
|
omap = toLuaBindings "o" config.vim.maps.operator;
|
||||||
|
icmap = toLuaBindings "ic" config.vim.maps.insertCommand;
|
||||||
|
|
||||||
resolveDag = {
|
resolveDag = {
|
||||||
name,
|
name,
|
||||||
dag,
|
dag,
|
||||||
mapResult,
|
mapResult,
|
||||||
}: let
|
}: let
|
||||||
sortedDag = nvim.dag.topoSort dag;
|
# When the value is a string, default it to dag.entryAnywhere
|
||||||
|
finalDag = lib.mapAttrs (name: value:
|
||||||
|
if builtins.isString value
|
||||||
|
then nvim.dag.entryAnywhere value
|
||||||
|
else value)
|
||||||
|
dag;
|
||||||
|
sortedDag = nvim.dag.topoSort finalDag;
|
||||||
result =
|
result =
|
||||||
if sortedDag ? result
|
if sortedDag ? result
|
||||||
then mapResult sortedDag.result
|
then mapResult sortedDag.result
|
||||||
|
@ -208,9 +314,22 @@ in {
|
||||||
in
|
in
|
||||||
nvim.dag.entryAfter ["globalsScript"] luaConfig;
|
nvim.dag.entryAfter ["globalsScript"] luaConfig;
|
||||||
|
|
||||||
|
# This is probably not the right way to set the config. I'm not sure how it should look like.
|
||||||
mappings = let
|
mappings = let
|
||||||
maps = [nmap imap vmap xmap smap cmap omap tmap nnoremap inoremap vnoremap xnoremap snoremap cnoremap onoremap tnoremap];
|
maps = [
|
||||||
mapConfig = concatStringsSep "\n" (map (v: concatStringsSep "\n" v) maps);
|
nmap
|
||||||
|
imap
|
||||||
|
vmap
|
||||||
|
xmap
|
||||||
|
smap
|
||||||
|
cmap
|
||||||
|
omap
|
||||||
|
tmap
|
||||||
|
lmap
|
||||||
|
icmap
|
||||||
|
allmap
|
||||||
|
];
|
||||||
|
mapConfig = wrapLuaConfig (concatStringsSep "\n" (map (v: concatStringsSep "\n" v) maps));
|
||||||
in
|
in
|
||||||
nvim.dag.entryAfter ["globalsScript"] mapConfig;
|
nvim.dag.entryAfter ["globalsScript"] mapConfig;
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,6 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim.dashboard.alpha = {
|
options.vim.dashboard.alpha = {
|
||||||
enable = mkEnableOption "Enable alpha.nvim";
|
enable = mkEnableOption "dashboard via alpha.nvim";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,10 +186,10 @@ in {
|
||||||
{ type = "padding", val = 1 },
|
{ type = "padding", val = 1 },
|
||||||
-- TODO: buttons should be added based on whether or not the relevant plugin is available
|
-- TODO: buttons should be added based on whether or not the relevant plugin is available
|
||||||
dashboard.button("e", " New file", "<cmd>ene<CR>"), -- available all the time
|
dashboard.button("e", " New file", "<cmd>ene<CR>"), -- available all the time
|
||||||
dashboard.button("SPC F", " Find file"), -- telescope
|
dashboard.button("SPC F", " Find file"), -- telescope
|
||||||
dashboard.button("SPC ff", " Live grep"), -- telescope
|
dashboard.button("SPC ff", " Live grep"), -- telescope
|
||||||
dashboard.button("SPC p", " Projects"), -- any project
|
dashboard.button("SPC p", " Projects"), -- any project
|
||||||
dashboard.button("q", " Quit", "<cmd>qa<CR>"), -- available all the time
|
dashboard.button("q", " Quit", "<cmd>qa<CR>"), -- available all the time
|
||||||
},
|
},
|
||||||
position = "center",
|
position = "center",
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,6 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim.dashboard.dashboard-nvim = {
|
options.vim.dashboard.dashboard-nvim = {
|
||||||
enable = mkEnableOption "Enable dashboard.nvim";
|
enable = mkEnableOption "dashboard via dashboard.nvim";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
with builtins;
|
with builtins;
|
||||||
with lib; {
|
with lib; {
|
||||||
options.vim.dashboard.startify = {
|
options.vim.dashboard.startify = {
|
||||||
enable = mkEnableOption "Enable vim-startify";
|
enable = mkEnableOption "dashboard via vim-startify";
|
||||||
|
|
||||||
bookmarks = mkOption {
|
bookmarks = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
|
|
5
modules/debugger/default.nix
Normal file
5
modules/debugger/default.nix
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
_: {
|
||||||
|
imports = [
|
||||||
|
./nvim-dap
|
||||||
|
];
|
||||||
|
}
|
70
modules/debugger/nvim-dap/config.nix
Normal file
70
modules/debugger/nvim-dap/config.nix
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
with lib;
|
||||||
|
with builtins; let
|
||||||
|
cfg = config.vim.debugger.nvim-dap;
|
||||||
|
self = import ./nvim-dap.nix {
|
||||||
|
inherit lib;
|
||||||
|
};
|
||||||
|
mappingDefinitions = self.options.vim.debugger.nvim-dap.mappings;
|
||||||
|
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||||
|
in {
|
||||||
|
config = mkMerge [
|
||||||
|
(mkIf cfg.enable {
|
||||||
|
vim.startPlugins = ["nvim-dap"];
|
||||||
|
|
||||||
|
vim.luaConfigRC =
|
||||||
|
{
|
||||||
|
# TODO customizable keymaps
|
||||||
|
nvim-dap = nvim.dag.entryAnywhere ''
|
||||||
|
local dap = require("dap")
|
||||||
|
vim.fn.sign_define("DapBreakpoint", { text = "🛑", texthl = "ErrorMsg", linehl = "", numhl = "" })
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
// mapAttrs (_: v: (nvim.dag.entryAfter ["nvim-dap"] v)) cfg.sources;
|
||||||
|
|
||||||
|
vim.maps.normal = mkMerge [
|
||||||
|
(mkSetLuaBinding mappings.continue "require('dap').continue")
|
||||||
|
(mkSetLuaBinding mappings.restart "require('dap').restart")
|
||||||
|
(mkSetLuaBinding mappings.terminate "require('dap').terminate")
|
||||||
|
(mkSetLuaBinding mappings.runLast "require('dap').run_last")
|
||||||
|
|
||||||
|
(mkSetLuaBinding mappings.toggleRepl "require('dap').repl.toggle")
|
||||||
|
(mkSetLuaBinding mappings.hover "require('dap.ui.widgets').hover")
|
||||||
|
(mkSetLuaBinding mappings.toggleBreakpoint "require('dap').toggle_breakpoint")
|
||||||
|
|
||||||
|
(mkSetLuaBinding mappings.runToCursor "require('dap').run_to_cursor")
|
||||||
|
(mkSetLuaBinding mappings.stepInto "require('dap').step_into")
|
||||||
|
(mkSetLuaBinding mappings.stepOut "require('dap').step_out")
|
||||||
|
(mkSetLuaBinding mappings.stepOver "require('dap').step_over")
|
||||||
|
(mkSetLuaBinding mappings.stepBack "require('dap').step_back")
|
||||||
|
|
||||||
|
(mkSetLuaBinding mappings.goUp "require('dap').up")
|
||||||
|
(mkSetLuaBinding mappings.goDown "require('dap').down")
|
||||||
|
];
|
||||||
|
})
|
||||||
|
(mkIf (cfg.enable && cfg.ui.enable) {
|
||||||
|
vim.startPlugins = ["nvim-dap-ui"];
|
||||||
|
|
||||||
|
vim.luaConfigRC.nvim-dap-ui = nvim.dag.entryAfter ["nvim-dap"] (''
|
||||||
|
local dapui = require("dapui")
|
||||||
|
dapui.setup()
|
||||||
|
''
|
||||||
|
+ optionalString cfg.ui.autoStart ''
|
||||||
|
dap.listeners.after.event_initialized["dapui_config"] = function()
|
||||||
|
dapui.open()
|
||||||
|
end
|
||||||
|
dap.listeners.before.event_terminated["dapui_config"] = function()
|
||||||
|
dapui.close()
|
||||||
|
end
|
||||||
|
dap.listeners.before.event_exited["dapui_config"] = function()
|
||||||
|
dapui.close()
|
||||||
|
end
|
||||||
|
'');
|
||||||
|
vim.maps.normal = mkSetLuaBinding mappings.toggleDapUI "require('dapui').toggle";
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
6
modules/debugger/nvim-dap/default.nix
Normal file
6
modules/debugger/nvim-dap/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
_: {
|
||||||
|
imports = [
|
||||||
|
./config.nix
|
||||||
|
./nvim-dap.nix
|
||||||
|
];
|
||||||
|
}
|
43
modules/debugger/nvim-dap/nvim-dap.nix
Normal file
43
modules/debugger/nvim-dap/nvim-dap.nix
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
{lib, ...}:
|
||||||
|
with lib; {
|
||||||
|
options.vim.debugger.nvim-dap = {
|
||||||
|
enable = mkEnableOption "Enable debugging via nvim-dap";
|
||||||
|
|
||||||
|
ui = {
|
||||||
|
enable = mkEnableOption "Enable UI extension for nvim-dap";
|
||||||
|
autoStart = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = "Automatically Opens and Closes DAP-UI upon starting/closing a debugging session";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
sources = mkOption {
|
||||||
|
default = {};
|
||||||
|
description = "List of debuggers to install";
|
||||||
|
type = with types; attrsOf string;
|
||||||
|
};
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
continue = mkMappingOption "Contiue" "<leader>dc";
|
||||||
|
restart = mkMappingOption "Restart" "<leader>dR";
|
||||||
|
terminate = mkMappingOption "Terminate" "<leader>dq";
|
||||||
|
runLast = mkMappingOption "Re-run Last Debug Session" "<leader>d.";
|
||||||
|
|
||||||
|
toggleRepl = mkMappingOption "Toggle Repl" "<leader>dr";
|
||||||
|
hover = mkMappingOption "Hover" "<leader>dh";
|
||||||
|
toggleBreakpoint = mkMappingOption "Toggle breakpoint" "<leader>db";
|
||||||
|
|
||||||
|
runToCursor = mkMappingOption "Continue to the current cursor" "<leader>dgc";
|
||||||
|
stepInto = mkMappingOption "Step into function" "<leader>dgi";
|
||||||
|
stepOut = mkMappingOption "Step out of function" "<leader>dgo";
|
||||||
|
stepOver = mkMappingOption "Next step" "<leader>dgj";
|
||||||
|
stepBack = mkMappingOption "Step back" "<leader>dgk";
|
||||||
|
|
||||||
|
goUp = mkMappingOption "Go up stacktrace" "<leader>dvo";
|
||||||
|
goDown = mkMappingOption "Go down stacktrace" "<leader>dvi";
|
||||||
|
|
||||||
|
toggleDapUI = mkMappingOption "Toggle DAP-UI" "<leader>du";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -25,13 +25,13 @@ inputs: {
|
||||||
// extraSpecialArgs;
|
// extraSpecialArgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
buildPlug = name:
|
buildPlug = {pname, ...} @ args:
|
||||||
buildVimPluginFrom2Nix rec {
|
assert lib.asserts.assertMsg (pname != "nvim-treesitter") "Use buildTreesitterPlug for building nvim-treesitter.";
|
||||||
pname = name;
|
buildVimPluginFrom2Nix (args
|
||||||
version = "master";
|
// {
|
||||||
src = assert lib.asserts.assertMsg (name != "nvim-treesitter") "Use buildTreesitterPlug for building nvim-treesitter.";
|
version = "master";
|
||||||
getAttr pname inputs;
|
src = getAttr pname inputs;
|
||||||
};
|
});
|
||||||
|
|
||||||
buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars);
|
buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars);
|
||||||
|
|
||||||
|
@ -45,7 +45,13 @@ inputs: {
|
||||||
(
|
(
|
||||||
if (plug == "nvim-treesitter")
|
if (plug == "nvim-treesitter")
|
||||||
then (buildTreesitterPlug vimOptions.treesitter.grammars)
|
then (buildTreesitterPlug vimOptions.treesitter.grammars)
|
||||||
else (buildPlug plug)
|
else if (plug == "flutter-tools-patched")
|
||||||
|
then
|
||||||
|
(buildPlug {
|
||||||
|
pname = "flutter-tools";
|
||||||
|
patches = [../patches/flutter-tools.patch];
|
||||||
|
})
|
||||||
|
else (buildPlug {pname = plug;})
|
||||||
)
|
)
|
||||||
else plug
|
else plug
|
||||||
))
|
))
|
||||||
|
@ -66,6 +72,7 @@ inputs: {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
|
imports = [./assertions.nix];
|
||||||
inherit (module) options config;
|
inherit (module) options config;
|
||||||
inherit (module._module.args) pkgs;
|
inherit (module._module.args) pkgs;
|
||||||
inherit neovim;
|
inherit neovim;
|
||||||
|
|
|
@ -1,30 +1,29 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.filetree.nvimTreeLua;
|
cfg = config.vim.filetree.nvimTreeLua;
|
||||||
|
self = import ./nvimtree-lua.nix {
|
||||||
|
inherit pkgs;
|
||||||
|
lib = lib;
|
||||||
|
};
|
||||||
|
mappings = self.options.vim.filetree.nvimTreeLua.mappings;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = ["nvim-tree-lua"];
|
vim.startPlugins = ["nvim-tree-lua"];
|
||||||
|
|
||||||
# vim.nnoremap = {
|
vim.maps.normal = mkMerge [
|
||||||
# "<C-n>" = ":NvimTreeToggle<CR>";
|
(mkBinding cfg.mappings.toggle ":NvimTreeToggle<cr>" mappings.toggle.description)
|
||||||
# "<leader>tr" = ":NvimTreeRefresh<CR>";
|
(mkBinding cfg.mappings.refresh ":NvimTreeRefresh<cr>" mappings.refresh.description)
|
||||||
# "<leader>tg" = ":NvimTreeFindFile<CR>";
|
(mkBinding cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
|
||||||
# "<leader>tf" = ":NvimTreeFocus<CR>";
|
(mkBinding cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
|
||||||
# };
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.nvimtreelua = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.nvimtreelua = nvim.dag.entryAnywhere ''
|
||||||
local opts = { silent = true, noremap = true }
|
|
||||||
|
|
||||||
vim.api.nvim_set_keymap("n", "<C-n>", ":NvimTreeToggle<cr>", opts)
|
|
||||||
vim.api.nvim_set_keymap("n", "<leader>tr", ":NvimTreeRefresh<cr>", opts)
|
|
||||||
vim.api.nvim_set_keymap("n", "<leader>tg", ":NvimTreeFindFile<cr>", opts)
|
|
||||||
vim.api.nvim_set_keymap("n", "<leader>tf", ":NvimTreeFocus<cr>", opts)
|
|
||||||
|
|
||||||
local function open_nvim_tree(data)
|
local function open_nvim_tree(data)
|
||||||
local IGNORED_FT = {
|
local IGNORED_FT = {
|
||||||
"markdown",
|
"markdown",
|
||||||
|
@ -80,7 +79,9 @@ in {
|
||||||
width = ${toString cfg.view.width},
|
width = ${toString cfg.view.width},
|
||||||
side = ${"'" + cfg.view.side + "'"},
|
side = ${"'" + cfg.view.side + "'"},
|
||||||
adaptive_size = ${boolToString cfg.view.adaptiveSize},
|
adaptive_size = ${boolToString cfg.view.adaptiveSize},
|
||||||
|
cursorline = ${boolToString cfg.view.cursorline}
|
||||||
},
|
},
|
||||||
|
|
||||||
git = {
|
git = {
|
||||||
enable = ${boolToString cfg.git.enable},
|
enable = ${boolToString cfg.git.enable},
|
||||||
ignore = ${boolToString cfg.git.ignore},
|
ignore = ${boolToString cfg.git.ignore},
|
||||||
|
|
|
@ -1,16 +1,34 @@
|
||||||
{
|
{
|
||||||
pkgs,
|
pkgs,
|
||||||
config,
|
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim.filetree.nvimTreeLua = {
|
options.vim.filetree.nvimTreeLua = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "filetree via nvim-tree-lua" // {default = false;};
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
mappings = {
|
||||||
description = "Enable nvim-tree-lua";
|
toggle = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<C-n>";
|
||||||
|
description = "Toggle NvimTree";
|
||||||
|
};
|
||||||
|
refresh = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<leader>tr";
|
||||||
|
description = "Refresh NvimTree";
|
||||||
|
};
|
||||||
|
findFile = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<leader>tg";
|
||||||
|
description = "Find file in NvimTree";
|
||||||
|
};
|
||||||
|
focus = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<leader>tf";
|
||||||
|
description = "Focus NvimTree";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
sortBy = mkOption {
|
sortBy = mkOption {
|
||||||
|
@ -160,6 +178,11 @@ with builtins; {
|
||||||
description = "Width of the tree in charecters";
|
description = "Width of the tree in charecters";
|
||||||
type = types.int;
|
type = types.int;
|
||||||
};
|
};
|
||||||
|
cursorline = mkOption {
|
||||||
|
default = false;
|
||||||
|
description = "Whether to display the cursor line in NvimTree";
|
||||||
|
type = types.bool;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
git = {
|
git = {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{
|
{
|
||||||
pkgs,
|
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
|
@ -7,40 +6,62 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.git;
|
cfg = config.vim.git;
|
||||||
|
|
||||||
|
self = import ./git.nix {inherit lib;};
|
||||||
|
gsMappingDefinitions = self.options.vim.git.gitsigns.mappings;
|
||||||
|
|
||||||
|
gsMappings = addDescriptionsToMappings cfg.gitsigns.mappings gsMappingDefinitions;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable (mkMerge [
|
config = mkIf cfg.enable (mkMerge [
|
||||||
(mkIf cfg.gitsigns.enable (mkMerge [
|
(mkIf cfg.gitsigns.enable (mkMerge [
|
||||||
{
|
{
|
||||||
vim.startPlugins = ["gitsigns-nvim"];
|
vim.startPlugins = ["gitsigns-nvim"];
|
||||||
|
|
||||||
|
vim.maps.normal = mkMerge [
|
||||||
|
(mkSetExprBinding gsMappings.nextHunk ''
|
||||||
|
function()
|
||||||
|
if vim.wo.diff then return ${toJSON gsMappings.nextHunk.value} end
|
||||||
|
|
||||||
|
vim.schedule(function() package.loaded.gitsigns.next_hunk() end)
|
||||||
|
|
||||||
|
return '<Ignore>'
|
||||||
|
end
|
||||||
|
'')
|
||||||
|
(mkSetExprBinding gsMappings.previousHunk ''
|
||||||
|
function()
|
||||||
|
if vim.wo.diff then return ${toJSON gsMappings.previousHunk.value} end
|
||||||
|
|
||||||
|
vim.schedule(function() package.loaded.gitsigns.prev_hunk() end)
|
||||||
|
|
||||||
|
return '<Ignore>'
|
||||||
|
end
|
||||||
|
'')
|
||||||
|
|
||||||
|
(mkSetLuaBinding gsMappings.stageHunk "package.loaded.gitsigns.stage_hunk")
|
||||||
|
(mkSetLuaBinding gsMappings.resetHunk "package.loaded.gitsigns.reset_hunk")
|
||||||
|
(mkSetLuaBinding gsMappings.undoStageHunk "package.loaded.gitsigns.undo_stage_hunk")
|
||||||
|
|
||||||
|
(mkSetLuaBinding gsMappings.stageBuffer "package.loaded.gitsigns.stage_buffer")
|
||||||
|
(mkSetLuaBinding gsMappings.resetBuffer "package.loaded.gitsigns.reset_buffer")
|
||||||
|
|
||||||
|
(mkSetLuaBinding gsMappings.previewHunk "package.loaded.gitsigns.preview_hunk")
|
||||||
|
|
||||||
|
(mkSetLuaBinding gsMappings.blameLine "function() package.loaded.gitsigns.blame_line{full=true} end")
|
||||||
|
(mkSetLuaBinding gsMappings.toggleBlame "package.loaded.gitsigns.toggle_current_line_blame")
|
||||||
|
|
||||||
|
(mkSetLuaBinding gsMappings.diffThis "package.loaded.gitsigns.diffthis")
|
||||||
|
(mkSetLuaBinding gsMappings.diffProject "function() package.loaded.gitsigns.diffthis('~') end")
|
||||||
|
|
||||||
|
(mkSetLuaBinding gsMappings.toggleDeleted "package.loaded.gitsigns.toggle_deleted")
|
||||||
|
];
|
||||||
|
|
||||||
|
vim.maps.visual = mkMerge [
|
||||||
|
(mkSetLuaBinding gsMappings.stageHunk "function() package.loaded.gitsigns.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end")
|
||||||
|
(mkSetLuaBinding gsMappings.resetHunk "function() package.loaded.gitsigns.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end")
|
||||||
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.gitsigns = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.gitsigns = nvim.dag.entryAnywhere ''
|
||||||
require('gitsigns').setup {
|
require('gitsigns').setup{}
|
||||||
keymaps = {
|
|
||||||
noremap = true,
|
|
||||||
|
|
||||||
['n <leader>gn'] = { expr = true, "&diff ? \'\' : '<cmd>Gitsigns next_hunk<CR>'"},
|
|
||||||
['n <leader>gp'] = { expr = true, "&diff ? \'\' : '<cmd>Gitsigns prev_hunk<CR>'"},
|
|
||||||
|
|
||||||
['n <leader>gs'] = '<cmd>Gitsigns stage_hunk<CR>',
|
|
||||||
['v <leader>gs'] = ':Gitsigns stage_hunk<CR>',
|
|
||||||
['n <leader>gu'] = '<cmd>Gitsigns undo_stage_hunk<CR>',
|
|
||||||
['n <leader>gr'] = '<cmd>Gitsigns reset_hunk<CR>',
|
|
||||||
['v <leader>gr'] = ':Gitsigns reset_hunk<CR>',
|
|
||||||
['n <leader>gR'] = '<cmd>Gitsigns reset_buffer<CR>',
|
|
||||||
['n <leader>gp'] = '<cmd>Gitsigns preview_hunk<CR>',
|
|
||||||
['n <leader>gb'] = '<cmd>lua require"gitsigns".blame_line{full=true}<CR>',
|
|
||||||
['n <leader>gS'] = '<cmd>Gitsigns stage_buffer<CR>',
|
|
||||||
['n <leader>gU'] = '<cmd>Gitsigns reset_buffer_index<CR>',
|
|
||||||
['n <leader>gts'] = ':Gitsigns toggle_signs<CR>',
|
|
||||||
['n <leader>gtn'] = ':Gitsigns toggle_numhl<CR>',
|
|
||||||
['n <leader>gtl'] = ':Gitsigns toggle_linehl<CR>',
|
|
||||||
['n <leader>gtw'] = ':Gitsigns toggle_word_diff<CR>',
|
|
||||||
|
|
||||||
-- Text objects
|
|
||||||
['o ih'] = ':<C-U>Gitsigns select_hunk<CR>',
|
|
||||||
['x ih'] = ':<C-U>Gitsigns select_hunk<CR>'
|
|
||||||
},
|
|
||||||
}
|
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,34 @@
|
||||||
{
|
{lib, ...}:
|
||||||
pkgs,
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; {
|
||||||
cfg = config.vim.git;
|
|
||||||
in {
|
|
||||||
options.vim.git = {
|
options.vim.git = {
|
||||||
enable = mkEnableOption "Git support";
|
enable = mkEnableOption "git tools via gitsigns";
|
||||||
|
|
||||||
gitsigns = {
|
gitsigns = {
|
||||||
enable = mkEnableOption "gitsigns";
|
enable = mkEnableOption "gitsigns";
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
nextHunk = mkMappingOption "Next hunk [Gitsigns]" "]c";
|
||||||
|
previousHunk = mkMappingOption "Previous hunk [Gitsigns]" "[c";
|
||||||
|
|
||||||
|
stageHunk = mkMappingOption "Stage hunk [Gitsigns]" "<leader>hs";
|
||||||
|
undoStageHunk = mkMappingOption "Undo stage hunk [Gitsigns]" "<leader>hu";
|
||||||
|
resetHunk = mkMappingOption "Reset hunk [Gitsigns]" "<leader>hr";
|
||||||
|
|
||||||
|
stageBuffer = mkMappingOption "Stage buffer [Gitsigns]" "<leader>hS";
|
||||||
|
resetBuffer = mkMappingOption "Reset buffer [Gitsigns]" "<leader>hR";
|
||||||
|
|
||||||
|
previewHunk = mkMappingOption "Preview hunk [Gitsigns]" "<leader>hP";
|
||||||
|
|
||||||
|
blameLine = mkMappingOption "Blame line [Gitsigns]" "<leader>hb";
|
||||||
|
toggleBlame = mkMappingOption "Toggle blame [Gitsigns]" "<leader>tb";
|
||||||
|
|
||||||
|
diffThis = mkMappingOption "Diff this [Gitsigns]" "<leader>hd";
|
||||||
|
diffProject = mkMappingOption "Diff project [Gitsigns]" "<leader>hD";
|
||||||
|
|
||||||
|
toggleDeleted = mkMappingOption "Toggle deleted [Gitsigns]" "<leader>td";
|
||||||
|
};
|
||||||
|
|
||||||
codeActions = mkEnableOption "gitsigns codeactions through null-ls";
|
codeActions = mkEnableOption "gitsigns codeactions through null-ls";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,8 +24,11 @@ with builtins; let
|
||||||
clangd = {
|
clangd = {
|
||||||
package = pkgs.clang-tools;
|
package = pkgs.clang-tools;
|
||||||
lspConfig = ''
|
lspConfig = ''
|
||||||
|
local clangd_cap = capabilities
|
||||||
|
-- use same offsetEncoding as null-ls
|
||||||
|
clangd_cap.offsetEncoding = {"utf-16"}
|
||||||
lspconfig.clangd.setup{
|
lspconfig.clangd.setup{
|
||||||
capabilities = capabilities;
|
capabilities = clangd_cap;
|
||||||
on_attach=default_on_attach;
|
on_attach=default_on_attach;
|
||||||
cmd = {"${cfg.lsp.package}/bin/clangd"};
|
cmd = {"${cfg.lsp.package}/bin/clangd"};
|
||||||
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.opts}"}
|
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.opts}"}
|
||||||
|
@ -33,6 +36,35 @@ with builtins; let
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
defaultDebugger = "lldb-vscode";
|
||||||
|
debuggers = {
|
||||||
|
lldb-vscode = {
|
||||||
|
package = pkgs.lldb;
|
||||||
|
dapConfig = ''
|
||||||
|
dap.adapters.lldb = {
|
||||||
|
type = 'executable',
|
||||||
|
command = '${cfg.dap.package}/bin/lldb-vscode',
|
||||||
|
name = 'lldb'
|
||||||
|
}
|
||||||
|
dap.configurations.cpp = {
|
||||||
|
{
|
||||||
|
name = 'Launch',
|
||||||
|
type = 'lldb',
|
||||||
|
request = 'launch',
|
||||||
|
program = function()
|
||||||
|
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||||
|
end,
|
||||||
|
cwd = "''${workspaceFolder}",
|
||||||
|
stopOnEntry = false,
|
||||||
|
args = {},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
dap.configurations.c = dap.configurations.cpp
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
in {
|
in {
|
||||||
options.vim.languages.clang = {
|
options.vim.languages.clang = {
|
||||||
enable = mkEnableOption "C/C++ language support";
|
enable = mkEnableOption "C/C++ language support";
|
||||||
|
@ -47,37 +79,50 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
treesitter = {
|
treesitter = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "C/C++ treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||||
description = "Enable C/C++ treesitter";
|
|
||||||
type = types.bool;
|
|
||||||
default = config.vim.languages.enableTreesitter;
|
|
||||||
};
|
|
||||||
cPackage = nvim.types.mkGrammarOption pkgs "c";
|
cPackage = nvim.types.mkGrammarOption pkgs "c";
|
||||||
cppPackage = nvim.types.mkGrammarOption pkgs "cpp";
|
cppPackage = nvim.types.mkGrammarOption pkgs "cpp";
|
||||||
};
|
};
|
||||||
|
|
||||||
lsp = {
|
lsp = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "Enable clang LSP support" // {default = config.vim.languages.enableLSP;};
|
||||||
description = "Enable clang LSP support";
|
|
||||||
type = types.bool;
|
|
||||||
default = config.vim.languages.enableLSP;
|
|
||||||
};
|
|
||||||
server = mkOption {
|
server = mkOption {
|
||||||
description = "The clang LSP server to use";
|
description = "The clang LSP server to use";
|
||||||
type = with types; enum (attrNames servers);
|
type = with types; enum (attrNames servers);
|
||||||
default = defaultServer;
|
default = defaultServer;
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
description = "clang LSP server package";
|
description = "clang LSP server package";
|
||||||
type = types.package;
|
type = types.package;
|
||||||
default = servers.${cfg.lsp.server}.package;
|
default = servers.${cfg.lsp.server}.package;
|
||||||
};
|
};
|
||||||
|
|
||||||
opts = mkOption {
|
opts = mkOption {
|
||||||
description = "Options to pass to clang LSP server";
|
description = "Options to pass to clang LSP server";
|
||||||
type = with types; nullOr str;
|
type = with types; nullOr str;
|
||||||
default = null;
|
default = null;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dap = {
|
||||||
|
enable = mkOption {
|
||||||
|
description = "Enable clang Debug Adapter";
|
||||||
|
type = types.bool;
|
||||||
|
default = config.vim.languages.enableDAP;
|
||||||
|
};
|
||||||
|
debugger = mkOption {
|
||||||
|
description = "clang debugger to use";
|
||||||
|
type = with types; enum (attrNames debuggers);
|
||||||
|
default = defaultDebugger;
|
||||||
|
};
|
||||||
|
package = mkOption {
|
||||||
|
description = "clang debugger package.";
|
||||||
|
type = types.package;
|
||||||
|
default = debuggers.${cfg.dap.debugger}.package;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable (mkMerge [
|
config = mkIf cfg.enable (mkMerge [
|
||||||
|
@ -95,5 +140,10 @@ in {
|
||||||
|
|
||||||
vim.lsp.lspconfig.sources.clang-lsp = servers.${cfg.lsp.server}.lspConfig;
|
vim.lsp.lspconfig.sources.clang-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
(mkIf cfg.dap.enable {
|
||||||
|
vim.debugger.nvim-dap.enable = true;
|
||||||
|
vim.debugger.nvim-dap.sources.clang-debugger = debuggers.${cfg.dap.debugger}.dapConfig;
|
||||||
|
})
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,10 @@ in {
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf (ftcfg.enable) {
|
(mkIf (ftcfg.enable) {
|
||||||
vim.startPlugins = ["flutter-tools"];
|
vim.startPlugins =
|
||||||
|
if ftcfg.enableNoResolvePatch
|
||||||
|
then ["flutter-tools-patched"]
|
||||||
|
else ["flutter-tools"];
|
||||||
|
|
||||||
vim.luaConfigRC.flutter-tools = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.flutter-tools = nvim.dag.entryAnywhere ''
|
||||||
require('flutter-tools').setup {
|
require('flutter-tools').setup {
|
||||||
|
@ -52,8 +55,12 @@ in {
|
||||||
on_attach = default_on_attach;
|
on_attach = default_on_attach;
|
||||||
flags = lsp_flags,
|
flags = lsp_flags,
|
||||||
},
|
},
|
||||||
|
${optionalString cfg.dap.enable ''
|
||||||
|
debugger = {
|
||||||
|
enabled = true,
|
||||||
|
},
|
||||||
|
''}
|
||||||
}
|
}
|
||||||
|
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -26,16 +26,12 @@ in {
|
||||||
enable = mkEnableOption "Dart language support";
|
enable = mkEnableOption "Dart language support";
|
||||||
|
|
||||||
treesitter = {
|
treesitter = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "Enable Dart treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||||
description = "Enable Dart treesitter";
|
|
||||||
type = types.bool;
|
|
||||||
default = config.vim.languages.enableTreesitter;
|
|
||||||
};
|
|
||||||
package = nvim.types.mkGrammarOption pkgs "dart";
|
package = nvim.types.mkGrammarOption pkgs "dart";
|
||||||
};
|
};
|
||||||
|
|
||||||
lsp = {
|
lsp = {
|
||||||
enable = mkEnableOption "Enable Dart LSP support";
|
enable = mkEnableOption "Dart LSP support";
|
||||||
server = mkOption {
|
server = mkOption {
|
||||||
description = "The Dart LSP server to use";
|
description = "The Dart LSP server to use";
|
||||||
type = with types; enum (attrNames servers);
|
type = with types; enum (attrNames servers);
|
||||||
|
@ -53,6 +49,14 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dap = {
|
||||||
|
enable = mkOption {
|
||||||
|
description = "Enable Dart DAP support via flutter-tools";
|
||||||
|
type = types.bool;
|
||||||
|
default = config.vim.languages.enableDAP;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
flutter-tools = {
|
flutter-tools = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
description = "Enable flutter-tools for flutter support";
|
description = "Enable flutter-tools for flutter support";
|
||||||
|
@ -60,6 +64,16 @@ in {
|
||||||
default = config.vim.languages.enableLSP;
|
default = config.vim.languages.enableLSP;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enableNoResolvePatch = mkOption {
|
||||||
|
description = ''
|
||||||
|
Patch flutter-tools so that it doesn't resolve symlinks when detecting flutter path.
|
||||||
|
This is required if you want to use a flutter package built with nix.
|
||||||
|
If you are using a flutter SDK installed from a different source and encounter the error "`dart` missing from PATH", disable this option.
|
||||||
|
'';
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
|
||||||
color = {
|
color = {
|
||||||
enable = mkEnableOption "Whether or mot to highlight color variables at all";
|
enable = mkEnableOption "Whether or mot to highlight color variables at all";
|
||||||
|
|
||||||
|
|
|
@ -22,10 +22,12 @@ in {
|
||||||
./ts.nix
|
./ts.nix
|
||||||
./zig.nix
|
./zig.nix
|
||||||
./html.nix
|
./html.nix
|
||||||
|
./svelte.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
options.vim.languages = {
|
options.vim.languages = {
|
||||||
enableLSP = mkEnable "LSP";
|
enableLSP = mkEnable "LSP";
|
||||||
|
enableDAP = mkEnable "Debug Adapter";
|
||||||
enableTreesitter = mkEnable "treesitter";
|
enableTreesitter = mkEnable "treesitter";
|
||||||
enableFormat = mkEnable "formatting";
|
enableFormat = mkEnable "formatting";
|
||||||
enableExtraDiagnostics = mkEnable "extra diagnostics";
|
enableExtraDiagnostics = mkEnable "extra diagnostics";
|
||||||
|
|
|
@ -6,6 +6,6 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim.languages.elixir = {
|
options.vim.languages.elixir = {
|
||||||
enable = mkEnableOption "elixir support";
|
enable = mkEnableOption "Elixir language support";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,36 +21,89 @@ with builtins; let
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
defaultDebugger = "delve";
|
||||||
|
debuggers = {
|
||||||
|
delve = {
|
||||||
|
package = pkgs.delve;
|
||||||
|
dapConfig = ''
|
||||||
|
dap.adapters.delve = {
|
||||||
|
type = "server",
|
||||||
|
port = "''${port}",
|
||||||
|
executable = {
|
||||||
|
command = "${getExe cfg.dap.package}",
|
||||||
|
args = { "dap", "-l", "127.0.0.1:''${port}" },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
dap.configurations.go = {
|
||||||
|
{
|
||||||
|
type = "delve",
|
||||||
|
name = "Debug",
|
||||||
|
request = "launch",
|
||||||
|
program = "''${file}",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type = "delve",
|
||||||
|
name = "Debug test", -- configuration for debugging test files
|
||||||
|
request = "launch",
|
||||||
|
mode = "test",
|
||||||
|
program = "''${file}",
|
||||||
|
},
|
||||||
|
-- works with go.mod packages and sub packages
|
||||||
|
{
|
||||||
|
type = "delve",
|
||||||
|
name = "Debug test (go.mod)",
|
||||||
|
request = "launch",
|
||||||
|
mode = "test",
|
||||||
|
program = "./''${relativeFileDirname}",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
in {
|
in {
|
||||||
options.vim.languages.go = {
|
options.vim.languages.go = {
|
||||||
enable = mkEnableOption "Go language support";
|
enable = mkEnableOption "Go language support";
|
||||||
|
|
||||||
treesitter = {
|
treesitter = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "Enable Go treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||||
description = "Enable Go treesitter";
|
|
||||||
type = types.bool;
|
|
||||||
default = config.vim.languages.enableTreesitter;
|
|
||||||
};
|
|
||||||
package = nvim.types.mkGrammarOption pkgs "go";
|
package = nvim.types.mkGrammarOption pkgs "go";
|
||||||
};
|
};
|
||||||
|
|
||||||
lsp = {
|
lsp = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "Enable Go LSP support" // {default = config.vim.languages.enableLSP;};
|
||||||
description = "Enable Go LSP support";
|
|
||||||
type = types.bool;
|
|
||||||
default = config.vim.languages.enableLSP;
|
|
||||||
};
|
|
||||||
server = mkOption {
|
server = mkOption {
|
||||||
description = "Go LSP server to use";
|
description = "Go LSP server to use";
|
||||||
type = with types; enum (attrNames servers);
|
type = with types; enum (attrNames servers);
|
||||||
default = defaultServer;
|
default = defaultServer;
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
description = "Go LSP server package";
|
description = "Go LSP server package";
|
||||||
type = types.package;
|
type = types.package;
|
||||||
default = servers.${cfg.lsp.server}.package;
|
default = servers.${cfg.lsp.server}.package;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dap = {
|
||||||
|
enable = mkOption {
|
||||||
|
description = "Enable Go Debug Adapter";
|
||||||
|
type = types.bool;
|
||||||
|
default = config.vim.languages.enableDAP;
|
||||||
|
};
|
||||||
|
debugger = mkOption {
|
||||||
|
description = "Go debugger to use";
|
||||||
|
type = with types; enum (attrNames debuggers);
|
||||||
|
default = defaultDebugger;
|
||||||
|
};
|
||||||
|
package = mkOption {
|
||||||
|
description = "Go debugger package.";
|
||||||
|
type = types.package;
|
||||||
|
default = debuggers.${cfg.dap.debugger}.package;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable (mkMerge [
|
config = mkIf cfg.enable (mkMerge [
|
||||||
|
@ -63,5 +116,10 @@ in {
|
||||||
vim.lsp.lspconfig.enable = true;
|
vim.lsp.lspconfig.enable = true;
|
||||||
vim.lsp.lspconfig.sources.go-lsp = servers.${cfg.lsp.server}.lspConfig;
|
vim.lsp.lspconfig.sources.go-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
(mkIf cfg.dap.enable {
|
||||||
|
vim.debugger.nvim-dap.enable = true;
|
||||||
|
vim.debugger.nvim-dap.sources.go-debugger = debuggers.${cfg.dap.debugger}.dapConfig;
|
||||||
|
})
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ with builtins; let
|
||||||
cfg = config.vim.languages.markdown;
|
cfg = config.vim.languages.markdown;
|
||||||
in {
|
in {
|
||||||
options.vim.languages.markdown = {
|
options.vim.languages.markdown = {
|
||||||
enable = mkEnableOption "Markdown language support";
|
enable = mkEnableOption "Markdown markup language support";
|
||||||
|
|
||||||
glow.enable = mkOption {
|
glow.enable = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
|
|
|
@ -96,11 +96,8 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
lsp = {
|
lsp = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "Enable Nix LSP support" // {default = config.vim.languages.enableLSP;};
|
||||||
description = "Enable Nix LSP support";
|
|
||||||
type = types.bool;
|
|
||||||
default = config.vim.languages.enableLSP;
|
|
||||||
};
|
|
||||||
server = mkOption {
|
server = mkOption {
|
||||||
description = "Nix LSP server to use";
|
description = "Nix LSP server to use";
|
||||||
type = types.str;
|
type = types.str;
|
||||||
|
@ -114,11 +111,8 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
format = {
|
format = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "Enable Nix formatting" // {default = config.vim.languages.enableFormat;};
|
||||||
description = "Enable Nix formatting";
|
|
||||||
type = types.bool;
|
|
||||||
default = config.vim.languages.enableFormat;
|
|
||||||
};
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
description = "Nix formatter to use";
|
description = "Nix formatter to use";
|
||||||
type = with types; enum (attrNames formats);
|
type = with types; enum (attrNames formats);
|
||||||
|
|
|
@ -36,16 +36,75 @@ with builtins; let
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
defaultDebugger = "debugpy";
|
||||||
|
debuggers = {
|
||||||
|
debugpy = {
|
||||||
|
# idk if this is the best way to install/run debugpy
|
||||||
|
package = pkgs.python3.withPackages (ps: with ps; [debugpy]);
|
||||||
|
dapConfig = ''
|
||||||
|
dap.adapters.python = function(cb, config)
|
||||||
|
if config.request == 'attach' then
|
||||||
|
---@diagnostic disable-next-line: undefined-field
|
||||||
|
local port = (config.connect or config).port
|
||||||
|
---@diagnostic disable-next-line: undefined-field
|
||||||
|
local host = (config.connect or config).host or '127.0.0.1'
|
||||||
|
cb({
|
||||||
|
type = 'server',
|
||||||
|
port = assert(port, '`connect.port` is required for a python `attach` configuration'),
|
||||||
|
host = host,
|
||||||
|
options = {
|
||||||
|
source_filetype = 'python',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
else
|
||||||
|
cb({
|
||||||
|
type = 'executable',
|
||||||
|
command = '${getExe cfg.dap.package}',
|
||||||
|
args = { '-m', 'debugpy.adapter' },
|
||||||
|
options = {
|
||||||
|
source_filetype = 'python',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
dap.configurations.python = {
|
||||||
|
{
|
||||||
|
-- The first three options are required by nvim-dap
|
||||||
|
type = 'python'; -- the type here established the link to the adapter definition: `dap.adapters.python`
|
||||||
|
request = 'launch';
|
||||||
|
name = "Launch file";
|
||||||
|
|
||||||
|
-- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options
|
||||||
|
|
||||||
|
program = "''${file}"; -- This configuration will launch the current file if used.
|
||||||
|
pythonPath = function()
|
||||||
|
-- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself.
|
||||||
|
-- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within.
|
||||||
|
-- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable.
|
||||||
|
local cwd = vim.fn.getcwd()
|
||||||
|
if vim.fn.executable(cwd .. '/venv/bin/python') == 1 then
|
||||||
|
return cwd .. '/venv/bin/python'
|
||||||
|
elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then
|
||||||
|
return cwd .. '/.venv/bin/python'
|
||||||
|
elseif vim.fn.executable("python") == 1 then
|
||||||
|
return vim.fn.exepath("python")
|
||||||
|
else -- WARNING cfg.dap.package probably has NO libraries other than builtins and debugpy
|
||||||
|
return '${getExe cfg.dap.package}'
|
||||||
|
end
|
||||||
|
end;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
in {
|
in {
|
||||||
options.vim.languages.python = {
|
options.vim.languages.python = {
|
||||||
enable = mkEnableOption "Python language support";
|
enable = mkEnableOption "Python language support";
|
||||||
|
|
||||||
treesitter = {
|
treesitter = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "Enable Python treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||||
description = "Enable Python treesitter";
|
|
||||||
type = types.bool;
|
|
||||||
default = config.vim.languages.enableTreesitter;
|
|
||||||
};
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
description = "Python treesitter grammar to use";
|
description = "Python treesitter grammar to use";
|
||||||
type = types.package;
|
type = types.package;
|
||||||
|
@ -54,16 +113,14 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
lsp = {
|
lsp = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "Enable Python LSP support" // {default = config.vim.languages.enableLSP;};
|
||||||
description = "Enable Python LSP support";
|
|
||||||
type = types.bool;
|
|
||||||
default = config.vim.languages.enableLSP;
|
|
||||||
};
|
|
||||||
server = mkOption {
|
server = mkOption {
|
||||||
description = "Python LSP server to use";
|
description = "Python LSP server to use";
|
||||||
type = with types; enum (attrNames servers);
|
type = with types; enum (attrNames servers);
|
||||||
default = defaultServer;
|
default = defaultServer;
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
description = "python LSP server package";
|
description = "python LSP server package";
|
||||||
type = types.package;
|
type = types.package;
|
||||||
|
@ -72,22 +129,43 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
format = {
|
format = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "Enable Python formatting" // {default = config.vim.languages.enableFormat;};
|
||||||
description = "Enable Python formatting";
|
|
||||||
type = types.bool;
|
|
||||||
default = config.vim.languages.enableFormat;
|
|
||||||
};
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
description = "Python formatter to use";
|
description = "Python formatter to use";
|
||||||
type = with types; enum (attrNames formats);
|
type = with types; enum (attrNames formats);
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
description = "Python formatter package";
|
description = "Python formatter package";
|
||||||
type = types.package;
|
type = types.package;
|
||||||
default = formats.${cfg.format.type}.package;
|
default = formats.${cfg.format.type}.package;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# TODO this implementation is very bare bones, I don't know enough python to implement everything
|
||||||
|
dap = {
|
||||||
|
enable = mkOption {
|
||||||
|
description = "Enable Python Debug Adapter";
|
||||||
|
type = types.bool;
|
||||||
|
default = config.vim.languages.enableDAP;
|
||||||
|
};
|
||||||
|
debugger = mkOption {
|
||||||
|
description = "Python debugger to use";
|
||||||
|
type = with types; enum (attrNames debuggers);
|
||||||
|
default = defaultDebugger;
|
||||||
|
};
|
||||||
|
package = mkOption {
|
||||||
|
description = ''
|
||||||
|
Python debugger package.
|
||||||
|
This is a python package with debugpy installed, see https://nixos.wiki/wiki/Python#Install_Python_Packages.
|
||||||
|
'';
|
||||||
|
example = literalExpression "with pkgs; python39.withPackages (ps: with ps; [debugpy])";
|
||||||
|
type = types.package;
|
||||||
|
default = debuggers.${cfg.dap.debugger}.package;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
config = mkIf cfg.enable (mkMerge [
|
config = mkIf cfg.enable (mkMerge [
|
||||||
(mkIf cfg.treesitter.enable {
|
(mkIf cfg.treesitter.enable {
|
||||||
|
@ -104,5 +182,10 @@ in {
|
||||||
vim.lsp.null-ls.enable = true;
|
vim.lsp.null-ls.enable = true;
|
||||||
vim.lsp.null-ls.sources.python-format = formats.${cfg.format.type}.nullConfig;
|
vim.lsp.null-ls.sources.python-format = formats.${cfg.format.type}.nullConfig;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
(mkIf cfg.dap.enable {
|
||||||
|
vim.debugger.nvim-dap.enable = true;
|
||||||
|
vim.debugger.nvim-dap.sources.python-debugger = debuggers.${cfg.dap.debugger}.dapConfig;
|
||||||
|
})
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,7 @@ in {
|
||||||
enable = mkEnableOption "Rust language support";
|
enable = mkEnableOption "Rust language support";
|
||||||
|
|
||||||
treesitter = {
|
treesitter = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "Enable Rust treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||||
description = "Enable Rust treesitter";
|
|
||||||
type = types.bool;
|
|
||||||
default = config.vim.languages.enableTreesitter;
|
|
||||||
};
|
|
||||||
package = nvim.types.mkGrammarOption pkgs "rust";
|
package = nvim.types.mkGrammarOption pkgs "rust";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,22 +26,33 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
lsp = {
|
lsp = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "Rust LSP support (rust-analyzer with extra tools)" // {default = config.vim.languages.enableLSP;};
|
||||||
description = "Rust LSP support (rust-analyzer with extra tools)";
|
|
||||||
type = types.bool;
|
|
||||||
default = config.vim.languages.enableLSP;
|
|
||||||
};
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
description = "rust-analyzer package";
|
description = "rust-analyzer package";
|
||||||
type = types.package;
|
type = types.package;
|
||||||
default = pkgs.rust-analyzer;
|
default = pkgs.rust-analyzer;
|
||||||
};
|
};
|
||||||
|
|
||||||
opts = mkOption {
|
opts = mkOption {
|
||||||
description = "Options to pass to rust analyzer";
|
description = "Options to pass to rust analyzer";
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "";
|
default = "";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dap = {
|
||||||
|
enable = mkOption {
|
||||||
|
description = "Rust Debug Adapter support";
|
||||||
|
type = types.bool;
|
||||||
|
default = config.vim.languages.enableDAP;
|
||||||
|
};
|
||||||
|
package = mkOption {
|
||||||
|
description = "lldb pacakge";
|
||||||
|
type = types.package;
|
||||||
|
default = pkgs.lldb;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable (mkMerge [
|
config = mkIf cfg.enable (mkMerge [
|
||||||
|
@ -68,8 +75,8 @@ in {
|
||||||
vim.treesitter.enable = true;
|
vim.treesitter.enable = true;
|
||||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||||
})
|
})
|
||||||
(mkIf cfg.lsp.enable {
|
(mkIf (cfg.lsp.enable || cfg.dap.enable) {
|
||||||
vim.startPlugins = ["rust-tools"];
|
vim.startPlugins = ["rust-tools"] ++ optionals cfg.dap.enable [cfg.dap.package];
|
||||||
|
|
||||||
vim.lsp.lspconfig.enable = true;
|
vim.lsp.lspconfig.enable = true;
|
||||||
vim.lsp.lspconfig.sources.rust-lsp = ''
|
vim.lsp.lspconfig.sources.rust-lsp = ''
|
||||||
|
@ -84,6 +91,21 @@ in {
|
||||||
vim.keymap.set("n", "<leader>rm", rt.expand_macro.expand_macro, opts)
|
vim.keymap.set("n", "<leader>rm", rt.expand_macro.expand_macro, opts)
|
||||||
vim.keymap.set("n", "<leader>rc", rt.open_cargo_toml.open_cargo_toml, opts)
|
vim.keymap.set("n", "<leader>rc", rt.open_cargo_toml.open_cargo_toml, opts)
|
||||||
vim.keymap.set("n", "<leader>rg", function() rt.crate_graph.view_crate_graph("x11", nil) end, opts)
|
vim.keymap.set("n", "<leader>rg", function() rt.crate_graph.view_crate_graph("x11", nil) end, opts)
|
||||||
|
${optionalString cfg.dap.enable ''
|
||||||
|
vim.keymap.set("n", "<leader>rd", ":RustDebuggables<cr>", opts)
|
||||||
|
vim.keymap.set(
|
||||||
|
"n", "${config.vim.debugger.nvim-dap.mappings.continue}",
|
||||||
|
function()
|
||||||
|
local dap = require("dap")
|
||||||
|
if dap.status() == "" then
|
||||||
|
vim.cmd "RustDebuggables"
|
||||||
|
else
|
||||||
|
dap.continue()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
opts
|
||||||
|
)
|
||||||
|
''}
|
||||||
end
|
end
|
||||||
local rustopts = {
|
local rustopts = {
|
||||||
tools = {
|
tools = {
|
||||||
|
@ -100,7 +122,17 @@ in {
|
||||||
settings = {
|
settings = {
|
||||||
${cfg.lsp.opts}
|
${cfg.lsp.opts}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
|
${optionalString cfg.dap.enable ''
|
||||||
|
dap = {
|
||||||
|
adapter = {
|
||||||
|
type = "executable",
|
||||||
|
command = "${cfg.dap.package}/bin/lldb-vscode",
|
||||||
|
name = "rt_lldb",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
''}
|
||||||
}
|
}
|
||||||
rt.setup(rustopts)
|
rt.setup(rustopts)
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -68,11 +68,8 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
treesitter = {
|
treesitter = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "Enable SQL treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||||
description = "Enable SQL treesitter";
|
|
||||||
type = types.bool;
|
|
||||||
default = config.vim.languages.enableTreesitter;
|
|
||||||
};
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
description = "SQL treesitter grammar to use";
|
description = "SQL treesitter grammar to use";
|
||||||
type = types.package;
|
type = types.package;
|
||||||
|
@ -81,16 +78,14 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
lsp = {
|
lsp = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "Enable SQL LSP support" // {default = config.vim.languages.enableLSP;};
|
||||||
description = "Enable SQL LSP support";
|
|
||||||
type = types.bool;
|
|
||||||
default = config.vim.languages.enableLSP;
|
|
||||||
};
|
|
||||||
server = mkOption {
|
server = mkOption {
|
||||||
description = "SQL LSP server to use";
|
description = "SQL LSP server to use";
|
||||||
type = with types; enum (attrNames servers);
|
type = with types; enum (attrNames servers);
|
||||||
default = defaultServer;
|
default = defaultServer;
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
description = "SQL LSP server package";
|
description = "SQL LSP server package";
|
||||||
type = types.package;
|
type = types.package;
|
||||||
|
@ -99,16 +94,14 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
format = {
|
format = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "Enable SQL formatting" // {default = config.vim.languages.enableFormat;};
|
||||||
description = "Enable SQL formatting";
|
|
||||||
type = types.bool;
|
|
||||||
default = config.vim.languages.enableFormat;
|
|
||||||
};
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
description = "SQL formatter to use";
|
description = "SQL formatter to use";
|
||||||
type = with types; enum (attrNames formats);
|
type = with types; enum (attrNames formats);
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
description = "SQL formatter package";
|
description = "SQL formatter package";
|
||||||
type = types.package;
|
type = types.package;
|
||||||
|
@ -117,11 +110,8 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
extraDiagnostics = {
|
extraDiagnostics = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "Enable extra SQL diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
|
||||||
description = "Enable extra SQL diagnostics";
|
|
||||||
type = types.bool;
|
|
||||||
default = config.vim.languages.enableExtraDiagnostics;
|
|
||||||
};
|
|
||||||
types = lib.nvim.types.diagnostics {
|
types = lib.nvim.types.diagnostics {
|
||||||
langDesc = "SQL";
|
langDesc = "SQL";
|
||||||
inherit diagnostics;
|
inherit diagnostics;
|
||||||
|
|
134
modules/languages/svelte.nix
Normal file
134
modules/languages/svelte.nix
Normal file
|
@ -0,0 +1,134 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
with lib;
|
||||||
|
with builtins; let
|
||||||
|
cfg = config.vim.languages.svelte;
|
||||||
|
|
||||||
|
defaultServer = "svelte";
|
||||||
|
servers = {
|
||||||
|
svelte = {
|
||||||
|
package = pkgs.nodePackages.svelte-language-server;
|
||||||
|
lspConfig = ''
|
||||||
|
lspconfig.svelte.setup {
|
||||||
|
capabilities = capabilities;
|
||||||
|
on_attach = attach_keymaps,
|
||||||
|
cmd = { "${cfg.lsp.package}/bin/svelteserver", "--stdio" }
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# TODO: specify packages
|
||||||
|
defaultFormat = "prettier";
|
||||||
|
formats = {
|
||||||
|
prettier = {
|
||||||
|
package = pkgs.nodePackages.prettier;
|
||||||
|
nullConfig = ''
|
||||||
|
table.insert(
|
||||||
|
ls_sources,
|
||||||
|
null_ls.builtins.formatting.prettier.with({
|
||||||
|
command = "${cfg.format.package}/bin/prettier",
|
||||||
|
})
|
||||||
|
)
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# TODO: specify packages
|
||||||
|
defaultDiagnostics = ["eslint_d"];
|
||||||
|
diagnostics = {
|
||||||
|
eslint_d = {
|
||||||
|
package = pkgs.nodePackages.eslint_d;
|
||||||
|
nullConfig = pkg: ''
|
||||||
|
table.insert(
|
||||||
|
ls_sources,
|
||||||
|
null_ls.builtins.diagnostics.eslint_d.with({
|
||||||
|
command = "${lib.getExe pkg}",
|
||||||
|
})
|
||||||
|
)
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
options.vim.languages.svelte = {
|
||||||
|
enable = mkEnableOption "Svelte language support";
|
||||||
|
|
||||||
|
treesitter = {
|
||||||
|
enable = mkEnableOption "Enable Svelte treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||||
|
|
||||||
|
sveltePackage = nvim.types.mkGrammarOption pkgs "svelte";
|
||||||
|
};
|
||||||
|
|
||||||
|
lsp = {
|
||||||
|
enable = mkEnableOption "Enable Svelte LSP support" // {default = config.vim.languages.enableLSP;};
|
||||||
|
|
||||||
|
server = mkOption {
|
||||||
|
description = "Svelte LSP server to use";
|
||||||
|
type = with types; enum (attrNames servers);
|
||||||
|
default = defaultServer;
|
||||||
|
};
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
description = "Svelte LSP server package";
|
||||||
|
type = types.package;
|
||||||
|
default = servers.${cfg.lsp.server}.package;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
format = {
|
||||||
|
enable = mkEnableOption "Enable Svelte formatting" // {default = config.vim.languages.enableFormat;};
|
||||||
|
|
||||||
|
type = mkOption {
|
||||||
|
description = "Svelte formatter to use";
|
||||||
|
type = with types; enum (attrNames formats);
|
||||||
|
default = defaultFormat;
|
||||||
|
};
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
description = "Svelte formatter package";
|
||||||
|
type = types.package;
|
||||||
|
default = formats.${cfg.format.type}.package;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
extraDiagnostics = {
|
||||||
|
enable = mkEnableOption "Enable extra Svelte diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
|
||||||
|
|
||||||
|
types = lib.nvim.types.diagnostics {
|
||||||
|
langDesc = "Svelte";
|
||||||
|
inherit diagnostics;
|
||||||
|
inherit defaultDiagnostics;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable (mkMerge [
|
||||||
|
(mkIf cfg.treesitter.enable {
|
||||||
|
vim.treesitter.enable = true;
|
||||||
|
vim.treesitter.grammars = [cfg.treesitter.sveltePackage];
|
||||||
|
})
|
||||||
|
|
||||||
|
(mkIf cfg.lsp.enable {
|
||||||
|
vim.lsp.lspconfig.enable = true;
|
||||||
|
vim.lsp.lspconfig.sources.svelte-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||||
|
})
|
||||||
|
|
||||||
|
(mkIf cfg.format.enable {
|
||||||
|
vim.lsp.null-ls.enable = true;
|
||||||
|
vim.lsp.null-ls.sources.svelte-format = formats.${cfg.format.type}.nullConfig;
|
||||||
|
})
|
||||||
|
|
||||||
|
(mkIf cfg.extraDiagnostics.enable {
|
||||||
|
vim.lsp.null-ls.enable = true;
|
||||||
|
vim.lsp.null-ls.sources = lib.nvim.languages.diagnosticsToLua {
|
||||||
|
lang = "svelte";
|
||||||
|
config = cfg.extraDiagnostics.types;
|
||||||
|
inherit diagnostics;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
}
|
|
@ -6,7 +6,7 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim.tidal = {
|
options.vim.tidal = {
|
||||||
enable = mkEnableOption "Enable tidalcycles tools and plugins";
|
enable = mkEnableOption "tidalcycles tools and plugins";
|
||||||
|
|
||||||
flash = mkOption {
|
flash = mkOption {
|
||||||
description = ''When sending a paragraph or a single line, vim-tidal will "flash" the selection for some milliseconds'';
|
description = ''When sending a paragraph or a single line, vim-tidal will "flash" the selection for some milliseconds'';
|
||||||
|
|
|
@ -36,18 +36,29 @@ with builtins; let
|
||||||
)
|
)
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
prettierd = {
|
||||||
|
package = pkgs.prettierd;
|
||||||
|
nullConfig = ''
|
||||||
|
table.insert(
|
||||||
|
ls_sources,
|
||||||
|
null_ls.builtins.formatting.prettier.with({
|
||||||
|
command = "${cfg.format.package}/bin/prettierd",
|
||||||
|
})
|
||||||
|
)
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# TODO: specify packages
|
# TODO: specify packages
|
||||||
defaultDiagnostics = ["eslint"];
|
defaultDiagnostics = ["eslint_d"];
|
||||||
diagnostics = {
|
diagnostics = {
|
||||||
eslint = {
|
eslint_d = {
|
||||||
package = pkgs.nodePackages.eslint;
|
package = pkgs.nodePackages.eslint_d;
|
||||||
nullConfig = pkg: ''
|
nullConfig = pkg: ''
|
||||||
table.insert(
|
table.insert(
|
||||||
ls_sources,
|
ls_sources,
|
||||||
null_ls.builtins.diagnostics.eslint.with({
|
null_ls.builtins.diagnostics.eslint_d.with({
|
||||||
command = "${pkg}/bin/eslint",
|
command = "${lib.getExe pkg}",
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
'';
|
'';
|
||||||
|
@ -58,26 +69,20 @@ in {
|
||||||
enable = mkEnableOption "Typescript/Javascript language support";
|
enable = mkEnableOption "Typescript/Javascript language support";
|
||||||
|
|
||||||
treesitter = {
|
treesitter = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "Enable Typescript/Javascript treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||||
description = "Enable Typescript/Javascript treesitter";
|
|
||||||
type = types.bool;
|
|
||||||
default = config.vim.languages.enableTreesitter;
|
|
||||||
};
|
|
||||||
tsPackage = nvim.types.mkGrammarOption pkgs "tsx";
|
tsPackage = nvim.types.mkGrammarOption pkgs "tsx";
|
||||||
jsPackage = nvim.types.mkGrammarOption pkgs "javascript";
|
jsPackage = nvim.types.mkGrammarOption pkgs "javascript";
|
||||||
};
|
};
|
||||||
|
|
||||||
lsp = {
|
lsp = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "Enable Typescript/Javascript LSP support" // {default = config.vim.languages.enableLSP;};
|
||||||
description = "Enable Typescript/Javascript LSP support";
|
|
||||||
type = types.bool;
|
|
||||||
default = config.vim.languages.enableLSP;
|
|
||||||
};
|
|
||||||
server = mkOption {
|
server = mkOption {
|
||||||
description = "Typescript/Javascript LSP server to use";
|
description = "Typescript/Javascript LSP server to use";
|
||||||
type = with types; enum (attrNames servers);
|
type = with types; enum (attrNames servers);
|
||||||
default = defaultServer;
|
default = defaultServer;
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
description = "Typescript/Javascript LSP server package";
|
description = "Typescript/Javascript LSP server package";
|
||||||
type = types.package;
|
type = types.package;
|
||||||
|
@ -86,16 +91,14 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
format = {
|
format = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "Enable Typescript/Javascript formatting" // {default = config.vim.languages.enableFormat;};
|
||||||
description = "Enable Typescript/Javascript formatting";
|
|
||||||
type = types.bool;
|
|
||||||
default = config.vim.languages.enableFormat;
|
|
||||||
};
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
description = "Typescript/Javascript formatter to use";
|
description = "Typescript/Javascript formatter to use";
|
||||||
type = with types; enum (attrNames formats);
|
type = with types; enum (attrNames formats);
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
description = "Typescript/Javascript formatter package";
|
description = "Typescript/Javascript formatter package";
|
||||||
type = types.package;
|
type = types.package;
|
||||||
|
@ -104,11 +107,8 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
extraDiagnostics = {
|
extraDiagnostics = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "Enable extra Typescript/Javascript diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
|
||||||
description = "Enable extra Typescript/Javascript diagnostics";
|
|
||||||
type = types.bool;
|
|
||||||
default = config.vim.languages.enableExtraDiagnostics;
|
|
||||||
};
|
|
||||||
types = lib.nvim.types.diagnostics {
|
types = lib.nvim.types.diagnostics {
|
||||||
langDesc = "Typescript/Javascript";
|
langDesc = "Typescript/Javascript";
|
||||||
inherit diagnostics;
|
inherit diagnostics;
|
||||||
|
|
|
@ -12,24 +12,19 @@ in {
|
||||||
enable = mkEnableOption "SQL language support";
|
enable = mkEnableOption "SQL language support";
|
||||||
|
|
||||||
treesitter = {
|
treesitter = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "Enable Zig treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||||
description = "Enable Zig treesitter";
|
|
||||||
type = types.bool;
|
|
||||||
default = config.vim.languages.enableTreesitter;
|
|
||||||
};
|
|
||||||
package = nvim.types.mkGrammarOption pkgs "zig";
|
package = nvim.types.mkGrammarOption pkgs "zig";
|
||||||
};
|
};
|
||||||
|
|
||||||
lsp = {
|
lsp = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "Zig LSP support (zls)" // {default = config.vim.languages.enableLSP;};
|
||||||
description = "Zig LSP support (zls)";
|
|
||||||
type = types.bool;
|
|
||||||
default = config.vim.languages.enableLSP;
|
|
||||||
};
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
description = "ZLS package";
|
description = "ZLS package";
|
||||||
type = types.package;
|
type = types.package;
|
||||||
default = pkgs.zls;
|
default = pkgs.zls;
|
||||||
};
|
};
|
||||||
|
|
||||||
zigPackage = mkOption {
|
zigPackage = mkOption {
|
||||||
description = "Zig package used by ZLS";
|
description = "Zig package used by ZLS";
|
||||||
type = types.package;
|
type = types.package;
|
||||||
|
|
|
@ -36,20 +36,49 @@ in {
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Enable formatting
|
-- Enable formatting
|
||||||
format_callback = function(client, bufnr)
|
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
|
||||||
group = augroup,
|
|
||||||
buffer = bufnr,
|
|
||||||
callback = function()
|
|
||||||
if vim.g.formatsave then
|
|
||||||
if client.supports_method("textDocument/formatting") then
|
|
||||||
local params = require'vim.lsp.util'.make_formatting_params({})
|
|
||||||
client.request('textDocument/formatting', params, nil, bufnr)
|
|
||||||
|
|
||||||
end
|
format_callback = function(client, bufnr)
|
||||||
end
|
if vim.g.formatsave then
|
||||||
|
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||||
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
|
group = augroup,
|
||||||
|
buffer = bufnr,
|
||||||
|
callback = function()
|
||||||
|
${
|
||||||
|
if config.vim.lsp.null-ls.enable
|
||||||
|
then ''
|
||||||
|
local function is_null_ls_formatting_enabled(bufnr)
|
||||||
|
local file_type = vim.api.nvim_buf_get_option(bufnr, "filetype")
|
||||||
|
local generators = require("null-ls.generators").get_available(
|
||||||
|
file_type,
|
||||||
|
require("null-ls.methods").internal.FORMATTING
|
||||||
|
)
|
||||||
|
return #generators > 0
|
||||||
end
|
end
|
||||||
})
|
|
||||||
|
if is_null_ls_formatting_enabled(bufnr) then
|
||||||
|
vim.lsp.buf.format({
|
||||||
|
bufnr = bufnr,
|
||||||
|
filter = function(client)
|
||||||
|
return client.name == "null-ls"
|
||||||
|
end
|
||||||
|
})
|
||||||
|
else
|
||||||
|
vim.lsp.buf.format({
|
||||||
|
bufnr = bufnr,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
''
|
||||||
|
else "
|
||||||
|
vim.lsp.buf.format({
|
||||||
|
bufnr = bufnr,
|
||||||
|
})
|
||||||
|
"
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
default_on_attach = function(client, bufnr)
|
default_on_attach = function(client, bufnr)
|
||||||
|
|
|
@ -6,41 +6,35 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.lsp;
|
cfg = config.vim.lsp;
|
||||||
|
self = import ./lspsaga.nix {inherit lib;};
|
||||||
|
|
||||||
|
mappingDefinitions = self.options.vim.lsp.lspsaga.mappings;
|
||||||
|
mappings = addDescriptionsToMappings cfg.lspsaga.mappings mappingDefinitions;
|
||||||
in {
|
in {
|
||||||
config = mkIf (cfg.enable && cfg.lspsaga.enable) {
|
config = mkIf (cfg.enable && cfg.lspsaga.enable) {
|
||||||
vim.startPlugins = ["lspsaga"];
|
vim.startPlugins = ["lspsaga"];
|
||||||
|
|
||||||
vim.vnoremap = {
|
vim.maps.visual = mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').range_code_action";
|
||||||
"<silent><leader>ca" = ":<C-U>lua require('lspsaga.codeaction').range_code_action()<CR>";
|
|
||||||
};
|
|
||||||
|
|
||||||
vim.nnoremap =
|
vim.maps.normal = mkMerge [
|
||||||
{
|
(mkSetLuaBinding mappings.lspFinder "require('lspsaga.provider').lsp_finder")
|
||||||
"<silent><leader>lf" = "<cmd>lua require'lspsaga.provider'.lsp_finder()<CR>";
|
(mkSetLuaBinding mappings.renderHoveredDoc "require('lspsaga.hover').render_hover_doc")
|
||||||
"<silent><leader>lh" = "<cmd>lua require('lspsaga.hover').render_hover_doc()<CR>";
|
|
||||||
"<silent><C-f>" = "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(1)<CR>";
|
(mkSetLuaBinding mappings.smartScrollUp "function() require('lspsaga.action').smart_scroll_with_saga(-1) end")
|
||||||
"<silent><C-b>" = "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(-1)<CR>";
|
(mkSetLuaBinding mappings.smartScrollDown "function() require('lspsaga.action').smart_scroll_with_saga(1) end")
|
||||||
"<silent><leader>lr" = "<cmd>lua require'lspsaga.rename'.rename()<CR>";
|
|
||||||
"<silent><leader>ld" = "<cmd>lua require'lspsaga.provider'.preview_definition()<CR>";
|
(mkSetLuaBinding mappings.rename "require('lspsaga.rename').rename")
|
||||||
"<silent><leader>ll" = "<cmd>lua require'lspsaga.diagnostic'.show_line_diagnostics()<CR>";
|
(mkSetLuaBinding mappings.previewDefinition "require('lspsaga.provider').preview_definition")
|
||||||
"<silent><leader>lc" = "<cmd>lua require'lspsaga.diagnostic'.show_cursor_diagnostics()<CR>";
|
|
||||||
"<silent><leader>lp" = "<cmd>lua require'lspsaga.diagnostic'.lsp_jump_diagnostic_prev()<CR>";
|
(mkSetLuaBinding mappings.showLineDiagnostics "require('lspsaga.diagnostic').show_line_diagnostics")
|
||||||
"<silent><leader>ln" = "<cmd>lua require'lspsaga.diagnostic'.lsp_jump_diagnostic_next()<CR>";
|
(mkSetLuaBinding mappings.showCursorDiagnostics "require('lspsaga.diagnostic').show_cursor_diagnostics")
|
||||||
}
|
|
||||||
// (
|
(mkSetLuaBinding mappings.nextDiagnostic "require('lspsaga.diagnostic').navigate('next')")
|
||||||
if (!cfg.nvimCodeActionMenu.enable)
|
(mkSetLuaBinding mappings.previousDiagnostic "require('lspsaga.diagnostic').navigate('prev')")
|
||||||
then {
|
|
||||||
"<silent><leader>ca" = "<cmd>lua require('lspsaga.codeaction').code_action()<CR>";
|
(mkIf (!cfg.nvimCodeActionMenu.enable) (mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').code_action"))
|
||||||
}
|
(mkIf (!cfg.lspSignature.enable) (mkSetLuaBinding mappings.signatureHelp "require('lspsaga.signaturehelp').signature_help"))
|
||||||
else {}
|
];
|
||||||
)
|
|
||||||
// (
|
|
||||||
if (!cfg.lspSignature.enable)
|
|
||||||
then {
|
|
||||||
"<silent><leader>ls" = "<cmd>lua require('lspsaga.signaturehelp').signature_help()<CR>";
|
|
||||||
}
|
|
||||||
else {}
|
|
||||||
);
|
|
||||||
|
|
||||||
vim.luaConfigRC.lspsage = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.lspsage = nvim.dag.entryAnywhere ''
|
||||||
-- Enable lspsaga
|
-- Enable lspsaga
|
||||||
|
|
|
@ -1,53 +1,28 @@
|
||||||
{
|
{lib, ...}:
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; {
|
||||||
cfg = config.vim.lsp;
|
options.vim.lsp.lspsaga = {
|
||||||
in {
|
enable = mkEnableOption "LSP Saga";
|
||||||
options.vim.lsp = {lspsaga = {enable = mkEnableOption "LSP Saga";};};
|
|
||||||
|
|
||||||
config = mkIf (cfg.enable && cfg.lspsaga.enable) {
|
mappings = {
|
||||||
vim.startPlugins = ["lspsaga"];
|
lspFinder = mkMappingOption "LSP Finder [LSPSaga]" "<leader>lf";
|
||||||
|
renderHoveredDoc = mkMappingOption "Rendered hovered docs [LSPSaga]" "<leader>lh";
|
||||||
|
|
||||||
vim.vnoremap = {
|
smartScrollUp = mkMappingOption "Smart scroll up [LSPSaga]" "<C-f>";
|
||||||
"<silent><leader>ca" = ":<C-U>lua require('lspsaga.codeaction').range_code_action()<CR>";
|
smartScrollDown = mkMappingOption "Smart scroll up [LSPSaga]" "<C-b>";
|
||||||
|
|
||||||
|
rename = mkMappingOption "Rename [LSPSaga]" "<leader>lr";
|
||||||
|
previewDefinition = mkMappingOption "Preview definition [LSPSaga]" "<leader>ld";
|
||||||
|
|
||||||
|
showLineDiagnostics = mkMappingOption "Show line diagnostics [LSPSaga]" "<leader>ll";
|
||||||
|
showCursorDiagnostics = mkMappingOption "Show cursor diagnostics [LSPSaga]" "<leader>lc";
|
||||||
|
|
||||||
|
nextDiagnostic = mkMappingOption "Next diagnostic [LSPSaga]" "<leader>ln";
|
||||||
|
previousDiagnostic = mkMappingOption "Previous diagnostic [LSPSaga]" "<leader>lp";
|
||||||
|
|
||||||
|
codeAction = mkMappingOption "Code action [LSPSaga]" "<leader>ca";
|
||||||
|
|
||||||
|
signatureHelp = mkMappingOption "Signature help [LSPSaga]" "<ledaer>ls";
|
||||||
};
|
};
|
||||||
|
|
||||||
vim.nnoremap =
|
|
||||||
{
|
|
||||||
"<silent><leader>lf" = "<cmd>lua require'lspsaga.provider'.lsp_finder()<CR>";
|
|
||||||
"<silent><leader>lh" = "<cmd>lua require('lspsaga.hover').render_hover_doc()<CR>";
|
|
||||||
"<silent><C-f>" = "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(1)<CR>";
|
|
||||||
"<silent><C-b>" = "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(-1)<CR>";
|
|
||||||
"<silent><leader>lr" = "<cmd>lua require'lspsaga.rename'.rename()<CR>";
|
|
||||||
"<silent><leader>ld" = "<cmd>lua require'lspsaga.provider'.preview_definition()<CR>";
|
|
||||||
"<silent><leader>ll" = "<cmd>lua require'lspsaga.diagnostic'.show_line_diagnostics()<CR>";
|
|
||||||
"<silent><leader>lc" = "<cmd>lua require'lspsaga.diagnostic'.show_cursor_diagnostics()<CR>";
|
|
||||||
"<silent><leader>lp" = "<cmd>lua require'lspsaga.diagnostic'.lsp_jump_diagnostic_prev()<CR>";
|
|
||||||
"<silent><leader>ln" = "<cmd>lua require'lspsaga.diagnostic'.lsp_jump_diagnostic_next()<CR>";
|
|
||||||
}
|
|
||||||
// (
|
|
||||||
if (!cfg.nvimCodeActionMenu.enable)
|
|
||||||
then {
|
|
||||||
"<silent><leader>ca" = "<cmd>lua require('lspsaga.codeaction').code_action()<CR>";
|
|
||||||
}
|
|
||||||
else {}
|
|
||||||
)
|
|
||||||
// (
|
|
||||||
if (!cfg.lspSignature.enable)
|
|
||||||
then {
|
|
||||||
"<silent><leader>ls" = "<cmd>lua require('lspsaga.signaturehelp').signature_help()<CR>";
|
|
||||||
}
|
|
||||||
else {}
|
|
||||||
);
|
|
||||||
|
|
||||||
vim.luaConfigRC.lspsage = nvim.dag.entryAnywhere ''
|
|
||||||
-- Enable lspsaga
|
|
||||||
local saga = require 'lspsaga'
|
|
||||||
saga.init_lsp_saga()
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,15 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.lsp;
|
cfg = config.vim.lsp;
|
||||||
|
|
||||||
|
self = import ./nvim-code-action-menu.nix {inherit lib;};
|
||||||
|
|
||||||
|
mappingDefinitions = self.options.vim.lsp.nvimCodeActionMenu.mappings;
|
||||||
|
mappings = addDescriptionsToMappings cfg.nvimCodeActionMenu.mappings mappingDefinitions;
|
||||||
in {
|
in {
|
||||||
config = mkIf (cfg.enable && cfg.nvimCodeActionMenu.enable) {
|
config = mkIf (cfg.enable && cfg.nvimCodeActionMenu.enable) {
|
||||||
vim.startPlugins = ["nvim-code-action-menu"];
|
vim.startPlugins = ["nvim-code-action-menu"];
|
||||||
|
|
||||||
vim.nnoremap = {
|
vim.maps.normal = mkSetBinding mappings.open ":CodeActionMenu<CR>";
|
||||||
"<silent><leader>ca" = ":CodeActionMenu<CR>";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
{
|
{lib, ...}:
|
||||||
config,
|
with lib; {
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
|
||||||
with builtins; {
|
|
||||||
options.vim.lsp = {
|
options.vim.lsp = {
|
||||||
nvimCodeActionMenu = {
|
nvimCodeActionMenu = {
|
||||||
enable = mkEnableOption "Enable nvim code action menu";
|
enable = mkEnableOption "Enable nvim code action menu";
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
open = mkMappingOption "Open code action menu [nvim-code-action-menu]" "<leader>ca";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,18 +6,23 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.lsp;
|
cfg = config.vim.lsp;
|
||||||
|
|
||||||
|
self = import ./trouble.nix {inherit lib;};
|
||||||
|
|
||||||
|
mappingDefinitions = self.options.vim.lsp.trouble.mappings;
|
||||||
|
mappings = addDescriptionsToMappings cfg.trouble.mappings mappingDefinitions;
|
||||||
in {
|
in {
|
||||||
config = mkIf (cfg.enable && cfg.trouble.enable) {
|
config = mkIf (cfg.enable && cfg.trouble.enable) {
|
||||||
vim.startPlugins = ["trouble"];
|
vim.startPlugins = ["trouble"];
|
||||||
|
|
||||||
vim.nnoremap = {
|
vim.maps.normal = mkMerge [
|
||||||
"<leader>xx" = "<cmd>TroubleToggle<CR>";
|
(mkSetBinding mappings.toggle "<cmd>TroubleToggle<CR>")
|
||||||
"<leader>lwd" = "<cmd>TroubleToggle workspace_diagnostics<CR>";
|
(mkSetBinding mappings.workspaceDiagnostics "<cmd>TroubleToggle workspace_diagnostics<CR>")
|
||||||
"<leader>ld" = "<cmd>TroubleToggle document_diagnostics<CR>";
|
(mkSetBinding mappings.documentDiagnostics "<cmd>TroubleToggle document_diagnostics<CR>")
|
||||||
"<leader>lr" = "<cmd>TroubleToggle lsp_references<CR>";
|
(mkSetBinding mappings.lspReferences "<cmd>TroubleToggle lsp_references<CR>")
|
||||||
"<leader>xq" = "<cmd>TroubleToggle quickfix<CR>";
|
(mkSetBinding mappings.quickfix "<cmd>TroubleToggle quickfix<CR>")
|
||||||
"<leader>xl" = "<cmd>TroubleToggle loclist<CR>";
|
(mkSetBinding mappings.locList "<cmd>TroubleToggle loclist<CR>")
|
||||||
};
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.trouble = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.trouble = nvim.dag.entryAnywhere ''
|
||||||
-- Enable trouble diagnostics viewer
|
-- Enable trouble diagnostics viewer
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
{
|
{lib, ...}:
|
||||||
config,
|
with lib; {
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
|
||||||
with builtins; {
|
|
||||||
options.vim.lsp = {
|
options.vim.lsp = {
|
||||||
trouble = {
|
trouble = {
|
||||||
enable = mkEnableOption "Enable trouble diagnostics viewer";
|
enable = mkEnableOption "Enable trouble diagnostics viewer";
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
toggle = mkMappingOption "Toggle trouble [trouble]" "<leader>xx";
|
||||||
|
workspaceDiagnostics = mkMappingOption "Workspace diagnostics [trouble]" "<leader>lwd";
|
||||||
|
documentDiagnostics = mkMappingOption "Document diagnostics [trouble]" "<leader>ld";
|
||||||
|
lspReferences = mkMappingOption "LSP References [trouble]" "<leader>lr";
|
||||||
|
quickfix = mkMappingOption "QuickFix [trouble]" "<leader>xq";
|
||||||
|
locList = mkMappingOption "LOCList [trouble]" "<leader>xl";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
{
|
{lib, ...}:
|
||||||
config,
|
with lib; {
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
|
||||||
with builtins; {
|
|
||||||
options.vim.minimap.codewindow = {
|
options.vim.minimap.codewindow = {
|
||||||
enable = mkEnableOption "Enable codewindow plugin for minimap view";
|
enable = mkEnableOption "codewindow plugin for minimap view";
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
open = mkMappingOption "Open minimap [codewindow]" "<leader>mo";
|
||||||
|
close = mkMappingOption "Close minimap [codewindow]" "<leader>mc";
|
||||||
|
toggle = mkMappingOption "Toggle minimap [codewindow]" "<leader>mm";
|
||||||
|
toggleFocus = mkMappingOption "Toggle minimap focus [codewindow]" "<leader>mf";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,19 +6,29 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.minimap.codewindow;
|
cfg = config.vim.minimap.codewindow;
|
||||||
|
|
||||||
|
self = import ./codewindow.nix {inherit lib;};
|
||||||
|
|
||||||
|
mappingDefinitions = self.options.vim.minimap.codewindow.mappings;
|
||||||
|
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = [
|
vim.startPlugins = [
|
||||||
"codewindow-nvim"
|
"codewindow-nvim"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
vim.maps.normal = mkMerge [
|
||||||
|
(mkSetLuaBinding mappings.open "require('codewindow').open_minimap")
|
||||||
|
(mkSetLuaBinding mappings.close "require('codewindow').close_minimap")
|
||||||
|
(mkSetLuaBinding mappings.toggle "require('codewindow').toggle_minimap")
|
||||||
|
(mkSetLuaBinding mappings.toggleFocus "require('codewindow').toggle_focus")
|
||||||
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.codewindow = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.codewindow = nvim.dag.entryAnywhere ''
|
||||||
local codewindow = require('codewindow')
|
local codewindow = require('codewindow')
|
||||||
codewindow.setup({
|
codewindow.setup({
|
||||||
exclude_filetypes = { 'NvimTree', 'orgagenda'},
|
exclude_filetypes = { 'NvimTree', 'orgagenda'},
|
||||||
}
|
})
|
||||||
)
|
|
||||||
codewindow.apply_default_keybinds()
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,6 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim.minimap.minimap-vim = {
|
options.vim.minimap.minimap-vim = {
|
||||||
enable = mkEnableOption "Enable minimap-vim plugin for minimap view";
|
enable = mkEnableOption "minimap-vim plugin for minimap view";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
./comments
|
./comments
|
||||||
./projects
|
./projects
|
||||||
./languages
|
./languages
|
||||||
|
./debugger
|
||||||
];
|
];
|
||||||
|
|
||||||
pkgsModule = {config, ...}: {
|
pkgsModule = {config, ...}: {
|
||||||
|
|
|
@ -12,10 +12,10 @@ in {
|
||||||
"mind-nvim"
|
"mind-nvim"
|
||||||
];
|
];
|
||||||
|
|
||||||
vim.nnoremap = {
|
vim.maps.normal = {
|
||||||
"<leader>om" = ":MindOpenMain<CR>";
|
"<leader>om" = {action = ":MindOpenMain<CR>";};
|
||||||
"<leader>op" = ":MindOpenProject<CR>";
|
"<leader>op" = {action = ":MindOpenProject<CR>";};
|
||||||
"<leader>oc" = ":MindClose<CR>";
|
"<leader>oc" = {action = ":MindClose<CR>";};
|
||||||
};
|
};
|
||||||
|
|
||||||
vim.luaConfigRC.mind-nvim = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.mind-nvim = nvim.dag.entryAnywhere ''
|
||||||
|
|
|
@ -6,6 +6,6 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim.notes.mind-nvim = {
|
options.vim.notes.mind-nvim = {
|
||||||
enable = mkEnableOption "The power of trees at your fingertips. ";
|
enable = mkEnableOption "organizer tool for Neovim.";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim.notes = {
|
options.vim.notes = {
|
||||||
obsidian = {
|
obsidian = {
|
||||||
enable = mkEnableOption "Complementary neovim plugins for Obsidian editor";
|
enable = mkEnableOption "complementary neovim plugins for Obsidian editor";
|
||||||
dir = mkOption {
|
dir = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "~/my-vault";
|
default = "~/my-vault";
|
||||||
|
|
|
@ -6,15 +6,15 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim.notes.orgmode = {
|
options.vim.notes.orgmode = {
|
||||||
enable = mkEnableOption "Enable nvim-orgmode: Neovim plugin for Emac Orgmode. Get the best of both worlds";
|
enable = mkEnableOption "nvim-orgmode: Neovim plugin for Emac Orgmode. Get the best of both worlds";
|
||||||
orgAgendaFiles = mkOption {
|
orgAgendaFiles = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "{'~/Dropbox/org/*', '~/my-orgs/**/*'}";
|
default = "{'~/Documents/org/*', '~/my-orgs/**/*'}";
|
||||||
description = "List of org files to be used as agenda files.";
|
description = "List of org files to be used as agenda files.";
|
||||||
};
|
};
|
||||||
orgDefaultNotesFile = mkOption {
|
orgDefaultNotesFile = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "~/Dropbox/org/refile.org";
|
default = "~/Documents/org/refile.org";
|
||||||
description = "Default org file to be used for notes.";
|
description = "Default org file to be used for notes.";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,17 +7,19 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.notes.todo-comments;
|
cfg = config.vim.notes.todo-comments;
|
||||||
|
self = import ./todo-comments.nix {inherit lib;};
|
||||||
|
mappings = self.options.vim.notes.todo-comments.mappings;
|
||||||
in {
|
in {
|
||||||
config = mkIf (cfg.enable) {
|
config = mkIf (cfg.enable) {
|
||||||
vim.startPlugins = [
|
vim.startPlugins = [
|
||||||
"todo-comments"
|
"todo-comments"
|
||||||
];
|
];
|
||||||
|
|
||||||
vim.nnoremap = {
|
vim.maps.normal = mkMerge [
|
||||||
"<leader>tdq" = ":TodoQuickFix<CR>";
|
(mkBinding cfg.mappings.quickFix ":TodoQuickFix<CR>" mappings.quickFix.description)
|
||||||
"<leader>tds" = ":TodoTelescope<CR>";
|
(mkIf config.vim.telescope.enable (mkBinding cfg.mappings.telescope ":TodoTelescope<CR>" mappings.telescope.description))
|
||||||
"<leader>tdt" = ":TodoTrouble<CR>";
|
(mkIf config.vim.lsp.trouble.enable (mkBinding cfg.mappings.trouble ":TodoTrouble<CR>" mappings.trouble.description))
|
||||||
};
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.todo-comments = ''
|
vim.luaConfigRC.todo-comments = ''
|
||||||
require('todo-comments').setup {
|
require('todo-comments').setup {
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
{
|
{lib, ...}:
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim.notes.todo-comments = {
|
options.vim.notes.todo-comments = {
|
||||||
enable = mkEnableOption "Enable todo-comments";
|
enable = mkEnableOption "todo-comments: highlight and search for todo comments like TODO, HACK, BUG in your code base";
|
||||||
|
|
||||||
patterns = {
|
patterns = {
|
||||||
highlight = mkOption {
|
highlight = mkOption {
|
||||||
|
@ -21,5 +17,11 @@ with builtins; {
|
||||||
description = "ripgrep regex pattern used for searching comments";
|
description = "ripgrep regex pattern used for searching comments";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
quickFix = mkMappingOption "Open Todo-s in a quickfix list" "<leader>tdq";
|
||||||
|
telescope = mkMappingOption "Open Todo-s in telescope" "<leader>tds";
|
||||||
|
trouble = mkMappingOption "Open Todo-s in Trouble" "<leader>tdt";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,59 +4,48 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; {
|
with builtins; let
|
||||||
options.vim.projects.project-nvim = {
|
cfg = config.vim.projects.project-nvim;
|
||||||
enable = mkEnableOption "Enable project-nvim for project management";
|
in {
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
vim.startPlugins = [
|
||||||
|
"project-nvim"
|
||||||
|
];
|
||||||
|
|
||||||
manualMode = mkOption {
|
vim.luaConfigRC.project-nvim = nvim.dag.entryAnywhere ''
|
||||||
type = types.bool;
|
require('project_nvim').setup({
|
||||||
default = true;
|
manual_mode = ${boolToString cfg.manualMode},
|
||||||
description = "don't automatically change the root directory so the user has the option to manually do so using `:ProjectRoot` command";
|
detection_methods = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.detectionMethods)} },
|
||||||
};
|
|
||||||
|
|
||||||
# detection methods should accept one or more strings from a list
|
-- All the patterns used to detect root dir, when **"pattern"** is in
|
||||||
detectionMethods = mkOption {
|
-- detection_methods
|
||||||
type = types.listOf types.str;
|
patterns = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.patterns)} },
|
||||||
default = ["lsp" "pattern"];
|
|
||||||
description = "Detection methods to use";
|
|
||||||
};
|
|
||||||
|
|
||||||
# patterns
|
-- Table of lsp clients to ignore by name
|
||||||
patterns = mkOption {
|
-- eg: { "efm", ... }
|
||||||
type = types.listOf types.str;
|
ignore_lsp = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.lspIgnored)} },
|
||||||
default = [".git" "_darcs" ".hg" ".bzr" ".svn" "Makefile" "package.json" "flake.nix" "cargo.toml"];
|
|
||||||
description = "Patterns to use for pattern detection method";
|
|
||||||
};
|
|
||||||
|
|
||||||
# table of lsp servers to ignore by name
|
-- Don't calculate root dir on specific directories
|
||||||
lspIgnored = mkOption {
|
-- Ex: { "~/.cargo/*", ... }
|
||||||
type = types.listOf types.str;
|
exclude_dirs = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.excludeDirs)} },
|
||||||
default = [];
|
|
||||||
description = "LSP servers no ignore by name";
|
|
||||||
};
|
|
||||||
|
|
||||||
excludeDirs = mkOption {
|
-- Show hidden files in telescope
|
||||||
type = types.listOf types.str;
|
show_hidden = ${boolToString cfg.showHidden},
|
||||||
default = [];
|
|
||||||
description = "Directories to exclude from project root search";
|
|
||||||
};
|
|
||||||
|
|
||||||
showHidden = mkOption {
|
-- When set to false, you will get a message when project.nvim changes your
|
||||||
type = types.bool;
|
-- directory.
|
||||||
default = false;
|
silent_chdir = ${boolToString cfg.silentChdir},
|
||||||
description = "Show hidden files in telescope picker";
|
|
||||||
};
|
|
||||||
|
|
||||||
silentChdir = mkOption {
|
-- What scope to change the directory, valid options are
|
||||||
type = types.bool;
|
-- * global (default)
|
||||||
default = true;
|
-- * tab
|
||||||
description = "Silently change directory when changing project";
|
-- * win
|
||||||
};
|
scope_chdir = '${toString cfg.scopeChdir}',
|
||||||
|
|
||||||
scopeChdir = mkOption {
|
-- Path where project.nvim will store the project history for use in
|
||||||
type = types.enum ["global" "tab" "win"];
|
-- telescope
|
||||||
default = "global";
|
datapath = vim.fn.stdpath("data"),
|
||||||
description = "What scope to change the directory";
|
})
|
||||||
};
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,48 +4,59 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; {
|
||||||
cfg = config.vim.projects.project-nvim;
|
options.vim.projects.project-nvim = {
|
||||||
in {
|
enable = mkEnableOption "Enable project-nvim for project management";
|
||||||
config = mkIf cfg.enable {
|
|
||||||
vim.startPlugins = [
|
|
||||||
"project-nvim"
|
|
||||||
];
|
|
||||||
|
|
||||||
vim.luaConfigRC.project-nvim = nvim.dag.entryAnywhere ''
|
manualMode = mkOption {
|
||||||
require('project_nvim').setup({
|
type = types.bool;
|
||||||
manual_mode = ${boolToString cfg.manualMode},
|
default = true;
|
||||||
detection_methods = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.detectionMethods)} },
|
description = "don't automatically change the root directory so the user has the option to manually do so using `:ProjectRoot` command";
|
||||||
|
};
|
||||||
|
|
||||||
-- All the patterns used to detect root dir, when **"pattern"** is in
|
# detection methods should accept one or more strings from a list
|
||||||
-- detection_methods
|
detectionMethods = mkOption {
|
||||||
patterns = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.patterns)} },
|
type = types.listOf types.str;
|
||||||
|
default = ["lsp" "pattern"];
|
||||||
|
description = "Detection methods to use";
|
||||||
|
};
|
||||||
|
|
||||||
-- Table of lsp clients to ignore by name
|
# patterns
|
||||||
-- eg: { "efm", ... }
|
patterns = mkOption {
|
||||||
ignore_lsp = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.lspIgnored)} },
|
type = types.listOf types.str;
|
||||||
|
default = [".git" "_darcs" ".hg" ".bzr" ".svn" "Makefile" "package.json" "flake.nix" "cargo.toml"];
|
||||||
|
description = "Patterns to use for pattern detection method";
|
||||||
|
};
|
||||||
|
|
||||||
-- Don't calculate root dir on specific directories
|
# table of lsp servers to ignore by name
|
||||||
-- Ex: { "~/.cargo/*", ... }
|
lspIgnored = mkOption {
|
||||||
exclude_dirs = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.excludeDirs)} },
|
type = types.listOf types.str;
|
||||||
|
default = [];
|
||||||
|
description = "LSP servers no ignore by name";
|
||||||
|
};
|
||||||
|
|
||||||
-- Show hidden files in telescope
|
excludeDirs = mkOption {
|
||||||
show_hidden = ${boolToString cfg.showHidden},
|
type = types.listOf types.str;
|
||||||
|
default = [];
|
||||||
|
description = "Directories to exclude from project root search";
|
||||||
|
};
|
||||||
|
|
||||||
-- When set to false, you will get a message when project.nvim changes your
|
showHidden = mkOption {
|
||||||
-- directory.
|
type = types.bool;
|
||||||
silent_chdir = ${boolToString cfg.silentChdir},
|
default = false;
|
||||||
|
description = "Show hidden files in telescope picker";
|
||||||
|
};
|
||||||
|
|
||||||
-- What scope to change the directory, valid options are
|
silentChdir = mkOption {
|
||||||
-- * global (default)
|
type = types.bool;
|
||||||
-- * tab
|
default = true;
|
||||||
-- * win
|
description = "Silently change directory when changing project";
|
||||||
scope_chdir = '${toString cfg.scopeChdir}',
|
};
|
||||||
|
|
||||||
-- Path where project.nvim will store the project history for use in
|
scopeChdir = mkOption {
|
||||||
-- telescope
|
type = types.enum ["global" "tab" "win"];
|
||||||
datapath = vim.fn.stdpath("data"),
|
default = "global";
|
||||||
})
|
description = "What scope to change the directory";
|
||||||
'';
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim.presence.presence-nvim = {
|
options.vim.presence.presence-nvim = {
|
||||||
enable = mkEnableOption "Enable presence.nvim plugin for discord rich presence";
|
enable = mkEnableOption "presence.nvim plugin for discord rich presence";
|
||||||
|
|
||||||
image_text = mkOption {
|
image_text = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
|
@ -22,9 +22,10 @@ with builtins; {
|
||||||
|
|
||||||
client_id = mkOption {
|
client_id = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "859194972255989790";
|
default = "79327144129396737";
|
||||||
description = "Client ID of the application";
|
description = "Client ID of the application";
|
||||||
};
|
};
|
||||||
|
|
||||||
auto_update = mkOption {
|
auto_update = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
|
|
|
@ -15,13 +15,13 @@ in {
|
||||||
]
|
]
|
||||||
++ optionals (cfg.usePicker) ["dressing-nvim"];
|
++ optionals (cfg.usePicker) ["dressing-nvim"];
|
||||||
|
|
||||||
vim.nnoremap = {
|
vim.maps.normal = mkMerge [
|
||||||
"<leader>sl" = ":SessionManager load_session<CR>";
|
(mkBinding cfg.mappings.loadSession ":SessionManager load_session<CR>" "Load session")
|
||||||
"<leader>sd" = ":SessionManager delete_session<CR>";
|
(mkBinding cfg.mappings.deleteSession ":SessionManager delete_session<CR>" "Delete session")
|
||||||
"<leader>sc" = ":SessionManager save_current_session<CR>";
|
(mkBinding cfg.mappings.saveCurrentSession ":SessionManager save_current_session<CR>" "Save current session")
|
||||||
"<leader>slt" = ":SessionManager load_last_session<CR>";
|
(mkBinding cfg.mappings.loadLastSession ":SessionManager load_last_session<CR>" "Load last session")
|
||||||
# TODO: load_current_dir_session
|
# TODO: load_current_dir_session
|
||||||
};
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.nvim-session-manager = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.nvim-session-manager = nvim.dag.entryAnywhere ''
|
||||||
local Path = require('plenary.path')
|
local Path = require('plenary.path')
|
||||||
|
|
|
@ -6,7 +6,30 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim.session.nvim-session-manager = {
|
options.vim.session.nvim-session-manager = {
|
||||||
enable = mkEnableOption "Enable nvim-session-manager";
|
enable = mkEnableOption "nvim-session-manager: manage sessions like folders in VSCode";
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
loadSession = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
description = "Load session";
|
||||||
|
default = "<leader>sl";
|
||||||
|
};
|
||||||
|
deleteSession = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
description = "Delete session";
|
||||||
|
default = "<leader>sd";
|
||||||
|
};
|
||||||
|
saveCurrentSession = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
description = "Save current session";
|
||||||
|
default = "<leader>sc";
|
||||||
|
};
|
||||||
|
loadLastSession = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
description = "Load last session";
|
||||||
|
default = "<leader>slt";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
usePicker = mkOption {
|
usePicker = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
{
|
{lib, ...}:
|
||||||
config,
|
with lib; {
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
|
||||||
with builtins; {
|
|
||||||
options.vim.snippets.vsnip = {
|
options.vim.snippets.vsnip = {
|
||||||
enable = mkEnableOption "Enable vim-vsnip";
|
enable = mkEnableOption "vim-vsnip: snippet LSP/VSCode's format";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,13 +12,14 @@ in {
|
||||||
];
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.lualine = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.lualine = nvim.dag.entryAnywhere ''
|
||||||
require('lualine').setup {
|
local lualine = require('lualine')
|
||||||
|
lualine.setup {
|
||||||
options = {
|
options = {
|
||||||
icons_enabled = ${boolToString cfg.icons.enable},
|
icons_enabled = ${boolToString cfg.icons.enable},
|
||||||
theme = "${cfg.theme}",
|
theme = "${cfg.theme}",
|
||||||
component_separators = {"${cfg.componentSeparator.left}","${cfg.componentSeparator.right}"},
|
component_separators = {"${cfg.componentSeparator.left}","${cfg.componentSeparator.right}"},
|
||||||
section_separators = {"${cfg.sectionSeparator.left}","${cfg.sectionSeparator.right}"},
|
section_separators = {"${cfg.sectionSeparator.left}","${cfg.sectionSeparator.right}"},
|
||||||
disabled_filetypes = { 'alpha' }, -- 'NvimTree'
|
disabled_filetypes = { 'alpha' },
|
||||||
always_divide_middle = true,
|
always_divide_middle = true,
|
||||||
globalstatus = ${boolToString cfg.globalStatus},
|
globalstatus = ${boolToString cfg.globalStatus},
|
||||||
ignore_focus = {'NvimTree'},
|
ignore_focus = {'NvimTree'},
|
||||||
|
|
|
@ -6,16 +6,16 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
supported_themes = import ./supported_themes.nix;
|
supported_themes = import ./supported_themes.nix;
|
||||||
|
colorPuccin =
|
||||||
|
if config.vim.statusline.lualine.theme == "catppuccin"
|
||||||
|
then "#181825"
|
||||||
|
else "none";
|
||||||
in {
|
in {
|
||||||
options.vim.statusline.lualine = {
|
options.vim.statusline.lualine = {
|
||||||
enable = mkEnableOption "lualine";
|
enable = mkEnableOption "lualine statusline plugin";
|
||||||
|
|
||||||
icons = {
|
icons = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "icons for lualine" // {default = true;};
|
||||||
type = types.bool;
|
|
||||||
description = "Enable icons for lualine";
|
|
||||||
default = true;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
refresh = {
|
refresh = {
|
||||||
|
@ -123,8 +123,10 @@ in {
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"mode",
|
"mode",
|
||||||
|
icons_enabled = true,
|
||||||
separator = {
|
separator = {
|
||||||
left = '▎',
|
left = '▎',
|
||||||
|
right = ''
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -141,11 +143,11 @@ in {
|
||||||
colored = true,
|
colored = true,
|
||||||
icon_only = true,
|
icon_only = true,
|
||||||
icon = { align = 'left' },
|
icon = { align = 'left' },
|
||||||
color = {bg='none', fg='lavender'},
|
color = {bg='${colorPuccin}', fg='lavender'},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename",
|
"filename",
|
||||||
color = {bg='none'},
|
color = {bg='${colorPuccin}'},
|
||||||
symbols = {modified = '', readonly = ''},
|
symbols = {modified = '', readonly = ''},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -168,7 +170,7 @@ in {
|
||||||
},
|
},
|
||||||
symbols = {added = '+', modified = '~', removed = '-'}, -- Changes the diff symbols
|
symbols = {added = '+', modified = '~', removed = '-'}, -- Changes the diff symbols
|
||||||
color = {
|
color = {
|
||||||
bg='none',
|
bg='${colorPuccin}',
|
||||||
fg='lavender'
|
fg='lavender'
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -181,10 +183,34 @@ in {
|
||||||
description = "active config for: | A | B | C (X) | Y | Z |";
|
description = "active config for: | A | B | C (X) | Y | Z |";
|
||||||
default = ''
|
default = ''
|
||||||
{
|
{
|
||||||
|
{
|
||||||
|
-- Lsp server name .
|
||||||
|
function()
|
||||||
|
local msg = 'No Active Lsp'
|
||||||
|
local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype')
|
||||||
|
local clients = vim.lsp.get_active_clients()
|
||||||
|
if next(clients) == nil then
|
||||||
|
return msg
|
||||||
|
end
|
||||||
|
for _, client in ipairs(clients) do
|
||||||
|
local filetypes = client.config.filetypes
|
||||||
|
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
|
||||||
|
return client.name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return msg
|
||||||
|
end,
|
||||||
|
icon = ' ',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"diagnostics",
|
"diagnostics",
|
||||||
sources = {'nvim_lsp', 'nvim_diagnostic', 'coc'},
|
sources = {'nvim_lsp', 'nvim_diagnostic', 'coc'},
|
||||||
symbols = {error = ' ', warn = ' ', info = ' ', hint = ' '}
|
symbols = {error = ' ', warn = ' ', info = ' ', hint = ' '},
|
||||||
|
diagnostics_color = {
|
||||||
|
color_error = { fg = 'red' },
|
||||||
|
color_warn = { fg = 'yellow' },
|
||||||
|
color_info = { fg = 'cyan' },
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
@ -196,13 +222,15 @@ in {
|
||||||
default = ''
|
default = ''
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"fileformat",
|
'searchcount',
|
||||||
color = {bg='none', fg='lavender'},
|
maxcount = 999,
|
||||||
symbols = {
|
timeout = 120,
|
||||||
unix = '', -- e712
|
color = {bg='${colorPuccin}', fg='lavender'}
|
||||||
dos = '', -- e70f
|
},
|
||||||
mac = '', -- e711
|
{
|
||||||
},
|
"branch",
|
||||||
|
icon = ' •',
|
||||||
|
color = {bg='${colorPuccin}', fg='lavender'},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
@ -215,21 +243,21 @@ in {
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"progress",
|
"progress",
|
||||||
color = {bg='none', fg='lavender'},
|
separator = {
|
||||||
|
left = '',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"location",
|
"location",
|
||||||
color = {bg='none', fg='lavender'},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"branch",
|
"fileformat",
|
||||||
icon = ' •',
|
color = {fg='black'},
|
||||||
separator = {
|
symbols = {
|
||||||
left = '(',
|
unix = '', -- e712
|
||||||
right = ')'
|
dos = '', -- e70f
|
||||||
|
mac = '', -- e711
|
||||||
},
|
},
|
||||||
color = {bg='none', fg='lavender'},
|
|
||||||
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.tabline.nvimBufferline;
|
cfg = config.vim.tabline.nvimBufferline;
|
||||||
|
self = import ./nvim-bufferline.nix {
|
||||||
|
inherit lib;
|
||||||
|
};
|
||||||
|
mappings = self.options.vim.tabline.nvimBufferline.mappings;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable (
|
config = mkIf cfg.enable (
|
||||||
let
|
let
|
||||||
|
@ -23,25 +27,18 @@ in {
|
||||||
"bufdelete-nvim"
|
"bufdelete-nvim"
|
||||||
];
|
];
|
||||||
|
|
||||||
vim.nnoremap = {
|
vim.maps.normal = mkMerge [
|
||||||
"<silent><leader>bn" = ":BufferLineCycleNext<CR>";
|
(mkLuaBinding cfg.mappings.closeCurrent "require(\"bufdelete\").bufdelete" mappings.closeCurrent.description)
|
||||||
"<silent><leader>bp" = ":BufferLineCyclePrev<CR>";
|
(mkBinding cfg.mappings.cycleNext ":BufferLineCycleNext<CR>" mappings.cycleNext.description)
|
||||||
"<silent><leader>bc" = ":BufferLinePick<CR>";
|
(mkBinding cfg.mappings.cycleNext ":BufferLineCycleNext<CR>" mappings.cycleNext.description)
|
||||||
"<silent><leader>bse" = ":BufferLineSortByExtension<CR>";
|
(mkBinding cfg.mappings.cyclePrevious ":BufferLineCyclePrev<CR>" mappings.cyclePrevious.description)
|
||||||
"<silent><leader>bsd" = ":BufferLineSortByDirectory<CR>";
|
(mkBinding cfg.mappings.pick ":BufferLinePick<CR>" mappings.pick.description)
|
||||||
"<silent><leader>bsi" = ":lua require'bufferline'.sort_buffers_by(function (buf_a, buf_b) return buf_a.id < buf_b.id end)<CR>";
|
(mkBinding cfg.mappings.sortByExtension ":BufferLineSortByExtension<CR>" mappings.sortByExtension.description)
|
||||||
"<silent><leader>bmn" = ":BufferLineMoveNext<CR>";
|
(mkBinding cfg.mappings.sortByDirectory ":BufferLineSortByDirectory<CR>" mappings.sortByDirectory.description)
|
||||||
"<silent><leader>bmp" = ":BufferLineMovePrev<CR>";
|
(mkLuaBinding cfg.mappings.sortById "function() require(\"bufferline\").sort_buffers_by(function (buf_a, buf_b) return buf_a.id < buf_b.id end) end" mappings.sortById.description)
|
||||||
"<silent><leader>b1" = "<Cmd>BufferLineGoToBuffer 1<CR>";
|
(mkBinding cfg.mappings.moveNext ":BufferLineMoveNext<CR>" mappings.moveNext.description)
|
||||||
"<silent><leader>b2" = "<Cmd>BufferLineGoToBuffer 2<CR>";
|
(mkBinding cfg.mappings.movePrevious ":BufferLineMovePrev<CR>" mappings.movePrevious.description)
|
||||||
"<silent><leader>b3" = "<Cmd>BufferLineGoToBuffer 3<CR>";
|
];
|
||||||
"<silent><leader>b4" = "<Cmd>BufferLineGoToBuffer 4<CR>";
|
|
||||||
"<silent><leader>b5" = "<Cmd>BufferLineGoToBuffer 5<CR>";
|
|
||||||
"<silent><leader>b6" = "<Cmd>BufferLineGoToBuffer 6<CR>";
|
|
||||||
"<silent><leader>b7" = "<Cmd>BufferLineGoToBuffer 7<CR>";
|
|
||||||
"<silent><leader>b8" = "<Cmd>BufferLineGoToBuffer 8<CR>";
|
|
||||||
"<silent><leader>b9" = "<Cmd>BufferLineGoToBuffer 9<CR>";
|
|
||||||
};
|
|
||||||
|
|
||||||
vim.luaConfigRC.nvimBufferline = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.nvimBufferline = nvim.dag.entryAnywhere ''
|
||||||
require("bufferline").setup{
|
require("bufferline").setup{
|
||||||
|
@ -51,10 +48,10 @@ in {
|
||||||
close_command = ${mouse.close},
|
close_command = ${mouse.close},
|
||||||
right_mouse_command = ${mouse.right},
|
right_mouse_command = ${mouse.right},
|
||||||
indicator = {
|
indicator = {
|
||||||
style = 'underline',
|
style = 'icon',
|
||||||
-- indicator_icon = '▎',
|
indicator_icon = '▎',
|
||||||
},
|
},
|
||||||
buffer_close_icon = '',
|
buffer_close_icon = '',
|
||||||
modified_icon = '●',
|
modified_icon = '●',
|
||||||
close_icon = '',
|
close_icon = '',
|
||||||
left_trunc_marker = '',
|
left_trunc_marker = '',
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
{
|
{lib, ...}:
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim.tabline.nvimBufferline = {
|
options.vim.tabline.nvimBufferline = {
|
||||||
enable = mkEnableOption "Enable nvim-bufferline-lua as a bufferline";
|
enable = mkEnableOption "nvim-bufferline-lua as a bufferline";
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
closeCurrent = mkMappingOption "Close buffer" null;
|
||||||
|
cycleNext = mkMappingOption "Next buffer" "<leader>bn";
|
||||||
|
cyclePrevious = mkMappingOption "Previous buffer" "<leader>bp";
|
||||||
|
pick = mkMappingOption "Pick buffer" "<leader>bc";
|
||||||
|
sortByExtension = mkMappingOption "Sort buffers by extension" "<leader>bse";
|
||||||
|
sortByDirectory = mkMappingOption "Sort buffers by directory" "<leader>bsd";
|
||||||
|
sortById = mkMappingOption "Sort buffers by ID" "<leader>bsi";
|
||||||
|
moveNext = mkMappingOption "Move next buffer" "<leader>bmn";
|
||||||
|
movePrevious = mkMappingOption "Move previous buffer" "<leader>bmp";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.terminal.toggleterm;
|
cfg = config.vim.terminal.toggleterm;
|
||||||
toggleKey = "<c-t>";
|
|
||||||
in {
|
in {
|
||||||
config = mkMerge [
|
config = mkMerge [
|
||||||
(
|
(
|
||||||
|
@ -15,9 +14,11 @@ in {
|
||||||
"toggleterm-nvim"
|
"toggleterm-nvim"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
vim.maps.normal = mkBinding cfg.mappings.open "<Cmd>execute v:count . \"ToggleTerm\"<CR>" "Toggle terminal";
|
||||||
|
|
||||||
vim.luaConfigRC.toggleterm = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.toggleterm = nvim.dag.entryAnywhere ''
|
||||||
require("toggleterm").setup({
|
require("toggleterm").setup({
|
||||||
open_mapping = [[${toggleKey}]],
|
open_mapping = null,
|
||||||
direction = '${toString cfg.direction}',
|
direction = '${toString cfg.direction}',
|
||||||
-- TODO: this should probably be turned into a module that uses the lua function if and only if the user has not set it
|
-- TODO: this should probably be turned into a module that uses the lua function if and only if the user has not set it
|
||||||
size = function(term)
|
size = function(term)
|
||||||
|
@ -55,11 +56,10 @@ in {
|
||||||
hidden = true,
|
hidden = true,
|
||||||
on_open = function(term)
|
on_open = function(term)
|
||||||
vim.cmd("startinsert!")
|
vim.cmd("startinsert!")
|
||||||
vim.keymap.set( 't', [[${toggleKey}]], function() term:toggle() end, {silent = true, noremap = true, buffer = term.bufnr})
|
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.keymap.set( 'n', [[<leader>gg]], function() lazygit:toggle() end, {silent = true, noremap = true})
|
vim.keymap.set('n', ${toJSON cfg.lazygit.mappings.open}, function() lazygit:toggle() end, {silent = true, noremap = true, desc = 'Open lazygit [toggleterm]'})
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -8,28 +8,43 @@ with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim.terminal.toggleterm = {
|
options.vim.terminal.toggleterm = {
|
||||||
enable = mkEnableOption "Enable toggleterm as a replacement to built-in terminal command";
|
enable = mkEnableOption "Enable toggleterm as a replacement to built-in terminal command";
|
||||||
|
mappings = {
|
||||||
|
open = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
description = "The keymapping to open toggleterm";
|
||||||
|
default = "<c-t>";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
direction = mkOption {
|
direction = mkOption {
|
||||||
type = types.enum ["horizontal" "vertical" "tab" "float"];
|
type = types.enum ["horizontal" "vertical" "tab" "float"];
|
||||||
default = "horizontal";
|
default = "horizontal";
|
||||||
description = "Direction of the terminal";
|
description = "Direction of the terminal";
|
||||||
};
|
};
|
||||||
|
|
||||||
enable_winbar = mkOption {
|
enable_winbar = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = "Enable winbar";
|
description = "Enable winbar";
|
||||||
};
|
};
|
||||||
|
|
||||||
lazygit = {
|
lazygit = {
|
||||||
enable = mkEnableOption "Enable LazyGit integration";
|
enable = mkEnableOption "LazyGit integration";
|
||||||
direction = mkOption {
|
direction = mkOption {
|
||||||
type = types.enum ["horizontal" "vertical" "tab" "float"];
|
type = types.enum ["horizontal" "vertical" "tab" "float"];
|
||||||
default = "float";
|
default = "float";
|
||||||
description = "Direction of the lazygit window";
|
description = "Direction of the lazygit window";
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
type = with types; nullOr package;
|
type = with types; nullOr package;
|
||||||
default = pkgs.lazygit;
|
default = pkgs.lazygit;
|
||||||
description = "The package that should be used for lazygit. Setting it to null will attempt to use lazygit from your PATH";
|
description = "The package that should be used for lazygit. Setting it to null will attempt to use lazygit from your PATH";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
open = mkMappingOption "Open lazygit [toggleterm]" "<leader>gg";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
integrations = {
|
integrations = {
|
||||||
nvimtree = {
|
nvimtree = {
|
||||||
enabled = true,
|
enabled = true,
|
||||||
transparent_panel = false,
|
transparent_panel = ${lib.boolToString transparent},
|
||||||
show_root = true,
|
show_root = true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -51,6 +51,13 @@
|
||||||
telescope = true,
|
telescope = true,
|
||||||
treesitter = true,
|
treesitter = true,
|
||||||
ts_rainbow = true,
|
ts_rainbow = true,
|
||||||
|
fidget = true,
|
||||||
|
alpha = true,
|
||||||
|
leap = true,
|
||||||
|
markdown = true,
|
||||||
|
noice = true,
|
||||||
|
notify = true, -- nvim-notify
|
||||||
|
which_key = true
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
-- setup must be called before loading
|
-- setup must be called before loading
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{
|
{
|
||||||
pkgs,
|
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
|
@ -8,6 +7,11 @@ with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.treesitter;
|
cfg = config.vim.treesitter;
|
||||||
usingNvimCmp = config.vim.autocomplete.enable && config.vim.autocomplete.type == "nvim-cmp";
|
usingNvimCmp = config.vim.autocomplete.enable && config.vim.autocomplete.type == "nvim-cmp";
|
||||||
|
|
||||||
|
self = import ./treesitter.nix {inherit lib;};
|
||||||
|
|
||||||
|
mappingDefinitions = self.options.vim.treesitter.mappings;
|
||||||
|
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins =
|
vim.startPlugins =
|
||||||
|
@ -16,6 +20,16 @@ in {
|
||||||
|
|
||||||
vim.autocomplete.sources = {"treesitter" = "[Treesitter]";};
|
vim.autocomplete.sources = {"treesitter" = "[Treesitter]";};
|
||||||
|
|
||||||
|
# For some reason, using mkSetLuaBinding and putting the lua code does not work. It just selects the whole file.
|
||||||
|
# This works though, and if it ain't broke, don't fix it.
|
||||||
|
vim.maps.normal = mkSetBinding mappings.incrementalSelection.init ":lua require('nvim-treesitter.incremental_selection').init_selection()<CR>";
|
||||||
|
|
||||||
|
vim.maps.visualOnly = mkMerge [
|
||||||
|
(mkSetBinding mappings.incrementalSelection.incrementByNode ":lua require('nvim-treesitter.incremental_selection').node_incremental()<CR>")
|
||||||
|
(mkSetBinding mappings.incrementalSelection.incrementByScope ":lua require('nvim-treesitter.incremental_selection').scope_incremental()<CR>")
|
||||||
|
(mkSetBinding mappings.incrementalSelection.decrementByNode ":lua require('nvim-treesitter.incremental_selection').node_decremental()<CR>")
|
||||||
|
];
|
||||||
|
|
||||||
# For some reason treesitter highlighting does not work on start if this is set before syntax on
|
# For some reason treesitter highlighting does not work on start if this is set before syntax on
|
||||||
vim.configRC.treesitter-fold = mkIf cfg.fold (nvim.dag.entryBefore ["basic"] ''
|
vim.configRC.treesitter-fold = mkIf cfg.fold (nvim.dag.entryBefore ["basic"] ''
|
||||||
set foldmethod=expr
|
set foldmethod=expr
|
||||||
|
@ -36,10 +50,10 @@ in {
|
||||||
incremental_selection = {
|
incremental_selection = {
|
||||||
enable = true,
|
enable = true,
|
||||||
keymaps = {
|
keymaps = {
|
||||||
init_selection = "gnn",
|
init_selection = false,
|
||||||
node_incremental = "grn",
|
node_incremental = false,
|
||||||
scope_incremental = "grc",
|
scope_incremental = false,
|
||||||
node_decremental = "grm",
|
node_decremental = false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,5 @@
|
||||||
{
|
{lib, ...}:
|
||||||
pkgs,
|
with lib; {
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
|
||||||
with builtins; let
|
|
||||||
cfg = config.vim.treesitter;
|
|
||||||
usingNvimCmp = config.vim.autocomplete.enable && config.vim.autocomplete.type == "nvim-cmp";
|
|
||||||
in {
|
|
||||||
options.vim.treesitter = {
|
options.vim.treesitter = {
|
||||||
enable = mkEnableOption "treesitter, also enabled automatically through language options";
|
enable = mkEnableOption "treesitter, also enabled automatically through language options";
|
||||||
|
|
||||||
|
@ -16,13 +7,21 @@ in {
|
||||||
|
|
||||||
autotagHtml = mkEnableOption "autoclose and rename html tag";
|
autotagHtml = mkEnableOption "autoclose and rename html tag";
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
incrementalSelection = {
|
||||||
|
init = mkMappingOption "Init selection [treesitter]" "gnn";
|
||||||
|
incrementByNode = mkMappingOption "Increment selection by node [treesitter]" "grn";
|
||||||
|
incrementByScope = mkMappingOption "Increment selection by scope [treesitter]" "grc";
|
||||||
|
decrementByNode = mkMappingOption "Decrement selection by node [treesitter]" "grm";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
grammars = mkOption {
|
grammars = mkOption {
|
||||||
type = with types; listOf package;
|
type = with types; listOf package;
|
||||||
default = [];
|
default = [];
|
||||||
description = nvim.nmd.asciiDoc ''
|
description = nvim.nmd.asciiDoc ''
|
||||||
List of treesitter grammars to install. For supported languages
|
List of treesitter grammars to install. For supported languages
|
||||||
use the `vim.language.<lang>.treesitter` option
|
use the `vim.language.<lang>.treesitter` option
|
||||||
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
67
modules/ui/colorizer/colorizer.nix
Normal file
67
modules/ui/colorizer/colorizer.nix
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
with lib;
|
||||||
|
with builtins; {
|
||||||
|
options.vim.ui.colorizer = {
|
||||||
|
enable = mkEnableOption "nvim-colorizer.lua for color highlighting";
|
||||||
|
|
||||||
|
options = {
|
||||||
|
rgb = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = "#RGB hex codes";
|
||||||
|
};
|
||||||
|
|
||||||
|
rrggbb = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = "#RRGGBB hex codes";
|
||||||
|
};
|
||||||
|
|
||||||
|
names = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = ''"Name" codes such as "Blue"'';
|
||||||
|
};
|
||||||
|
|
||||||
|
rgb_fn = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "CSS rgb() and rgba() functions";
|
||||||
|
};
|
||||||
|
|
||||||
|
rrggbbaa = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "#RRGGBBAA hex codes";
|
||||||
|
};
|
||||||
|
|
||||||
|
hsl_fn = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "CSS hsl() and hsla() functions";
|
||||||
|
};
|
||||||
|
|
||||||
|
css = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = "Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB";
|
||||||
|
};
|
||||||
|
|
||||||
|
css_fn = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "Enable all CSS *functions*: rgb_fn, hsl_fn";
|
||||||
|
};
|
||||||
|
|
||||||
|
mode = mkOption {
|
||||||
|
type = types.enum ["foreground" "background"];
|
||||||
|
default = "background";
|
||||||
|
description = "Set the display mode";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
32
modules/ui/colorizer/config.nix
Normal file
32
modules/ui/colorizer/config.nix
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
with lib;
|
||||||
|
with builtins; let
|
||||||
|
cfg = config.vim.ui.colorizer;
|
||||||
|
in {
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
vim.startPlugins = [
|
||||||
|
"nvim-colorizer-lua"
|
||||||
|
];
|
||||||
|
|
||||||
|
vim.luaConfigRC.colorizer = nvim.dag.entryAnywhere ''
|
||||||
|
require('colorizer').setup({
|
||||||
|
DEFAULT_OPTIONS = {
|
||||||
|
RGB = ${boolToString cfg.options.rgb};
|
||||||
|
RRGGBB = ${boolToString cfg.options.rrggbb};
|
||||||
|
names = ${boolToString cfg.options.names};
|
||||||
|
RRGGBBAA = ${boolToString cfg.options.rrggbbaa};
|
||||||
|
rgb_fn = ${boolToString cfg.options.rgb_fn};
|
||||||
|
hsl_fn = ${boolToString cfg.options.hsl_fn};
|
||||||
|
css = ${boolToString cfg.options.css};
|
||||||
|
css_fn = ${boolToString cfg.options.css_fn};
|
||||||
|
mode = '${toString cfg.options.mode}';
|
||||||
|
}
|
||||||
|
})
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
|
@ -4,5 +4,7 @@ _: {
|
||||||
./modes
|
./modes
|
||||||
./notifications
|
./notifications
|
||||||
./smartcolumn
|
./smartcolumn
|
||||||
|
./colorizer
|
||||||
|
./illuminate
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
24
modules/ui/illuminate/config.nix
Normal file
24
modules/ui/illuminate/config.nix
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
with lib;
|
||||||
|
with builtins; let
|
||||||
|
cfg = config.vim.ui.illuminate;
|
||||||
|
in {
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
vim.startPlugins = ["vim-illuminate"];
|
||||||
|
|
||||||
|
vim.luaConfigRC.vim-illuminate = nvim.dag.entryAnywhere ''
|
||||||
|
require('illuminate').configure({
|
||||||
|
filetypes_denylist = {
|
||||||
|
'dirvish',
|
||||||
|
'fugitive',
|
||||||
|
'NvimTree',
|
||||||
|
'TelescopePrompt',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
6
modules/ui/illuminate/default.nix
Normal file
6
modules/ui/illuminate/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
_: {
|
||||||
|
imports = [
|
||||||
|
./config.nix
|
||||||
|
./illuminate.nix
|
||||||
|
];
|
||||||
|
}
|
11
modules/ui/illuminate/illuminate.nix
Normal file
11
modules/ui/illuminate/illuminate.nix
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
with lib;
|
||||||
|
with builtins; {
|
||||||
|
options.vim.ui.illuminate = {
|
||||||
|
enable = mkEnableOption "vim-illuminate: automatically highlight other uses of the word under the cursor";
|
||||||
|
};
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue