mirror of
https://github.com/nix-community/nixvim.git
synced 2025-08-09 12:25:03 +02:00
Merge branch 'main' into add-package-option
This commit is contained in:
commit
b381c38113
74 changed files with 2083 additions and 713 deletions
|
@ -18,6 +18,7 @@ in
|
|||
colorscheme = mkOption {
|
||||
type = types.enum themes;
|
||||
description = "The base16 colorscheme to use";
|
||||
default = head themes;
|
||||
};
|
||||
|
||||
setUpBar = mkOption {
|
||||
|
|
|
@ -3,56 +3,93 @@ with lib;
|
|||
let
|
||||
cfg = config.colorschemes.tokyonight;
|
||||
style = types.enum [ "storm" "night" "day" ];
|
||||
helpers = import ../helpers.nix { inherit lib; };
|
||||
in
|
||||
{
|
||||
options = {
|
||||
colorschemes.tokyonight = {
|
||||
enable = mkEnableOption "Enable tokyonight";
|
||||
style = mkOption {
|
||||
type = types.nullOr style;
|
||||
default = null;
|
||||
type = style;
|
||||
default = "storm";
|
||||
description = "Theme style";
|
||||
};
|
||||
terminalColors = mkEnableOption
|
||||
"Configure the colors used when opening a :terminal in Neovim";
|
||||
italicComments = mkEnableOption "Make comments italic";
|
||||
italicKeywords = mkEnableOption "Make keywords italic";
|
||||
italicFunctions = mkEnableOption "Make functions italic";
|
||||
italicVariables = mkEnableOption "Make variables and identifiers italic";
|
||||
terminalColors = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Configure the colors used when opening a :terminal in Neovim";
|
||||
};
|
||||
transparent =
|
||||
mkEnableOption "Enable this to disable setting the background color";
|
||||
hideInactiveStatusline = mkEnableOption
|
||||
"Enabling this option will hide inactive statuslines and replace them with a thin border";
|
||||
transparentSidebar = mkEnableOption
|
||||
"Sidebar like windows like NvimTree get a transparent background";
|
||||
darkSidebar = mkEnableOption
|
||||
"Sidebar like windows like NvimTree get a darker background";
|
||||
darkFloat = mkEnableOption
|
||||
"Float windows like the lsp diagnostics windows get a darker background";
|
||||
lualineBold = mkEnableOption
|
||||
"When true, section headers in the lualine theme will be bold";
|
||||
styles =
|
||||
let
|
||||
mkBackgroundStyle = name: mkOption {
|
||||
type = types.enum [ "dark" "transparent" "normal" ];
|
||||
description = "Background style for ${name}";
|
||||
default = "dark";
|
||||
};
|
||||
in
|
||||
{
|
||||
comments = mkOption {
|
||||
type = types.attrsOf types.anything;
|
||||
description = "Define comments highlight properties";
|
||||
default = { italic = true; };
|
||||
};
|
||||
keywords = mkOption {
|
||||
type = types.attrsOf types.anything;
|
||||
description = "Define keywords highlight properties";
|
||||
default = { italic = true; };
|
||||
};
|
||||
functions = mkOption {
|
||||
type = types.attrsOf types.anything;
|
||||
description = "Define functions highlight properties";
|
||||
default = { };
|
||||
};
|
||||
variables = mkOption {
|
||||
type = types.attrsOf types.anything;
|
||||
description = "Define variables highlight properties";
|
||||
default = { };
|
||||
};
|
||||
sidebars = mkBackgroundStyle "sidebars";
|
||||
floats = mkBackgroundStyle "floats";
|
||||
};
|
||||
sidebars = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ "qf" "help" ];
|
||||
description = "Set a darker background on sidebar-like windows";
|
||||
example = ''["qf" "vista_kind" "terminal" "packer"]'';
|
||||
};
|
||||
dayBrightness = mkOption {
|
||||
type = types.numbers.between 0.0 1.0;
|
||||
default = 0.3;
|
||||
description = "Adjusts the brightness of the colors of the **Day** style";
|
||||
};
|
||||
hideInactiveStatusline =
|
||||
mkEnableOption
|
||||
"Enabling this option will hide inactive statuslines and replace them with a thin border";
|
||||
dimInactive = mkEnableOption "dims inactive windows";
|
||||
lualineBold =
|
||||
mkEnableOption
|
||||
"When true, section headers in the lualine theme will be bold";
|
||||
};
|
||||
};
|
||||
config = mkIf cfg.enable {
|
||||
colorscheme = "tokyonight";
|
||||
extraPlugins = [ pkgs.vimPlugins.tokyonight-nvim ];
|
||||
options = { termguicolors = true; };
|
||||
globals = {
|
||||
tokyonight_style = mkIf (!isNull cfg.style) cfg.style;
|
||||
tokyonight_terminal_colors = mkIf (!cfg.terminalColors) 0;
|
||||
|
||||
tokyonight_italic_comments = mkIf (!cfg.italicComments) 0;
|
||||
tokyonight_italic_keywords = mkIf (!cfg.italicKeywords) 0;
|
||||
tokyonight_italic_functions = mkIf (cfg.italicFunctions) 1;
|
||||
tokyonight_italic_variables = mkIf (cfg.italicVariables) 1;
|
||||
|
||||
tokyonight_transparent = mkIf (cfg.transparent) 1;
|
||||
tokyonight_hide_inactive_statusline =
|
||||
mkIf (cfg.hideInactiveStatusline) 1;
|
||||
tokyonight_transparent_sidebar = mkIf (cfg.transparentSidebar) 1;
|
||||
tokyonight_dark_sidebar = mkIf (!cfg.darkSidebar) 0;
|
||||
tokyonight_dark_float = mkIf (!cfg.darkFloat) 0;
|
||||
tokyonight_lualine_bold = mkIf (cfg.lualineBold) 1;
|
||||
};
|
||||
extraConfigLuaPre =
|
||||
let
|
||||
setupOptions = with cfg; {
|
||||
inherit (cfg) style transparent styles sidebars;
|
||||
terminal_colors = terminalColors;
|
||||
hide_inactive_statusline = hideInactiveStatusline;
|
||||
dim_inactive = dimInactive;
|
||||
lualine_bold = lualineBold;
|
||||
day_brightness = dayBrightness;
|
||||
};
|
||||
in
|
||||
''
|
||||
require("tokyonight").setup(${helpers.toLuaObject setupOptions})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -7,6 +7,11 @@ in
|
|||
options = {
|
||||
plugins.copilot = {
|
||||
enable = mkEnableOption "Enable copilot";
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
description = "The copilot plugin package to use";
|
||||
default = pkgs.vimPlugins.copilot-vim;
|
||||
};
|
||||
filetypes = mkOption {
|
||||
type = types.attrsOf types.bool;
|
||||
description = "A dictionary mapping file types to their enabled status";
|
||||
|
@ -27,7 +32,7 @@ in
|
|||
|
||||
config =
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = [ pkgs.vimPlugins.copilot-vim ];
|
||||
extraPlugins = [ cfg.package ];
|
||||
globals = {
|
||||
copilot_node_command = "${pkgs.nodejs-16_x}/bin/node";
|
||||
copilot_filetypes = cfg.filetypes;
|
||||
|
|
92
plugins/completion/lspkind.nix
Normal file
92
plugins/completion/lspkind.nix
Normal file
|
@ -0,0 +1,92 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.lspkind;
|
||||
helpers = import ../helpers.nix { inherit lib; };
|
||||
in
|
||||
{
|
||||
options.plugins.lspkind = {
|
||||
enable = mkEnableOption "lspkind.nvim";
|
||||
mode = mkOption {
|
||||
type = with types; nullOr (enum [ "text" "text_symbol" "symbol_text" "symbol" ]);
|
||||
default = null;
|
||||
description = "Defines how annotations are shown";
|
||||
};
|
||||
|
||||
preset = mkOption {
|
||||
type = with types; nullOr (enum [ "default" "codicons" ]);
|
||||
default = null;
|
||||
description = "Default symbol map";
|
||||
};
|
||||
|
||||
symbolMap = mkOption {
|
||||
type = with types; nullOr (attrsOf str);
|
||||
default = null;
|
||||
description = "Override preset symbols";
|
||||
};
|
||||
|
||||
cmp = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Integrate with nvim-cmp";
|
||||
};
|
||||
|
||||
maxWidth = mkOption {
|
||||
type = with types; nullOr int;
|
||||
default = null;
|
||||
description = "Maximum number of characters to show in the popup";
|
||||
};
|
||||
|
||||
ellipsisChar = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
description = "Character to show when the popup exceeds maxwidth";
|
||||
};
|
||||
|
||||
menu = mkOption {
|
||||
type = with types; nullOr (attrsOf str);
|
||||
default = null;
|
||||
description = "Show source names in the popup";
|
||||
};
|
||||
|
||||
after = mkOption {
|
||||
type = with types; nullOr types.str;
|
||||
default = null;
|
||||
description = "Function to run after calculating the formatting. function(entry, vim_item, kind)";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
doCmp = cfg.cmp.enable && config.plugins.nvim-cmp.enable;
|
||||
options = {
|
||||
mode = cfg.mode;
|
||||
preset = cfg.preset;
|
||||
symbol_map = cfg.symbolMap;
|
||||
} // (if doCmp then {
|
||||
maxwidth = cfg.cmp.maxWidth;
|
||||
ellipsis_char = cfg.cmp.ellipsisChar;
|
||||
menu = cfg.cmp.menu;
|
||||
} else { });
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = [ pkgs.vimPlugins.lspkind-nvim ];
|
||||
|
||||
extraConfigLua = optionalString (!doCmp) ''
|
||||
require('lspkind').init(${helpers.toLuaObject options})
|
||||
'';
|
||||
|
||||
plugins.nvim-cmp.formatting.format =
|
||||
if cfg.cmp.after != null then ''
|
||||
function(entry, vim_item)
|
||||
local kind = require('lspkind').cmp_format(${helpers.toLuaObject options})(entry, vim_item)
|
||||
|
||||
return (${cfg.cmp.after})(entry, vim_after, kind)
|
||||
end
|
||||
'' else ''
|
||||
require('lspkind').cmp_format(${helpers.toLuaObject options})
|
||||
'';
|
||||
};
|
||||
}
|
|
@ -309,6 +309,8 @@ in
|
|||
type = types.nullOr (types.submodule ({ ... }: {
|
||||
options = {
|
||||
inherit border winhighlight zindex;
|
||||
col_offset = mkNullOrOption types.int "Offsets the completion window relative to the cursor";
|
||||
side_padding = mkNullOrOption types.int "The amount of padding to add on the completion window's sides";
|
||||
};
|
||||
}));
|
||||
};
|
||||
|
|
|
@ -14,14 +14,19 @@
|
|||
./completion/copilot.nix
|
||||
./completion/nvim-cmp
|
||||
./completion/nvim-cmp/sources
|
||||
./completion/lspkind.nix
|
||||
|
||||
./git/fugitive.nix
|
||||
./git/gitgutter.nix
|
||||
./git/gitsigns.nix
|
||||
./git/neogit.nix
|
||||
|
||||
./languages/ledger.nix
|
||||
./languages/nix.nix
|
||||
./languages/plantuml-syntax.nix
|
||||
./languages/treesitter.nix
|
||||
./languages/treesitter-context.nix
|
||||
./languages/treesitter-refactor.nix
|
||||
./languages/zig.nix
|
||||
|
||||
./null-ls
|
||||
|
@ -29,9 +34,12 @@
|
|||
./nvim-lsp
|
||||
./nvim-lsp/lspsaga.nix
|
||||
./nvim-lsp/lsp-lines.nix
|
||||
./nvim-lsp/trouble.nix
|
||||
|
||||
./pluginmanagers/packer.nix
|
||||
|
||||
./snippets/luasnip
|
||||
|
||||
./statuslines/airline.nix
|
||||
./statuslines/lightline.nix
|
||||
./statuslines/lualine.nix
|
||||
|
@ -56,5 +64,6 @@
|
|||
./utils/undotree.nix
|
||||
./utils/dashboard.nix
|
||||
./utils/emmet.nix
|
||||
./utils/magma-nvim.nix
|
||||
];
|
||||
}
|
||||
|
|
433
plugins/git/gitsigns.nix
Normal file
433
plugins/git/gitsigns.nix
Normal file
|
@ -0,0 +1,433 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
helpers,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
signOptions = defaults:
|
||||
with types; {
|
||||
hl = mkOption {
|
||||
type = str;
|
||||
description = "Specifies the highlight group to use for the sign";
|
||||
default = defaults.hl;
|
||||
};
|
||||
text = mkOption {
|
||||
type = str;
|
||||
description = "Specifies the character to use for the sign";
|
||||
default = defaults.text;
|
||||
};
|
||||
numhl = mkOption {
|
||||
type = str;
|
||||
description = "Specifies the highlight group to use for the number column";
|
||||
default = defaults.numhl;
|
||||
};
|
||||
linehl = mkOption {
|
||||
type = str;
|
||||
description = "Specifies the highlight group to use for the line";
|
||||
default = defaults.linehl;
|
||||
};
|
||||
showCount = mkEnableOption "Enable showing count of hunk, e.g. number of deleted lines";
|
||||
};
|
||||
signSetupOptions = values: {
|
||||
inherit (values) hl text numhl linehl;
|
||||
show_count = values.showCount;
|
||||
};
|
||||
|
||||
luaFunction = types.submodule {
|
||||
options.function = mkOption {
|
||||
type = types.str;
|
||||
description = "Lua function definition";
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.plugins.gitsigns = {
|
||||
enable = mkEnableOption "Enable gitsigns plugin";
|
||||
signs = {
|
||||
add = signOptions {
|
||||
hl = "GitSignsAdd";
|
||||
text = "┃";
|
||||
numhl = "GitSignsAddNr";
|
||||
linehl = "GitSignsAddLn";
|
||||
};
|
||||
change = signOptions {
|
||||
hl = "GitSignsChange";
|
||||
text = "┃";
|
||||
numhl = "GitSignsChangeNr";
|
||||
linehl = "GitSignsChangeLn";
|
||||
};
|
||||
delete = signOptions {
|
||||
hl = "GitSignsDelete";
|
||||
text = "▁";
|
||||
numhl = "GitSignsDeleteNr";
|
||||
linehl = "GitSignsDeleteLn";
|
||||
};
|
||||
topdelete = signOptions {
|
||||
hl = "GitSignsDelete";
|
||||
text = "▔";
|
||||
numhl = "GitSignsDeleteNr";
|
||||
linehl = "GitSignsDeleteLn";
|
||||
};
|
||||
changedelete = signOptions {
|
||||
hl = "GitSignsChange";
|
||||
text = "~";
|
||||
numhl = "GitSignsChangeNr";
|
||||
linehl = "GitSignsChangeLn";
|
||||
};
|
||||
untracked = signOptions {
|
||||
hl = "GitSignsAdd";
|
||||
text = "┆";
|
||||
numhl = "GitSignsAddNr";
|
||||
linehl = "GitSignsAddLn";
|
||||
};
|
||||
};
|
||||
worktrees = let
|
||||
worktreeModule = {
|
||||
options = {
|
||||
toplevel = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
gitdir = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
mkOption {
|
||||
type = types.nullOr (types.listOf (types.submodule worktreeModule));
|
||||
default = null;
|
||||
description = ''
|
||||
Detached working trees.
|
||||
If normal attaching fails, then each entry in the table is attempted with the work tree
|
||||
details set.
|
||||
'';
|
||||
};
|
||||
onAttach = mkOption {
|
||||
type = types.nullOr luaFunction;
|
||||
default = null;
|
||||
description = ''
|
||||
Callback called when attaching to a buffer. Mainly used to setup keymaps
|
||||
when `config.keymaps` is empty. The buffer number is passed as the first
|
||||
argument.
|
||||
|
||||
This callback can return `false` to prevent attaching to the buffer.
|
||||
'';
|
||||
example = ''
|
||||
\'\'
|
||||
function(bufnr)
|
||||
if vim.api.nvim_buf_get_name(bufnr):match(<PATTERN>) then
|
||||
-- Don't attach to specific buffers whose name matches a pattern
|
||||
return false
|
||||
end
|
||||
-- Setup keymaps
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'hs', '<cmd>lua require"gitsigns".stage_hunk()<CR>', {})
|
||||
... -- More keymaps
|
||||
end
|
||||
\'\'
|
||||
'';
|
||||
};
|
||||
|
||||
watchGitDir = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Whether the watcher is enabled";
|
||||
};
|
||||
interval = mkOption {
|
||||
type = types.int;
|
||||
default = 1000;
|
||||
description = "Interval the watcher waits between polls of the gitdir in milliseconds";
|
||||
};
|
||||
followFiles = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "If a file is moved with `git mv`, switch the buffer to the new location";
|
||||
};
|
||||
};
|
||||
signPriority = mkOption {
|
||||
type = types.int;
|
||||
default = 6;
|
||||
description = "Priority to use for signs";
|
||||
};
|
||||
signcolumn = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Enable/disable symbols in the sign column.
|
||||
|
||||
When enabled the highlights defined in `signs.*.hl` and symbols defined
|
||||
in `signs.*.text` are used.
|
||||
'';
|
||||
};
|
||||
numhl = mkEnableOption ''
|
||||
Enable/disable line number highlights.
|
||||
|
||||
When enabled the highlights defined in `signs.*.numhl` are used. If
|
||||
the highlight group does not exist, then it is automatically defined
|
||||
and linked to the corresponding highlight group in `signs.*.hl`.
|
||||
'';
|
||||
linehl = mkEnableOption ''
|
||||
Enable/disable line highlights.
|
||||
|
||||
When enabled the highlights defined in `signs.*.linehl` are used. If
|
||||
the highlight group does not exist, then it is automatically defined
|
||||
and linked to the corresponding highlight group in `signs.*.hl`.
|
||||
'';
|
||||
showDeleted = mkEnableOption ''
|
||||
Show the old version of hunks inline in the buffer (via virtual lines).
|
||||
|
||||
Note: Virtual lines currently use the highlight `GitSignsDeleteVirtLn`.
|
||||
'';
|
||||
diffOpts = let
|
||||
diffOptModule = {
|
||||
options = {
|
||||
algorithm = mkOption {
|
||||
type = types.enum ["myers" "minimal" "patience" "histogram"];
|
||||
default = "myers";
|
||||
description = "Diff algorithm to use";
|
||||
};
|
||||
internal = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Use Neovim's built in xdiff library for running diffs";
|
||||
};
|
||||
indentHeuristic = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Use the indent heuristic for the internal diff library.";
|
||||
};
|
||||
vertical = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Start diff mode with vertical splits";
|
||||
};
|
||||
linematch = mkOption {
|
||||
type = types.nullOr types.int;
|
||||
default = null;
|
||||
description = ''
|
||||
Enable second-stage diff on hunks to align lines.
|
||||
Requires `internal=true`.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
mkOption {
|
||||
type = types.nullOr (types.submodule diffOptModule);
|
||||
default = null;
|
||||
description = "Diff options. If set to null they are derived from the vim diffopt";
|
||||
};
|
||||
base = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = "The object/revision to diff against. Default to 'index'";
|
||||
};
|
||||
countChars = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
default = {
|
||||
"1" = "1";
|
||||
"2" = "2";
|
||||
"3" = "3";
|
||||
"4" = "4";
|
||||
"5" = "5";
|
||||
"6" = "6";
|
||||
"7" = "7";
|
||||
"8" = "8";
|
||||
"9" = "9";
|
||||
"+" = ">";
|
||||
};
|
||||
description = ''
|
||||
The count characters used when `signs.*.show_count` is enabled. The
|
||||
`+` entry is used as a fallback. With the default, any count outside
|
||||
of 1-9 uses the `>` character in the sign.
|
||||
|
||||
Possible use cases for this field:
|
||||
• to specify unicode characters for the counts instead of 1-9.
|
||||
• to define characters to be used for counts greater than 9.
|
||||
'';
|
||||
};
|
||||
statusFormatter = mkOption {
|
||||
type = luaFunction;
|
||||
default = {
|
||||
function = ''
|
||||
function(status)
|
||||
local added, changed, removed = status.added, status.changed, status.removed
|
||||
local status_txt = {}
|
||||
if added and added > 0 then table.insert(status_txt, '+'..added ) end
|
||||
if changed and changed > 0 then table.insert(status_txt, '~'..changed) end
|
||||
if removed and removed > 0 then table.insert(status_txt, '-'..removed) end
|
||||
return table.concat(status_txt, ' ')
|
||||
end
|
||||
'';
|
||||
};
|
||||
description = "Function used to format `b:gitsigns_status`";
|
||||
};
|
||||
maxFileLength = mkOption {
|
||||
type = types.int;
|
||||
default = 40000;
|
||||
description = "Max file length (in lines) to attach to";
|
||||
};
|
||||
previewConfig = mkOption {
|
||||
type = types.attrsOf types.anything;
|
||||
default = {
|
||||
border = "single";
|
||||
style = "minimal";
|
||||
relative = "cursor";
|
||||
row = 0;
|
||||
col = 1;
|
||||
};
|
||||
description = ''
|
||||
Option overrides for the Gitsigns preview window.
|
||||
Table is passed directly to `nvim_open_win`.
|
||||
'';
|
||||
};
|
||||
attachToUntracked = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Attach to untracked files.";
|
||||
};
|
||||
updateDebounce = mkOption {
|
||||
type = types.number;
|
||||
default = 100;
|
||||
description = "Debounce time for updates (in milliseconds).";
|
||||
};
|
||||
currentLineBlame = mkEnableOption ''
|
||||
Adds an unobtrusive and customisable blame annotation at the end of the current line.
|
||||
'';
|
||||
currentLineBlameOpts = {
|
||||
virtText = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Whether to show a virtual text blame annotation";
|
||||
};
|
||||
virtTextPos = mkOption {
|
||||
type = types.enum ["eol" "overlay" "right_align"];
|
||||
default = "eol";
|
||||
description = "Blame annotation position";
|
||||
};
|
||||
delay = mkOption {
|
||||
type = types.int;
|
||||
default = 1000;
|
||||
description = "Sets the delay (in milliseconds) before blame virtual text is displayed";
|
||||
};
|
||||
ignoreWhitespace = mkEnableOption "Ignore whitespace when running blame";
|
||||
virtTextPriority = mkOption {
|
||||
type = types.int;
|
||||
default = 100;
|
||||
description = "Priority of virtual text";
|
||||
};
|
||||
};
|
||||
currentLineBlameFormatter = {
|
||||
normal = mkOption {
|
||||
type = types.either types.str luaFunction;
|
||||
default = " <author>, <author_time> - <summary>";
|
||||
description = ''
|
||||
String or function used to format the virtual text of
|
||||
|gitsigns-config-current_line_blame|.
|
||||
|
||||
See |gitsigns-config-current_line_blame_formatter| for more details.
|
||||
'';
|
||||
};
|
||||
|
||||
nonCommitted = mkOption {
|
||||
type = types.either types.str luaFunction;
|
||||
default = " <author>";
|
||||
description = ''
|
||||
String or function used to format the virtual text of
|
||||
|gitsigns-config-current_line_blame| for lines that aren't committed.
|
||||
'';
|
||||
};
|
||||
};
|
||||
trouble = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
default = null;
|
||||
description = ''
|
||||
When using setqflist() or setloclist(), open Trouble instead of the quickfix/location list
|
||||
window.
|
||||
'';
|
||||
};
|
||||
yadm.enable = mkEnableOption "Enable YADM support";
|
||||
wordDiff = mkEnableOption ''
|
||||
Highlight intra-line word differences in the buffer.
|
||||
Requires `config.diff_opts.internal = true`.
|
||||
'';
|
||||
debugMode = mkEnableOption ''
|
||||
Enables debug logging and makes the following functions available: `dump_cache`,
|
||||
`debug_messages`, `clear_debug`.
|
||||
'';
|
||||
};
|
||||
|
||||
config = let
|
||||
cfg = config.plugins.gitsigns;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = with pkgs.vimPlugins; [
|
||||
gitsigns-nvim
|
||||
];
|
||||
extraConfigLua = let
|
||||
luaFnOrStrToObj = val:
|
||||
if builtins.isString val
|
||||
then val
|
||||
else {__raw = val.function;};
|
||||
setupOptions = {
|
||||
inherit (cfg) worktrees signcolumn numhl linehl trouble yadm;
|
||||
signs = mapAttrs (_: signSetupOptions) cfg.signs;
|
||||
on_attach =
|
||||
if cfg.onAttach != null
|
||||
then {__raw = cfg.onAttach.function;}
|
||||
else null;
|
||||
watch_gitdir = {
|
||||
inherit (cfg.watchGitDir) enable interval;
|
||||
follow_files = cfg.watchGitDir.followFiles;
|
||||
};
|
||||
sign_priority = cfg.signPriority;
|
||||
show_deleted = cfg.showDeleted;
|
||||
diff_opts =
|
||||
if cfg.diffOpts == null
|
||||
then null
|
||||
else {
|
||||
inherit (cfg.diffOpts) algorithm internal vertical linematch;
|
||||
indent_heuristic = cfg.diffOpts.indentHeuristic;
|
||||
};
|
||||
count_chars = let
|
||||
isStrInt = s: (builtins.match "[0-9]+" s) != null;
|
||||
in {
|
||||
__raw =
|
||||
"{"
|
||||
+ (concatStringsSep "," (
|
||||
lib.mapAttrsToList (
|
||||
name: value:
|
||||
if isStrInt name
|
||||
then "[${name}] = ${helpers.toLuaObject value}"
|
||||
else "[${helpers.toLuaObject name}] = ${helpers.toLuaObject value}"
|
||||
)
|
||||
cfg.countChars
|
||||
))
|
||||
+ "}";
|
||||
};
|
||||
status_formatter = {__raw = cfg.statusFormatter.function;};
|
||||
max_file_length = cfg.maxFileLength;
|
||||
preview_config = cfg.previewConfig;
|
||||
attach_to_untracked = cfg.attachToUntracked;
|
||||
update_debounce = cfg.updateDebounce;
|
||||
current_line_blame = cfg.currentLineBlame;
|
||||
current_line_blame_opts = let
|
||||
cfgCl = cfg.currentLineBlameOpts;
|
||||
in {
|
||||
inherit (cfgCl) delay;
|
||||
virt_text = cfgCl.virtText;
|
||||
virt_text_pos = cfgCl.virtTextPos;
|
||||
ignore_whitespace = cfgCl.ignoreWhitespace;
|
||||
virt_text_priority = cfgCl.virtTextPriority;
|
||||
};
|
||||
current_line_blame_formatter = luaFnOrStrToObj cfg.currentLineBlameFormatter.normal;
|
||||
current_line_blame_formatter_nc = luaFnOrStrToObj cfg.currentLineBlameFormatter.nonCommitted;
|
||||
word_diff = cfg.wordDiff;
|
||||
debug_mode = cfg.debugMode;
|
||||
};
|
||||
in ''
|
||||
require('gitsigns').setup(${helpers.toLuaObject setupOptions})
|
||||
'';
|
||||
};
|
||||
}
|
|
@ -22,7 +22,9 @@ rec {
|
|||
"{" + concatMapStringsSep "," toLuaObject args + "}"
|
||||
else if builtins.isString args then
|
||||
# This should be enough!
|
||||
escapeShellArg args
|
||||
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
|
||||
|
@ -104,6 +106,17 @@ rec {
|
|||
inherit value global;
|
||||
};
|
||||
|
||||
extraOptionsOptions = {
|
||||
extraOptions = mkOption {
|
||||
default = { };
|
||||
type = types.attrs;
|
||||
description = ''
|
||||
These attributes will be added to the table parameter for the setup function.
|
||||
(Can override other attributes set by nixvim)
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
mkRaw = r: { __raw = r; };
|
||||
|
||||
wrapDo = string: ''
|
||||
|
|
33
plugins/languages/plantuml-syntax.nix
Normal file
33
plugins/languages/plantuml-syntax.nix
Normal file
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib; {
|
||||
options.plugins.plantuml-syntax = {
|
||||
enable = mkEnableOption "Enable plantuml syntax support";
|
||||
setMakeprg = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Set the makeprg to 'plantuml'";
|
||||
};
|
||||
executableScript = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = "Set the script to be called with makeprg, default to 'plantuml' in PATH";
|
||||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
cfg = config.plugins.plantuml-syntax;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = with pkgs.vimPlugins; [plantuml-syntax];
|
||||
|
||||
globals = {
|
||||
plantuml_set_makeprg = cfg.setMakeprg;
|
||||
plantuml_executable_script = cfg.executableScript;
|
||||
};
|
||||
};
|
||||
}
|
56
plugins/languages/treesitter-context.nix
Normal file
56
plugins/languages/treesitter-context.nix
Normal file
|
@ -0,0 +1,56 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib; {
|
||||
options.plugins.treesitter-context = {
|
||||
enable = mkEnableOption "Enable nvim-treesitter-context";
|
||||
|
||||
maxLines = mkOption {
|
||||
type = types.nullOr types.ints.positive;
|
||||
default = null;
|
||||
description = "How many lines the window should span. Null means no limit";
|
||||
};
|
||||
|
||||
trimScope = mkOption {
|
||||
type = types.enum ["outer" "inner"];
|
||||
default = "outer";
|
||||
description = "Which context lines to discard if `max_lines` is exceeded";
|
||||
};
|
||||
|
||||
maxWindowHeight = mkOption {
|
||||
type = types.nullOr types.ints.positive;
|
||||
default = null;
|
||||
description = "Minimum editor window height to enable context";
|
||||
};
|
||||
|
||||
patterns = mkOption {
|
||||
type = types.attrsOf (types.listOf types.str);
|
||||
default = {};
|
||||
description = ''
|
||||
Patterns to use for context delimitation. The 'default' key matches all filetypes
|
||||
'';
|
||||
};
|
||||
|
||||
exactPatterns = mkOption {
|
||||
type = types.attrsOf types.bool;
|
||||
default = {};
|
||||
description = "Treat the coresponding entry in patterns as an exact match";
|
||||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
cfg = config.plugins.treesitter-context;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = with pkgs.vimPlugins; [nvim-treesitter-context];
|
||||
|
||||
plugins.treesitter.moduleConfig.context = {
|
||||
max_lines = cfg.maxLines;
|
||||
trim_scope = cfg.trimScope;
|
||||
min_window_height = cfg.maxWindowHeight;
|
||||
};
|
||||
};
|
||||
}
|
128
plugins/languages/treesitter-refactor.nix
Normal file
128
plugins/languages/treesitter-refactor.nix
Normal file
|
@ -0,0 +1,128 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; {
|
||||
options.plugins.treesitter-refactor = let
|
||||
disable = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
description = "List of languages to disable the module on";
|
||||
};
|
||||
in {
|
||||
enable =
|
||||
mkEnableOption
|
||||
"Enable treesitter-refactor (requires plugins.treesitter.enable to be true)";
|
||||
highlightDefinitions = {
|
||||
inherit disable;
|
||||
enable =
|
||||
mkEnableOption
|
||||
"Highlights definition and usages of the current symbol under the cursor.";
|
||||
clearOnCursorMove = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Controls if highlights should be cleared when the cursor is moved. If your 'updatetime'
|
||||
is around `100` you can set this to false to have a less laggy experience.
|
||||
'';
|
||||
};
|
||||
};
|
||||
highlightCurrentScope = {
|
||||
inherit disable;
|
||||
enable = mkEnableOption "Highlights the block from the current scope where the cursor is.";
|
||||
};
|
||||
smartRename = {
|
||||
inherit disable;
|
||||
enable =
|
||||
mkEnableOption
|
||||
"Renames the symbol under the cursor within the current scope (and current file).";
|
||||
keymaps = {
|
||||
smartRename = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = "grr";
|
||||
description = "rename symbol under the cursor";
|
||||
};
|
||||
};
|
||||
};
|
||||
navigation = {
|
||||
inherit disable;
|
||||
enable = mkEnableOption ''
|
||||
Provides "go to definition" for the symbol under the cursor,
|
||||
and lists the definitions from the current file.
|
||||
'';
|
||||
|
||||
keymaps = {
|
||||
gotoDefinition = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = "gnd";
|
||||
description = "go to the definition of the symbol under the cursor";
|
||||
};
|
||||
gotoDefinitionLspFallback = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
go to the definition of the symbol under the cursor or use vim.lsp.buf.definition if
|
||||
the symbol can not be resolved. You can use your own fallback function if create a
|
||||
mapping fo `lua require'nvim-treesitter.refactor.navigation(nil, fallback_function)<cr>`.
|
||||
'';
|
||||
};
|
||||
listDefinitons = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = "gnD";
|
||||
description = "list all definitions from the current file";
|
||||
};
|
||||
listDefinitonsToc = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = "gO";
|
||||
description = ''
|
||||
list all definitions from the current file like a table of contents (similar to the one
|
||||
you see when pressing |gO| in help files).
|
||||
'';
|
||||
};
|
||||
gotoNextUsage = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = "<a-*>";
|
||||
description = "go to next usage of identifier under the cursor";
|
||||
};
|
||||
gotoPreviousUsage = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = "<a-#>";
|
||||
description = "go to previous usage of identifier";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
cfg = config.plugins.treesitter-refactor;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = with pkgs.vimPlugins; [nvim-treesitter-refactor];
|
||||
plugins.treesitter.moduleConfig.refactor = {
|
||||
highlight_definitions = {
|
||||
inherit (cfg.highlightDefinitions) enable disable;
|
||||
clear_on_cursor_move = cfg.highlightDefinitions.clearOnCursorMove;
|
||||
};
|
||||
highlight_current_scope = cfg.highlightCurrentScope;
|
||||
smart_rename = {
|
||||
inherit (cfg.smartRename) enable disable;
|
||||
keymaps = {smart_rename = cfg.smartRename.keymaps.smartRename;};
|
||||
};
|
||||
navigation = {
|
||||
inherit (cfg.navigation) enable disable;
|
||||
keymaps = let
|
||||
cfgK = cfg.navigation.keymaps;
|
||||
in {
|
||||
goto_definition = cfgK.gotoDefinition;
|
||||
goto_definition_lsp_fallback = cfgK.gotoDefinitionLspFallback;
|
||||
list_definitions = cfgK.listDefinitons;
|
||||
list_definitions_toc = cfgK.listDefinitonsToc;
|
||||
goto_next_usage = cfgK.gotoNextUsage;
|
||||
goto_previous_usage = cfgK.gotoPreviousUsage;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -21,6 +21,19 @@ in
|
|||
description = "Either \"all\" or a list of languages";
|
||||
};
|
||||
|
||||
parserInstallDir = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default =
|
||||
if cfg.nixGrammars
|
||||
then null
|
||||
else "$XDG_DATA_HOME/nvim/treesitter"
|
||||
;
|
||||
description = ''
|
||||
Location of the parsers to be installed by the plugin (only needed when nixGrammars is disabled).
|
||||
This default might not work on your own install, please make sure that $XDG_DATA_HOME is set if you want to use the default. Otherwise, change it to something that will work for you!
|
||||
'';
|
||||
};
|
||||
|
||||
ignoreInstall = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
|
@ -59,6 +72,18 @@ in
|
|||
indent = mkEnableOption "Enable tree-sitter based indentation";
|
||||
|
||||
folding = mkEnableOption "Enable tree-sitter based folding";
|
||||
|
||||
grammarPackages = mkOption {
|
||||
type = with types; listOf package;
|
||||
default = pkgs.tree-sitter.allGrammars;
|
||||
description = "Grammar packages to install";
|
||||
};
|
||||
|
||||
moduleConfig = mkOption {
|
||||
type = types.attrsOf types.anything;
|
||||
default = { };
|
||||
description = "This is the configuration for extra modules. It should not be used directly";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -90,15 +115,18 @@ in
|
|||
|
||||
ensure_installed = if cfg.nixGrammars then [ ] else cfg.ensureInstalled;
|
||||
ignore_install = cfg.ignoreInstall;
|
||||
};
|
||||
parser_install_dir = cfg.parserInstallDir;
|
||||
} // cfg.moduleConfig;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraConfigLua = ''
|
||||
extraConfigLua = (optionalString (cfg.parserInstallDir != null) ''
|
||||
vim.opt.runtimepath:append("${cfg.parserInstallDir}")
|
||||
'') + ''
|
||||
require('nvim-treesitter.configs').setup(${helpers.toLuaObject tsOptions})
|
||||
'';
|
||||
|
||||
extraPlugins = with pkgs; if cfg.nixGrammars then
|
||||
[ (vimPlugins.nvim-treesitter.withPlugins (_: tree-sitter.allGrammars)) ]
|
||||
[ (vimPlugins.nvim-treesitter.withPlugins (_: cfg.grammarPackages)) ]
|
||||
else [ vimPlugins.nvim-treesitter ];
|
||||
extraPackages = [ pkgs.tree-sitter pkgs.nodejs ];
|
||||
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
{ pkgs, config, lib, ... }@args:
|
||||
{ pkgs, config, lib, inputs, ... }@args:
|
||||
let
|
||||
helpers = import ./helpers.nix args;
|
||||
serverData = {
|
||||
code_actions = {
|
||||
};
|
||||
completion = {
|
||||
code_actions = {
|
||||
gitsigns = { };
|
||||
};
|
||||
completion = { };
|
||||
diagnostics = {
|
||||
flake8 = {
|
||||
packages = [ pkgs.python3Packages.flake8 ];
|
||||
};
|
||||
shellcheck = {
|
||||
packages = [ pkgs.shellcheck ];
|
||||
};
|
||||
};
|
||||
formatting = {
|
||||
phpcbf = {
|
||||
|
@ -21,8 +27,17 @@ let
|
|||
prettier = {
|
||||
packages = [ pkgs.nodePackages.prettier ];
|
||||
};
|
||||
flake8 = {
|
||||
packages = [ pkgs.python3Packages.flake8 ];
|
||||
black = {
|
||||
packages = [ pkgs.python3Packages.black ];
|
||||
};
|
||||
beautysh = {
|
||||
packages = [ inputs.beautysh.packages.${pkgs.system}.beautysh-python38 ];
|
||||
};
|
||||
fourmolu = {
|
||||
packages = [ pkgs.haskellPackages.fourmolu ];
|
||||
};
|
||||
fnlfmt = {
|
||||
packages = [ pkgs.fnlfmt ];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -32,11 +47,20 @@ let
|
|||
# sourceType = "formatting";
|
||||
# packages = [...];
|
||||
# }]
|
||||
serverDataFormatted = lib.mapAttrsToList (sourceType: sourceSet:
|
||||
lib.mapAttrsToList (name: attrs: attrs // { inherit sourceType name; }) sourceSet
|
||||
) serverData;
|
||||
serverDataFormatted = lib.mapAttrsToList
|
||||
(sourceType: sourceSet:
|
||||
lib.mapAttrsToList (name: attrs: attrs // { inherit sourceType name; }) sourceSet
|
||||
)
|
||||
serverData;
|
||||
dataFlattened = lib.flatten serverDataFormatted;
|
||||
in
|
||||
{
|
||||
imports = lib.lists.map (helpers.mkServer) dataFlattened;
|
||||
|
||||
config = let
|
||||
cfg = config.plugins.null-ls;
|
||||
in
|
||||
lib.mkIf cfg.enable {
|
||||
plugins.gitsigns.enable = lib.mkIf (cfg.sources.code_actions.gitsigns.enable) true;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
{ pkgs, config, lib, ... }@args:
|
||||
with lib;
|
||||
let
|
||||
helpers = import ./helpers.nix args;
|
||||
servers = [
|
||||
{
|
||||
name = "bashls";
|
||||
description = "Enable bashls, for bash.";
|
||||
packages = [ pkgs.nodePackages.bash-language-server ];
|
||||
}
|
||||
{
|
||||
name = "clangd";
|
||||
description = "Enable clangd LSP, for C/C++.";
|
||||
|
@ -12,6 +18,102 @@ let
|
|||
description = "Enable cssls, for CSS";
|
||||
package = pkgs.nodePackages.vscode-langservers-extracted;
|
||||
}
|
||||
{
|
||||
name = "dartls";
|
||||
description = "Enable dart language-server, for dart";
|
||||
packages = [ pkgs.dart ];
|
||||
extraOptions = {
|
||||
analysisExcludedFolders = mkOption {
|
||||
type = types.nullOr (types.listOf types.str);
|
||||
default = null;
|
||||
description = ''
|
||||
An array of paths (absolute or relative to each workspace folder) that should be
|
||||
excluded from analysis.
|
||||
'';
|
||||
};
|
||||
enableSdkFormatter = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
default = null;
|
||||
description = ''
|
||||
When set to false, prevents registration (or unregisters) the SDK formatter. When set
|
||||
to true or not supplied, will register/reregister the SDK formatter
|
||||
'';
|
||||
};
|
||||
lineLength = mkOption {
|
||||
type = types.nullOr types.int;
|
||||
default = null;
|
||||
description = ''
|
||||
The number of characters the formatter should wrap code at. If unspecified, code will
|
||||
be wrapped at 80 characters.
|
||||
'';
|
||||
};
|
||||
completeFunctionCalls = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
When set to true, completes functions/methods with their required parameters.
|
||||
'';
|
||||
};
|
||||
showTodos = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to generate diagnostics for TODO comments. If unspecified, diagnostics will not
|
||||
be generated.
|
||||
'';
|
||||
};
|
||||
renameFilesWithClasses = mkOption {
|
||||
type = types.nullOr (types.enum [ "always" "prompt" ]);
|
||||
default = null;
|
||||
description = ''
|
||||
When set to "always", will include edits to rename files when classes are renamed if the
|
||||
filename matches the class name (but in snake_form). When set to "prompt", a prompt will
|
||||
be shown on each class rename asking to confirm the file rename. Otherwise, files will
|
||||
not be renamed. Renames are performed using LSP's ResourceOperation edits - that means
|
||||
the rename is simply included in the resulting WorkspaceEdit and must be handled by the
|
||||
client.
|
||||
'';
|
||||
};
|
||||
enableSnippets = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
default = null;
|
||||
description = ''
|
||||
Whether to include code snippets (such as class, stful, switch) in code completion. When
|
||||
unspecified, snippets will be included.
|
||||
'';
|
||||
};
|
||||
updateImportsOnRename = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
default = null;
|
||||
description = ''
|
||||
Whether to update imports and other directives when files are renamed. When unspecified,
|
||||
imports will be updated if the client supports willRenameFiles requests
|
||||
'';
|
||||
};
|
||||
documentation = mkOption {
|
||||
type = types.nullOr (types.enum [ "none" "summary" "full" ]);
|
||||
default = null;
|
||||
description = ''
|
||||
The typekind of dartdocs to include in Hovers, Code Completion, Signature Help and other
|
||||
similar requests. If not set, defaults to full
|
||||
'';
|
||||
};
|
||||
includeDependenciesInWorkspaceSymbols = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
default = null;
|
||||
description = ''
|
||||
Whether to include symbols from dependencies and Dart/Flutter SDKs in Workspace Symbol
|
||||
results. If not set, defaults to true.
|
||||
'';
|
||||
};
|
||||
};
|
||||
settings = cfg: { dart = cfg; };
|
||||
}
|
||||
{
|
||||
name = "denols";
|
||||
description = "Enable denols, for Deno";
|
||||
packages = [ pkgs.deno ];
|
||||
}
|
||||
{
|
||||
name = "eslint";
|
||||
description = "Enable eslint";
|
||||
|
@ -42,6 +144,42 @@ let
|
|||
description = "Enable jsonls, for JSON";
|
||||
package = pkgs.nodePackages.vscode-langservers-extracted;
|
||||
}
|
||||
{
|
||||
name = "nil_ls";
|
||||
description = "Enable nil, for Nix";
|
||||
packages = [ pkgs.nil ];
|
||||
extraOptions = {
|
||||
formatting.command = mkOption {
|
||||
type = types.nullOr (types.listOf types.str);
|
||||
default = null;
|
||||
description = ''
|
||||
External formatter command (with arguments).
|
||||
It should accepts file content in stdin and print the formatted code into stdout.
|
||||
'';
|
||||
};
|
||||
diagnostics = {
|
||||
ignored = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = ''
|
||||
Ignored diagnostic kinds.
|
||||
The kind identifier is a snake_cased_string usually shown together
|
||||
with the diagnostic message.
|
||||
'';
|
||||
};
|
||||
excludedFiles = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = ''
|
||||
Files to exclude from showing diagnostics. Useful for generated files.
|
||||
It accepts an array of paths. Relative paths are joint to the workspace root.
|
||||
Glob patterns are currently not supported.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
settings = cfg: { nil = { inherit (cfg) formatting diagnostics; }; };
|
||||
}
|
||||
{
|
||||
name = "pyright";
|
||||
description = "Enable pyright, for Python.";
|
||||
|
@ -56,6 +194,16 @@ let
|
|||
description = "Enable rust-analyzer, for Rust.";
|
||||
serverName = "rust_analyzer";
|
||||
}
|
||||
{
|
||||
name = "tailwindcss";
|
||||
description = "Enable tailwindcss language server, for tailwindcss";
|
||||
packages = [ pkgs.nodePackages."@tailwindcss/language-server" ];
|
||||
}
|
||||
{
|
||||
name = "texlab";
|
||||
description = "Enable texlab language server, for LaTeX";
|
||||
packages = [ pkgs.texlab ];
|
||||
}
|
||||
{
|
||||
name = "tsserver";
|
||||
description = "Enable tsserver for typescript";
|
||||
|
@ -73,6 +221,12 @@ let
|
|||
name = "zls";
|
||||
description = "Enable zls, for Zig.";
|
||||
}
|
||||
{
|
||||
name = "hls";
|
||||
description = "Enable haskell language server";
|
||||
packages = [ pkgs.haskell-language-server ];
|
||||
cmd = [ "haskell-language-server-wrapper" ];
|
||||
}
|
||||
];
|
||||
in
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@ in
|
|||
|
||||
onAttach = mkOption {
|
||||
type = types.lines;
|
||||
description = "A lua function to be run when a new LSP buffer is attached. The argument `client` is provided.";
|
||||
description = "A lua function to be run when a new LSP buffer is attached. The argument `client` and `bufnr` is provided.";
|
||||
default = "";
|
||||
};
|
||||
|
||||
|
@ -69,7 +69,7 @@ in
|
|||
do
|
||||
${cfg.preConfig}
|
||||
local __lspServers = ${helpers.toLuaObject cfg.enabledServers}
|
||||
local __lspOnAttach = function(client)
|
||||
local __lspOnAttach = function(client, bufnr)
|
||||
${cfg.onAttach}
|
||||
end
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
, package ? pkgs.${name}
|
||||
, extraPackages ? { }
|
||||
, cmd ? null
|
||||
, settings ? null
|
||||
, extraOptions ? { }
|
||||
, ...
|
||||
}:
|
||||
# returns a module
|
||||
|
@ -49,6 +51,7 @@
|
|||
name = serverName;
|
||||
extraOptions = {
|
||||
inherit cmd;
|
||||
settings = if settings != null then settings cfg else { };
|
||||
};
|
||||
}];
|
||||
};
|
||||
|
|
|
@ -8,10 +8,24 @@ in
|
|||
options = {
|
||||
plugins.lsp-lines = {
|
||||
enable = mkEnableOption "lsp_lines.nvim";
|
||||
currentLine = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Show diagnostics only on current line";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
diagnosticConfig = {
|
||||
virtual_text = false;
|
||||
virtual_lines =
|
||||
if cfg.currentLine then {
|
||||
only_current_line = true;
|
||||
} else true;
|
||||
};
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = [ pkgs.vimPlugins.lsp_lines-nvim ];
|
||||
|
||||
|
@ -19,9 +33,7 @@ in
|
|||
do
|
||||
require("lsp_lines").setup()
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_text = false
|
||||
})
|
||||
vim.diagnostic.config(${ helpers.toLuaObject diagnosticConfig })
|
||||
end
|
||||
'';
|
||||
};
|
||||
|
|
24
plugins/nvim-lsp/trouble.nix
Normal file
24
plugins/nvim-lsp/trouble.nix
Normal file
|
@ -0,0 +1,24 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
let
|
||||
cfg = config.plugins.trouble;
|
||||
helpers = import ../helpers.nix { inherit lib; };
|
||||
in
|
||||
with lib;
|
||||
# with helpers;
|
||||
{
|
||||
options.plugins.trouble = {
|
||||
enable = mkEnableOption "trouble.nvim";
|
||||
|
||||
position = helpers.mkNullOrOption (types.enum [ "top" "left" "right" "bottom" ]) "Position of the list";
|
||||
height = helpers.mkNullOrOption types.int "Height of the trouble list when position is top or bottom";
|
||||
width = helpers.mkNullOrOption types.int "Width of the trouble list when position is left or right";
|
||||
icons = helpers.mkNullOrOption types.bool "Use devicons for filenames";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
extraPlugins = with pkgs.vimPlugins; [
|
||||
trouble-nvim
|
||||
nvim-web-devicons
|
||||
];
|
||||
};
|
||||
}
|
|
@ -53,7 +53,7 @@
|
|||
pname = "std2";
|
||||
version = "48bb39b69ed631ef64eed6123443484133fd20fc";
|
||||
|
||||
doCheck = false;
|
||||
doCheck = true;
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "ms-jpq";
|
||||
|
@ -84,4 +84,42 @@
|
|||
sha256 = "sha256-AtkG2XRVZgvJzH2iLr7UT/U1+LXxenvNckdapnJV+8A=";
|
||||
};
|
||||
};
|
||||
|
||||
magma-nvim = pkgs.vimUtils.buildVimPlugin rec {
|
||||
pname = "magma-nvim";
|
||||
version = "94370733757d550594fe4a1d65643949d7485989";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "WhiteBlackGoose";
|
||||
repo = "magma-nvim-goose";
|
||||
rev = version;
|
||||
sha256 = "sha256-IaslJK1F2BxTvZzKGH9OKOl2RICi4d4rSgjliAIAqK4=";
|
||||
};
|
||||
|
||||
|
||||
|
||||
passthru.python3Dependencies = ps: with ps; [
|
||||
pynvim
|
||||
jupyter-client
|
||||
ueberzug
|
||||
pillow
|
||||
cairosvg
|
||||
plotly
|
||||
ipykernel
|
||||
pyperclip
|
||||
(ps.buildPythonPackage rec {
|
||||
pname = "pnglatex";
|
||||
version = "1.1";
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
hash = "sha256-CZUGDUkmttO0BzFYbGFSNMPkWzFC/BW4NmAeOwz4Y9M=";
|
||||
};
|
||||
doCheck = false;
|
||||
meta = with lib; {
|
||||
homepage = "https://github.com/MaT1g3R/pnglatex";
|
||||
description = "a small program that converts LaTeX snippets to png";
|
||||
};
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
98
plugins/snippets/luasnip/default.nix
Normal file
98
plugins/snippets/luasnip/default.nix
Normal file
|
@ -0,0 +1,98 @@
|
|||
{ pkgs, config, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.luasnip;
|
||||
helpers = import ../../helpers.nix { lib = lib; };
|
||||
in
|
||||
{
|
||||
options.plugins.luasnip = {
|
||||
enable = mkEnableOption "Enable luasnip";
|
||||
|
||||
package = mkOption {
|
||||
default = pkgs.vimPlugins.luasnip;
|
||||
type = types.package;
|
||||
};
|
||||
|
||||
fromVscode = mkOption {
|
||||
default = [ ];
|
||||
example = ''
|
||||
[
|
||||
{}
|
||||
{
|
||||
paths = ./path/to/snippets;
|
||||
}
|
||||
]
|
||||
# generates:
|
||||
#
|
||||
# require("luasnip.loaders.from_vscode").lazy_load({})
|
||||
# require("luasnip.loaders.from_vscode").lazy_load({['paths'] = {'/nix/store/.../path/to/snippets'}})
|
||||
#
|
||||
'';
|
||||
type = types.listOf (types.submodule {
|
||||
options = {
|
||||
lazyLoad = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether or not to lazy load the snippets
|
||||
'';
|
||||
};
|
||||
|
||||
# TODO: add option to also include the default runtimepath
|
||||
paths = mkOption {
|
||||
default = null;
|
||||
type = with types; nullOr (oneOf
|
||||
[
|
||||
str
|
||||
path
|
||||
helpers.rawType
|
||||
(listOf (oneOf
|
||||
[
|
||||
str
|
||||
path
|
||||
helpers.rawType
|
||||
]))
|
||||
]);
|
||||
};
|
||||
|
||||
exclude = mkOption {
|
||||
type = types.nullOr (types.listOf types.str);
|
||||
default = null;
|
||||
description = ''
|
||||
List of languages to exclude, by default is empty.
|
||||
'';
|
||||
};
|
||||
|
||||
include = mkOption {
|
||||
type = types.nullOr (types.listOf types.str);
|
||||
default = null;
|
||||
description = ''
|
||||
List of languages to include, by default is not set.
|
||||
'';
|
||||
};
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
# TODO: add support for snipmate
|
||||
# TODO: add support for lua
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
|
||||
fromVscodeLoaders = lists.map
|
||||
(loader:
|
||||
let
|
||||
options = attrsets.getAttrs [ "paths" "exclude" "include" ] loader;
|
||||
in
|
||||
''
|
||||
require("luasnip.loaders.from_vscode").${optionalString loader.lazyLoad "lazy_"}load(${helpers.toLuaObject options})
|
||||
'')
|
||||
cfg.fromVscode;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = [ cfg.package ];
|
||||
extraConfigLua = concatStringsSep "\n" fromVscodeLoaders;
|
||||
};
|
||||
}
|
|
@ -35,6 +35,18 @@ in
|
|||
description = "Configuration for the extensions. Don't use this directly";
|
||||
default = { };
|
||||
};
|
||||
|
||||
defaults = mkOption {
|
||||
type = types.nullOr types.attrs;
|
||||
default = null;
|
||||
description = "Telescope default configuration";
|
||||
};
|
||||
|
||||
extraOptions = mkOption {
|
||||
type = types.attrs;
|
||||
default = { };
|
||||
description = "An attribute set, that lets you set extra options or override options set by nixvim";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
@ -50,13 +62,16 @@ in
|
|||
let $BAT_THEME = '${cfg.highlightTheme}'
|
||||
'';
|
||||
|
||||
extraConfigLua = ''
|
||||
extraConfigLua = let
|
||||
options = {
|
||||
extensions = cfg.extensionConfig;
|
||||
defaults = cfg.defaults;
|
||||
} // cfg.extraOptions;
|
||||
in ''
|
||||
do
|
||||
local __telescopeExtensions = ${helpers.toLuaObject cfg.enabledExtensions}
|
||||
|
||||
require('telescope').setup{
|
||||
extensions = ${helpers.toLuaObject cfg.extensionConfig}
|
||||
}
|
||||
require('telescope').setup(${helpers.toLuaObject options})
|
||||
|
||||
for i, extension in ipairs(__telescopeExtensions) do
|
||||
require('telescope').load_extension(extension)
|
||||
|
|
111
plugins/utils/magma-nvim.nix
Normal file
111
plugins/utils/magma-nvim.nix
Normal file
|
@ -0,0 +1,111 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.magma-nvim;
|
||||
plugins = import ../plugin-defs.nix { inherit pkgs; };
|
||||
package = pkgs.fetchFromGitHub {
|
||||
owner = "dccsillag";
|
||||
repo = "magma-nvim";
|
||||
rev = version;
|
||||
sha256 = "sha256-IaslJK1F2BxTvZzKGH9OKOl2RICi4d4rSgjliAIAqK4=";
|
||||
};
|
||||
in {
|
||||
options = {
|
||||
plugins.magma-nvim = {
|
||||
enable = mkEnableOption "Enable magma-nvim?";
|
||||
image_provider = mkOption {
|
||||
type = types.enum [ "none" "ueberzug" "kitty" ];
|
||||
default = "none";
|
||||
example = "ueberzug";
|
||||
description =
|
||||
" This configures how to display images. The following options are available:
|
||||
none -- don't show imagesmagma_image_provider.
|
||||
ueberzug -- use Ueberzug to display images.
|
||||
kitty -- use the Kitty protocol to display images.";
|
||||
};
|
||||
automatically_open_output = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
example = false;
|
||||
description =
|
||||
" If this is true, then whenever you have an active cell its output window will be automatically shown.
|
||||
If this is false, then the output window will only be automatically shown when you've just evaluated the code. So, if you take your cursor out of the cell, and then come back, the output window won't be opened (but the cell will be highlighted). This means that there will be nothing covering your code. You can then open the output window at will using :MagmaShowOutput.";
|
||||
};
|
||||
|
||||
wrap_output = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
example = false;
|
||||
description =
|
||||
" If this is true, then text output in the output window will be wrapped (akin to set wrap).";
|
||||
};
|
||||
|
||||
output_window_borders = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
example = false;
|
||||
description =
|
||||
" If this is true, then the output window will have rounded borders. If it is false, it will have no borders.";
|
||||
};
|
||||
|
||||
cell_highlight_group = mkOption {
|
||||
type = types.str;
|
||||
default = "CursorLine";
|
||||
# example = "";
|
||||
description =
|
||||
" The highlight group to be used for highlighting cells.";
|
||||
};
|
||||
save_path = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description =
|
||||
"Where to save/load with :MagmaSave and :MagmaLoad (with no parameters).
|
||||
The generated file is placed in this directory, with the filename itself being the buffer's name, with % replaced by %% and / replaced by %, and postfixed with the extension .json.";
|
||||
};
|
||||
show_mimetype_debug = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
example = true;
|
||||
description =
|
||||
" If this is true, then before any non-iostream output chunk, Magma shows the mimetypes it received for it.
|
||||
This is meant for debugging and adding new mimetypes.";
|
||||
};
|
||||
package = mkOption {
|
||||
type = types.nullOr types.package;
|
||||
default = null;
|
||||
example =
|
||||
"package = pkgs.fetchFromGitHub {
|
||||
owner = \"WhiteBlackGoose\";
|
||||
repo = \"magma-nvim-goose\";
|
||||
rev = version;
|
||||
sha256 = \"sha256-IaslJK1F2BxTvZzKGH9OKOl2RICi4d4rSgjliAIAqK4=\";} ";
|
||||
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
config = mkIf cfg.enable {
|
||||
extraPlugins = [ (
|
||||
if cfg.package != null then plugins.magma-nvim.override {src = cfg.package;} else plugins.magma-nvim
|
||||
)];
|
||||
|
||||
|
||||
globals = {
|
||||
magma_image_provider =
|
||||
mkIf (cfg.image_provider != "none") cfg.image_provider;
|
||||
magma_automatically_open_output =
|
||||
mkIf (!cfg.automatically_open_output) cfg.automatically_open_output;
|
||||
magma_wrap_output = mkIf (!cfg.wrap_output) cfg.wrap_output;
|
||||
magma_output_window_borders =
|
||||
mkIf (!cfg.output_window_borders) cfg.output_window_borders;
|
||||
magma_highlight_group = mkIf (cfg.cell_highlight_group != "CursorLine")
|
||||
cfg.cell_highlight_group;
|
||||
magma_show_mimetype_debug =
|
||||
mkIf cfg.show_mimetype_debug cfg.show_mimetype_debug;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -48,11 +48,17 @@ in
|
|||
description = "Hijack cursor";
|
||||
};
|
||||
|
||||
# TODO: change this to it's new definition sync_root_with_cwd
|
||||
updateCwd = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
default = null;
|
||||
};
|
||||
|
||||
respectBufCwd = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
default = null;
|
||||
};
|
||||
|
||||
updateToBufDir = {
|
||||
enable = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
|
@ -94,6 +100,7 @@ in
|
|||
default = null;
|
||||
};
|
||||
|
||||
# TODO: change this to it's new definition update_root
|
||||
updateCwd = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
default = null;
|
||||
|
@ -214,12 +221,13 @@ in
|
|||
open_on_tab = cfg.openOnTab;
|
||||
hijack_cursor = cfg.hijackCursor;
|
||||
update_cwd = cfg.updateCwd;
|
||||
respect_buf_cwd = cfg.respectBufCwd;
|
||||
update_to_buf_dir = {
|
||||
enable = cfg.updateToBufDir.enable;
|
||||
auto_open = cfg.updateToBufDir.autoOpen;
|
||||
};
|
||||
diagnostics = cfg.diagnostics;
|
||||
updateFocusedFile = {
|
||||
update_focused_file = {
|
||||
enable = cfg.updateFocusedFile.enable;
|
||||
update_cwd = cfg.updateFocusedFile.updateCwd;
|
||||
ignore_list = cfg.updateFocusedFile.ignoreList;
|
||||
|
|
|
@ -5,7 +5,7 @@ let
|
|||
helpers = import ../helpers.nix { inherit lib; };
|
||||
in
|
||||
{
|
||||
options.plugins.project-nvim = {
|
||||
options.plugins.project-nvim = helpers.extraOptionsOptions // {
|
||||
enable = mkEnableOption "Enable project.nvim";
|
||||
|
||||
manualMode = mkOption {
|
||||
|
@ -52,6 +52,7 @@ in
|
|||
type = types.nullOr (types.either types.str helpers.rawType);
|
||||
default = null;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config =
|
||||
|
@ -66,7 +67,7 @@ in
|
|||
silent_chdir = cfg.silentChdir;
|
||||
scope_schdir = cfg.scopeChdir;
|
||||
data_path = cfg.dataPath;
|
||||
};
|
||||
} // cfg.extraOptions;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = [ pkgs.vimPlugins.project-nvim ];
|
||||
|
|
|
@ -35,6 +35,11 @@ in
|
|||
default = 10;
|
||||
};
|
||||
|
||||
color = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
};
|
||||
|
||||
width = mkOption {
|
||||
type = types.int;
|
||||
default = 10;
|
||||
|
@ -117,6 +122,7 @@ in
|
|||
cfg.ignored_buffertypes);
|
||||
popup = {
|
||||
inherit (cfg) blend width;
|
||||
winhl = if (!isNull cfg.color) then "SpecsPopColor" else "PMenu";
|
||||
delay_ms = cfg.delay;
|
||||
inc_ms = cfg.increment;
|
||||
fader = helpers.mkRaw (if cfg.fader.builtin == null then
|
||||
|
@ -133,6 +139,8 @@ in
|
|||
mkIf cfg.enable {
|
||||
extraPlugins = [ pkgs.vimPlugins.specs-nvim ];
|
||||
|
||||
highlight.SpecsPopColor.bg = mkIf (!isNull cfg.color) cfg.color;
|
||||
|
||||
extraConfigLua = ''
|
||||
require('specs').setup(${setup})
|
||||
'';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue