mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-07 17:15:58 +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.
|
||||
|
||||
## 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.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
|
|
14
.github/README.md
vendored
14
.github/README.md
vendored
|
@ -78,7 +78,7 @@ nix run github:notashelf/neovim-flake#tidal
|
|||
|
||||
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
|
||||
|
||||
|
@ -103,8 +103,8 @@ I am always looking for new ways to help improve this flake. If you would like t
|
|||
## Philosophy
|
||||
|
||||
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.
|
||||
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
|
||||
(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, 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).
|
||||
|
||||
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.
|
||||
<br/><br/>
|
||||
|
||||
**Q**: Can you add *X*?
|
||||
**Q**: Can you add _X_?
|
||||
<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
|
||||
|
||||
|
@ -140,6 +140,8 @@ Special thanks to
|
|||
|
||||
- [@fufexan](https://github.com/fufexan) - For the transition to flake-parts
|
||||
- [@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!
|
||||
|
||||
|
@ -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:
|
||||
|
||||
- [@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)
|
||||
- [@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)
|
||||
|
||||
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
|
||||
- name: Build neovim-flake with default settings
|
||||
run: nix build .#${{ matrix.package }} --print-build-logs
|
||||
- name: Upload doc artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: doc
|
||||
path: result/share/doc/neovim-flake/
|
||||
|
||||
|
||||
|
|
|
@ -39,6 +39,13 @@ inputs: let
|
|||
lspSignature.enable = true;
|
||||
};
|
||||
|
||||
vim.debugger = {
|
||||
nvim-dap = {
|
||||
enable = true;
|
||||
ui.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
vim.languages = {
|
||||
enableLSP = true;
|
||||
enableFormat = true;
|
||||
|
@ -54,6 +61,7 @@ inputs: let
|
|||
crates.enable = true;
|
||||
};
|
||||
ts.enable = isMaximal;
|
||||
svelte.enable = isMaximal;
|
||||
go.enable = isMaximal;
|
||||
zig.enable = isMaximal;
|
||||
python.enable = isMaximal;
|
||||
|
@ -108,6 +116,7 @@ inputs: let
|
|||
};
|
||||
view = {
|
||||
width = 25;
|
||||
cursorline = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -133,12 +142,12 @@ inputs: let
|
|||
|
||||
vim.minimap = {
|
||||
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 = {
|
||||
dashboard-nvim.enable = false;
|
||||
alpha.enable = true;
|
||||
alpha.enable = isMaximal;
|
||||
};
|
||||
|
||||
vim.notify = {
|
||||
|
@ -150,8 +159,10 @@ inputs: let
|
|||
};
|
||||
|
||||
vim.utility = {
|
||||
colorizer.enable = true;
|
||||
icon-picker.enable = true;
|
||||
ccc.enable = isMaximal;
|
||||
vim-wakatime.enable = isMaximal;
|
||||
icon-picker.enable = isMaximal;
|
||||
surround.enable = isMaximal;
|
||||
diffview-nvim.enable = true;
|
||||
motion = {
|
||||
hop.enable = true;
|
||||
|
@ -175,16 +186,27 @@ inputs: let
|
|||
|
||||
vim.ui = {
|
||||
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 = {
|
||||
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 = {
|
||||
nvim-session-manager.enable = true;
|
||||
nvim-session-manager.enable = isMaximal;
|
||||
};
|
||||
|
||||
vim.gestures = {
|
||||
|
@ -202,6 +224,7 @@ inputs: let
|
|||
image_text = "The Superior Text Editor";
|
||||
client_id = "793271441293967371";
|
||||
main_image = "neovim";
|
||||
show_time = true;
|
||||
rich_presence = {
|
||||
editing_text = "Editing %s";
|
||||
};
|
|
@ -16,11 +16,12 @@
|
|||
|
||||
</para>
|
||||
</preface>
|
||||
<xi:include href="try-it-out.xml"/>
|
||||
<xi:include href="default-configs.xml"/>
|
||||
<xi:include href="custom-configs.xml"/>
|
||||
<xi:include href="home-manager.xml"/>
|
||||
<xi:include href="languages.xml"/>
|
||||
<xi:include href="manual/try-it-out.xml"/>
|
||||
<xi:include href="manual/default-configs.xml"/>
|
||||
<xi:include href="manual/custom-configs.xml"/>
|
||||
<xi:include href="manual/custom-plugins.xml"/>
|
||||
<xi:include href="manual/home-manager.xml"/>
|
||||
<xi:include href="manual/languages.xml"/>
|
||||
<appendix xml:id="ch-options">
|
||||
<title>Configuration Options</title>
|
||||
<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]
|
||||
----
|
||||
$ 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.2.adoc[]
|
||||
include::rl-0.3.adoc[]
|
||||
include::rl-0.4.adoc[]
|
||||
|
|
|
@ -1,15 +1,73 @@
|
|||
[[sec-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]]
|
||||
=== 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 `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 = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
|
||||
# FIXME: zig compiler - therefore the maximal version - is broken on darwin
|
||||
# see https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/compilers/zig/0.10.nix#L70
|
||||
# "x86_64-darwin"
|
||||
# "aarch64-darwin"
|
||||
"x86_64-darwin"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
|
||||
imports = [
|
||||
|
@ -29,7 +26,7 @@
|
|||
flake = {
|
||||
lib = {
|
||||
inherit (import ./lib/stdlib-extended.nix nixpkgs.lib) nvim;
|
||||
inherit (import ./extra.nix inputs) neovimConfiguration;
|
||||
inherit (import ./configuration.nix inputs) neovimConfiguration;
|
||||
};
|
||||
|
||||
homeManagerModules = {
|
||||
|
@ -49,6 +46,7 @@
|
|||
...
|
||||
}: {
|
||||
devShells.default = pkgs.mkShell {nativeBuildInputs = [config.packages.nix];};
|
||||
formatter = pkgs.alejandra;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -164,6 +162,17 @@
|
|||
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
|
||||
nvim-tree-lua = {
|
||||
url = "github:nvim-tree/nvim-tree.lua";
|
||||
|
@ -330,7 +339,7 @@
|
|||
flake = false;
|
||||
};
|
||||
nvim-web-devicons = {
|
||||
url = "github:kyazdani42/nvim-web-devicons";
|
||||
url = "github:nvim-tree/nvim-web-devicons";
|
||||
flake = false;
|
||||
};
|
||||
gitsigns-nvim = {
|
||||
|
@ -339,7 +348,7 @@
|
|||
};
|
||||
|
||||
fidget-nvim = {
|
||||
url = "github:j-hui/fidget.nvim";
|
||||
url = "github:j-hui/fidget.nvim?ref=legacy";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
|
@ -373,7 +382,7 @@
|
|||
};
|
||||
|
||||
# Utilities
|
||||
colorizer = {
|
||||
ccc = {
|
||||
url = "github:uga-rosa/ccc.nvim";
|
||||
flake = false;
|
||||
};
|
||||
|
@ -418,6 +427,11 @@
|
|||
flake = false;
|
||||
};
|
||||
|
||||
nvim-surround = {
|
||||
url = "github:kylechui/nvim-surround";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
# Note-taking
|
||||
obsidian-nvim = {
|
||||
url = "github:epwalsh/obsidian.nvim";
|
||||
|
@ -451,6 +465,16 @@
|
|||
flake = false;
|
||||
};
|
||||
|
||||
nvim-colorizer-lua = {
|
||||
url = "github:norcalli/nvim-colorizer.lua";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
vim-illuminate = {
|
||||
url = "github:RRethy/vim-illuminate";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
# Assistant
|
||||
copilot-lua = {
|
||||
url = "github:zbirenbaum/copilot.lua";
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (import ../extra.nix inputs) neovimConfiguration mainConfig;
|
||||
inherit (import ../configuration.nix inputs) neovimConfiguration mainConfig;
|
||||
|
||||
buildPkg = pkgs: modules:
|
||||
(neovimConfiguration {inherit pkgs modules;})
|
||||
|
|
33
lib/lua.nix
33
lib/lua.nix
|
@ -1,12 +1,43 @@
|
|||
# Helpers for converting values to lua
|
||||
{lib}: {
|
||||
{lib}: rec {
|
||||
# yes? no.
|
||||
yesNo = value:
|
||||
if value
|
||||
then "yes"
|
||||
else "no";
|
||||
|
||||
# Convert a null value to lua's nil
|
||||
nullString = value:
|
||||
if value == null
|
||||
then "nil"
|
||||
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
|
||||
cfg = config.programs.neovim-flake;
|
||||
inherit (import ../../extra.nix inputs) neovimConfiguration;
|
||||
inherit (import ../../configuration.nix inputs) neovimConfiguration;
|
||||
set = neovimConfiguration {
|
||||
inherit pkgs;
|
||||
modules = [cfg.settings];
|
||||
};
|
||||
in {
|
||||
meta.maintainers = [maintainers.notashelf];
|
||||
meta.maintainers = with maintainers; [NotAShelf];
|
||||
|
||||
options.programs.neovim-flake = {
|
||||
enable = mkEnableOption "A NeoVim IDE with a focus on configurability and extensibility.";
|
||||
|
|
|
@ -4,9 +4,70 @@
|
|||
nixpkgsLib: let
|
||||
mkNvimLib = import ./.;
|
||||
in
|
||||
nixpkgsLib.extend (self: super: {
|
||||
nixpkgsLib.extend (self: super: rec {
|
||||
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.
|
||||
literalExpression = super.literalExpression or super.literalExample;
|
||||
literalDocBook = super.literalDocBook or super.literalExample;
|
||||
|
|
|
@ -50,7 +50,7 @@ with lib; let
|
|||
"nvim-notify"
|
||||
"cinnamon-nvim"
|
||||
"cheatsheet-nvim"
|
||||
"colorizer"
|
||||
"ccc"
|
||||
"cellular-automaton"
|
||||
"presence-nvim"
|
||||
"icon-picker-nvim"
|
||||
|
@ -73,6 +73,7 @@ with lib; let
|
|||
"diffview-nvim"
|
||||
"todo-comments"
|
||||
"flutter-tools"
|
||||
"flutter-tools-patched"
|
||||
"hop-nvim"
|
||||
"leap-nvim"
|
||||
"modes-nvim"
|
||||
|
@ -81,6 +82,11 @@ with lib; let
|
|||
"project-nvim"
|
||||
"elixir-ls"
|
||||
"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.
|
||||
pluginsType = with types;
|
||||
|
|
|
@ -6,11 +6,16 @@
|
|||
with lib; let
|
||||
cfg = config.vim;
|
||||
in {
|
||||
config = {
|
||||
assertions = mkMerge [
|
||||
{
|
||||
assertion = cfg.kommentary.enable;
|
||||
message = "Kommentary has been deprecated in favor of comments-nvim";
|
||||
}
|
||||
{
|
||||
assertion = cfg.utility.colorizer.enable;
|
||||
message = "config.utility.colorizer has been renamed to config.utility.ccc";
|
||||
}
|
||||
mkIf
|
||||
(config.programs.neovim-flake.enable)
|
||||
{
|
||||
|
@ -18,4 +23,5 @@ in {
|
|||
message = "You cannot use `programs.neovim-flake.enable` with `programs.neovim.enable`";
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -7,18 +7,73 @@
|
|||
with lib;
|
||||
with builtins; let
|
||||
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 {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"copilot-lua"
|
||||
pkgs.nodejs-slim-16_x
|
||||
cfg.copilotNodePackage
|
||||
];
|
||||
|
||||
vim.luaConfigRC.copilot = nvim.dag.entryAnywhere ''
|
||||
require("copilot").setup({
|
||||
-- available options: https://github.com/zbirenbaum/copilot.lua
|
||||
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 builtins; {
|
||||
with builtins; let
|
||||
cfg = config.vim.assistant.copilot;
|
||||
in {
|
||||
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 {
|
||||
type = types.str;
|
||||
default = "${lib.getExe pkgs.nodejs-slim-16_x}";
|
||||
default = "${lib.getExe cfg.copilotNodePackage}";
|
||||
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 {
|
||||
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 ''
|
||||
require('tabnine').setup({
|
||||
disable_auto_comment = ${boolToString cfg.disable_auto_comment},
|
||||
accept_keymap = ${cfg.accept_keymap},
|
||||
dismiss_keymap = ${cfg.dismiss_keymap},
|
||||
accept_keymap = null,
|
||||
dismiss_keymap = null,
|
||||
debounce_ms = ${cfg.debounce_ms},
|
||||
execlude_filetypes = ${cfg.execlude_filetypes},
|
||||
exclude_filetypes = ${cfg.exclude_filetypes},
|
||||
})
|
||||
'';
|
||||
};
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{lib, ...}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
options.vim.assistant.tabnine = {
|
||||
enable = mkEnableOption "Enable TabNine assistant";
|
||||
enable = mkEnableOption "Tabnine assistant";
|
||||
|
||||
disable_auto_comment = mkOption {
|
||||
type = types.bool;
|
||||
|
@ -14,16 +10,9 @@ with builtins; {
|
|||
description = "Disable auto comment";
|
||||
};
|
||||
|
||||
accept_keymap = mkOption {
|
||||
type = types.str;
|
||||
default = "<Tab>";
|
||||
description = "Accept keymap";
|
||||
};
|
||||
|
||||
dismiss_keymap = mkOption {
|
||||
type = types.str;
|
||||
default = "<C-]>";
|
||||
description = "Dismiss keymap";
|
||||
mappings = {
|
||||
accept = mkMappingOption "Accept [Tabnine]" "<Tab>";
|
||||
dismiss = mkMappingOption "Dismiss [Tabnine]" "<C-]>";
|
||||
};
|
||||
|
||||
debounce_ms = mkOption {
|
||||
|
@ -32,10 +21,10 @@ with builtins; {
|
|||
description = "Debounce ms";
|
||||
};
|
||||
|
||||
execlude_filetypes = mkOption {
|
||||
exclude_filetypes = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = ["TelescopePrompt" "NvimTree" "alpha"];
|
||||
description = "Execlude filetypes";
|
||||
description = "Exclude filetypes";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,17 +1,9 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
{lib, ...}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
options.vim = {
|
||||
autopairs = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Enable autopairs";
|
||||
};
|
||||
enable = mkEnableOption "autopairs" // {default = false;};
|
||||
|
||||
type = mkOption {
|
||||
type = types.enum ["nvim-autopairs"];
|
||||
|
|
|
@ -10,21 +10,51 @@ in {
|
|||
config = {
|
||||
vim.startPlugins = ["plenary-nvim"];
|
||||
|
||||
vim.nmap = mkIf cfg.disableArrows {
|
||||
"<up>" = "<nop>";
|
||||
"<down>" = "<nop>";
|
||||
"<left>" = "<nop>";
|
||||
"<right>" = "<nop>";
|
||||
vim.maps.normal =
|
||||
mkIf cfg.disableArrows {
|
||||
"<up>" = {
|
||||
action = "<nop>";
|
||||
|
||||
noremap = false;
|
||||
};
|
||||
"<down>" = {
|
||||
action = "<nop>";
|
||||
|
||||
noremap = false;
|
||||
};
|
||||
"<left>" = {
|
||||
action = "<nop>";
|
||||
noremap = false;
|
||||
};
|
||||
"<right>" = {
|
||||
action = "<nop>";
|
||||
noremap = false;
|
||||
};
|
||||
}
|
||||
// mkIf cfg.mapLeaderSpace {
|
||||
"<space>" = {
|
||||
action = "<nop>";
|
||||
};
|
||||
};
|
||||
|
||||
vim.imap = mkIf cfg.disableArrows {
|
||||
"<up>" = "<nop>";
|
||||
"<down>" = "<nop>";
|
||||
"<left>" = "<nop>";
|
||||
"<right>" = "<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.nnoremap = mkIf cfg.mapLeaderSpace {"<space>" = "<nop>";};
|
||||
|
||||
vim.configRC.basic = nvim.dag.entryAfter ["globalsScript"] ''
|
||||
" Debug mode settings
|
||||
|
@ -45,6 +75,8 @@ in {
|
|||
set shortmess+=c
|
||||
set tm=${toString cfg.mapTimeout}
|
||||
set hidden
|
||||
set cursorlineopt=${toString cfg.cursorlineOpt}
|
||||
|
||||
${optionalString cfg.splitBelow ''
|
||||
set splitbelow
|
||||
''}
|
||||
|
@ -106,6 +138,10 @@ in {
|
|||
${optionalString (!cfg.enableEditorconfig) ''
|
||||
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; {
|
||||
options.vim = {
|
||||
debugMode = {
|
||||
enable = mkEnableOption "Enable debug mode";
|
||||
enable = mkEnableOption "debug mode";
|
||||
level = mkOption {
|
||||
type = types.int;
|
||||
default = 20;
|
||||
description = "Set the debug level";
|
||||
};
|
||||
|
||||
logFile = mkOption {
|
||||
type = types.path;
|
||||
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 {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
|
@ -144,5 +155,13 @@ with builtins; {
|
|||
default = true;
|
||||
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 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{lib, ...}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
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 builtins; let
|
||||
cfg = config.vim.comments.comment-nvim;
|
||||
self = import ./comment-nvim.nix {
|
||||
inherit lib;
|
||||
};
|
||||
mappings = self.options.vim.comments.comment-nvim.mappings;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"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 ''
|
||||
require('Comment').setup()
|
||||
require('Comment').setup({
|
||||
mappings = { basic = false, extra = false, },
|
||||
})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
|
@ -8,6 +7,12 @@ with lib;
|
|||
with builtins; let
|
||||
cfg = config.vim.autocomplete;
|
||||
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 =
|
||||
concatMapStringsSep
|
||||
"\n"
|
||||
|
@ -46,6 +51,139 @@ in {
|
|||
"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 ''
|
||||
local nvim_cmp_menu_map = function(entry, vim_item)
|
||||
-- name for each source
|
||||
|
@ -60,59 +198,29 @@ in {
|
|||
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'
|
||||
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 = {
|
||||
expand = function(args)
|
||||
vim.fn["vsnip#anonymous"](args.body)
|
||||
end,
|
||||
},
|
||||
|
||||
sources = {
|
||||
${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 = {
|
||||
completeopt = 'menu,menuone,noinsert',
|
||||
},
|
||||
|
||||
formatting = {
|
||||
format =
|
||||
${
|
||||
|
|
|
@ -1,40 +1,18 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
{lib, ...}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
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 {
|
||||
with builtins; {
|
||||
options.vim = {
|
||||
autocomplete = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "enable autocomplete";
|
||||
enable = mkEnableOption "enable autocomplete" // {default = false;};
|
||||
|
||||
mappings = {
|
||||
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 {
|
||||
|
|
|
@ -9,16 +9,113 @@ with builtins; let
|
|||
|
||||
wrapLuaConfig = luaConfig: ''
|
||||
lua << EOF
|
||||
${optionalString cfg.enableLuaLoader ''
|
||||
vim.loader.enable()
|
||||
''}
|
||||
${luaConfig}
|
||||
EOF
|
||||
'';
|
||||
|
||||
mkMappingOption = it:
|
||||
mkOption ({
|
||||
default = {};
|
||||
type = with types; attrsOf (nullOr str);
|
||||
mkBool = value: description:
|
||||
mkOption {
|
||||
type = types.bool;
|
||||
default = value;
|
||||
description = description;
|
||||
};
|
||||
|
||||
# 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...)
|
||||
}
|
||||
// it);
|
||||
*/
|
||||
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 {
|
||||
options.vim = {
|
||||
viAlias = mkOption {
|
||||
|
@ -35,13 +132,13 @@ in {
|
|||
|
||||
configRC = mkOption {
|
||||
description = "vimrc contents";
|
||||
type = nvim.types.dagOf types.lines;
|
||||
type = types.oneOf [(nvim.types.dagOf types.lines) types.str];
|
||||
default = {};
|
||||
};
|
||||
|
||||
luaConfigRC = mkOption {
|
||||
description = "vim lua config";
|
||||
type = nvim.types.dagOf types.lines;
|
||||
type = types.oneOf [(nvim.types.dagOf types.lines) types.str];
|
||||
default = {};
|
||||
};
|
||||
|
||||
|
@ -67,64 +164,38 @@ in {
|
|||
type = types.attrs;
|
||||
};
|
||||
|
||||
nnoremap =
|
||||
mkMappingOption {description = "Defines 'Normal mode' mappings";};
|
||||
maps = mkOption {
|
||||
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 {
|
||||
description = "Defines 'Insert and Replace mode' mappings";
|
||||
visualOnly = mapOptions "visual only";
|
||||
operator = mapOptions "operator-pending";
|
||||
insertCommand = mapOptions "insert and command-line";
|
||||
lang = mapOptions "insert, command-line and lang-arg";
|
||||
command = mapOptions "command-line";
|
||||
};
|
||||
|
||||
vnoremap = mkMappingOption {
|
||||
description = "Defines 'Visual and Select mode' mappings";
|
||||
};
|
||||
default = {};
|
||||
description = ''
|
||||
Custom keybindings for any mode.
|
||||
|
||||
xnoremap =
|
||||
mkMappingOption {description = "Defines 'Visual mode' mappings";};
|
||||
For plain maps (e.g. just 'map' or 'remap') use maps.normalVisualOp.
|
||||
'';
|
||||
|
||||
snoremap =
|
||||
mkMappingOption {description = "Defines 'Select mode' mappings";};
|
||||
|
||||
cnoremap =
|
||||
mkMappingOption {description = "Defines 'Command-line mode' mappings";};
|
||||
|
||||
onoremap = mkMappingOption {
|
||||
description = "Defines 'Operator pending mode' mappings";
|
||||
example = ''
|
||||
maps = {
|
||||
normal."<leader>m" = {
|
||||
silent = true;
|
||||
action = "<cmd>make<CR>";
|
||||
}; # Same as nnoremap <leader>m <silent> <cmd>make<CR>
|
||||
};
|
||||
|
||||
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}")
|
||||
(filterNonNull cfg.globals);
|
||||
|
||||
matchCtrl = it: match "Ctrl-(.)(.*)" it;
|
||||
mapKeyBinding = it: let
|
||||
groups = matchCtrl it;
|
||||
in
|
||||
if groups == null
|
||||
then it
|
||||
else "<C-${toUpper (head groups)}>${head (tail groups)}";
|
||||
mapVimBinding = prefix: mappings:
|
||||
mapAttrsFlatten (name: value: "${prefix} ${mapKeyBinding name} ${value}")
|
||||
(filterNonNull mappings);
|
||||
toLuaObject = args:
|
||||
if builtins.isAttrs args
|
||||
then
|
||||
if hasAttr "__raw" args
|
||||
then args.__raw
|
||||
else if hasAttr "__empty" args
|
||||
then "{ }"
|
||||
else
|
||||
"{"
|
||||
+ (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;
|
||||
imap = mapVimBinding "imap" config.vim.imap;
|
||||
vmap = mapVimBinding "vmap" config.vim.vmap;
|
||||
xmap = mapVimBinding "xmap" config.vim.xmap;
|
||||
smap = mapVimBinding "smap" config.vim.smap;
|
||||
cmap = mapVimBinding "cmap" config.vim.cmap;
|
||||
omap = mapVimBinding "omap" config.vim.omap;
|
||||
tmap = mapVimBinding "tmap" config.vim.tmap;
|
||||
toLuaBindings = mode: maps:
|
||||
builtins.map (value: ''
|
||||
vim.keymap.set(${toLuaObject mode}, ${toLuaObject value.key}, ${toLuaObject value.action}, ${toLuaObject value.config})
|
||||
'') (genMaps mode maps);
|
||||
|
||||
nnoremap = mapVimBinding "nnoremap" config.vim.nnoremap;
|
||||
inoremap = mapVimBinding "inoremap" config.vim.inoremap;
|
||||
vnoremap = mapVimBinding "vnoremap" config.vim.vnoremap;
|
||||
xnoremap = mapVimBinding "xnoremap" config.vim.xnoremap;
|
||||
snoremap = mapVimBinding "snoremap" config.vim.snoremap;
|
||||
cnoremap = mapVimBinding "cnoremap" config.vim.cnoremap;
|
||||
onoremap = mapVimBinding "onoremap" config.vim.onoremap;
|
||||
tnoremap = mapVimBinding "tnoremap" config.vim.tnoremap;
|
||||
# I'm not sure if every one of these will work.
|
||||
allmap = toLuaBindings "" config.vim.maps.normalVisualOp;
|
||||
nmap = toLuaBindings "n" config.vim.maps.normal;
|
||||
vmap = toLuaBindings "v" config.vim.maps.visual;
|
||||
xmap = toLuaBindings "x" config.vim.maps.visualOnly;
|
||||
smap = toLuaBindings "s" config.vim.maps.select;
|
||||
imap = toLuaBindings "i" config.vim.maps.insert;
|
||||
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 = {
|
||||
name,
|
||||
dag,
|
||||
mapResult,
|
||||
}: 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 =
|
||||
if sortedDag ? result
|
||||
then mapResult sortedDag.result
|
||||
|
@ -208,9 +314,22 @@ in {
|
|||
in
|
||||
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
|
||||
maps = [nmap imap vmap xmap smap cmap omap tmap nnoremap inoremap vnoremap xnoremap snoremap cnoremap onoremap tnoremap];
|
||||
mapConfig = concatStringsSep "\n" (map (v: concatStringsSep "\n" v) maps);
|
||||
maps = [
|
||||
nmap
|
||||
imap
|
||||
vmap
|
||||
xmap
|
||||
smap
|
||||
cmap
|
||||
omap
|
||||
tmap
|
||||
lmap
|
||||
icmap
|
||||
allmap
|
||||
];
|
||||
mapConfig = wrapLuaConfig (concatStringsSep "\n" (map (v: concatStringsSep "\n" v) maps));
|
||||
in
|
||||
nvim.dag.entryAfter ["globalsScript"] mapConfig;
|
||||
};
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
with lib;
|
||||
with builtins; {
|
||||
options.vim.dashboard.alpha = {
|
||||
enable = mkEnableOption "Enable alpha.nvim";
|
||||
enable = mkEnableOption "dashboard via alpha.nvim";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -186,10 +186,10 @@ in {
|
|||
{ type = "padding", val = 1 },
|
||||
-- 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("SPC F", " Find file"), -- telescope
|
||||
dashboard.button("SPC ff", " Live grep"), -- telescope
|
||||
dashboard.button("SPC F", " Find file"), -- telescope
|
||||
dashboard.button("SPC ff", " Live grep"), -- telescope
|
||||
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",
|
||||
}
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
with lib;
|
||||
with builtins; {
|
||||
options.vim.dashboard.dashboard-nvim = {
|
||||
enable = mkEnableOption "Enable dashboard.nvim";
|
||||
enable = mkEnableOption "dashboard via dashboard.nvim";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
with builtins;
|
||||
with lib; {
|
||||
options.vim.dashboard.startify = {
|
||||
enable = mkEnableOption "Enable vim-startify";
|
||||
enable = mkEnableOption "dashboard via vim-startify";
|
||||
|
||||
bookmarks = mkOption {
|
||||
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;
|
||||
};
|
||||
|
||||
buildPlug = name:
|
||||
buildVimPluginFrom2Nix rec {
|
||||
pname = name;
|
||||
buildPlug = {pname, ...} @ args:
|
||||
assert lib.asserts.assertMsg (pname != "nvim-treesitter") "Use buildTreesitterPlug for building nvim-treesitter.";
|
||||
buildVimPluginFrom2Nix (args
|
||||
// {
|
||||
version = "master";
|
||||
src = assert lib.asserts.assertMsg (name != "nvim-treesitter") "Use buildTreesitterPlug for building nvim-treesitter.";
|
||||
getAttr pname inputs;
|
||||
};
|
||||
src = getAttr pname inputs;
|
||||
});
|
||||
|
||||
buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars);
|
||||
|
||||
|
@ -45,7 +45,13 @@ inputs: {
|
|||
(
|
||||
if (plug == "nvim-treesitter")
|
||||
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
|
||||
))
|
||||
|
@ -66,6 +72,7 @@ inputs: {
|
|||
};
|
||||
};
|
||||
in {
|
||||
imports = [./assertions.nix];
|
||||
inherit (module) options config;
|
||||
inherit (module._module.args) pkgs;
|
||||
inherit neovim;
|
||||
|
|
|
@ -1,30 +1,29 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.filetree.nvimTreeLua;
|
||||
self = import ./nvimtree-lua.nix {
|
||||
inherit pkgs;
|
||||
lib = lib;
|
||||
};
|
||||
mappings = self.options.vim.filetree.nvimTreeLua.mappings;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = ["nvim-tree-lua"];
|
||||
|
||||
# vim.nnoremap = {
|
||||
# "<C-n>" = ":NvimTreeToggle<CR>";
|
||||
# "<leader>tr" = ":NvimTreeRefresh<CR>";
|
||||
# "<leader>tg" = ":NvimTreeFindFile<CR>";
|
||||
# "<leader>tf" = ":NvimTreeFocus<CR>";
|
||||
# };
|
||||
vim.maps.normal = mkMerge [
|
||||
(mkBinding cfg.mappings.toggle ":NvimTreeToggle<cr>" mappings.toggle.description)
|
||||
(mkBinding cfg.mappings.refresh ":NvimTreeRefresh<cr>" mappings.refresh.description)
|
||||
(mkBinding cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
|
||||
(mkBinding cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
|
||||
];
|
||||
|
||||
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 IGNORED_FT = {
|
||||
"markdown",
|
||||
|
@ -80,7 +79,9 @@ in {
|
|||
width = ${toString cfg.view.width},
|
||||
side = ${"'" + cfg.view.side + "'"},
|
||||
adaptive_size = ${boolToString cfg.view.adaptiveSize},
|
||||
cursorline = ${boolToString cfg.view.cursorline}
|
||||
},
|
||||
|
||||
git = {
|
||||
enable = ${boolToString cfg.git.enable},
|
||||
ignore = ${boolToString cfg.git.ignore},
|
||||
|
|
|
@ -1,16 +1,34 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
options.vim.filetree.nvimTreeLua = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Enable nvim-tree-lua";
|
||||
enable = mkEnableOption "filetree via nvim-tree-lua" // {default = false;};
|
||||
|
||||
mappings = {
|
||||
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 {
|
||||
|
@ -160,6 +178,11 @@ with builtins; {
|
|||
description = "Width of the tree in charecters";
|
||||
type = types.int;
|
||||
};
|
||||
cursorline = mkOption {
|
||||
default = false;
|
||||
description = "Whether to display the cursor line in NvimTree";
|
||||
type = types.bool;
|
||||
};
|
||||
};
|
||||
|
||||
git = {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
|
@ -7,40 +6,62 @@
|
|||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.git;
|
||||
|
||||
self = import ./git.nix {inherit lib;};
|
||||
gsMappingDefinitions = self.options.vim.git.gitsigns.mappings;
|
||||
|
||||
gsMappings = addDescriptionsToMappings cfg.gitsigns.mappings gsMappingDefinitions;
|
||||
in {
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.gitsigns.enable (mkMerge [
|
||||
{
|
||||
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 ''
|
||||
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>'
|
||||
},
|
||||
}
|
||||
require('gitsigns').setup{}
|
||||
'';
|
||||
}
|
||||
|
||||
|
|
|
@ -1,19 +1,34 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{lib, ...}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.git;
|
||||
in {
|
||||
with builtins; {
|
||||
options.vim.git = {
|
||||
enable = mkEnableOption "Git support";
|
||||
enable = mkEnableOption "git tools via gitsigns";
|
||||
|
||||
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";
|
||||
};
|
||||
};
|
||||
|
|
|
@ -24,8 +24,11 @@ with builtins; let
|
|||
clangd = {
|
||||
package = pkgs.clang-tools;
|
||||
lspConfig = ''
|
||||
local clangd_cap = capabilities
|
||||
-- use same offsetEncoding as null-ls
|
||||
clangd_cap.offsetEncoding = {"utf-16"}
|
||||
lspconfig.clangd.setup{
|
||||
capabilities = capabilities;
|
||||
capabilities = clangd_cap;
|
||||
on_attach=default_on_attach;
|
||||
cmd = {"${cfg.lsp.package}/bin/clangd"};
|
||||
${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 {
|
||||
options.vim.languages.clang = {
|
||||
enable = mkEnableOption "C/C++ language support";
|
||||
|
@ -47,37 +79,50 @@ in {
|
|||
};
|
||||
|
||||
treesitter = {
|
||||
enable = mkOption {
|
||||
description = "Enable C/C++ treesitter";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableTreesitter;
|
||||
};
|
||||
enable = mkEnableOption "C/C++ treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
cPackage = nvim.types.mkGrammarOption pkgs "c";
|
||||
cppPackage = nvim.types.mkGrammarOption pkgs "cpp";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkOption {
|
||||
description = "Enable clang LSP support";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableLSP;
|
||||
};
|
||||
enable = mkEnableOption "Enable clang LSP support" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
server = mkOption {
|
||||
description = "The clang LSP server to use";
|
||||
type = with types; enum (attrNames servers);
|
||||
default = defaultServer;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "clang LSP server package";
|
||||
type = types.package;
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
|
||||
opts = mkOption {
|
||||
description = "Options to pass to clang LSP server";
|
||||
type = with types; nullOr str;
|
||||
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 [
|
||||
|
@ -95,5 +140,10 @@ in {
|
|||
|
||||
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) {
|
||||
vim.startPlugins = ["flutter-tools"];
|
||||
vim.startPlugins =
|
||||
if ftcfg.enableNoResolvePatch
|
||||
then ["flutter-tools-patched"]
|
||||
else ["flutter-tools"];
|
||||
|
||||
vim.luaConfigRC.flutter-tools = nvim.dag.entryAnywhere ''
|
||||
require('flutter-tools').setup {
|
||||
|
@ -52,8 +55,12 @@ in {
|
|||
on_attach = default_on_attach;
|
||||
flags = lsp_flags,
|
||||
},
|
||||
${optionalString cfg.dap.enable ''
|
||||
debugger = {
|
||||
enabled = true,
|
||||
},
|
||||
''}
|
||||
}
|
||||
|
||||
'';
|
||||
})
|
||||
]);
|
||||
|
|
|
@ -26,16 +26,12 @@ in {
|
|||
enable = mkEnableOption "Dart language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkOption {
|
||||
description = "Enable Dart treesitter";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableTreesitter;
|
||||
};
|
||||
enable = mkEnableOption "Enable Dart treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
package = nvim.types.mkGrammarOption pkgs "dart";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "Enable Dart LSP support";
|
||||
enable = mkEnableOption "Dart LSP support";
|
||||
server = mkOption {
|
||||
description = "The Dart LSP server to use";
|
||||
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 = {
|
||||
enable = mkOption {
|
||||
description = "Enable flutter-tools for flutter support";
|
||||
|
@ -60,6 +64,16 @@ in {
|
|||
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 = {
|
||||
enable = mkEnableOption "Whether or mot to highlight color variables at all";
|
||||
|
||||
|
|
|
@ -22,10 +22,12 @@ in {
|
|||
./ts.nix
|
||||
./zig.nix
|
||||
./html.nix
|
||||
./svelte.nix
|
||||
];
|
||||
|
||||
options.vim.languages = {
|
||||
enableLSP = mkEnable "LSP";
|
||||
enableDAP = mkEnable "Debug Adapter";
|
||||
enableTreesitter = mkEnable "treesitter";
|
||||
enableFormat = mkEnable "formatting";
|
||||
enableExtraDiagnostics = mkEnable "extra diagnostics";
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
with lib;
|
||||
with builtins; {
|
||||
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 {
|
||||
options.vim.languages.go = {
|
||||
enable = mkEnableOption "Go language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkOption {
|
||||
description = "Enable Go treesitter";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableTreesitter;
|
||||
};
|
||||
enable = mkEnableOption "Enable Go treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
|
||||
package = nvim.types.mkGrammarOption pkgs "go";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkOption {
|
||||
description = "Enable Go LSP support";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableLSP;
|
||||
};
|
||||
enable = mkEnableOption "Enable Go LSP support" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
server = mkOption {
|
||||
description = "Go LSP server to use";
|
||||
type = with types; enum (attrNames servers);
|
||||
default = defaultServer;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "Go LSP server package";
|
||||
type = types.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 [
|
||||
|
@ -63,5 +116,10 @@ in {
|
|||
vim.lsp.lspconfig.enable = true;
|
||||
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;
|
||||
in {
|
||||
options.vim.languages.markdown = {
|
||||
enable = mkEnableOption "Markdown language support";
|
||||
enable = mkEnableOption "Markdown markup language support";
|
||||
|
||||
glow.enable = mkOption {
|
||||
type = types.bool;
|
||||
|
|
|
@ -96,11 +96,8 @@ in {
|
|||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkOption {
|
||||
description = "Enable Nix LSP support";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableLSP;
|
||||
};
|
||||
enable = mkEnableOption "Enable Nix LSP support" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
server = mkOption {
|
||||
description = "Nix LSP server to use";
|
||||
type = types.str;
|
||||
|
@ -114,11 +111,8 @@ in {
|
|||
};
|
||||
|
||||
format = {
|
||||
enable = mkOption {
|
||||
description = "Enable Nix formatting";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableFormat;
|
||||
};
|
||||
enable = mkEnableOption "Enable Nix formatting" // {default = config.vim.languages.enableFormat;};
|
||||
|
||||
type = mkOption {
|
||||
description = "Nix formatter to use";
|
||||
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 {
|
||||
options.vim.languages.python = {
|
||||
enable = mkEnableOption "Python language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkOption {
|
||||
description = "Enable Python treesitter";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableTreesitter;
|
||||
};
|
||||
enable = mkEnableOption "Enable Python treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
package = mkOption {
|
||||
description = "Python treesitter grammar to use";
|
||||
type = types.package;
|
||||
|
@ -54,16 +113,14 @@ in {
|
|||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkOption {
|
||||
description = "Enable Python LSP support";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableLSP;
|
||||
};
|
||||
enable = mkEnableOption "Enable Python LSP support" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
server = mkOption {
|
||||
description = "Python LSP server to use";
|
||||
type = with types; enum (attrNames servers);
|
||||
default = defaultServer;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "python LSP server package";
|
||||
type = types.package;
|
||||
|
@ -72,22 +129,43 @@ in {
|
|||
};
|
||||
|
||||
format = {
|
||||
enable = mkOption {
|
||||
description = "Enable Python formatting";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableFormat;
|
||||
};
|
||||
enable = mkEnableOption "Enable Python formatting" // {default = config.vim.languages.enableFormat;};
|
||||
|
||||
type = mkOption {
|
||||
description = "Python formatter to use";
|
||||
type = with types; enum (attrNames formats);
|
||||
default = defaultFormat;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "Python formatter package";
|
||||
type = types.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 [
|
||||
(mkIf cfg.treesitter.enable {
|
||||
|
@ -104,5 +182,10 @@ in {
|
|||
vim.lsp.null-ls.enable = true;
|
||||
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";
|
||||
|
||||
treesitter = {
|
||||
enable = mkOption {
|
||||
description = "Enable Rust treesitter";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableTreesitter;
|
||||
};
|
||||
enable = mkEnableOption "Enable Rust treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
package = nvim.types.mkGrammarOption pkgs "rust";
|
||||
};
|
||||
|
||||
|
@ -30,22 +26,33 @@ in {
|
|||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkOption {
|
||||
description = "Rust LSP support (rust-analyzer with extra tools)";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableLSP;
|
||||
};
|
||||
enable = mkEnableOption "Rust LSP support (rust-analyzer with extra tools)" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
package = mkOption {
|
||||
description = "rust-analyzer package";
|
||||
type = types.package;
|
||||
default = pkgs.rust-analyzer;
|
||||
};
|
||||
|
||||
opts = mkOption {
|
||||
description = "Options to pass to rust analyzer";
|
||||
type = types.str;
|
||||
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 [
|
||||
|
@ -68,8 +75,8 @@ in {
|
|||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
})
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.startPlugins = ["rust-tools"];
|
||||
(mkIf (cfg.lsp.enable || cfg.dap.enable) {
|
||||
vim.startPlugins = ["rust-tools"] ++ optionals cfg.dap.enable [cfg.dap.package];
|
||||
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
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>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)
|
||||
${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
|
||||
local rustopts = {
|
||||
tools = {
|
||||
|
@ -100,7 +122,17 @@ in {
|
|||
settings = {
|
||||
${cfg.lsp.opts}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
${optionalString cfg.dap.enable ''
|
||||
dap = {
|
||||
adapter = {
|
||||
type = "executable",
|
||||
command = "${cfg.dap.package}/bin/lldb-vscode",
|
||||
name = "rt_lldb",
|
||||
},
|
||||
},
|
||||
''}
|
||||
}
|
||||
rt.setup(rustopts)
|
||||
'';
|
||||
|
|
|
@ -68,11 +68,8 @@ in {
|
|||
};
|
||||
|
||||
treesitter = {
|
||||
enable = mkOption {
|
||||
description = "Enable SQL treesitter";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableTreesitter;
|
||||
};
|
||||
enable = mkEnableOption "Enable SQL treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
|
||||
package = mkOption {
|
||||
description = "SQL treesitter grammar to use";
|
||||
type = types.package;
|
||||
|
@ -81,16 +78,14 @@ in {
|
|||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkOption {
|
||||
description = "Enable SQL LSP support";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableLSP;
|
||||
};
|
||||
enable = mkEnableOption "Enable SQL LSP support" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
server = mkOption {
|
||||
description = "SQL LSP server to use";
|
||||
type = with types; enum (attrNames servers);
|
||||
default = defaultServer;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "SQL LSP server package";
|
||||
type = types.package;
|
||||
|
@ -99,16 +94,14 @@ in {
|
|||
};
|
||||
|
||||
format = {
|
||||
enable = mkOption {
|
||||
description = "Enable SQL formatting";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableFormat;
|
||||
};
|
||||
enable = mkEnableOption "Enable SQL formatting" // {default = config.vim.languages.enableFormat;};
|
||||
|
||||
type = mkOption {
|
||||
description = "SQL formatter to use";
|
||||
type = with types; enum (attrNames formats);
|
||||
default = defaultFormat;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "SQL formatter package";
|
||||
type = types.package;
|
||||
|
@ -117,11 +110,8 @@ in {
|
|||
};
|
||||
|
||||
extraDiagnostics = {
|
||||
enable = mkOption {
|
||||
description = "Enable extra SQL diagnostics";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableExtraDiagnostics;
|
||||
};
|
||||
enable = mkEnableOption "Enable extra SQL diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
|
||||
|
||||
types = lib.nvim.types.diagnostics {
|
||||
langDesc = "SQL";
|
||||
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 builtins; {
|
||||
options.vim.tidal = {
|
||||
enable = mkEnableOption "Enable tidalcycles tools and plugins";
|
||||
enable = mkEnableOption "tidalcycles tools and plugins";
|
||||
|
||||
flash = mkOption {
|
||||
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
|
||||
defaultDiagnostics = ["eslint"];
|
||||
defaultDiagnostics = ["eslint_d"];
|
||||
diagnostics = {
|
||||
eslint = {
|
||||
package = pkgs.nodePackages.eslint;
|
||||
eslint_d = {
|
||||
package = pkgs.nodePackages.eslint_d;
|
||||
nullConfig = pkg: ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.diagnostics.eslint.with({
|
||||
command = "${pkg}/bin/eslint",
|
||||
null_ls.builtins.diagnostics.eslint_d.with({
|
||||
command = "${lib.getExe pkg}",
|
||||
})
|
||||
)
|
||||
'';
|
||||
|
@ -58,26 +69,20 @@ in {
|
|||
enable = mkEnableOption "Typescript/Javascript language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkOption {
|
||||
description = "Enable Typescript/Javascript treesitter";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableTreesitter;
|
||||
};
|
||||
enable = mkEnableOption "Enable Typescript/Javascript treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
tsPackage = nvim.types.mkGrammarOption pkgs "tsx";
|
||||
jsPackage = nvim.types.mkGrammarOption pkgs "javascript";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkOption {
|
||||
description = "Enable Typescript/Javascript LSP support";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableLSP;
|
||||
};
|
||||
enable = mkEnableOption "Enable Typescript/Javascript LSP support" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
server = mkOption {
|
||||
description = "Typescript/Javascript LSP server to use";
|
||||
type = with types; enum (attrNames servers);
|
||||
default = defaultServer;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "Typescript/Javascript LSP server package";
|
||||
type = types.package;
|
||||
|
@ -86,16 +91,14 @@ in {
|
|||
};
|
||||
|
||||
format = {
|
||||
enable = mkOption {
|
||||
description = "Enable Typescript/Javascript formatting";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableFormat;
|
||||
};
|
||||
enable = mkEnableOption "Enable Typescript/Javascript formatting" // {default = config.vim.languages.enableFormat;};
|
||||
|
||||
type = mkOption {
|
||||
description = "Typescript/Javascript formatter to use";
|
||||
type = with types; enum (attrNames formats);
|
||||
default = defaultFormat;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "Typescript/Javascript formatter package";
|
||||
type = types.package;
|
||||
|
@ -104,11 +107,8 @@ in {
|
|||
};
|
||||
|
||||
extraDiagnostics = {
|
||||
enable = mkOption {
|
||||
description = "Enable extra Typescript/Javascript diagnostics";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableExtraDiagnostics;
|
||||
};
|
||||
enable = mkEnableOption "Enable extra Typescript/Javascript diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
|
||||
|
||||
types = lib.nvim.types.diagnostics {
|
||||
langDesc = "Typescript/Javascript";
|
||||
inherit diagnostics;
|
||||
|
|
|
@ -12,24 +12,19 @@ in {
|
|||
enable = mkEnableOption "SQL language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkOption {
|
||||
description = "Enable Zig treesitter";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableTreesitter;
|
||||
};
|
||||
enable = mkEnableOption "Enable Zig treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
package = nvim.types.mkGrammarOption pkgs "zig";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkOption {
|
||||
description = "Zig LSP support (zls)";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableLSP;
|
||||
};
|
||||
enable = mkEnableOption "Zig LSP support (zls)" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
package = mkOption {
|
||||
description = "ZLS package";
|
||||
type = types.package;
|
||||
default = pkgs.zls;
|
||||
};
|
||||
|
||||
zigPackage = mkOption {
|
||||
description = "Zig package used by ZLS";
|
||||
type = types.package;
|
||||
|
|
|
@ -36,20 +36,49 @@ in {
|
|||
end
|
||||
|
||||
-- Enable formatting
|
||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
|
||||
format_callback = function(client, bufnr)
|
||||
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 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)
|
||||
${
|
||||
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
|
||||
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
|
||||
|
||||
default_on_attach = function(client, bufnr)
|
||||
|
|
|
@ -6,41 +6,35 @@
|
|||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.lsp;
|
||||
self = import ./lspsaga.nix {inherit lib;};
|
||||
|
||||
mappingDefinitions = self.options.vim.lsp.lspsaga.mappings;
|
||||
mappings = addDescriptionsToMappings cfg.lspsaga.mappings mappingDefinitions;
|
||||
in {
|
||||
config = mkIf (cfg.enable && cfg.lspsaga.enable) {
|
||||
vim.startPlugins = ["lspsaga"];
|
||||
|
||||
vim.vnoremap = {
|
||||
"<silent><leader>ca" = ":<C-U>lua require('lspsaga.codeaction').range_code_action()<CR>";
|
||||
};
|
||||
vim.maps.visual = mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').range_code_action";
|
||||
|
||||
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.maps.normal = mkMerge [
|
||||
(mkSetLuaBinding mappings.lspFinder "require('lspsaga.provider').lsp_finder")
|
||||
(mkSetLuaBinding mappings.renderHoveredDoc "require('lspsaga.hover').render_hover_doc")
|
||||
|
||||
(mkSetLuaBinding mappings.smartScrollUp "function() require('lspsaga.action').smart_scroll_with_saga(-1) end")
|
||||
(mkSetLuaBinding mappings.smartScrollDown "function() require('lspsaga.action').smart_scroll_with_saga(1) end")
|
||||
|
||||
(mkSetLuaBinding mappings.rename "require('lspsaga.rename').rename")
|
||||
(mkSetLuaBinding mappings.previewDefinition "require('lspsaga.provider').preview_definition")
|
||||
|
||||
(mkSetLuaBinding mappings.showLineDiagnostics "require('lspsaga.diagnostic').show_line_diagnostics")
|
||||
(mkSetLuaBinding mappings.showCursorDiagnostics "require('lspsaga.diagnostic').show_cursor_diagnostics")
|
||||
|
||||
(mkSetLuaBinding mappings.nextDiagnostic "require('lspsaga.diagnostic').navigate('next')")
|
||||
(mkSetLuaBinding mappings.previousDiagnostic "require('lspsaga.diagnostic').navigate('prev')")
|
||||
|
||||
(mkIf (!cfg.nvimCodeActionMenu.enable) (mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').code_action"))
|
||||
(mkIf (!cfg.lspSignature.enable) (mkSetLuaBinding mappings.signatureHelp "require('lspsaga.signaturehelp').signature_help"))
|
||||
];
|
||||
|
||||
vim.luaConfigRC.lspsage = nvim.dag.entryAnywhere ''
|
||||
-- Enable lspsaga
|
||||
|
|
|
@ -1,53 +1,28 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{lib, ...}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.lsp;
|
||||
in {
|
||||
options.vim.lsp = {lspsaga = {enable = mkEnableOption "LSP Saga";};};
|
||||
with builtins; {
|
||||
options.vim.lsp.lspsaga = {
|
||||
enable = mkEnableOption "LSP Saga";
|
||||
|
||||
config = mkIf (cfg.enable && cfg.lspsaga.enable) {
|
||||
vim.startPlugins = ["lspsaga"];
|
||||
mappings = {
|
||||
lspFinder = mkMappingOption "LSP Finder [LSPSaga]" "<leader>lf";
|
||||
renderHoveredDoc = mkMappingOption "Rendered hovered docs [LSPSaga]" "<leader>lh";
|
||||
|
||||
vim.vnoremap = {
|
||||
"<silent><leader>ca" = ":<C-U>lua require('lspsaga.codeaction').range_code_action()<CR>";
|
||||
smartScrollUp = mkMappingOption "Smart scroll up [LSPSaga]" "<C-f>";
|
||||
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 builtins; let
|
||||
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 {
|
||||
config = mkIf (cfg.enable && cfg.nvimCodeActionMenu.enable) {
|
||||
vim.startPlugins = ["nvim-code-action-menu"];
|
||||
|
||||
vim.nnoremap = {
|
||||
"<silent><leader>ca" = ":CodeActionMenu<CR>";
|
||||
};
|
||||
vim.maps.normal = mkSetBinding mappings.open ":CodeActionMenu<CR>";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
{lib, ...}:
|
||||
with lib; {
|
||||
options.vim.lsp = {
|
||||
nvimCodeActionMenu = {
|
||||
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 builtins; let
|
||||
cfg = config.vim.lsp;
|
||||
|
||||
self = import ./trouble.nix {inherit lib;};
|
||||
|
||||
mappingDefinitions = self.options.vim.lsp.trouble.mappings;
|
||||
mappings = addDescriptionsToMappings cfg.trouble.mappings mappingDefinitions;
|
||||
in {
|
||||
config = mkIf (cfg.enable && cfg.trouble.enable) {
|
||||
vim.startPlugins = ["trouble"];
|
||||
|
||||
vim.nnoremap = {
|
||||
"<leader>xx" = "<cmd>TroubleToggle<CR>";
|
||||
"<leader>lwd" = "<cmd>TroubleToggle workspace_diagnostics<CR>";
|
||||
"<leader>ld" = "<cmd>TroubleToggle document_diagnostics<CR>";
|
||||
"<leader>lr" = "<cmd>TroubleToggle lsp_references<CR>";
|
||||
"<leader>xq" = "<cmd>TroubleToggle quickfix<CR>";
|
||||
"<leader>xl" = "<cmd>TroubleToggle loclist<CR>";
|
||||
};
|
||||
vim.maps.normal = mkMerge [
|
||||
(mkSetBinding mappings.toggle "<cmd>TroubleToggle<CR>")
|
||||
(mkSetBinding mappings.workspaceDiagnostics "<cmd>TroubleToggle workspace_diagnostics<CR>")
|
||||
(mkSetBinding mappings.documentDiagnostics "<cmd>TroubleToggle document_diagnostics<CR>")
|
||||
(mkSetBinding mappings.lspReferences "<cmd>TroubleToggle lsp_references<CR>")
|
||||
(mkSetBinding mappings.quickfix "<cmd>TroubleToggle quickfix<CR>")
|
||||
(mkSetBinding mappings.locList "<cmd>TroubleToggle loclist<CR>")
|
||||
];
|
||||
|
||||
vim.luaConfigRC.trouble = nvim.dag.entryAnywhere ''
|
||||
-- Enable trouble diagnostics viewer
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
{lib, ...}:
|
||||
with lib; {
|
||||
options.vim.lsp = {
|
||||
trouble = {
|
||||
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 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
{lib, ...}:
|
||||
with lib; {
|
||||
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 builtins; let
|
||||
cfg = config.vim.minimap.codewindow;
|
||||
|
||||
self = import ./codewindow.nix {inherit lib;};
|
||||
|
||||
mappingDefinitions = self.options.vim.minimap.codewindow.mappings;
|
||||
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"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 ''
|
||||
local codewindow = require('codewindow')
|
||||
codewindow.setup({
|
||||
exclude_filetypes = { 'NvimTree', 'orgagenda'},
|
||||
}
|
||||
)
|
||||
codewindow.apply_default_keybinds()
|
||||
})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
with lib;
|
||||
with builtins; {
|
||||
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
|
||||
./projects
|
||||
./languages
|
||||
./debugger
|
||||
];
|
||||
|
||||
pkgsModule = {config, ...}: {
|
||||
|
|
|
@ -12,10 +12,10 @@ in {
|
|||
"mind-nvim"
|
||||
];
|
||||
|
||||
vim.nnoremap = {
|
||||
"<leader>om" = ":MindOpenMain<CR>";
|
||||
"<leader>op" = ":MindOpenProject<CR>";
|
||||
"<leader>oc" = ":MindClose<CR>";
|
||||
vim.maps.normal = {
|
||||
"<leader>om" = {action = ":MindOpenMain<CR>";};
|
||||
"<leader>op" = {action = ":MindOpenProject<CR>";};
|
||||
"<leader>oc" = {action = ":MindClose<CR>";};
|
||||
};
|
||||
|
||||
vim.luaConfigRC.mind-nvim = nvim.dag.entryAnywhere ''
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
with lib;
|
||||
with builtins; {
|
||||
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; {
|
||||
options.vim.notes = {
|
||||
obsidian = {
|
||||
enable = mkEnableOption "Complementary neovim plugins for Obsidian editor";
|
||||
enable = mkEnableOption "complementary neovim plugins for Obsidian editor";
|
||||
dir = mkOption {
|
||||
type = types.str;
|
||||
default = "~/my-vault";
|
||||
|
|
|
@ -6,15 +6,15 @@
|
|||
with lib;
|
||||
with builtins; {
|
||||
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 {
|
||||
type = types.str;
|
||||
default = "{'~/Dropbox/org/*', '~/my-orgs/**/*'}";
|
||||
default = "{'~/Documents/org/*', '~/my-orgs/**/*'}";
|
||||
description = "List of org files to be used as agenda files.";
|
||||
};
|
||||
orgDefaultNotesFile = mkOption {
|
||||
type = types.str;
|
||||
default = "~/Dropbox/org/refile.org";
|
||||
default = "~/Documents/org/refile.org";
|
||||
description = "Default org file to be used for notes.";
|
||||
};
|
||||
};
|
||||
|
|
|
@ -7,17 +7,19 @@
|
|||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.notes.todo-comments;
|
||||
self = import ./todo-comments.nix {inherit lib;};
|
||||
mappings = self.options.vim.notes.todo-comments.mappings;
|
||||
in {
|
||||
config = mkIf (cfg.enable) {
|
||||
vim.startPlugins = [
|
||||
"todo-comments"
|
||||
];
|
||||
|
||||
vim.nnoremap = {
|
||||
"<leader>tdq" = ":TodoQuickFix<CR>";
|
||||
"<leader>tds" = ":TodoTelescope<CR>";
|
||||
"<leader>tdt" = ":TodoTrouble<CR>";
|
||||
};
|
||||
vim.maps.normal = mkMerge [
|
||||
(mkBinding cfg.mappings.quickFix ":TodoQuickFix<CR>" mappings.quickFix.description)
|
||||
(mkIf config.vim.telescope.enable (mkBinding cfg.mappings.telescope ":TodoTelescope<CR>" mappings.telescope.description))
|
||||
(mkIf config.vim.lsp.trouble.enable (mkBinding cfg.mappings.trouble ":TodoTrouble<CR>" mappings.trouble.description))
|
||||
];
|
||||
|
||||
vim.luaConfigRC.todo-comments = ''
|
||||
require('todo-comments').setup {
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{lib, ...}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
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 = {
|
||||
highlight = mkOption {
|
||||
|
@ -21,5 +17,11 @@ with builtins; {
|
|||
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 builtins; {
|
||||
options.vim.projects.project-nvim = {
|
||||
enable = mkEnableOption "Enable project-nvim for project management";
|
||||
with builtins; let
|
||||
cfg = config.vim.projects.project-nvim;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"project-nvim"
|
||||
];
|
||||
|
||||
manualMode = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "don't automatically change the root directory so the user has the option to manually do so using `:ProjectRoot` command";
|
||||
};
|
||||
vim.luaConfigRC.project-nvim = nvim.dag.entryAnywhere ''
|
||||
require('project_nvim').setup({
|
||||
manual_mode = ${boolToString cfg.manualMode},
|
||||
detection_methods = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.detectionMethods)} },
|
||||
|
||||
# detection methods should accept one or more strings from a list
|
||||
detectionMethods = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = ["lsp" "pattern"];
|
||||
description = "Detection methods to use";
|
||||
};
|
||||
-- All the patterns used to detect root dir, when **"pattern"** is in
|
||||
-- detection_methods
|
||||
patterns = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.patterns)} },
|
||||
|
||||
# patterns
|
||||
patterns = mkOption {
|
||||
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";
|
||||
};
|
||||
-- Table of lsp clients to ignore by name
|
||||
-- eg: { "efm", ... }
|
||||
ignore_lsp = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.lspIgnored)} },
|
||||
|
||||
# table of lsp servers to ignore by name
|
||||
lspIgnored = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
description = "LSP servers no ignore by name";
|
||||
};
|
||||
-- Don't calculate root dir on specific directories
|
||||
-- Ex: { "~/.cargo/*", ... }
|
||||
exclude_dirs = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.excludeDirs)} },
|
||||
|
||||
excludeDirs = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
description = "Directories to exclude from project root search";
|
||||
};
|
||||
-- Show hidden files in telescope
|
||||
show_hidden = ${boolToString cfg.showHidden},
|
||||
|
||||
showHidden = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Show hidden files in telescope picker";
|
||||
};
|
||||
-- When set to false, you will get a message when project.nvim changes your
|
||||
-- directory.
|
||||
silent_chdir = ${boolToString cfg.silentChdir},
|
||||
|
||||
silentChdir = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Silently change directory when changing project";
|
||||
};
|
||||
-- What scope to change the directory, valid options are
|
||||
-- * global (default)
|
||||
-- * tab
|
||||
-- * win
|
||||
scope_chdir = '${toString cfg.scopeChdir}',
|
||||
|
||||
scopeChdir = mkOption {
|
||||
type = types.enum ["global" "tab" "win"];
|
||||
default = "global";
|
||||
description = "What scope to change the directory";
|
||||
};
|
||||
-- Path where project.nvim will store the project history for use in
|
||||
-- telescope
|
||||
datapath = vim.fn.stdpath("data"),
|
||||
})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,48 +4,59 @@
|
|||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.projects.project-nvim;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"project-nvim"
|
||||
];
|
||||
with builtins; {
|
||||
options.vim.projects.project-nvim = {
|
||||
enable = mkEnableOption "Enable project-nvim for project management";
|
||||
|
||||
vim.luaConfigRC.project-nvim = nvim.dag.entryAnywhere ''
|
||||
require('project_nvim').setup({
|
||||
manual_mode = ${boolToString cfg.manualMode},
|
||||
detection_methods = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.detectionMethods)} },
|
||||
manualMode = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
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
|
||||
patterns = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.patterns)} },
|
||||
# detection methods should accept one or more strings from a list
|
||||
detectionMethods = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = ["lsp" "pattern"];
|
||||
description = "Detection methods to use";
|
||||
};
|
||||
|
||||
-- Table of lsp clients to ignore by name
|
||||
-- eg: { "efm", ... }
|
||||
ignore_lsp = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.lspIgnored)} },
|
||||
# patterns
|
||||
patterns = mkOption {
|
||||
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
|
||||
-- Ex: { "~/.cargo/*", ... }
|
||||
exclude_dirs = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.excludeDirs)} },
|
||||
# table of lsp servers to ignore by name
|
||||
lspIgnored = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
description = "LSP servers no ignore by name";
|
||||
};
|
||||
|
||||
-- Show hidden files in telescope
|
||||
show_hidden = ${boolToString cfg.showHidden},
|
||||
excludeDirs = mkOption {
|
||||
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
|
||||
-- directory.
|
||||
silent_chdir = ${boolToString cfg.silentChdir},
|
||||
showHidden = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Show hidden files in telescope picker";
|
||||
};
|
||||
|
||||
-- What scope to change the directory, valid options are
|
||||
-- * global (default)
|
||||
-- * tab
|
||||
-- * win
|
||||
scope_chdir = '${toString cfg.scopeChdir}',
|
||||
silentChdir = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Silently change directory when changing project";
|
||||
};
|
||||
|
||||
-- Path where project.nvim will store the project history for use in
|
||||
-- telescope
|
||||
datapath = vim.fn.stdpath("data"),
|
||||
})
|
||||
'';
|
||||
scopeChdir = mkOption {
|
||||
type = types.enum ["global" "tab" "win"];
|
||||
default = "global";
|
||||
description = "What scope to change the directory";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
with lib;
|
||||
with builtins; {
|
||||
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 {
|
||||
type = types.str;
|
||||
|
@ -22,9 +22,10 @@ with builtins; {
|
|||
|
||||
client_id = mkOption {
|
||||
type = types.str;
|
||||
default = "859194972255989790";
|
||||
default = "79327144129396737";
|
||||
description = "Client ID of the application";
|
||||
};
|
||||
|
||||
auto_update = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
|
|
|
@ -15,13 +15,13 @@ in {
|
|||
]
|
||||
++ optionals (cfg.usePicker) ["dressing-nvim"];
|
||||
|
||||
vim.nnoremap = {
|
||||
"<leader>sl" = ":SessionManager load_session<CR>";
|
||||
"<leader>sd" = ":SessionManager delete_session<CR>";
|
||||
"<leader>sc" = ":SessionManager save_current_session<CR>";
|
||||
"<leader>slt" = ":SessionManager load_last_session<CR>";
|
||||
vim.maps.normal = mkMerge [
|
||||
(mkBinding cfg.mappings.loadSession ":SessionManager load_session<CR>" "Load session")
|
||||
(mkBinding cfg.mappings.deleteSession ":SessionManager delete_session<CR>" "Delete session")
|
||||
(mkBinding cfg.mappings.saveCurrentSession ":SessionManager save_current_session<CR>" "Save current session")
|
||||
(mkBinding cfg.mappings.loadLastSession ":SessionManager load_last_session<CR>" "Load last session")
|
||||
# TODO: load_current_dir_session
|
||||
};
|
||||
];
|
||||
|
||||
vim.luaConfigRC.nvim-session-manager = nvim.dag.entryAnywhere ''
|
||||
local Path = require('plenary.path')
|
||||
|
|
|
@ -6,7 +6,30 @@
|
|||
with lib;
|
||||
with builtins; {
|
||||
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 {
|
||||
type = types.bool;
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
{lib, ...}:
|
||||
with lib; {
|
||||
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 ''
|
||||
require('lualine').setup {
|
||||
local lualine = require('lualine')
|
||||
lualine.setup {
|
||||
options = {
|
||||
icons_enabled = ${boolToString cfg.icons.enable},
|
||||
theme = "${cfg.theme}",
|
||||
component_separators = {"${cfg.componentSeparator.left}","${cfg.componentSeparator.right}"},
|
||||
section_separators = {"${cfg.sectionSeparator.left}","${cfg.sectionSeparator.right}"},
|
||||
disabled_filetypes = { 'alpha' }, -- 'NvimTree'
|
||||
disabled_filetypes = { 'alpha' },
|
||||
always_divide_middle = true,
|
||||
globalstatus = ${boolToString cfg.globalStatus},
|
||||
ignore_focus = {'NvimTree'},
|
||||
|
|
|
@ -6,16 +6,16 @@
|
|||
with lib;
|
||||
with builtins; let
|
||||
supported_themes = import ./supported_themes.nix;
|
||||
colorPuccin =
|
||||
if config.vim.statusline.lualine.theme == "catppuccin"
|
||||
then "#181825"
|
||||
else "none";
|
||||
in {
|
||||
options.vim.statusline.lualine = {
|
||||
enable = mkEnableOption "lualine";
|
||||
enable = mkEnableOption "lualine statusline plugin";
|
||||
|
||||
icons = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
description = "Enable icons for lualine";
|
||||
default = true;
|
||||
};
|
||||
enable = mkEnableOption "icons for lualine" // {default = true;};
|
||||
};
|
||||
|
||||
refresh = {
|
||||
|
@ -123,8 +123,10 @@ in {
|
|||
{
|
||||
{
|
||||
"mode",
|
||||
icons_enabled = true,
|
||||
separator = {
|
||||
left = '▎',
|
||||
right = ''
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -141,11 +143,11 @@ in {
|
|||
colored = true,
|
||||
icon_only = true,
|
||||
icon = { align = 'left' },
|
||||
color = {bg='none', fg='lavender'},
|
||||
color = {bg='${colorPuccin}', fg='lavender'},
|
||||
},
|
||||
{
|
||||
"filename",
|
||||
color = {bg='none'},
|
||||
color = {bg='${colorPuccin}'},
|
||||
symbols = {modified = '', readonly = ''},
|
||||
},
|
||||
}
|
||||
|
@ -168,7 +170,7 @@ in {
|
|||
},
|
||||
symbols = {added = '+', modified = '~', removed = '-'}, -- Changes the diff symbols
|
||||
color = {
|
||||
bg='none',
|
||||
bg='${colorPuccin}',
|
||||
fg='lavender'
|
||||
},
|
||||
},
|
||||
|
@ -181,10 +183,34 @@ in {
|
|||
description = "active config for: | A | B | C (X) | Y | Z |";
|
||||
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",
|
||||
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 = ''
|
||||
{
|
||||
{
|
||||
"fileformat",
|
||||
color = {bg='none', fg='lavender'},
|
||||
symbols = {
|
||||
unix = '', -- e712
|
||||
dos = '', -- e70f
|
||||
mac = '', -- e711
|
||||
'searchcount',
|
||||
maxcount = 999,
|
||||
timeout = 120,
|
||||
color = {bg='${colorPuccin}', fg='lavender'}
|
||||
},
|
||||
{
|
||||
"branch",
|
||||
icon = ' •',
|
||||
color = {bg='${colorPuccin}', fg='lavender'},
|
||||
},
|
||||
}
|
||||
'';
|
||||
|
@ -215,21 +243,21 @@ in {
|
|||
{
|
||||
{
|
||||
"progress",
|
||||
color = {bg='none', fg='lavender'},
|
||||
separator = {
|
||||
left = '',
|
||||
},
|
||||
},
|
||||
{
|
||||
"location",
|
||||
color = {bg='none', fg='lavender'},
|
||||
},
|
||||
{
|
||||
"branch",
|
||||
icon = ' •',
|
||||
separator = {
|
||||
left = '(',
|
||||
right = ')'
|
||||
"fileformat",
|
||||
color = {fg='black'},
|
||||
symbols = {
|
||||
unix = '', -- e712
|
||||
dos = '', -- e70f
|
||||
mac = '', -- e711
|
||||
},
|
||||
color = {bg='none', fg='lavender'},
|
||||
|
||||
},
|
||||
}
|
||||
'';
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.tabline.nvimBufferline;
|
||||
self = import ./nvim-bufferline.nix {
|
||||
inherit lib;
|
||||
};
|
||||
mappings = self.options.vim.tabline.nvimBufferline.mappings;
|
||||
in {
|
||||
config = mkIf cfg.enable (
|
||||
let
|
||||
|
@ -23,25 +27,18 @@ in {
|
|||
"bufdelete-nvim"
|
||||
];
|
||||
|
||||
vim.nnoremap = {
|
||||
"<silent><leader>bn" = ":BufferLineCycleNext<CR>";
|
||||
"<silent><leader>bp" = ":BufferLineCyclePrev<CR>";
|
||||
"<silent><leader>bc" = ":BufferLinePick<CR>";
|
||||
"<silent><leader>bse" = ":BufferLineSortByExtension<CR>";
|
||||
"<silent><leader>bsd" = ":BufferLineSortByDirectory<CR>";
|
||||
"<silent><leader>bsi" = ":lua require'bufferline'.sort_buffers_by(function (buf_a, buf_b) return buf_a.id < buf_b.id end)<CR>";
|
||||
"<silent><leader>bmn" = ":BufferLineMoveNext<CR>";
|
||||
"<silent><leader>bmp" = ":BufferLineMovePrev<CR>";
|
||||
"<silent><leader>b1" = "<Cmd>BufferLineGoToBuffer 1<CR>";
|
||||
"<silent><leader>b2" = "<Cmd>BufferLineGoToBuffer 2<CR>";
|
||||
"<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.maps.normal = mkMerge [
|
||||
(mkLuaBinding cfg.mappings.closeCurrent "require(\"bufdelete\").bufdelete" mappings.closeCurrent.description)
|
||||
(mkBinding cfg.mappings.cycleNext ":BufferLineCycleNext<CR>" mappings.cycleNext.description)
|
||||
(mkBinding cfg.mappings.cycleNext ":BufferLineCycleNext<CR>" mappings.cycleNext.description)
|
||||
(mkBinding cfg.mappings.cyclePrevious ":BufferLineCyclePrev<CR>" mappings.cyclePrevious.description)
|
||||
(mkBinding cfg.mappings.pick ":BufferLinePick<CR>" mappings.pick.description)
|
||||
(mkBinding cfg.mappings.sortByExtension ":BufferLineSortByExtension<CR>" mappings.sortByExtension.description)
|
||||
(mkBinding cfg.mappings.sortByDirectory ":BufferLineSortByDirectory<CR>" mappings.sortByDirectory.description)
|
||||
(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)
|
||||
(mkBinding cfg.mappings.moveNext ":BufferLineMoveNext<CR>" mappings.moveNext.description)
|
||||
(mkBinding cfg.mappings.movePrevious ":BufferLineMovePrev<CR>" mappings.movePrevious.description)
|
||||
];
|
||||
|
||||
vim.luaConfigRC.nvimBufferline = nvim.dag.entryAnywhere ''
|
||||
require("bufferline").setup{
|
||||
|
@ -51,10 +48,10 @@ in {
|
|||
close_command = ${mouse.close},
|
||||
right_mouse_command = ${mouse.right},
|
||||
indicator = {
|
||||
style = 'underline',
|
||||
-- indicator_icon = '▎',
|
||||
style = 'icon',
|
||||
indicator_icon = '▎',
|
||||
},
|
||||
buffer_close_icon = '',
|
||||
buffer_close_icon = '',
|
||||
modified_icon = '●',
|
||||
close_icon = '',
|
||||
left_trunc_marker = '',
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{lib, ...}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
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 builtins; let
|
||||
cfg = config.vim.terminal.toggleterm;
|
||||
toggleKey = "<c-t>";
|
||||
in {
|
||||
config = mkMerge [
|
||||
(
|
||||
|
@ -15,9 +14,11 @@ in {
|
|||
"toggleterm-nvim"
|
||||
];
|
||||
|
||||
vim.maps.normal = mkBinding cfg.mappings.open "<Cmd>execute v:count . \"ToggleTerm\"<CR>" "Toggle terminal";
|
||||
|
||||
vim.luaConfigRC.toggleterm = nvim.dag.entryAnywhere ''
|
||||
require("toggleterm").setup({
|
||||
open_mapping = [[${toggleKey}]],
|
||||
open_mapping = null,
|
||||
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
|
||||
size = function(term)
|
||||
|
@ -55,11 +56,10 @@ in {
|
|||
hidden = true,
|
||||
on_open = function(term)
|
||||
vim.cmd("startinsert!")
|
||||
vim.keymap.set( 't', [[${toggleKey}]], function() term:toggle() end, {silent = true, noremap = true, buffer = term.bufnr})
|
||||
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; {
|
||||
options.vim.terminal.toggleterm = {
|
||||
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 {
|
||||
type = types.enum ["horizontal" "vertical" "tab" "float"];
|
||||
default = "horizontal";
|
||||
description = "Direction of the terminal";
|
||||
};
|
||||
|
||||
enable_winbar = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Enable winbar";
|
||||
};
|
||||
|
||||
lazygit = {
|
||||
enable = mkEnableOption "Enable LazyGit integration";
|
||||
enable = mkEnableOption "LazyGit integration";
|
||||
direction = mkOption {
|
||||
type = types.enum ["horizontal" "vertical" "tab" "float"];
|
||||
default = "float";
|
||||
description = "Direction of the lazygit window";
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = with types; nullOr package;
|
||||
default = pkgs.lazygit;
|
||||
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 = {
|
||||
nvimtree = {
|
||||
enabled = true,
|
||||
transparent_panel = false,
|
||||
transparent_panel = ${lib.boolToString transparent},
|
||||
show_root = true,
|
||||
},
|
||||
|
||||
|
@ -51,6 +51,13 @@
|
|||
telescope = true,
|
||||
treesitter = 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
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
|
@ -8,6 +7,11 @@ with lib;
|
|||
with builtins; let
|
||||
cfg = config.vim.treesitter;
|
||||
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 {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins =
|
||||
|
@ -16,6 +20,16 @@ in {
|
|||
|
||||
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
|
||||
vim.configRC.treesitter-fold = mkIf cfg.fold (nvim.dag.entryBefore ["basic"] ''
|
||||
set foldmethod=expr
|
||||
|
@ -36,10 +50,10 @@ in {
|
|||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = "gnn",
|
||||
node_incremental = "grn",
|
||||
scope_incremental = "grc",
|
||||
node_decremental = "grm",
|
||||
init_selection = false,
|
||||
node_incremental = false,
|
||||
scope_incremental = false,
|
||||
node_decremental = false,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,14 +1,5 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.treesitter;
|
||||
usingNvimCmp = config.vim.autocomplete.enable && config.vim.autocomplete.type == "nvim-cmp";
|
||||
in {
|
||||
{lib, ...}:
|
||||
with lib; {
|
||||
options.vim.treesitter = {
|
||||
enable = mkEnableOption "treesitter, also enabled automatically through language options";
|
||||
|
||||
|
@ -16,13 +7,21 @@ in {
|
|||
|
||||
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 {
|
||||
type = with types; listOf package;
|
||||
default = [];
|
||||
description = nvim.nmd.asciiDoc ''
|
||||
List of treesitter grammars to install. For supported languages
|
||||
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
|
||||
./notifications
|
||||
./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