mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-09 14:45:58 +01:00
Compare commits
3 commits
b88728fea0
...
aa6727ce71
Author | SHA1 | Date | |
---|---|---|---|
|
aa6727ce71 | ||
ad9d0c6cdb | |||
5e12c2315a |
3 changed files with 111 additions and 69 deletions
|
@ -5,8 +5,9 @@
|
|||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.lists) optional;
|
||||
inherit (lib.lists) optional optionals;
|
||||
inherit (lib.trivial) boolToString;
|
||||
inherit (lib.nvim.lists) listContainsValues;
|
||||
inherit (lib.nvim.binds) mkSetBinding addDescriptionsToMappings;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.dag) entryBefore entryAnywhere;
|
||||
|
@ -23,6 +24,7 @@ in {
|
|||
startPlugins = ["nvim-treesitter"] ++ optional usingNvimCmp "cmp-treesitter";
|
||||
|
||||
autocomplete.sources = {"treesitter" = "[Treesitter]";};
|
||||
treesitter.grammars = optionals cfg.addDefaultGrammars cfg.defaultGrammars;
|
||||
|
||||
maps = {
|
||||
# HACK: Using mkSetLuaBinding and putting the lua code does not work for some reason: It just selects the whole file.
|
||||
|
@ -35,6 +37,7 @@ in {
|
|||
(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
|
||||
configRC.treesitter-fold = mkIf cfg.fold (entryBefore ["basic"] ''
|
||||
set foldmethod=expr
|
||||
|
@ -43,7 +46,7 @@ in {
|
|||
'');
|
||||
|
||||
luaConfigRC.treesitter = entryAnywhere ''
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
require('nvim-treesitter.configs').setup {
|
||||
-- Disable imperative treesitter options that would attempt to fetch
|
||||
-- grammars into the read-only Nix store. To add additional grammars here
|
||||
-- you must use the `config.vim.treesitter.grammars` option.
|
||||
|
@ -51,13 +54,23 @@ in {
|
|||
sync_install = false,
|
||||
ensure_installed = {},
|
||||
|
||||
-- Indentation module for Treesitter
|
||||
indent = {
|
||||
enable = true,
|
||||
disable = {},
|
||||
},
|
||||
|
||||
-- Highlight module for Treesitter
|
||||
highlight = {
|
||||
enable = ${boolToString cfg.highlight.enable},
|
||||
disable = ${toLuaObject cfg.highlight.disable},
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
|
||||
-- Indentation module for Treesitter
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
disable = {},
|
||||
keymaps = {
|
||||
init_selection = false,
|
||||
node_incremental = false,
|
||||
|
|
|
@ -4,11 +4,9 @@
|
|||
...
|
||||
}: let
|
||||
inherit (lib.options) mkOption mkEnableOption literalMD;
|
||||
inherit (lib.types) listOf package str either bool;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
inherit (lib.types) listOf package str either;
|
||||
inherit (lib.nvim.types) luaInline;
|
||||
|
||||
inherit (pkgs.vimPlugins.nvim-treesitter) builtGrammars;
|
||||
inherit (lib.nvim.types) luaInline mkGrammarOption;
|
||||
in {
|
||||
options.vim.treesitter = {
|
||||
enable = mkEnableOption "treesitter, also enabled automatically through language options";
|
||||
|
@ -37,7 +35,7 @@ in {
|
|||
highlight = {
|
||||
enable = mkEnableOption "highlighting with treesitter";
|
||||
disable = mkOption {
|
||||
type = either (luaInline (listOf str));
|
||||
type = either (listOf str) luaInline;
|
||||
default = [];
|
||||
example = literalMD ''
|
||||
```lua
|
||||
|
@ -69,20 +67,33 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
addDefaultGrammars = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to add the default grammars to the list of grammars
|
||||
to install.
|
||||
This option is only relevant if treesitter has been enabled.
|
||||
'';
|
||||
};
|
||||
|
||||
defaultGrammars = mkOption {
|
||||
internal = true;
|
||||
readOnly = true;
|
||||
type = listOf package;
|
||||
default = with builtGrammars; [c lua vim vimdoc query];
|
||||
default = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [c lua vim vimdoc query];
|
||||
description = ''
|
||||
A list of treesitter grammars that will be installed by default
|
||||
if treesitter has been enabled.
|
||||
if treesitter has been enabled and {option}`vim.treeesitter.addDefaultGrammars`
|
||||
has been set to true.
|
||||
|
||||
::: {.warning}
|
||||
::: {.note}
|
||||
Regardless of which language module options you enable, Neovim
|
||||
depends on those grammars to be enabled while treesitter is enabled.
|
||||
This list cannot be modified, but its contents will only be appended
|
||||
if the list of grammars does not contain the required grammars.
|
||||
|
||||
This list cannot be modified, but if you would like to bring your own
|
||||
parsers instead of those provided here, you can set `addDefaultGrammars`
|
||||
to false
|
||||
:::
|
||||
'';
|
||||
};
|
||||
|
|
|
@ -1,27 +1,37 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.lists) optionals;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.trivial) boolToString;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
|
||||
cfg = config.vim.ui.noice;
|
||||
tscfg = config.vim.treesitter;
|
||||
cmptype = config.vim.autocomplete.type;
|
||||
|
||||
defaultGrammars = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [vim regex lua bash markdown];
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
vim = {
|
||||
startPlugins = [
|
||||
"noice-nvim"
|
||||
"nui-nvim"
|
||||
];
|
||||
|
||||
vim.luaConfigRC.noice-nvim = entryAnywhere ''
|
||||
treesitter.grammars = optionals tscfg.addDefaultGrammars defaultGrammars;
|
||||
|
||||
luaConfigRC.noice-nvim = entryAnywhere ''
|
||||
require("noice").setup({
|
||||
lsp = {
|
||||
override = {
|
||||
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
|
||||
["vim.lsp.util.stylize_markdown"] = true,
|
||||
["cmp.entry.get_documentation"] = true,
|
||||
${optionalString (cmptype == "nvim-cmp") "[\"cmp.entry.get_documentation\"] = true,"}
|
||||
},
|
||||
|
||||
signature = {
|
||||
|
@ -29,6 +39,13 @@ in {
|
|||
},
|
||||
},
|
||||
|
||||
hover = {
|
||||
enabled = true,
|
||||
silent = false, -- set to true to not show a message if hover is not available
|
||||
view = nil, -- when nil, use defaults from documentation
|
||||
opts = {}, -- merged with defaults from documentation
|
||||
},
|
||||
|
||||
presets = {
|
||||
bottom_search = true, -- use a classic bottom cmdline for search
|
||||
command_palette = true, -- position the cmdline and popupmenu together
|
||||
|
@ -50,7 +67,7 @@ in {
|
|||
messages = {
|
||||
-- NOTE: If you enable messages, then the cmdline is enabled automatically.
|
||||
-- This is a current Neovim limitation.
|
||||
enabled = false, -- enables the Noice messages UI
|
||||
enabled = true, -- enables the Noice messages UI
|
||||
view = "notify", -- default view for messages
|
||||
view_error = "notify", -- view for errors
|
||||
view_warn = "notify", -- view for warnings
|
||||
|
@ -72,4 +89,5 @@ in {
|
|||
})
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue