mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-01-02 17:15:55 +00:00
modules: start breaking down core modules; simplify tree structure
This commit is contained in:
parent
4703ed7731
commit
370913e827
242 changed files with 178 additions and 124 deletions
90
modules/plugins/assistant/copilot/config.nix
Normal file
90
modules/plugins/assistant/copilot/config.nix
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) toJSON;
|
||||
inherit (lib) mkIf nvim mkLuaBinding mkMerge;
|
||||
|
||||
cfg = config.vim.assistant.copilot;
|
||||
|
||||
wrapPanelBinding = luaFunction: key: ''
|
||||
function()
|
||||
local s, _ = pcall(${luaFunction})
|
||||
|
||||
if not s then
|
||||
local termcode = vim.api.nvim_replace_termcodes(${toJSON key}, true, false, true)
|
||||
|
||||
vim.fn.feedkeys(termcode, 'n')
|
||||
end
|
||||
end
|
||||
'';
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins =
|
||||
[
|
||||
"copilot-lua"
|
||||
cfg.copilotNodePackage
|
||||
]
|
||||
++ lib.optionals (cfg.cmp.enable) [
|
||||
"copilot-cmp"
|
||||
];
|
||||
|
||||
vim.luaConfigRC.copilot = nvim.dag.entryAnywhere ''
|
||||
require("copilot").setup({
|
||||
-- available options: https://github.com/zbirenbaum/copilot.lua
|
||||
copilot_node_command = "${cfg.copilotNodeCommand}",
|
||||
panel = {
|
||||
enabled = ${lib.boolToString (!cfg.cmp.enable)},
|
||||
keymap = {
|
||||
jump_prev = false,
|
||||
jump_next = false,
|
||||
accept = false,
|
||||
refresh = false,
|
||||
open = false,
|
||||
},
|
||||
layout = {
|
||||
position = "${cfg.panel.position}",
|
||||
ratio = ${toString cfg.panel.ratio},
|
||||
},
|
||||
},
|
||||
suggestion = {
|
||||
enabled = ${lib.boolToString (!cfg.cmp.enable)},
|
||||
keymap = {
|
||||
accept = false,
|
||||
accept_word = false,
|
||||
accept_line = false,
|
||||
next = false,
|
||||
prev = false,
|
||||
dismiss = false,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
${lib.optionalString (cfg.cmp.enable) ''
|
||||
require("copilot_cmp").setup()
|
||||
''}
|
||||
'';
|
||||
|
||||
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")
|
||||
];
|
||||
};
|
||||
}
|
||||
113
modules/plugins/assistant/copilot/copilot.nix
Normal file
113
modules/plugins/assistant/copilot/copilot.nix
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption mkOption types;
|
||||
|
||||
cfg = config.vim.assistant.copilot;
|
||||
in {
|
||||
options.vim.assistant.copilot = {
|
||||
enable = mkEnableOption "GitHub Copilot AI assistant";
|
||||
cmp.enable = mkEnableOption "nvim-cmp integration for GitHub Copilot";
|
||||
|
||||
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";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
copilotNodeCommand = mkOption {
|
||||
type = types.str;
|
||||
default = "${lib.getExe cfg.copilotNodePackage}";
|
||||
description = ''
|
||||
The command that will be executed to initiate nodejs for GitHub Copilot.
|
||||
Recommended to leave as default.
|
||||
'';
|
||||
};
|
||||
|
||||
copilotNodePackage = mkOption {
|
||||
type = with types; nullOr package;
|
||||
default = pkgs.nodejs-slim;
|
||||
description = ''
|
||||
The nodeJS package that will be used for GitHub Copilot. If you are using a custom node command
|
||||
you may want to set this option to null so that the package is not pulled from nixpkgs.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
6
modules/plugins/assistant/copilot/default.nix
Normal file
6
modules/plugins/assistant/copilot/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./copilot.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
||||
6
modules/plugins/assistant/default.nix
Normal file
6
modules/plugins/assistant/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./copilot
|
||||
# ./tabnine.nix # removed until I find a way around the initialisation script the plugin requires
|
||||
];
|
||||
}
|
||||
54
modules/plugins/assistant/tabnine/config.nix
Normal file
54
modules/plugins/assistant/tabnine/config.nix
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) toJSON;
|
||||
inherit (lib) mkIf mkMerge mkExprBinding boolToString nvim;
|
||||
|
||||
cfg = config.vim.assistant.tabnine;
|
||||
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 "${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 "${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 = null,
|
||||
dismiss_keymap = null,
|
||||
debounce_ms = ${cfg.debounce_ms},
|
||||
exclude_filetypes = ${cfg.exclude_filetypes},
|
||||
})
|
||||
'';
|
||||
};
|
||||
}
|
||||
6
modules/plugins/assistant/tabnine/default.nix
Normal file
6
modules/plugins/assistant/tabnine/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./config.nix
|
||||
./tabnine.nix
|
||||
];
|
||||
}
|
||||
30
modules/plugins/assistant/tabnine/tabnine.nix
Normal file
30
modules/plugins/assistant/tabnine/tabnine.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib) mkEnableOption mkOption types mkMappingOption;
|
||||
in {
|
||||
options.vim.assistant.tabnine = {
|
||||
enable = mkEnableOption "Tabnine assistant";
|
||||
|
||||
disable_auto_comment = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Disable auto comment";
|
||||
};
|
||||
|
||||
mappings = {
|
||||
accept = mkMappingOption "Accept [Tabnine]" "<Tab>";
|
||||
dismiss = mkMappingOption "Dismiss [Tabnine]" "<C-]>";
|
||||
};
|
||||
|
||||
debounce_ms = mkOption {
|
||||
type = types.int;
|
||||
default = 800;
|
||||
description = "Debounce ms";
|
||||
};
|
||||
|
||||
exclude_filetypes = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = ["TelescopePrompt" "NvimTree" "alpha"];
|
||||
description = "Exclude filetypes";
|
||||
};
|
||||
};
|
||||
}
|
||||
5
modules/plugins/autopairs/default.nix
Normal file
5
modules/plugins/autopairs/default.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
_: {
|
||||
imports = [
|
||||
./nvim-autopairs
|
||||
];
|
||||
}
|
||||
26
modules/plugins/autopairs/nvim-autopairs/config.nix
Normal file
26
modules/plugins/autopairs/nvim-autopairs/config.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf nvim optionalString boolToString;
|
||||
|
||||
cfg = config.vim.autopairs;
|
||||
in {
|
||||
config =
|
||||
mkIf (cfg.enable)
|
||||
{
|
||||
vim.startPlugins = ["nvim-autopairs"];
|
||||
|
||||
vim.luaConfigRC.autopairs = nvim.dag.entryAnywhere ''
|
||||
require("nvim-autopairs").setup{}
|
||||
${optionalString (config.vim.autocomplete.type == "nvim-compe") ''
|
||||
require('nvim-autopairs.completion.compe').setup({
|
||||
map_cr = ${boolToString cfg.nvim-compe.map_cr},
|
||||
map_complete = ${boolToString cfg.nvim-compe.map_complete},
|
||||
auto_select = ${boolToString cfg.nvim-compe.auto_select},
|
||||
})
|
||||
''}
|
||||
'';
|
||||
};
|
||||
}
|
||||
6
modules/plugins/autopairs/nvim-autopairs/default.nix
Normal file
6
modules/plugins/autopairs/nvim-autopairs/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./config.nix
|
||||
./nvim-autopairs.nix
|
||||
];
|
||||
}
|
||||
35
modules/plugins/autopairs/nvim-autopairs/nvim-autopairs.nix
Normal file
35
modules/plugins/autopairs/nvim-autopairs/nvim-autopairs.nix
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib) mkEnableOption mkOption types;
|
||||
in {
|
||||
options.vim = {
|
||||
autopairs = {
|
||||
enable = mkEnableOption "autopairs" // {default = false;};
|
||||
|
||||
type = mkOption {
|
||||
type = types.enum ["nvim-autopairs"];
|
||||
default = "nvim-autopairs";
|
||||
description = "Set the autopairs type. Options: nvim-autopairs [nvim-autopairs]";
|
||||
};
|
||||
|
||||
nvim-compe = {
|
||||
map_cr = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''map <CR> on insert mode'';
|
||||
};
|
||||
|
||||
map_complete = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "auto insert `(` after select function or method item";
|
||||
};
|
||||
|
||||
auto_select = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "auto select first item";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
18
modules/plugins/comments/comment-nvim/comment-nvim.nix
Normal file
18
modules/plugins/comments/comment-nvim/comment-nvim.nix
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib) mkEnableOption mkMappingOption;
|
||||
in {
|
||||
options.vim.comments.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";
|
||||
};
|
||||
};
|
||||
}
|
||||
50
modules/plugins/comments/comment-nvim/config.nix
Normal file
50
modules/plugins/comments/comment-nvim/config.nix
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf mkMerge mkExprBinding mkBinding nvim;
|
||||
|
||||
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({
|
||||
mappings = { basic = false, extra = false, },
|
||||
})
|
||||
'';
|
||||
};
|
||||
}
|
||||
6
modules/plugins/comments/comment-nvim/default.nix
Normal file
6
modules/plugins/comments/comment-nvim/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./config.nix
|
||||
./comment-nvim.nix
|
||||
];
|
||||
}
|
||||
5
modules/plugins/comments/default.nix
Normal file
5
modules/plugins/comments/default.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
_: {
|
||||
imports = [
|
||||
./comment-nvim
|
||||
];
|
||||
}
|
||||
5
modules/plugins/completion/default.nix
Normal file
5
modules/plugins/completion/default.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
_: {
|
||||
imports = [
|
||||
./nvim-cmp
|
||||
];
|
||||
}
|
||||
241
modules/plugins/completion/nvim-cmp/config.nix
Normal file
241
modules/plugins/completion/nvim-cmp/config.nix
Normal file
|
|
@ -0,0 +1,241 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) toJSON;
|
||||
inherit (lib) addDescriptionsToMappings concatMapStringsSep attrNames concatStringsSep mapAttrsToList mkIf mkSetLuaBinding mkMerge optionalString;
|
||||
inherit (lib.nvim) dag;
|
||||
|
||||
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"
|
||||
(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 dag.entryAfter ["lspkind"]
|
||||
else dag.entryAnywhere;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"nvim-cmp"
|
||||
"cmp-buffer"
|
||||
"cmp-vsnip"
|
||||
"cmp-path"
|
||||
"vim-vsnip"
|
||||
];
|
||||
|
||||
vim.autocomplete.sources = {
|
||||
"nvim-cmp" = null;
|
||||
"vsnip" = "[VSnip]";
|
||||
"buffer" = "[Buffer]";
|
||||
"crates" = "[Crates]";
|
||||
"path" = "[Path]";
|
||||
"copilot" = "[Copilot]";
|
||||
};
|
||||
|
||||
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(${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(${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 ''
|
||||
require('cmp').mapping.scroll_docs(-4)
|
||||
'')
|
||||
(mkSetLuaBinding mappings.scrollDocsDown ''
|
||||
require('cmp').mapping.scroll_docs(4)
|
||||
'')
|
||||
];
|
||||
|
||||
vim.maps.command = mkMerge [
|
||||
(mkSetLuaBinding mappings.complete ''
|
||||
require('cmp').complete
|
||||
'')
|
||||
(mkSetLuaBinding mappings.close ''
|
||||
require('cmp').mapping.close()
|
||||
'')
|
||||
(mkSetLuaBinding mappings.scrollDocsUp ''
|
||||
require('cmp').mapping.scroll_docs(-4)
|
||||
'')
|
||||
(mkSetLuaBinding mappings.scrollDocsDown ''
|
||||
require('cmp').mapping.scroll_docs(4)
|
||||
'')
|
||||
];
|
||||
|
||||
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(${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
|
||||
vim_item.menu = ({
|
||||
${builtMaps}
|
||||
})[entry.source.name]
|
||||
print(vim_item.menu)
|
||||
return vim_item
|
||||
end
|
||||
|
||||
${optionalString lspkindEnabled ''
|
||||
lspkind_opts.before = ${cfg.formatting.format}
|
||||
''}
|
||||
|
||||
local cmp = require'cmp'
|
||||
cmp.setup({
|
||||
${optionalString (config.vim.ui.borders.enable) ''
|
||||
-- explicitly enabled by setting ui.borders.enable = true
|
||||
-- TODO: try to get nvim-cmp to follow global border style
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
''}
|
||||
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
vim.fn["vsnip#anonymous"](args.body)
|
||||
end,
|
||||
},
|
||||
|
||||
sources = {
|
||||
${builtSources}
|
||||
},
|
||||
|
||||
completion = {
|
||||
completeopt = 'menu,menuone,noinsert',
|
||||
},
|
||||
|
||||
formatting = {
|
||||
format =
|
||||
${
|
||||
if lspkindEnabled
|
||||
then "lspkind.cmp_format(lspkind_opts)"
|
||||
else cfg.formatting.format
|
||||
},
|
||||
}
|
||||
})
|
||||
${optionalString (config.vim.autopairs.enable && config.vim.autopairs.type == "nvim-autopairs") ''
|
||||
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
|
||||
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { text = ""} }))
|
||||
''}
|
||||
'');
|
||||
|
||||
vim.snippets.vsnip.enable =
|
||||
if (cfg.type == "nvim-cmp")
|
||||
then true
|
||||
else config.vim.snippets.vsnip.enable;
|
||||
};
|
||||
}
|
||||
6
modules/plugins/completion/nvim-cmp/default.nix
Normal file
6
modules/plugins/completion/nvim-cmp/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./config.nix
|
||||
./nvim-cmp.nix
|
||||
];
|
||||
}
|
||||
64
modules/plugins/completion/nvim-cmp/nvim-cmp.nix
Normal file
64
modules/plugins/completion/nvim-cmp/nvim-cmp.nix
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib) mkEnableOption mkMappingOption mkOption types;
|
||||
in {
|
||||
options.vim = {
|
||||
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 {
|
||||
type = types.enum ["nvim-cmp"];
|
||||
default = "nvim-cmp";
|
||||
description = "Set the autocomplete plugin. Options: [nvim-cmp]";
|
||||
};
|
||||
|
||||
sources = mkOption {
|
||||
description = ''
|
||||
Attribute set of source names for nvim-cmp.
|
||||
|
||||
If an attribute set is provided, then the menu value of
|
||||
`vim_item` in the format will be set to the value (if
|
||||
utilizing the `nvim_cmp_menu_map` function).
|
||||
|
||||
Note: only use a single attribute name per attribute set
|
||||
'';
|
||||
type = with types; attrsOf (nullOr str);
|
||||
default = {};
|
||||
example = ''
|
||||
{nvim-cmp = null; buffer = "[Buffer]";}
|
||||
'';
|
||||
};
|
||||
|
||||
formatting = {
|
||||
format = mkOption {
|
||||
description = ''
|
||||
The function used to customize the appearance of the completion menu.
|
||||
|
||||
If [](#opt-vim.lsp.lspkind.enable) is true, then the function
|
||||
will be called before modifications from lspkind.
|
||||
|
||||
Default is to call the menu mapping function.
|
||||
'';
|
||||
type = types.str;
|
||||
default = "nvim_cmp_menu_map";
|
||||
example = lib.literalMD ''
|
||||
```lua
|
||||
function(entry, vim_item)
|
||||
return vim_item
|
||||
end
|
||||
```
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
11
modules/plugins/dashboard/alpha/alpha.nix
Normal file
11
modules/plugins/dashboard/alpha/alpha.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption;
|
||||
in {
|
||||
options.vim.dashboard.alpha = {
|
||||
enable = mkEnableOption "dashboard via alpha.nvim";
|
||||
};
|
||||
}
|
||||
219
modules/plugins/dashboard/alpha/config.nix
Normal file
219
modules/plugins/dashboard/alpha/config.nix
Normal file
|
|
@ -0,0 +1,219 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf nvim;
|
||||
|
||||
cfg = config.vim.dashboard.alpha;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"alpha-nvim"
|
||||
"nvim-web-devicons"
|
||||
];
|
||||
|
||||
# the entire credit for this dashboard configuration to https://github.com/Rishabh672003
|
||||
# honestly, excellent work
|
||||
vim.luaConfigRC.alpha = nvim.dag.entryAnywhere ''
|
||||
local alpha = require("alpha")
|
||||
local plenary_path = require("plenary.path")
|
||||
local dashboard = require("alpha.themes.dashboard")
|
||||
local cdir = vim.fn.getcwd()
|
||||
local if_nil = vim.F.if_nil
|
||||
|
||||
local nvim_web_devicons = {
|
||||
enabled = true,
|
||||
highlight = true,
|
||||
}
|
||||
|
||||
local function get_extension(fn)
|
||||
local match = fn:match("^.+(%..+)$")
|
||||
local ext = ""
|
||||
if match ~= nil then
|
||||
ext = match:sub(2)
|
||||
end
|
||||
return ext
|
||||
end
|
||||
|
||||
local function icon(fn)
|
||||
local nwd = require("nvim-web-devicons")
|
||||
local ext = get_extension(fn)
|
||||
return nwd.get_icon(fn, ext, { default = true })
|
||||
end
|
||||
|
||||
local function file_button(fn, sc, short_fn)
|
||||
short_fn = short_fn or fn
|
||||
local ico_txt
|
||||
local fb_hl = {}
|
||||
|
||||
if nvim_web_devicons.enabled then
|
||||
local ico, hl = icon(fn)
|
||||
local hl_option_type = type(nvim_web_devicons.highlight)
|
||||
if hl_option_type == "boolean" then
|
||||
if hl and nvim_web_devicons.highlight then
|
||||
table.insert(fb_hl, { hl, 0, 3 })
|
||||
end
|
||||
end
|
||||
if hl_option_type == "string" then
|
||||
table.insert(fb_hl, { nvim_web_devicons.highlight, 0, 3 })
|
||||
end
|
||||
ico_txt = ico .. " "
|
||||
else
|
||||
ico_txt = ""
|
||||
end
|
||||
local file_button_el = dashboard.button(sc, ico_txt .. short_fn, "<cmd>e " .. fn .. " <CR>")
|
||||
local fn_start = short_fn:match(".*[/\\]")
|
||||
if fn_start ~= nil then
|
||||
table.insert(fb_hl, { "Comment", #ico_txt - 2, #fn_start + #ico_txt })
|
||||
end
|
||||
file_button_el.opts.hl = fb_hl
|
||||
return file_button_el
|
||||
end
|
||||
|
||||
local default_mru_ignore = { "gitcommit" }
|
||||
|
||||
local mru_opts = {
|
||||
ignore = function(path, ext)
|
||||
return (string.find(path, "COMMIT_EDITMSG")) or (vim.tbl_contains(default_mru_ignore, ext))
|
||||
end,
|
||||
}
|
||||
|
||||
--- @param start number
|
||||
--- @param cwd string optional
|
||||
--- @param items_number number optional number of items to generate, default = 10
|
||||
local function mru(start, cwd, items_number, opts)
|
||||
opts = opts or mru_opts
|
||||
items_number = if_nil(items_number, 15)
|
||||
|
||||
local oldfiles = {}
|
||||
for _, v in pairs(vim.v.oldfiles) do
|
||||
if #oldfiles == items_number then
|
||||
break
|
||||
end
|
||||
local cwd_cond
|
||||
if not cwd then
|
||||
cwd_cond = true
|
||||
else
|
||||
cwd_cond = vim.startswith(v, cwd)
|
||||
end
|
||||
local ignore = (opts.ignore and opts.ignore(v, get_extension(v))) or false
|
||||
if (vim.fn.filereadable(v) == 1) and cwd_cond and not ignore then
|
||||
oldfiles[#oldfiles + 1] = v
|
||||
end
|
||||
end
|
||||
local target_width = 35
|
||||
|
||||
local tbl = {}
|
||||
for i, fn in ipairs(oldfiles) do
|
||||
local short_fn
|
||||
if cwd then
|
||||
short_fn = vim.fn.fnamemodify(fn, ":.")
|
||||
else
|
||||
short_fn = vim.fn.fnamemodify(fn, ":~")
|
||||
end
|
||||
|
||||
if #short_fn > target_width then
|
||||
short_fn = plenary_path.new(short_fn):shorten(1, { -2, -1 })
|
||||
if #short_fn > target_width then
|
||||
short_fn = plenary_path.new(short_fn):shorten(1, { -1 })
|
||||
end
|
||||
end
|
||||
|
||||
local shortcut = tostring(i + start - 1)
|
||||
|
||||
local file_button_el = file_button(fn, shortcut, short_fn)
|
||||
tbl[i] = file_button_el
|
||||
end
|
||||
return {
|
||||
type = "group",
|
||||
val = tbl,
|
||||
opts = {},
|
||||
}
|
||||
end
|
||||
|
||||
local default_header = {
|
||||
type = "text",
|
||||
val = {
|
||||
|
||||
[[███ ██ ███████ ██████ ██ ██ ██ ███ ███]],
|
||||
[[████ ██ ██ ██ ██ ██ ██ ██ ████ ████]],
|
||||
[[██ ██ ██ █████ ██ ██ ██ ██ ██ ██ ████ ██]],
|
||||
[[██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██]],
|
||||
[[██ ████ ███████ ██████ ████ ██ ██ ██]],
|
||||
|
||||
-- [[ __ ]],
|
||||
-- [[ ___ ___ ___ __ __ /\_\ ___ ___ ]],
|
||||
-- [[ / _ `\ / __`\ / __`\/\ \/\ \\/\ \ / __` __`\ ]],
|
||||
-- [[/\ \/\ \/\ __//\ \_\ \ \ \_/ |\ \ \/\ \/\ \/\ \ ]],
|
||||
-- [[\ \_\ \_\ \____\ \____/\ \___/ \ \_\ \_\ \_\ \_\]],
|
||||
-- [[ \/_/\/_/\/____/\/___/ \/__/ \/_/\/_/\/_/\/_/]],
|
||||
},
|
||||
opts = {
|
||||
position = "center",
|
||||
hl = "Type",
|
||||
-- wrap = "overflow";
|
||||
},
|
||||
}
|
||||
|
||||
local section_mru = {
|
||||
type = "group",
|
||||
val = {
|
||||
{
|
||||
type = "text",
|
||||
val = "Recent files",
|
||||
opts = {
|
||||
hl = "SpecialComment",
|
||||
shrink_margin = false,
|
||||
position = "center",
|
||||
},
|
||||
},
|
||||
{ type = "padding", val = 1 },
|
||||
{
|
||||
type = "group",
|
||||
val = function()
|
||||
return { mru(0, cdir) }
|
||||
end,
|
||||
opts = { shrink_margin = false },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
local buttons = {
|
||||
type = "group",
|
||||
val = {
|
||||
{ type = "text", val = "Quick links", opts = { hl = "SpecialComment", position = "center" } },
|
||||
{ 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 p", " Projects"), -- any project
|
||||
dashboard.button("q", " Quit", "<cmd>qa<CR>"), -- available all the time
|
||||
},
|
||||
position = "center",
|
||||
}
|
||||
|
||||
local config = {
|
||||
layout = {
|
||||
{ type = "padding", val = 2 },
|
||||
default_header,
|
||||
{ type = "padding", val = 2 },
|
||||
section_mru,
|
||||
{ type = "padding", val = 2 },
|
||||
buttons,
|
||||
},
|
||||
opts = {
|
||||
margin = 5,
|
||||
setup = function()
|
||||
vim.cmd([[
|
||||
autocmd alpha_temp DirChanged * lua require('alpha').redraw()
|
||||
]])
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
alpha.setup(config)
|
||||
'';
|
||||
};
|
||||
}
|
||||
6
modules/plugins/dashboard/alpha/default.nix
Normal file
6
modules/plugins/dashboard/alpha/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./alpha.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
||||
19
modules/plugins/dashboard/dashboard-nvim/config.nix
Normal file
19
modules/plugins/dashboard/dashboard-nvim/config.nix
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf nvim;
|
||||
|
||||
cfg = config.vim.dashboard.dashboard-nvim;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"dashboard-nvim"
|
||||
];
|
||||
|
||||
vim.luaConfigRC.dashboard-nvim = nvim.dag.entryAnywhere ''
|
||||
require("dashboard").setup{}
|
||||
'';
|
||||
};
|
||||
}
|
||||
11
modules/plugins/dashboard/dashboard-nvim/dashboard-nvim.nix
Normal file
11
modules/plugins/dashboard/dashboard-nvim/dashboard-nvim.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption;
|
||||
in {
|
||||
options.vim.dashboard.dashboard-nvim = {
|
||||
enable = mkEnableOption "dashboard via dashboard.nvim";
|
||||
};
|
||||
}
|
||||
6
modules/plugins/dashboard/dashboard-nvim/default.nix
Normal file
6
modules/plugins/dashboard/dashboard-nvim/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./dashboard-nvim.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
||||
7
modules/plugins/dashboard/default.nix
Normal file
7
modules/plugins/dashboard/default.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{...}: {
|
||||
imports = [
|
||||
./alpha
|
||||
./dashboard-nvim
|
||||
./startify
|
||||
];
|
||||
}
|
||||
50
modules/plugins/dashboard/startify/config.nix
Normal file
50
modules/plugins/dashboard/startify/config.nix
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf nvim;
|
||||
inherit (nvim.vim) mkVimBool;
|
||||
|
||||
cfg = config.vim.dashboard.startify;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = with pkgs.vimPlugins; [vim-startify];
|
||||
|
||||
vim.globals = {
|
||||
"startify_custom_header" =
|
||||
if cfg.customHeader == []
|
||||
then null
|
||||
else cfg.customHeader;
|
||||
"startify_custom_footer" =
|
||||
if cfg.customFooter == []
|
||||
then null
|
||||
else cfg.customFooter;
|
||||
"startify_bookmarks" = cfg.bookmarks;
|
||||
"startify_lists" = cfg.lists;
|
||||
"startify_change_to_dir" = mkVimBool cfg.changeToDir;
|
||||
"startify_change_to_vcs_root" = mkVimBool cfg.changeToVCRoot;
|
||||
"startify_change_cmd" = cfg.changeDirCmd;
|
||||
"startify_skiplist" = cfg.skipList;
|
||||
"startify_update_oldfiles" = mkVimBool cfg.updateOldFiles;
|
||||
"startify_session_autoload" = mkVimBool cfg.sessionAutoload;
|
||||
"startify_commands" = cfg.commands;
|
||||
"startify_files_number" = cfg.filesNumber;
|
||||
"startify_custom_indices" = cfg.customIndices;
|
||||
"startify_disable_at_vimenter" = mkVimBool cfg.disableOnStartup;
|
||||
"startify_enable_unsafe" = mkVimBool cfg.unsafe;
|
||||
"startify_padding_left" = cfg.paddingLeft;
|
||||
"startify_use_env" = mkVimBool cfg.useEnv;
|
||||
"startify_session_before_save" = cfg.sessionBeforeSave;
|
||||
"startify_session_persistence" = mkVimBool cfg.sessionPersistence;
|
||||
"startify_session_delete_buffers" = mkVimBool cfg.sessionDeleteBuffers;
|
||||
"startify_session_dir" = cfg.sessionDir;
|
||||
"startify_skiplist_server" = cfg.skipListServer;
|
||||
"startify_session_remove_lines" = cfg.sessionRemoveLines;
|
||||
"startify_session_savevars" = cfg.sessionSavevars;
|
||||
"startify_session_savecmds" = cfg.sessionSavecmds;
|
||||
"startify_session_sort" = mkVimBool cfg.sessionSort;
|
||||
};
|
||||
};
|
||||
}
|
||||
6
modules/plugins/dashboard/startify/default.nix
Normal file
6
modules/plugins/dashboard/startify/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./startify.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
||||
189
modules/plugins/dashboard/startify/startify.nix
Normal file
189
modules/plugins/dashboard/startify/startify.nix
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption mkOption types;
|
||||
in {
|
||||
options.vim.dashboard.startify = {
|
||||
enable = mkEnableOption "dashboard via vim-startify";
|
||||
|
||||
bookmarks = mkOption {
|
||||
default = [];
|
||||
description = ''List of book marks to disaply on start page'';
|
||||
type = with types; listOf attrs;
|
||||
example = {"c" = "~/.vimrc";};
|
||||
};
|
||||
|
||||
changeToDir = mkOption {
|
||||
default = true;
|
||||
description = "Should vim change to the directory of the file you open";
|
||||
type = types.bool;
|
||||
};
|
||||
|
||||
changeToVCRoot = mkOption {
|
||||
default = false;
|
||||
description = "Should vim change to the version control root when opening a file";
|
||||
type = types.bool;
|
||||
};
|
||||
|
||||
changeDirCmd = mkOption {
|
||||
default = "lcd";
|
||||
description = "Command to change the current window with. Can be cd, lcd or tcd";
|
||||
type = types.enum ["cd" "lcd" "tcd"];
|
||||
};
|
||||
|
||||
customHeader = mkOption {
|
||||
default = [];
|
||||
description = "Text to place in the header";
|
||||
type = with types; listOf str;
|
||||
};
|
||||
|
||||
customFooter = mkOption {
|
||||
default = [];
|
||||
description = "Text to place in the footer";
|
||||
type = with types; listOf str;
|
||||
};
|
||||
|
||||
lists = mkOption {
|
||||
default = [
|
||||
{
|
||||
type = "files";
|
||||
header = ["MRU"];
|
||||
}
|
||||
{
|
||||
type = "dir";
|
||||
header = ["MRU Current Directory"];
|
||||
}
|
||||
{
|
||||
type = "sessions";
|
||||
header = ["Sessions"];
|
||||
}
|
||||
{
|
||||
type = "bookmarks";
|
||||
header = ["Bookmarks"];
|
||||
}
|
||||
{
|
||||
type = "commands";
|
||||
header = ["Commands"];
|
||||
}
|
||||
];
|
||||
description = "Specify the lists and in what order they are displayed on startify.";
|
||||
type = with types; listOf attrs;
|
||||
};
|
||||
|
||||
skipList = mkOption {
|
||||
default = [];
|
||||
description = "List of regex patterns to exclude from MRU lists";
|
||||
type = with types; listOf str;
|
||||
};
|
||||
|
||||
updateOldFiles = mkOption {
|
||||
default = false;
|
||||
description = "Set if you want startify to always update and not just when neovim closes";
|
||||
type = types.bool;
|
||||
};
|
||||
|
||||
sessionAutoload = mkOption {
|
||||
default = false;
|
||||
description = "Make startify auto load Session.vim files from the current directory";
|
||||
type = types.bool;
|
||||
};
|
||||
|
||||
commands = mkOption {
|
||||
default = [];
|
||||
description = "Commands that are presented to the user on startify page";
|
||||
type = with types; listOf (oneOf [str attrs (listOf str)]);
|
||||
};
|
||||
|
||||
filesNumber = mkOption {
|
||||
default = 10;
|
||||
description = "How many files to list";
|
||||
type = types.int;
|
||||
};
|
||||
|
||||
customIndices = mkOption {
|
||||
default = [];
|
||||
description = "Specify a list of default charecters to use instead of numbers";
|
||||
type = with types; listOf str;
|
||||
};
|
||||
|
||||
disableOnStartup = mkOption {
|
||||
default = false;
|
||||
description = "Prevent startify from opening on startup but can be called with :Startify";
|
||||
type = types.bool;
|
||||
};
|
||||
|
||||
unsafe = mkOption {
|
||||
default = false;
|
||||
description = "Turns on unsafe mode for Startify. Stops resolving links, checking files are readable and filtering bookmark list";
|
||||
type = types.bool;
|
||||
};
|
||||
|
||||
paddingLeft = mkOption {
|
||||
default = 3;
|
||||
description = "Number of spaces used for left padding.";
|
||||
type = types.int;
|
||||
};
|
||||
|
||||
useEnv = mkOption {
|
||||
default = false;
|
||||
description = "Show environment variables in path if name is shorter than value";
|
||||
type = types.bool;
|
||||
};
|
||||
|
||||
sessionBeforeSave = mkOption {
|
||||
default = [];
|
||||
description = "Commands to run before saving a session";
|
||||
type = with types; listOf str;
|
||||
};
|
||||
|
||||
sessionPersistence = mkOption {
|
||||
default = false;
|
||||
description = "Persist session before leaving vim or switching session";
|
||||
type = types.bool;
|
||||
};
|
||||
|
||||
sessionDeleteBuffers = mkOption {
|
||||
default = true;
|
||||
description = "Delete all buffers when loading or closing a session";
|
||||
type = types.bool;
|
||||
};
|
||||
|
||||
sessionDir = mkOption {
|
||||
default = "~/.vim/session";
|
||||
description = "Directory to save and load sessions from";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
skipListServer = mkOption {
|
||||
default = [];
|
||||
description = "List of vim servers to not load startify for";
|
||||
type = with types; listOf str;
|
||||
};
|
||||
|
||||
sessionRemoveLines = mkOption {
|
||||
default = [];
|
||||
description = "Patterns to remove from session files";
|
||||
type = with types; listOf str;
|
||||
};
|
||||
|
||||
sessionSavevars = mkOption {
|
||||
default = [];
|
||||
description = "List of variables to save into a session file.";
|
||||
type = with types; listOf str;
|
||||
};
|
||||
|
||||
sessionSavecmds = mkOption {
|
||||
default = [];
|
||||
description = "List of commands to run when loading a session.";
|
||||
type = with types; listOf str;
|
||||
};
|
||||
|
||||
sessionSort = mkOption {
|
||||
default = false;
|
||||
description = "Set if you want items sorted by date rather than alphabetically";
|
||||
type = types.bool;
|
||||
};
|
||||
};
|
||||
}
|
||||
5
modules/plugins/debugger/default.nix
Normal file
5
modules/plugins/debugger/default.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
_: {
|
||||
imports = [
|
||||
./nvim-dap
|
||||
];
|
||||
}
|
||||
70
modules/plugins/debugger/nvim-dap/config.nix
Normal file
70
modules/plugins/debugger/nvim-dap/config.nix
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) addDescriptionsToMappings mkMerge mkIf mapAttrs nvim mkSetLuaBinding optionalString;
|
||||
|
||||
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/plugins/debugger/nvim-dap/default.nix
Normal file
6
modules/plugins/debugger/nvim-dap/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./config.nix
|
||||
./nvim-dap.nix
|
||||
];
|
||||
}
|
||||
44
modules/plugins/debugger/nvim-dap/nvim-dap.nix
Normal file
44
modules/plugins/debugger/nvim-dap/nvim-dap.nix
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib) mkEnableOption mkOption types mkMappingOption;
|
||||
in {
|
||||
options.vim.debugger.nvim-dap = {
|
||||
enable = mkEnableOption "debugging via nvim-dap";
|
||||
|
||||
ui = {
|
||||
enable = mkEnableOption "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 str;
|
||||
};
|
||||
|
||||
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";
|
||||
};
|
||||
};
|
||||
}
|
||||
5
modules/plugins/filetree/default.nix
Normal file
5
modules/plugins/filetree/default.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
_: {
|
||||
imports = [
|
||||
./nvimtree
|
||||
];
|
||||
}
|
||||
308
modules/plugins/filetree/nvimtree/config.nix
Normal file
308
modules/plugins/filetree/nvimtree/config.nix
Normal file
|
|
@ -0,0 +1,308 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf mkMerge mkBinding nvim boolToString;
|
||||
|
||||
cfg = config.vim.filetree.nvimTree;
|
||||
self = import ./nvimtree.nix {
|
||||
inherit pkgs;
|
||||
lib = lib;
|
||||
};
|
||||
mappings = self.options.vim.filetree.nvimTree.mappings;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = ["nvim-tree-lua"];
|
||||
|
||||
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 ''
|
||||
${
|
||||
lib.optionalString (cfg.disableNetrw) ''
|
||||
-- disable netrew completely
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
''
|
||||
}
|
||||
|
||||
require'nvim-tree'.setup({
|
||||
disable_netrw = ${boolToString cfg.disableNetrw},
|
||||
hijack_netrw = ${boolToString cfg.hijackNetrw},
|
||||
auto_reload_on_write = ${boolToString cfg.autoreloadOnWrite},
|
||||
|
||||
sort = {
|
||||
sorter = "${cfg.sort.sorter}",
|
||||
folders_first = ${boolToString cfg.sort.foldersFirst},
|
||||
},
|
||||
|
||||
hijack_unnamed_buffer_when_opening = ${boolToString cfg.hijackUnnamedBufferWhenOpening},
|
||||
hijack_cursor = ${boolToString cfg.hijackCursor},
|
||||
root_dirs = ${nvim.lua.listToLuaTable cfg.rootDirs},
|
||||
prefer_startup_root = ${boolToString cfg.preferStartupRoot},
|
||||
sync_root_with_cwd = ${boolToString cfg.syncRootWithCwd},
|
||||
reload_on_bufenter = ${boolToString cfg.reloadOnBufEnter},
|
||||
respect_buf_cwd = ${boolToString cfg.respectBufCwd},
|
||||
|
||||
hijack_directories = {
|
||||
enable = ${boolToString cfg.hijackDirectories.enable},
|
||||
auto_open = ${boolToString cfg.hijackDirectories.autoOpen},
|
||||
},
|
||||
|
||||
update_focused_file = {
|
||||
enable = ${boolToString cfg.updateFocusedFile.enable},
|
||||
update_root = ${boolToString cfg.updateFocusedFile.updateRoot},
|
||||
ignore_list = ${nvim.lua.listToLuaTable cfg.updateFocusedFile.ignoreList},
|
||||
},
|
||||
|
||||
system_open = {
|
||||
cmd = "${cfg.systemOpen.cmd}",
|
||||
args = ${nvim.lua.listToLuaTable cfg.systemOpen.args},
|
||||
},
|
||||
|
||||
diagnostics = {
|
||||
enable = ${boolToString cfg.diagnostics.enable},
|
||||
icons = {
|
||||
hint = "${cfg.diagnostics.icons.hint}",
|
||||
info = "${cfg.diagnostics.icons.info}",
|
||||
warning = "${cfg.diagnostics.icons.warning}",
|
||||
error = "${cfg.diagnostics.icons.error}",
|
||||
},
|
||||
|
||||
severity = {
|
||||
min = vim.diagnostic.severity.${cfg.diagnostics.severity.min},
|
||||
max = vim.diagnostic.severity.${cfg.diagnostics.severity.max},
|
||||
},
|
||||
},
|
||||
|
||||
git = {
|
||||
enable = ${boolToString cfg.git.enable},
|
||||
show_on_dirs = ${boolToString cfg.git.showOnDirs},
|
||||
show_on_open_dirs = ${boolToString cfg.git.showOnOpenDirs},
|
||||
disable_for_dirs = ${nvim.lua.listToLuaTable cfg.git.disableForDirs},
|
||||
timeout = ${toString cfg.git.timeout},
|
||||
},
|
||||
|
||||
modified = {
|
||||
enable = ${boolToString cfg.modified.enable},
|
||||
show_on_dirs = ${boolToString cfg.modified.showOnDirs},
|
||||
show_on_open_dirs = ${boolToString cfg.modified.showOnOpenDirs},
|
||||
},
|
||||
|
||||
filesystem_watchers = {
|
||||
enable = ${boolToString cfg.filesystemWatchers.enable},
|
||||
debounce_delay = ${toString cfg.filesystemWatchers.debounceDelay},
|
||||
ignore_dirs = ${nvim.lua.listToLuaTable cfg.filesystemWatchers.ignoreDirs},
|
||||
},
|
||||
|
||||
select_prompts = ${boolToString cfg.selectPrompts},
|
||||
|
||||
view = {
|
||||
centralize_selection = ${boolToString cfg.view.centralizeSelection},
|
||||
cursorline = ${boolToString cfg.view.cursorline},
|
||||
debounce_delay = ${toString cfg.view.debounceDelay},
|
||||
width = ${nvim.lua.expToLua cfg.view.width},
|
||||
side = "${cfg.view.side}",
|
||||
preserve_window_proportions = ${boolToString cfg.view.preserveWindowProportions},
|
||||
number = ${boolToString cfg.view.number},
|
||||
relativenumber = ${boolToString cfg.view.relativenumber},
|
||||
signcolumn = "${cfg.view.signcolumn}",
|
||||
float = {
|
||||
enable = ${boolToString cfg.view.float.enable},
|
||||
quit_on_focus_loss = ${boolToString cfg.view.float.quitOnFocusLoss},
|
||||
open_win_config = {
|
||||
relative = "${cfg.view.float.openWinConfig.relative}",
|
||||
border = "${cfg.view.float.openWinConfig.border}",
|
||||
width = ${toString cfg.view.float.openWinConfig.width},
|
||||
height = ${toString cfg.view.float.openWinConfig.height},
|
||||
row = ${toString cfg.view.float.openWinConfig.row},
|
||||
col = ${toString cfg.view.float.openWinConfig.col},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
renderer = {
|
||||
add_trailing = ${boolToString cfg.renderer.addTrailing},
|
||||
group_empty = ${boolToString cfg.renderer.groupEmpty},
|
||||
full_name = ${boolToString cfg.renderer.fullName},
|
||||
highlight_git = ${boolToString cfg.renderer.highlightGit},
|
||||
highlight_opened_files = ${cfg.renderer.highlightOpenedFiles},
|
||||
highlight_modified = ${cfg.renderer.highlightModified},
|
||||
root_folder_label = ${nvim.lua.expToLua cfg.renderer.rootFolderLabel},
|
||||
indent_width = ${toString cfg.renderer.indentWidth},
|
||||
indent_markers = {
|
||||
enable = ${boolToString cfg.renderer.indentMarkers.enable},
|
||||
inline_arrows = ${boolToString cfg.renderer.indentMarkers.inlineArrows},
|
||||
icons = ${nvim.lua.expToLua cfg.renderer.indentMarkers.icons},
|
||||
},
|
||||
|
||||
special_files = ${nvim.lua.listToLuaTable cfg.renderer.specialFiles},
|
||||
symlink_destination = ${boolToString cfg.renderer.symlinkDestination},
|
||||
|
||||
icons = {
|
||||
webdev_colors = ${boolToString cfg.renderer.icons.webdevColors},
|
||||
git_placement = "${cfg.renderer.icons.gitPlacement}",
|
||||
modified_placement = "${cfg.renderer.icons.modifiedPlacement}",
|
||||
padding = "${cfg.renderer.icons.padding}",
|
||||
symlink_arrow = "${cfg.renderer.icons.symlinkArrow}",
|
||||
|
||||
show = {
|
||||
git = ${boolToString cfg.renderer.icons.show.git},
|
||||
folder = ${boolToString cfg.renderer.icons.show.folder},
|
||||
folder_arrow = ${boolToString cfg.renderer.icons.show.folderArrow},
|
||||
file = ${boolToString cfg.renderer.icons.show.file},
|
||||
modified = ${boolToString cfg.renderer.icons.show.modified},
|
||||
},
|
||||
|
||||
glyphs = {
|
||||
default = "${cfg.renderer.icons.glyphs.default}",
|
||||
symlink = "${cfg.renderer.icons.glyphs.symlink}",
|
||||
modified = "${cfg.renderer.icons.glyphs.modified}",
|
||||
|
||||
folder = {
|
||||
default = "${cfg.renderer.icons.glyphs.folder.default}",
|
||||
open = "${cfg.renderer.icons.glyphs.folder.open}",
|
||||
arrow_open = "${cfg.renderer.icons.glyphs.folder.arrowOpen}",
|
||||
arrow_closed = "${cfg.renderer.icons.glyphs.folder.arrowClosed}",
|
||||
empty = "${cfg.renderer.icons.glyphs.folder.empty}",
|
||||
empty_open = "${cfg.renderer.icons.glyphs.folder.emptyOpen}",
|
||||
symlink = "${cfg.renderer.icons.glyphs.folder.symlink}",
|
||||
symlink_open = "${cfg.renderer.icons.glyphs.folder.symlinkOpen}",
|
||||
},
|
||||
|
||||
git = {
|
||||
unstaged = "${cfg.renderer.icons.glyphs.git.unstaged}",
|
||||
staged = "${cfg.renderer.icons.glyphs.git.staged}",
|
||||
unmerged = "${cfg.renderer.icons.glyphs.git.unmerged}",
|
||||
renamed = "${cfg.renderer.icons.glyphs.git.renamed}",
|
||||
untracked = "${cfg.renderer.icons.glyphs.git.untracked}",
|
||||
deleted = "${cfg.renderer.icons.glyphs.git.deleted}",
|
||||
ignored = "${cfg.renderer.icons.glyphs.git.ignored}",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
filters = {
|
||||
git_ignored = ${boolToString cfg.filters.gitIgnored},
|
||||
dotfiles = ${boolToString cfg.filters.dotfiles},
|
||||
git_clean = ${boolToString cfg.filters.gitClean},
|
||||
no_buffer = ${boolToString cfg.filters.noBuffer},
|
||||
exclude = ${nvim.lua.listToLuaTable cfg.filters.exclude},
|
||||
},
|
||||
|
||||
trash = {
|
||||
cmd = "${cfg.trash.cmd}",
|
||||
},
|
||||
|
||||
actions = {
|
||||
use_system_clipboard = ${boolToString cfg.actions.useSystemClipboard},
|
||||
change_dir = {
|
||||
enable = ${boolToString cfg.actions.changeDir.enable},
|
||||
global = ${boolToString cfg.actions.changeDir.global},
|
||||
restrict_above_cwd = ${boolToString cfg.actions.changeDir.restrictAboveCwd},
|
||||
},
|
||||
|
||||
expand_all = {
|
||||
max_folder_discovery = ${toString cfg.actions.expandAll.maxFolderDiscovery},
|
||||
exclude = ${nvim.lua.listToLuaTable cfg.actions.expandAll.exclude},
|
||||
},
|
||||
|
||||
file_popup = {
|
||||
open_win_config = ${nvim.lua.expToLua cfg.actions.filePopup.openWinConfig},
|
||||
},
|
||||
|
||||
open_file = {
|
||||
quit_on_open = ${boolToString cfg.actions.openFile.quitOnOpen},
|
||||
eject = ${boolToString cfg.actions.openFile.eject},
|
||||
resize_window = ${boolToString cfg.actions.openFile.resizeWindow},
|
||||
window_picker = {
|
||||
enable = ${boolToString cfg.actions.openFile.windowPicker.enable},
|
||||
picker = "${cfg.actions.openFile.windowPicker.picker}",
|
||||
chars = "${cfg.actions.openFile.windowPicker.chars}",
|
||||
exclude = {
|
||||
filetype = ${nvim.lua.listToLuaTable cfg.actions.openFile.windowPicker.exclude.filetype},
|
||||
buftype = ${nvim.lua.listToLuaTable cfg.actions.openFile.windowPicker.exclude.buftype},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
remove_file = {
|
||||
close_window = ${boolToString cfg.actions.removeFile.closeWindow},
|
||||
},
|
||||
},
|
||||
|
||||
live_filter = {
|
||||
prefix = "${cfg.liveFilter.prefix}",
|
||||
always_show_folders = ${boolToString cfg.liveFilter.alwaysShowFolders},
|
||||
},
|
||||
|
||||
tab = {
|
||||
sync = {
|
||||
open = ${boolToString cfg.tab.sync.open},
|
||||
close = ${boolToString cfg.tab.sync.close},
|
||||
ignore = ${nvim.lua.listToLuaTable cfg.tab.sync.ignore},
|
||||
},
|
||||
},
|
||||
|
||||
notify = {
|
||||
threshold = vim.log.levels.${cfg.notify.threshold},
|
||||
absolute_path = ${boolToString cfg.notify.absolutePath},
|
||||
},
|
||||
|
||||
ui = {
|
||||
confirm = {
|
||||
remove = ${boolToString cfg.ui.confirm.remove},
|
||||
trash = ${boolToString cfg.ui.confirm.trash},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- autostart behaviour
|
||||
${
|
||||
lib.optionalString (cfg.openOnSetup) ''
|
||||
-- Open on startup has been deprecated
|
||||
-- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup
|
||||
|
||||
-- use a nix eval to dynamically insert the open on startup function
|
||||
local function open_nvim_tree(data)
|
||||
local IGNORED_FT = {
|
||||
"markdown",
|
||||
}
|
||||
|
||||
-- buffer is a real file on the disk
|
||||
local real_file = vim.fn.filereadable(data.file) == 1
|
||||
|
||||
-- buffer is a [No Name]
|
||||
local no_name = data.file == "" and vim.bo[data.buf].buftype == ""
|
||||
|
||||
-- &ft
|
||||
local filetype = vim.bo[data.buf].ft
|
||||
|
||||
-- only files please
|
||||
if not real_file and not no_name then
|
||||
return
|
||||
end
|
||||
|
||||
-- skip ignored filetypes
|
||||
if vim.tbl_contains(IGNORED_FT, filetype) then
|
||||
return
|
||||
end
|
||||
|
||||
-- open the tree but don't focus it
|
||||
require("nvim-tree.api").tree.toggle({ focus = false })
|
||||
end
|
||||
|
||||
-- function to automatically open the tree on VimEnter
|
||||
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
|
||||
''
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
||||
6
modules/plugins/filetree/nvimtree/default.nix
Normal file
6
modules/plugins/filetree/nvimtree/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./config.nix
|
||||
./nvimtree.nix
|
||||
];
|
||||
}
|
||||
1115
modules/plugins/filetree/nvimtree/nvimtree.nix
Normal file
1115
modules/plugins/filetree/nvimtree/nvimtree.nix
Normal file
File diff suppressed because it is too large
Load diff
80
modules/plugins/git/config.nix
Normal file
80
modules/plugins/git/config.nix
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) toJSON;
|
||||
inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetExprBinding mkSetLuaBinding nvim;
|
||||
|
||||
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{}
|
||||
'';
|
||||
}
|
||||
|
||||
(mkIf cfg.gitsigns.codeActions {
|
||||
vim.lsp.null-ls.enable = true;
|
||||
vim.lsp.null-ls.sources.gitsigns-ca = ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.code_actions.gitsigns
|
||||
)
|
||||
'';
|
||||
})
|
||||
]))
|
||||
]);
|
||||
}
|
||||
6
modules/plugins/git/default.nix
Normal file
6
modules/plugins/git/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{...}: {
|
||||
imports = [
|
||||
./config.nix
|
||||
./git.nix
|
||||
];
|
||||
}
|
||||
35
modules/plugins/git/git.nix
Normal file
35
modules/plugins/git/git.nix
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib) mkEnableOption mkMappingOption;
|
||||
in {
|
||||
options.vim.git = {
|
||||
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";
|
||||
};
|
||||
};
|
||||
}
|
||||
114
modules/plugins/languages/bash/bash.nix
Normal file
114
modules/plugins/languages/bash/bash.nix
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib) mkOption mkEnableOption types isList nvim;
|
||||
|
||||
cfg = config.vim.languages.bash;
|
||||
|
||||
defaultServer = "bash-ls";
|
||||
servers = {
|
||||
bash-ls = {
|
||||
package = pkgs.nodePackages.bash-language-server;
|
||||
lspConfig = ''
|
||||
lspconfig.bashls.setup{
|
||||
capabilities = capabilities;
|
||||
on_attach = default_on_attach;
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/bash-language-server", "start"}''
|
||||
};
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
defaultFormat = "shfmt";
|
||||
formats = {
|
||||
shfmt = {
|
||||
package = pkgs.shfmt;
|
||||
nullConfig = ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.formatting.shfmt.with({
|
||||
command = "${pkgs.shfmt}/bin/shfmt",
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
defaultDiagnostics = ["shellcheck"];
|
||||
diagnostics = {
|
||||
shellcheck = {
|
||||
package = pkgs.shellcheck;
|
||||
nullConfig = pkg: ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.diagnostics.shellcheck.with({
|
||||
command = "${pkg}/bin/shellcheck",
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.bash = {
|
||||
enable = mkEnableOption "Bash language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkEnableOption "Bash treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
package = lib.nvim.types.mkGrammarOption pkgs "bash";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "Enable Bash LSP support" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
server = mkOption {
|
||||
description = "Bash LSP server to use";
|
||||
type = with types; enum (attrNames servers);
|
||||
default = defaultServer;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "bash-language-server package, or the command to run as a list of strings";
|
||||
example = lib.literalExpression ''[lib.getExe pkgs.nodePackages.bash-language-server "start"]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = pkgs.nodePackages.bash-language-server;
|
||||
};
|
||||
};
|
||||
|
||||
format = {
|
||||
enable = mkOption {
|
||||
description = "Enable Bash formatting";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableFormat;
|
||||
};
|
||||
type = mkOption {
|
||||
description = "Bash formatter to use";
|
||||
type = with types; enum (attrNames formats);
|
||||
default = defaultFormat;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "Bash formatter package";
|
||||
type = types.package;
|
||||
default = formats.${cfg.format.type}.package;
|
||||
};
|
||||
};
|
||||
|
||||
extraDiagnostics = {
|
||||
enable = mkEnableOption "extra Bash diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
|
||||
|
||||
types = lib.nvim.types.diagnostics {
|
||||
langDesc = "Bash";
|
||||
inherit diagnostics;
|
||||
inherit defaultDiagnostics;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
80
modules/plugins/languages/bash/config.nix
Normal file
80
modules/plugins/languages/bash/config.nix
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) isList nvim mkIf mkMerge;
|
||||
|
||||
cfg = config.vim.languages.bash;
|
||||
diagnostics = {
|
||||
shellcheck = {
|
||||
package = pkgs.shellcheck;
|
||||
nullConfig = pkg: ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.diagnostics.shellcheck.with({
|
||||
command = "${pkg}/bin/shellcheck",
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
formats = {
|
||||
shfmt = {
|
||||
package = pkgs.shfmt;
|
||||
nullConfig = ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.formatting.shfmt.with({
|
||||
command = "${pkgs.shfmt}/bin/shfmt",
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
servers = {
|
||||
bash-ls = {
|
||||
package = pkgs.nodePackages.bash-language-server;
|
||||
lspConfig = ''
|
||||
lspconfig.bashls.setup{
|
||||
capabilities = capabilities;
|
||||
on_attach = default_on_attach;
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/bash-language-server", "start"}''
|
||||
};
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
vim.lsp.lspconfig.sources.bash-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||
})
|
||||
|
||||
(mkIf cfg.format.enable {
|
||||
vim.lsp.null-ls.enable = true;
|
||||
vim.lsp.null-ls.sources.bash-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 = "bash";
|
||||
config = cfg.extraDiagnostics.types;
|
||||
inherit diagnostics;
|
||||
};
|
||||
})
|
||||
]);
|
||||
}
|
||||
6
modules/plugins/languages/bash/default.nix
Normal file
6
modules/plugins/languages/bash/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./bash.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
||||
155
modules/plugins/languages/clang.nix
Normal file
155
modules/plugins/languages/clang.nix
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib) isList nvim optionalString mkEnableOption mkOption types mkIf mkMerge;
|
||||
|
||||
cfg = config.vim.languages.clang;
|
||||
|
||||
defaultServer = "ccls";
|
||||
packageToCmd = package: defaultCmd:
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{ "${cfg.lsp.package}/bin/${defaultCmd}" }'';
|
||||
servers = {
|
||||
ccls = {
|
||||
package = pkgs.ccls;
|
||||
lspConfig = ''
|
||||
lspconfig.ccls.setup{
|
||||
capabilities = capabilities;
|
||||
on_attach=default_on_attach;
|
||||
cmd = ${packageToCmd cfg.lsp.package "ccls"};
|
||||
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.opts}"}
|
||||
}
|
||||
'';
|
||||
};
|
||||
clangd = {
|
||||
package = pkgs.clang-tools_16;
|
||||
lspConfig = ''
|
||||
local clangd_cap = capabilities
|
||||
-- use same offsetEncoding as null-ls
|
||||
clangd_cap.offsetEncoding = {"utf-16"}
|
||||
lspconfig.clangd.setup{
|
||||
capabilities = clangd_cap;
|
||||
on_attach=default_on_attach;
|
||||
cmd = ${packageToCmd cfg.lsp.package "clangd"};
|
||||
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.opts}"}
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
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";
|
||||
|
||||
cHeader = mkOption {
|
||||
description = ''
|
||||
C syntax for headers. Can fix treesitter errors, see:
|
||||
https://www.reddit.com/r/neovim/comments/orfpcd/question_does_the_c_parser_from_nvimtreesitter/
|
||||
'';
|
||||
type = types.bool;
|
||||
default = false;
|
||||
};
|
||||
|
||||
treesitter = {
|
||||
enable = mkEnableOption "C/C++ treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
cPackage = nvim.types.mkGrammarOption pkgs "c";
|
||||
cppPackage = nvim.types.mkGrammarOption pkgs "cpp";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "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, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
|
||||
type = with types; either package (listOf str);
|
||||
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 [
|
||||
(mkIf cfg.cHeader {
|
||||
vim.configRC.c-header = nvim.dag.entryAnywhere "let g:c_syntax_for_h = 1";
|
||||
})
|
||||
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.cPackage cfg.treesitter.cppPackage];
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
|
||||
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;
|
||||
})
|
||||
]);
|
||||
}
|
||||
74
modules/plugins/languages/css.nix
Normal file
74
modules/plugins/languages/css.nix
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib) mkEnableOption mkOption mkIf mkMerge isList types nvim;
|
||||
|
||||
cfg = config.vim.languages.css;
|
||||
|
||||
defaultServer = "vscode-langservers-extracted";
|
||||
servers = {
|
||||
vscode-langservers-extracted = {
|
||||
package = pkgs.nodePackages.vscode-langservers-extracted;
|
||||
lspConfig = ''
|
||||
-- enable (broadcasting) snippet capability for completion
|
||||
-- see <https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#cssls>
|
||||
local css_capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
css_capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
|
||||
-- cssls setup
|
||||
lspconfig.cssls.setup {
|
||||
capabilities = css_capabilities;
|
||||
on_attach = default_on_attach;
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/vscode-css-language-server", "--stdio"}''
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.css = {
|
||||
enable = mkEnableOption "CSS language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkEnableOption "CSS treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
|
||||
package = nvim.types.mkGrammarOption pkgs "css";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "CSS LSP support" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
server = mkOption {
|
||||
description = "CSS LSP server to use";
|
||||
type = with types; enum (attrNames servers);
|
||||
default = defaultServer;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "CSS LSP server package, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
vim.lsp.lspconfig.sources.tailwindcss-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||
})
|
||||
]);
|
||||
}
|
||||
71
modules/plugins/languages/dart/config.nix
Normal file
71
modules/plugins/languages/dart/config.nix
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) isList nvim mkIf mkMerge optionalString boolToString;
|
||||
|
||||
cfg = config.vim.languages.dart;
|
||||
ftcfg = cfg.flutter-tools;
|
||||
servers = {
|
||||
dart = {
|
||||
package = pkgs.dart;
|
||||
lspConfig = ''
|
||||
lspconfig.dartls.setup{
|
||||
capabilities = capabilities;
|
||||
on_attach=default_on_attach;
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/dart", "language-server", "--protocol=lsp"}''
|
||||
};
|
||||
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.dartOpts}"}
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
|
||||
vim.lsp.lspconfig.sources.dart-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||
})
|
||||
|
||||
(mkIf (ftcfg.enable) {
|
||||
vim.startPlugins =
|
||||
if ftcfg.enableNoResolvePatch
|
||||
then ["flutter-tools-patched"]
|
||||
else ["flutter-tools"];
|
||||
|
||||
vim.luaConfigRC.flutter-tools = nvim.dag.entryAnywhere ''
|
||||
require('flutter-tools').setup {
|
||||
lsp = {
|
||||
color = { -- show the derived colours for dart variables
|
||||
enabled = ${boolToString ftcfg.color.enable}, -- whether or not to highlight color variables at all, only supported on flutter >= 2.10
|
||||
background = ${boolToString ftcfg.color.highlightBackground}, -- highlight the background
|
||||
foreground = ${boolToString ftcfg.color.highlightForeground}, -- highlight the foreground
|
||||
virtual_text = ${boolToString ftcfg.color.virtualText.enable}, -- show the highlight using virtual text
|
||||
virtual_text_str = ${ftcfg.color.virtualText.character} -- the virtual text character to highlight
|
||||
},
|
||||
|
||||
capabilities = capabilities,
|
||||
on_attach = default_on_attach;
|
||||
flags = lsp_flags,
|
||||
},
|
||||
${optionalString cfg.dap.enable ''
|
||||
debugger = {
|
||||
enabled = true,
|
||||
},
|
||||
''}
|
||||
}
|
||||
'';
|
||||
})
|
||||
]);
|
||||
}
|
||||
110
modules/plugins/languages/dart/dart.nix
Normal file
110
modules/plugins/languages/dart/dart.nix
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib) isList nvim mkEnableOption mkOption types optionalString;
|
||||
|
||||
cfg = config.vim.languages.dart;
|
||||
defaultServer = "dart";
|
||||
servers = {
|
||||
dart = {
|
||||
package = pkgs.dart;
|
||||
lspConfig = ''
|
||||
lspconfig.dartls.setup{
|
||||
capabilities = capabilities;
|
||||
on_attach=default_on_attach;
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/dart", "language-server", "--protocol=lsp"}''
|
||||
};
|
||||
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.dartOpts}"}
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.dart = {
|
||||
enable = mkEnableOption "Dart language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkEnableOption "Dart treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
package = nvim.types.mkGrammarOption pkgs "dart";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "Dart LSP support";
|
||||
server = mkOption {
|
||||
description = "The Dart LSP server to use";
|
||||
type = with types; enum (attrNames servers);
|
||||
default = defaultServer;
|
||||
};
|
||||
package = mkOption {
|
||||
description = "Dart LSP server package, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
opts = mkOption {
|
||||
description = "Options to pass to Dart LSP server";
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
|
||||
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";
|
||||
type = types.bool;
|
||||
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";
|
||||
|
||||
highlightBackground = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Highlight the background";
|
||||
};
|
||||
|
||||
highlightForeground = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Highlight the foreground";
|
||||
};
|
||||
|
||||
virtualText = {
|
||||
enable = mkEnableOption "Show the highlight using virtual text";
|
||||
|
||||
character = mkOption {
|
||||
type = types.str;
|
||||
default = "■";
|
||||
description = "Virtual text character to highlight";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
6
modules/plugins/languages/dart/default.nix
Normal file
6
modules/plugins/languages/dart/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./dart.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
||||
37
modules/plugins/languages/default.nix
Normal file
37
modules/plugins/languages/default.nix
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.nvim.languages) mkEnable;
|
||||
in {
|
||||
imports = [
|
||||
./bash
|
||||
./dart
|
||||
./elixir
|
||||
./markdown
|
||||
./tidal
|
||||
|
||||
./clang.nix
|
||||
./css.nix
|
||||
./go.nix
|
||||
./html.nix
|
||||
./java.nix
|
||||
./lua.nix
|
||||
./nim.nix
|
||||
./nix.nix
|
||||
./php.nix
|
||||
./python.nix
|
||||
./rust.nix
|
||||
./sql.nix
|
||||
./svelte.nix
|
||||
./tailwind.nix
|
||||
./terraform.nix
|
||||
./ts.nix
|
||||
./zig.nix
|
||||
];
|
||||
|
||||
options.vim.languages = {
|
||||
enableLSP = mkEnable "LSP";
|
||||
enableDAP = mkEnable "Debug Adapter";
|
||||
enableTreesitter = mkEnable "Treesitter";
|
||||
enableFormat = mkEnable "Formatting";
|
||||
enableExtraDiagnostics = mkEnable "extra diagnostics";
|
||||
};
|
||||
}
|
||||
66
modules/plugins/languages/elixir/config.nix
Normal file
66
modules/plugins/languages/elixir/config.nix
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) nvim mkIf getExe;
|
||||
|
||||
cfg = config.vim.languages.elixir;
|
||||
in {
|
||||
config = mkIf (cfg.enable) {
|
||||
vim.startPlugins = [
|
||||
"elixir-tools"
|
||||
];
|
||||
|
||||
vim.luaConfigRC.elixir-tools = nvim.dag.entryAnywhere ''
|
||||
local elixir = require("elixir")
|
||||
local elixirls = require("elixir.elixirls")
|
||||
|
||||
elixir.setup {
|
||||
elixirls = {
|
||||
|
||||
|
||||
-- alternatively, point to an existing elixir-ls installation (optional)
|
||||
-- not currently supported by elixirls, but can be a table if you wish to pass other args `{"path/to/elixirls", "--foo"}`
|
||||
cmd = "${getExe pkgs.elixir-ls}",
|
||||
|
||||
-- default settings, use the `settings` function to override settings
|
||||
settings = elixirls.settings {
|
||||
dialyzerEnabled = true,
|
||||
fetchDeps = false,
|
||||
enableTestLenses = false,
|
||||
suggestSpecs = false,
|
||||
},
|
||||
|
||||
on_attach = function(client, bufnr)
|
||||
local map_opts = { buffer = true, noremap = true}
|
||||
|
||||
-- run the codelens under the cursor
|
||||
vim.keymap.set("n", "<space>r", vim.lsp.codelens.run, map_opts)
|
||||
-- remove the pipe operator
|
||||
vim.keymap.set("n", "<space>fp", ":ElixirFromPipe<cr>", map_opts)
|
||||
-- add the pipe operator
|
||||
vim.keymap.set("n", "<space>tp", ":ElixirToPipe<cr>", map_opts)
|
||||
vim.keymap.set("v", "<space>em", ":ElixirExpandMacro<cr>", map_opts)
|
||||
|
||||
-- bindings for standard LSP functions.
|
||||
vim.keymap.set("n", "<space>df", "<cmd>lua vim.lsp.buf.format()<cr>", map_opts)
|
||||
vim.keymap.set("n", "<space>gd", "<cmd>lua vim.diagnostic.open_float()<cr>", map_opts)
|
||||
vim.keymap.set("n", "<space>dt", "<cmd>lua vim.lsp.buf.definition()<cr>", map_opts)
|
||||
vim.keymap.set("n", "<space>K", "<cmd>lua vim.lsp.buf.hover()<cr>", map_opts)
|
||||
vim.keymap.set("n", "<space>gD","<cmd>lua vim.lsp.buf.implementation()<cr>", map_opts)
|
||||
vim.keymap.set("n", "<space>1gD","<cmd>lua vim.lsp.buf.type_definition()<cr>", map_opts)
|
||||
-- keybinds for fzf-lsp.nvim: https://github.com/gfanto/fzf-lsp.nvim
|
||||
-- you could also use telescope.nvim: https://github.com/nvim-telescope/telescope.nvim
|
||||
-- there are also core vim.lsp functions that put the same data in the loclist
|
||||
vim.keymap.set("n", "<space>gr", ":References<cr>", map_opts)
|
||||
vim.keymap.set("n", "<space>g0", ":DocumentSymbols<cr>", map_opts)
|
||||
vim.keymap.set("n", "<space>gW", ":WorkspaceSymbols<cr>", map_opts)
|
||||
vim.keymap.set("n", "<leader>d", ":Diagnostics<cr>", map_opts)
|
||||
end
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
||||
6
modules/plugins/languages/elixir/default.nix
Normal file
6
modules/plugins/languages/elixir/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./config.nix
|
||||
./elixir-tools.nix
|
||||
];
|
||||
}
|
||||
11
modules/plugins/languages/elixir/elixir-tools.nix
Normal file
11
modules/plugins/languages/elixir/elixir-tools.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption;
|
||||
in {
|
||||
options.vim.languages.elixir = {
|
||||
enable = mkEnableOption "Elixir language support";
|
||||
};
|
||||
}
|
||||
131
modules/plugins/languages/go.nix
Normal file
131
modules/plugins/languages/go.nix
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib) isList nvim getExe mkEnableOption mkOption types mkMerge mkIf;
|
||||
|
||||
cfg = config.vim.languages.go;
|
||||
|
||||
defaultServer = "gopls";
|
||||
servers = {
|
||||
gopls = {
|
||||
package = pkgs.gopls;
|
||||
lspConfig = ''
|
||||
lspconfig.gopls.setup {
|
||||
capabilities = capabilities;
|
||||
on_attach = default_on_attach;
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/gopls", "serve"}''
|
||||
},
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
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 = mkEnableOption "Go treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
|
||||
package = nvim.types.mkGrammarOption pkgs "go";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "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, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
|
||||
type = with types; either package (listOf str);
|
||||
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 [
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
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;
|
||||
})
|
||||
]);
|
||||
}
|
||||
42
modules/plugins/languages/html.nix
Normal file
42
modules/plugins/languages/html.nix
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption mkOption types nvim mkIf mkMerge optional;
|
||||
|
||||
cfg = config.vim.languages.html;
|
||||
in {
|
||||
options.vim.languages.html = {
|
||||
enable = mkEnableOption "HTML language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkOption {
|
||||
description = "Enable HTML treesitter";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableTreesitter;
|
||||
};
|
||||
package = nvim.types.mkGrammarOption pkgs "html";
|
||||
|
||||
autotagHtml = mkOption {
|
||||
description = "Enable autoclose/autorename of html tags (nvim-ts-autotag)";
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
|
||||
vim.startPlugins = optional cfg.treesitter.autotagHtml "nvim-ts-autotag";
|
||||
|
||||
vim.luaConfigRC.html-autotag = mkIf cfg.treesitter.autotagHtml (nvim.dag.entryAnywhere ''
|
||||
require('nvim-ts-autotag').setup()
|
||||
'');
|
||||
})
|
||||
]);
|
||||
}
|
||||
52
modules/plugins/languages/java.nix
Normal file
52
modules/plugins/languages/java.nix
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge getExe;
|
||||
|
||||
cfg = config.vim.languages.java;
|
||||
in {
|
||||
options.vim.languages.java = {
|
||||
enable = mkEnableOption "Java language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkEnableOption "Java treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
package = nvim.types.mkGrammarOption pkgs "java";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "Java LSP support (java-language-server)" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
package = mkOption {
|
||||
description = "java language server package, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = pkgs.jdt-language-server;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
vim.lsp.lspconfig.sources.jdtls = ''
|
||||
lspconfig.jdtls.setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = default_on_attach,
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${getExe cfg.lsp.package}", "-data", vim.fn.stdpath("cache").."/jdtls/workspace"}''
|
||||
},
|
||||
}
|
||||
'';
|
||||
})
|
||||
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
})
|
||||
]);
|
||||
}
|
||||
59
modules/plugins/languages/lua.nix
Normal file
59
modules/plugins/languages/lua.nix
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge optionalString getExe;
|
||||
|
||||
cfg = config.vim.languages.lua;
|
||||
in {
|
||||
options.vim.languages.lua = {
|
||||
enable = mkEnableOption "Lua language support";
|
||||
treesitter = {
|
||||
enable = mkEnableOption "Lua Treesitter support" // {default = config.vim.languages.enableTreesitter;};
|
||||
package = nvim.types.mkGrammarOption pkgs "lua";
|
||||
};
|
||||
lsp = {
|
||||
enable = mkEnableOption "Lua LSP support via LuaLS" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
package = mkOption {
|
||||
description = "LuaLS package, or the command to run as a list of strings";
|
||||
type = with types; either package (listOf str);
|
||||
default = pkgs.lua-language-server;
|
||||
};
|
||||
|
||||
neodev.enable = mkEnableOption "neodev.nvim integration, useful for neovim plugin developers";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
vim.lsp.lspconfig.sources.lua-lsp = ''
|
||||
lspconfig.lua_ls.setup {
|
||||
capabilities = capabilities;
|
||||
on_attach = default_on_attach;
|
||||
${optionalString cfg.lsp.neodev.enable "before_init = require('neodev.lsp').before_init;"}
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${getExe cfg.lsp.package}"}''
|
||||
};
|
||||
}
|
||||
'';
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.neodev.enable {
|
||||
vim.startPlugins = ["neodev-nvim"];
|
||||
vim.luaConfigRC.neodev = nvim.dag.entryBefore ["lua-lsp"] ''
|
||||
require("neodev").setup({})
|
||||
'';
|
||||
})
|
||||
]);
|
||||
}
|
||||
40
modules/plugins/languages/markdown/config.nix
Normal file
40
modules/plugins/languages/markdown/config.nix
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) nvim mkIf mkMerge isList;
|
||||
|
||||
cfg = config.vim.languages.markdown;
|
||||
servers = {
|
||||
marksman = {
|
||||
package = pkgs.marksman;
|
||||
lspConfig = ''
|
||||
lspconfig.marksman.setup{
|
||||
capabilities = capabilities;
|
||||
on_attach = default_on_attach;
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/marksman", "server"}''
|
||||
},
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
|
||||
vim.treesitter.grammars = [cfg.treesitter.mdPackage cfg.treesitter.mdInlinePackage];
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
|
||||
vim.lsp.lspconfig.sources.markdown-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||
})
|
||||
]);
|
||||
}
|
||||
6
modules/plugins/languages/markdown/default.nix
Normal file
6
modules/plugins/languages/markdown/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{...}: {
|
||||
imports = [
|
||||
./config.nix
|
||||
./markdown.nix
|
||||
];
|
||||
}
|
||||
59
modules/plugins/languages/markdown/markdown.nix
Normal file
59
modules/plugins/languages/markdown/markdown.nix
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib) mkEnableOption mkOption types nvim isList;
|
||||
|
||||
cfg = config.vim.languages.markdown;
|
||||
defaultServer = "marksman";
|
||||
servers = {
|
||||
marksman = {
|
||||
package = pkgs.marksman;
|
||||
lspConfig = ''
|
||||
lspconfig.marksman.setup{
|
||||
capabilities = capabilities;
|
||||
on_attach = default_on_attach;
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/marksman", "server"}''
|
||||
},
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.markdown = {
|
||||
enable = mkEnableOption "Markdown markup language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkOption {
|
||||
description = "Enable Markdown treesitter";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableTreesitter;
|
||||
};
|
||||
mdPackage = nvim.types.mkGrammarOption pkgs "markdown";
|
||||
mdInlinePackage = nvim.types.mkGrammarOption pkgs "markdown-inline";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "Enable Markdown LSP support" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
server = mkOption {
|
||||
description = "Markdown LSP server to use";
|
||||
type = with types; enum (attrNames servers);
|
||||
default = defaultServer;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "Markdown LSP server package, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
115
modules/plugins/languages/nim.nix
Normal file
115
modules/plugins/languages/nim.nix
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge;
|
||||
cfg = config.vim.languages.nim;
|
||||
|
||||
defaultServer = "nimlsp";
|
||||
servers = {
|
||||
nimlsp = {
|
||||
package = pkgs.nimlsp;
|
||||
lspConfig = ''
|
||||
lspconfig.nimls.setup{
|
||||
capabilities = capabilities;
|
||||
on_attach = default_on_attach;
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''
|
||||
{"${cfg.lsp.package}/bin/nimlsp"}
|
||||
''
|
||||
};
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
defaultFormat = "nimpretty";
|
||||
formats = {
|
||||
nimpretty = {
|
||||
package = pkgs.nim;
|
||||
nullConfig = ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.formatting.nimpretty.with({
|
||||
command = "${pkgs.nim}/bin/nimpretty",
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.nim = {
|
||||
enable = mkEnableOption "Nim language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkOption {
|
||||
description = "Enable Nim treesitter";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableTreesitter;
|
||||
};
|
||||
package = nvim.types.mkGrammarOption pkgs "nim";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "Nim LSP support" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
server = mkOption {
|
||||
description = "Nim LSP server to use";
|
||||
type = types.str;
|
||||
default = defaultServer;
|
||||
};
|
||||
package = mkOption {
|
||||
description = "Nim LSP server package, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.nimlsp]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
};
|
||||
|
||||
format = {
|
||||
enable = mkEnableOption "Nim formatting" // {default = config.vim.languages.enableFormat;};
|
||||
|
||||
type = mkOption {
|
||||
description = "Nim formatter to use";
|
||||
type = with types; enum (attrNames formats);
|
||||
default = defaultFormat;
|
||||
};
|
||||
package = mkOption {
|
||||
description = "Nim formatter package";
|
||||
type = types.package;
|
||||
default = formats.${cfg.format.type}.package;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
{
|
||||
assertions = [
|
||||
{
|
||||
assertion = !pkgs.stdenv.isDarwin;
|
||||
message = "Nim language support is only available on Linux";
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
vim.lsp.lspconfig.sources.nim-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||
})
|
||||
|
||||
(mkIf cfg.format.enable {
|
||||
vim.lsp.null-ls.enable = true;
|
||||
vim.lsp.null-ls.sources.nim-format = formats.${cfg.format.type}.nullConfig;
|
||||
})
|
||||
]);
|
||||
}
|
||||
205
modules/plugins/languages/nix.nix
Normal file
205
modules/plugins/languages/nix.nix
Normal file
|
|
@ -0,0 +1,205 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge optionalString;
|
||||
|
||||
cfg = config.vim.languages.nix;
|
||||
|
||||
useFormat = "on_attach = default_on_attach";
|
||||
noFormat = "on_attach = attach_keymaps";
|
||||
|
||||
defaultServer = "nil";
|
||||
packageToCmd = package: defaultCmd:
|
||||
if isList package
|
||||
then lib.nvim.lua.expToLua package
|
||||
else ''{"${package}/bin/${defaultCmd}"}'';
|
||||
servers = {
|
||||
rnix = {
|
||||
package = pkgs.rnix-lsp;
|
||||
internalFormatter = cfg.format.type == "nixpkgs-fmt";
|
||||
lspConfig = ''
|
||||
lspconfig.rnix.setup{
|
||||
capabilities = capabilities,
|
||||
${
|
||||
if (cfg.format.enable && cfg.format.type == "nixpkgs-fmt")
|
||||
then useFormat
|
||||
else noFormat
|
||||
},
|
||||
cmd = ${packageToCmd cfg.lsp.package "rnix-lsp"},
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
nil = {
|
||||
package = pkgs.nil;
|
||||
internalFormatter = true;
|
||||
lspConfig = ''
|
||||
lspconfig.nil_ls.setup{
|
||||
capabilities = capabilities,
|
||||
${
|
||||
if cfg.format.enable
|
||||
then useFormat
|
||||
else noFormat
|
||||
},
|
||||
cmd = ${packageToCmd cfg.lsp.package "nil"},
|
||||
${optionalString cfg.format.enable ''
|
||||
settings = {
|
||||
["nil"] = {
|
||||
${optionalString (cfg.format.type == "alejandra")
|
||||
''
|
||||
formatting = {
|
||||
command = {"${cfg.format.package}/bin/alejandra", "--quiet"},
|
||||
},
|
||||
''}
|
||||
${optionalString (cfg.format.type == "nixpkgs-fmt")
|
||||
''
|
||||
formatting = {
|
||||
command = {"${cfg.format.package}/bin/nixpkgs-fmt"},
|
||||
},
|
||||
''}
|
||||
},
|
||||
},
|
||||
''}
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
defaultFormat = "alejandra";
|
||||
formats = {
|
||||
alejandra = {
|
||||
package = pkgs.alejandra;
|
||||
nullConfig = ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.formatting.alejandra.with({
|
||||
command = "${cfg.format.package}/bin/alejandra"
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
nixpkgs-fmt = {
|
||||
package = pkgs.nixpkgs-fmt;
|
||||
# Never need to use null-ls for nixpkgs-fmt
|
||||
};
|
||||
};
|
||||
|
||||
defaultDiagnostics = ["statix" "deadnix"];
|
||||
diagnostics = {
|
||||
statix = {
|
||||
package = pkgs.statix;
|
||||
nullConfig = pkg: ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.diagnostics.statix.with({
|
||||
command = "${pkg}/bin/statix",
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
deadnix = {
|
||||
package = pkgs.deadnix;
|
||||
nullConfig = pkg: ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.diagnostics.deadnix.with({
|
||||
command = "${pkg}/bin/deadnix",
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.nix = {
|
||||
enable = mkEnableOption "Nix language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkOption {
|
||||
description = "Enable Nix treesitter";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableTreesitter;
|
||||
};
|
||||
package = nvim.types.mkGrammarOption pkgs "nix";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "Nix LSP support" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
server = mkOption {
|
||||
description = "Nix LSP server to use";
|
||||
type = types.str;
|
||||
default = defaultServer;
|
||||
};
|
||||
package = mkOption {
|
||||
description = "Nix LSP server package, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
};
|
||||
|
||||
format = {
|
||||
enable = mkEnableOption "Nix formatting" // {default = config.vim.languages.enableFormat;};
|
||||
|
||||
type = mkOption {
|
||||
description = "Nix formatter to use";
|
||||
type = with types; enum (attrNames formats);
|
||||
default = defaultFormat;
|
||||
};
|
||||
package = mkOption {
|
||||
description = "Nix formatter package";
|
||||
type = types.package;
|
||||
default = formats.${cfg.format.type}.package;
|
||||
};
|
||||
};
|
||||
|
||||
extraDiagnostics = {
|
||||
enable = mkOption {
|
||||
description = "Enable extra Nix diagnostics";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableExtraDiagnostics;
|
||||
};
|
||||
types = lib.nvim.types.diagnostics {
|
||||
langDesc = "Nix";
|
||||
inherit diagnostics;
|
||||
inherit defaultDiagnostics;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
{
|
||||
vim.configRC.nix = nvim.dag.entryAnywhere ''
|
||||
autocmd filetype nix setlocal tabstop=2 shiftwidth=2 softtabstop=2
|
||||
'';
|
||||
}
|
||||
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
vim.lsp.lspconfig.sources.nix-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||
})
|
||||
|
||||
(mkIf (cfg.format.enable && !servers.${cfg.lsp.server}.internalFormatter) {
|
||||
vim.lsp.null-ls.enable = true;
|
||||
vim.lsp.null-ls.sources.nix-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 = "nix";
|
||||
config = cfg.extraDiagnostics.types;
|
||||
inherit diagnostics;
|
||||
};
|
||||
})
|
||||
]);
|
||||
}
|
||||
101
modules/plugins/languages/php.nix
Normal file
101
modules/plugins/languages/php.nix
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge getExe;
|
||||
|
||||
cfg = config.vim.languages.php;
|
||||
|
||||
defaultServer = "phpactor";
|
||||
servers = {
|
||||
phpactor = {
|
||||
package = pkgs.phpactor;
|
||||
lspConfig = ''
|
||||
lspconfig.phpactor.setup{
|
||||
capabilities = capabilities,
|
||||
on_attach = default_on_attach,
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''
|
||||
{
|
||||
"${getExe cfg.lsp.package}",
|
||||
"language-server"
|
||||
},
|
||||
''
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
phan = {
|
||||
package = pkgs.php81Packages.phan;
|
||||
lspConfig = ''
|
||||
lspconfig.phan.setup{
|
||||
capabilities = capabilities,
|
||||
on_attach = default_on_attach,
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''
|
||||
{
|
||||
"${getExe cfg.lsp.package}",
|
||||
"-m",
|
||||
"json",
|
||||
"--no-color",
|
||||
"--no-progress-bar",
|
||||
"-x",
|
||||
"-u",
|
||||
"-S",
|
||||
"--language-server-on-stdin",
|
||||
"--allow-polyfill-parser"
|
||||
},
|
||||
''
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.php = {
|
||||
enable = mkEnableOption "PHP language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkEnableOption "PHP treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
package = nvim.types.mkGrammarOption pkgs "php";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "PHP LSP support" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
server = mkOption {
|
||||
description = "PHP LSP server to use";
|
||||
type = with types; enum (attrNames servers);
|
||||
default = defaultServer;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "PHP LSP server package, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
})
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig = {
|
||||
enable = true;
|
||||
sources.php-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||
};
|
||||
})
|
||||
]);
|
||||
}
|
||||
225
modules/plugins/languages/python.nix
Normal file
225
modules/plugins/languages/python.nix
Normal file
|
|
@ -0,0 +1,225 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge getExe literalExpression;
|
||||
|
||||
cfg = config.vim.languages.python;
|
||||
|
||||
defaultServer = "pyright";
|
||||
servers = {
|
||||
pyright = {
|
||||
package = pkgs.nodePackages.pyright;
|
||||
lspConfig = ''
|
||||
lspconfig.pyright.setup{
|
||||
capabilities = capabilities;
|
||||
on_attach = default_on_attach;
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/pyright-langserver", "--stdio"}''
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
defaultFormat = "black";
|
||||
formats = {
|
||||
black = {
|
||||
package = pkgs.black;
|
||||
nullConfig = ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.formatting.black.with({
|
||||
command = "${cfg.format.package}/bin/black",
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
isort = {
|
||||
package = pkgs.isort;
|
||||
nullConfig = ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.formatting.isort.with({
|
||||
command = "${cfg.format.package}/bin/isort",
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
black-and-isort = {
|
||||
package = pkgs.writeShellApplication {
|
||||
name = "black";
|
||||
text = ''
|
||||
black --quiet - "$@" | isort --profile black -
|
||||
'';
|
||||
runtimeInputs = [pkgs.black pkgs.isort];
|
||||
};
|
||||
nullConfig = ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.formatting.black.with({
|
||||
command = "${cfg.format.package}/bin/black",
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
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 = mkEnableOption "Python treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
package = mkOption {
|
||||
description = "Python treesitter grammar to use";
|
||||
type = types.package;
|
||||
default = pkgs.vimPlugins.nvim-treesitter.builtGrammars.python;
|
||||
};
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "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, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
};
|
||||
|
||||
format = {
|
||||
enable = mkEnableOption "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 {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
vim.lsp.lspconfig.sources.python-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||
})
|
||||
|
||||
(mkIf cfg.format.enable {
|
||||
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;
|
||||
})
|
||||
]);
|
||||
}
|
||||
146
modules/plugins/languages/rust.nix
Normal file
146
modules/plugins/languages/rust.nix
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge optionalString boolToString optionals;
|
||||
|
||||
cfg = config.vim.languages.rust;
|
||||
in {
|
||||
options.vim.languages.rust = {
|
||||
enable = mkEnableOption "Rust language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkEnableOption "Rust treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
package = nvim.types.mkGrammarOption pkgs "rust";
|
||||
};
|
||||
|
||||
crates = {
|
||||
enable = mkEnableOption "crates-nvim, tools for managing dependencies";
|
||||
codeActions = mkOption {
|
||||
description = "Enable code actions through null-ls";
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "Rust LSP support (rust-analyzer with extra tools)" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
package = mkOption {
|
||||
description = "rust-analyzer package, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
|
||||
type = with types; either package (listOf str);
|
||||
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 [
|
||||
(mkIf cfg.crates.enable {
|
||||
vim.lsp.null-ls.enable = mkIf cfg.crates.codeActions true;
|
||||
|
||||
vim.startPlugins = ["crates-nvim"];
|
||||
|
||||
vim.autocomplete.sources = {"crates" = "[Crates]";};
|
||||
vim.luaConfigRC.rust-crates = nvim.dag.entryAnywhere ''
|
||||
require('crates').setup {
|
||||
null_ls = {
|
||||
enabled = ${boolToString cfg.crates.codeActions},
|
||||
name = "crates.nvim",
|
||||
}
|
||||
}
|
||||
'';
|
||||
})
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
})
|
||||
(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 = ''
|
||||
local rt = require('rust-tools')
|
||||
rust_on_attach = function(client, bufnr)
|
||||
default_on_attach(client, bufnr)
|
||||
local opts = { noremap=true, silent=true, buffer = bufnr }
|
||||
vim.keymap.set("n", "<leader>ris", rt.inlay_hints.set, opts)
|
||||
vim.keymap.set("n", "<leader>riu", rt.inlay_hints.unset, opts)
|
||||
vim.keymap.set("n", "<leader>rr", rt.runnables.runnables, opts)
|
||||
vim.keymap.set("n", "<leader>rp", rt.parent_module.parent_module, opts)
|
||||
vim.keymap.set("n", "<leader>rm", rt.expand_macro.expand_macro, opts)
|
||||
vim.keymap.set("n", "<leader>rc", rt.open_cargo_toml.open_cargo_toml, opts)
|
||||
vim.keymap.set("n", "<leader>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 = {
|
||||
autoSetHints = true,
|
||||
hover_with_actions = false,
|
||||
inlay_hints = {
|
||||
only_current_line = false,
|
||||
}
|
||||
},
|
||||
server = {
|
||||
capabilities = capabilities,
|
||||
on_attach = rust_on_attach,
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/rust-analyzer"}''
|
||||
},
|
||||
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)
|
||||
'';
|
||||
})
|
||||
]);
|
||||
}
|
||||
156
modules/plugins/languages/sql.nix
Normal file
156
modules/plugins/languages/sql.nix
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge;
|
||||
|
||||
cfg = config.vim.languages.sql;
|
||||
sqlfluffDefault = pkgs.sqlfluff;
|
||||
|
||||
defaultServer = "sqls";
|
||||
servers = {
|
||||
sqls = {
|
||||
package = pkgs.sqls;
|
||||
lspConfig = ''
|
||||
lspconfig.sqls.setup {
|
||||
on_attach = function(client)
|
||||
client.server_capabilities.execute_command = true
|
||||
on_attach_keymaps(client, bufnr)
|
||||
require'sqls'.setup{}
|
||||
end,
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{ "${cfg.lsp.package}/bin/sqls", "-config", string.format("%s/config.yml", vim.fn.getcwd()) }''
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
defaultFormat = "sqlfluff";
|
||||
formats = {
|
||||
sqlfluff = {
|
||||
package = sqlfluffDefault;
|
||||
nullConfig = ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.formatting.sqlfluff.with({
|
||||
command = "${cfg.format.package}/bin/sqlfluff",
|
||||
extra_args = {"--dialect", "${cfg.dialect}"}
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
defaultDiagnostics = ["sqlfluff"];
|
||||
diagnostics = {
|
||||
sqlfluff = {
|
||||
package = sqlfluffDefault;
|
||||
nullConfig = pkg: ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.diagnostics.sqlfluff.with({
|
||||
command = "${pkg}/bin/sqlfluff",
|
||||
extra_args = {"--dialect", "${cfg.dialect}"}
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.sql = {
|
||||
enable = mkEnableOption "SQL language support";
|
||||
|
||||
dialect = mkOption {
|
||||
description = "SQL dialect for sqlfluff (if used)";
|
||||
type = types.str;
|
||||
default = "ansi";
|
||||
};
|
||||
|
||||
treesitter = {
|
||||
enable = mkEnableOption "SQL treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
|
||||
package = mkOption {
|
||||
description = "SQL treesitter grammar to use";
|
||||
type = types.package;
|
||||
default = pkgs.vimPlugins.nvim-treesitter.builtGrammars.sql;
|
||||
};
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "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, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
};
|
||||
|
||||
format = {
|
||||
enable = mkEnableOption "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;
|
||||
default = formats.${cfg.format.type}.package;
|
||||
};
|
||||
};
|
||||
|
||||
extraDiagnostics = {
|
||||
enable = mkEnableOption "extra SQL diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
|
||||
|
||||
types = lib.nvim.types.diagnostics {
|
||||
langDesc = "SQL";
|
||||
inherit diagnostics;
|
||||
inherit defaultDiagnostics;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.startPlugins = ["sqls-nvim"];
|
||||
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
vim.lsp.lspconfig.sources.sql-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||
})
|
||||
|
||||
(mkIf cfg.format.enable {
|
||||
vim.lsp.null-ls.enable = true;
|
||||
vim.lsp.null-ls.sources."sql-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 = "sql";
|
||||
config = cfg.extraDiagnostics.types;
|
||||
inherit diagnostics;
|
||||
};
|
||||
})
|
||||
]);
|
||||
}
|
||||
140
modules/plugins/languages/svelte.nix
Normal file
140
modules/plugins/languages/svelte.nix
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge;
|
||||
|
||||
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 = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${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 "Svelte treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
|
||||
sveltePackage = nvim.types.mkGrammarOption pkgs "svelte";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "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, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
};
|
||||
|
||||
format = {
|
||||
enable = mkEnableOption "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 "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;
|
||||
};
|
||||
})
|
||||
]);
|
||||
}
|
||||
57
modules/plugins/languages/tailwind.nix
Normal file
57
modules/plugins/languages/tailwind.nix
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib) mkEnableOption mkOption mkIf mkMerge isList types nvim;
|
||||
|
||||
cfg = config.vim.languages.tailwind;
|
||||
|
||||
defaultServer = "tailwindcss-language-server";
|
||||
servers = {
|
||||
tailwindcss-language-server = {
|
||||
package = pkgs.tailwindcss-language-server;
|
||||
lspConfig = ''
|
||||
lspconfig.tailwindcss.setup {
|
||||
capabilities = capabilities;
|
||||
on_attach = default_on_attach;
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/tailwindcss-language-server", "--stdio"}''
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.tailwind = {
|
||||
enable = mkEnableOption "Tailwindcss language support";
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "Tailwindcss LSP support" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
server = mkOption {
|
||||
description = "Tailwindcss LSP server to use";
|
||||
type = with types; enum (attrNames servers);
|
||||
default = defaultServer;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "Tailwindcss LSP server package, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
vim.lsp.lspconfig.sources.css-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||
})
|
||||
]);
|
||||
}
|
||||
46
modules/plugins/languages/terraform.nix
Normal file
46
modules/plugins/languages/terraform.nix
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) nvim mkEnableOption mkOption types mkIf mkMerge;
|
||||
|
||||
cfg = config.vim.languages.terraform;
|
||||
in {
|
||||
options.vim.languages.terraform = {
|
||||
enable = mkEnableOption "Terraform/HCL support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkEnableOption "Terraform treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
package = nvim.types.mkGrammarOption pkgs "terraform";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "Terraform LSP support (terraform-ls)" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
package = mkOption {
|
||||
description = "terraform-ls package";
|
||||
type = with types; package;
|
||||
default = pkgs.terraform-ls;
|
||||
};
|
||||
};
|
||||
};
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
vim.lsp.lspconfig.sources.terraform-ls = ''
|
||||
lspconfig.terraformls.setup {
|
||||
capabilities = capabilities,
|
||||
on_attach=default_on_attach,
|
||||
cmd = {"${cfg.lsp.package}/bin/terraform-ls", "serve"},
|
||||
}
|
||||
'';
|
||||
})
|
||||
]);
|
||||
}
|
||||
23
modules/plugins/languages/tidal/config.nix
Normal file
23
modules/plugins/languages/tidal/config.nix
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf;
|
||||
|
||||
cfg = config.vim.tidal;
|
||||
in {
|
||||
config = mkIf (cfg.enable) {
|
||||
vim.startPlugins = [
|
||||
# From tidalcycles flake
|
||||
pkgs.vimPlugins.vim-tidal
|
||||
];
|
||||
|
||||
vim.globals = {
|
||||
"tidal_target" = "terminal";
|
||||
"tidal_flash_duration" = 150;
|
||||
"tidal_sc_enable" = cfg.openSC;
|
||||
};
|
||||
};
|
||||
}
|
||||
6
modules/plugins/languages/tidal/default.nix
Normal file
6
modules/plugins/languages/tidal/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{...}: {
|
||||
imports = [
|
||||
./tidal.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
||||
23
modules/plugins/languages/tidal/tidal.nix
Normal file
23
modules/plugins/languages/tidal/tidal.nix
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption mkOption types;
|
||||
in {
|
||||
options.vim.tidal = {
|
||||
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'';
|
||||
type = types.int;
|
||||
default = 150;
|
||||
};
|
||||
|
||||
openSC = mkOption {
|
||||
description = "Automatically run the supercollider CLI, sclang, alongside the Tidal GHCI terminal.";
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
166
modules/plugins/languages/ts.nix
Normal file
166
modules/plugins/languages/ts.nix
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge;
|
||||
|
||||
cfg = config.vim.languages.ts;
|
||||
|
||||
defaultServer = "tsserver";
|
||||
servers = {
|
||||
tsserver = {
|
||||
package = pkgs.nodePackages.typescript-language-server;
|
||||
lspConfig = ''
|
||||
lspconfig.tsserver.setup {
|
||||
capabilities = capabilities;
|
||||
on_attach = attach_keymaps,
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/typescript-language-server", "--stdio"}''
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
denols = {
|
||||
package = pkgs.deno;
|
||||
lspConfig = ''
|
||||
vim.g.markdown_fenced_languages = { "ts=typescript" }
|
||||
lspconfig.denols.setup {
|
||||
capabilities = capabilities;
|
||||
on_attach = attach_keymaps,
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/deno", "lsp"}''
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
# 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",
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
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_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.ts = {
|
||||
enable = mkEnableOption "Typescript/Javascript language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkEnableOption "Typescript/Javascript treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
tsPackage = nvim.types.mkGrammarOption pkgs "tsx";
|
||||
jsPackage = nvim.types.mkGrammarOption pkgs "javascript";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "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, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
};
|
||||
|
||||
format = {
|
||||
enable = mkEnableOption "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;
|
||||
default = formats.${cfg.format.type}.package;
|
||||
};
|
||||
};
|
||||
|
||||
extraDiagnostics = {
|
||||
enable = mkEnableOption "extra Typescript/Javascript diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
|
||||
|
||||
types = lib.nvim.types.diagnostics {
|
||||
langDesc = "Typescript/Javascript";
|
||||
inherit diagnostics;
|
||||
inherit defaultDiagnostics;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.tsPackage cfg.treesitter.jsPackage];
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
vim.lsp.lspconfig.sources.ts-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||
})
|
||||
|
||||
(mkIf cfg.format.enable {
|
||||
vim.lsp.null-ls.enable = true;
|
||||
vim.lsp.null-ls.sources.ts-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 = "ts";
|
||||
config = cfg.extraDiagnostics.types;
|
||||
inherit diagnostics;
|
||||
};
|
||||
})
|
||||
]);
|
||||
}
|
||||
63
modules/plugins/languages/zig.nix
Normal file
63
modules/plugins/languages/zig.nix
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge;
|
||||
|
||||
cfg = config.vim.languages.zig;
|
||||
in {
|
||||
options.vim.languages.zig = {
|
||||
enable = mkEnableOption "Zig language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkEnableOption "Zig treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
package = nvim.types.mkGrammarOption pkgs "zig";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "Zig LSP support (zls)" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
package = mkOption {
|
||||
description = "ZLS package, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = pkgs.zls;
|
||||
};
|
||||
|
||||
zigPackage = mkOption {
|
||||
description = "Zig package used by ZLS";
|
||||
type = types.package;
|
||||
default = pkgs.zig;
|
||||
};
|
||||
};
|
||||
};
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
vim.lsp.lspconfig.sources.zig-lsp = ''
|
||||
lspconfig.zls.setup {
|
||||
capabilities = capabilities,
|
||||
on_attach=default_on_attach,
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/zls"}''
|
||||
},
|
||||
settings = {
|
||||
["zls"] = {
|
||||
zig_exe_path = "${cfg.lsp.zigPackage}/bin/zig",
|
||||
zig_lib_path = "${cfg.lsp.zigPackage}/lib/zig",
|
||||
}
|
||||
}
|
||||
}
|
||||
'';
|
||||
})
|
||||
]);
|
||||
}
|
||||
113
modules/plugins/lsp/config.nix
Normal file
113
modules/plugins/lsp/config.nix
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) addDescriptionsToMappings mkIf optional boolToString optionalString;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
usingNvimCmp = config.vim.autocomplete.enable && config.vim.autocomplete.type == "nvim-cmp";
|
||||
self = import ./module.nix {inherit config lib pkgs;};
|
||||
|
||||
mappingDefinitions = self.options.vim.lsp.mappings;
|
||||
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||
mkBinding = binding: action: "vim.api.nvim_buf_set_keymap(bufnr, 'n', '${binding.value}', '<cmd>lua ${action}<CR>', {noremap=true, silent=true, desc='${binding.description}'})";
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = optional usingNvimCmp "cmp-nvim-lsp";
|
||||
|
||||
vim.autocomplete.sources = {"nvim_lsp" = "[LSP]";};
|
||||
vim.luaConfigRC.lsp-setup = ''
|
||||
vim.g.formatsave = ${boolToString cfg.formatOnSave};
|
||||
|
||||
local attach_keymaps = function(client, bufnr)
|
||||
${mkBinding mappings.goToDeclaration "vim.lsp.buf.declaration()"}
|
||||
${mkBinding mappings.goToDefinition "vim.lsp.buf.definition()"}
|
||||
${mkBinding mappings.goToType "vim.lsp.buf.type_definition()"}
|
||||
${mkBinding mappings.listImplementations "vim.lsp.buf.implementation()"}
|
||||
${mkBinding mappings.listReferences "vim.lsp.buf.references()"}
|
||||
${mkBinding mappings.nextDiagnostic "vim.diagnostic.goto_next()"}
|
||||
${mkBinding mappings.previousDiagnostic "vim.diagnostic.goto_prev()"}
|
||||
${mkBinding mappings.openDiagnosticFloat "vim.diagnostic.open_float()"}
|
||||
${mkBinding mappings.documentHighlight "vim.lsp.buf.document_highlight()"}
|
||||
${mkBinding mappings.listDocumentSymbols "vim.lsp.buf.document_symbol()"}
|
||||
${mkBinding mappings.addWorkspaceFolder "vim.lsp.buf.add_workspace_folder()"}
|
||||
${mkBinding mappings.removeWorkspaceFolder "vim.lsp.buf.remove_workspace_folder()"}
|
||||
${mkBinding mappings.listWorkspaceFolders "print(vim.inspect(vim.lsp.buf.list_workspace_folders()))"}
|
||||
${mkBinding mappings.listWorkspaceSymbols "vim.lsp.buf.workspace_symbol()"}
|
||||
${mkBinding mappings.hover "vim.lsp.buf.hover()"}
|
||||
${mkBinding mappings.signatureHelp "vim.lsp.buf.signature_help()"}
|
||||
${mkBinding mappings.renameSymbol "vim.lsp.buf.rename()"}
|
||||
${mkBinding mappings.codeAction "vim.lsp.buf.code_action()"}
|
||||
${mkBinding mappings.format "vim.lsp.buf.format()"}
|
||||
${mkBinding mappings.toggleFormatOnSave "vim.b.disableFormatSave = not vim.b.disableFormatSave"}
|
||||
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 config.vim.lsp.null-ls.enable
|
||||
then ''
|
||||
if vim.b.disableFormatSave then
|
||||
return
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
${optionalString (config.vim.ui.breadcrumbs.enable) ''local navic = require("nvim-navic")''}
|
||||
default_on_attach = function(client, bufnr)
|
||||
attach_keymaps(client, bufnr)
|
||||
format_callback(client, bufnr)
|
||||
${optionalString (config.vim.ui.breadcrumbs.enable) ''
|
||||
-- let navic attach to buffers
|
||||
if client.server_capabilities.documentSymbolProvider then
|
||||
navic.attach(client, bufnr)
|
||||
end
|
||||
''}
|
||||
end
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
${optionalString usingNvimCmp "capabilities = require('cmp_nvim_lsp').default_capabilities()"}
|
||||
'';
|
||||
};
|
||||
}
|
||||
21
modules/plugins/lsp/default.nix
Normal file
21
modules/plugins/lsp/default.nix
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
_: {
|
||||
imports = [
|
||||
# nvim lsp support
|
||||
./config.nix
|
||||
./module.nix
|
||||
|
||||
./lspconfig
|
||||
./lspsaga
|
||||
./null-ls
|
||||
|
||||
# lsp plugins
|
||||
./lspsaga
|
||||
./nvim-code-action-menu
|
||||
./trouble
|
||||
./lsp-signature
|
||||
./lightbulb
|
||||
./lspkind
|
||||
./lsplines
|
||||
./nvim-docs-view
|
||||
];
|
||||
}
|
||||
22
modules/plugins/lsp/lightbulb/config.nix
Normal file
22
modules/plugins/lsp/lightbulb/config.nix
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf nvim;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
in {
|
||||
config = mkIf (cfg.enable && cfg.lightbulb.enable) {
|
||||
vim.startPlugins = ["nvim-lightbulb"];
|
||||
|
||||
vim.configRC.lightbulb = nvim.dag.entryAnywhere ''
|
||||
autocmd CursorHold,CursorHoldI * lua require'nvim-lightbulb'.update_lightbulb()
|
||||
'';
|
||||
|
||||
vim.luaConfigRC.lightbulb = nvim.dag.entryAnywhere ''
|
||||
-- Enable trouble diagnostics viewer
|
||||
require'nvim-lightbulb'.setup()
|
||||
'';
|
||||
};
|
||||
}
|
||||
6
modules/plugins/lsp/lightbulb/default.nix
Normal file
6
modules/plugins/lsp/lightbulb/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./lightbulb.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
||||
13
modules/plugins/lsp/lightbulb/lightbulb.nix
Normal file
13
modules/plugins/lsp/lightbulb/lightbulb.nix
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption;
|
||||
in {
|
||||
options.vim.lsp = {
|
||||
lightbulb = {
|
||||
enable = mkEnableOption "Lightbulb for code actions. Requires an emoji font";
|
||||
};
|
||||
};
|
||||
}
|
||||
27
modules/plugins/lsp/lsp-signature/config.nix
Normal file
27
modules/plugins/lsp/lsp-signature/config.nix
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf nvim optionalString;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
in {
|
||||
config = mkIf (cfg.enable && cfg.lspSignature.enable) {
|
||||
vim.startPlugins = [
|
||||
"lsp-signature"
|
||||
];
|
||||
|
||||
vim.luaConfigRC.lsp-signature = nvim.dag.entryAnywhere ''
|
||||
-- Enable lsp signature viewer
|
||||
require("lsp_signature").setup({
|
||||
${optionalString (config.vim.ui.borders.plugins.lsp-signature.enable) ''
|
||||
bind = true, -- This is mandatory, otherwise border config won't get registered.
|
||||
handler_opts = {
|
||||
border = "${config.vim.ui.borders.plugins.lsp-signature.style}"
|
||||
}
|
||||
''}
|
||||
})
|
||||
'';
|
||||
};
|
||||
}
|
||||
6
modules/plugins/lsp/lsp-signature/default.nix
Normal file
6
modules/plugins/lsp/lsp-signature/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./lsp-signature.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
||||
13
modules/plugins/lsp/lsp-signature/lsp-signature.nix
Normal file
13
modules/plugins/lsp/lsp-signature/lsp-signature.nix
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption;
|
||||
in {
|
||||
options.vim.lsp = {
|
||||
lspSignature = {
|
||||
enable = mkEnableOption "lsp signature viewer";
|
||||
};
|
||||
};
|
||||
}
|
||||
32
modules/plugins/lsp/lspconfig/config.nix
Normal file
32
modules/plugins/lsp/lspconfig/config.nix
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf mkMerge nvim optionalString mapAttrs;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
in {
|
||||
config = mkIf cfg.lspconfig.enable (mkMerge [
|
||||
{
|
||||
vim.lsp.enable = true;
|
||||
|
||||
vim.startPlugins = ["nvim-lspconfig"];
|
||||
|
||||
vim.luaConfigRC.lspconfig = nvim.dag.entryAfter ["lsp-setup"] ''
|
||||
local lspconfig = require('lspconfig')
|
||||
|
||||
${
|
||||
# TODO: make border style configurable
|
||||
optionalString (config.vim.ui.borders.enable) ''
|
||||
require('lspconfig.ui.windows').default_options.border = '${config.vim.ui.borders.globalStyle}'
|
||||
''
|
||||
}
|
||||
'';
|
||||
}
|
||||
{
|
||||
vim.luaConfigRC = mapAttrs (_: v: (nvim.dag.entryAfter ["lspconfig"] v)) cfg.lspconfig.sources;
|
||||
}
|
||||
]);
|
||||
}
|
||||
6
modules/plugins/lsp/lspconfig/default.nix
Normal file
6
modules/plugins/lsp/lspconfig/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./config.nix
|
||||
./lspconfig.nix
|
||||
];
|
||||
}
|
||||
18
modules/plugins/lsp/lspconfig/lspconfig.nix
Normal file
18
modules/plugins/lsp/lspconfig/lspconfig.nix
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption mkOption types;
|
||||
in {
|
||||
options.vim.lsp.lspconfig = {
|
||||
enable = mkEnableOption "nvim-lspconfig, also enabled automatically";
|
||||
|
||||
sources = mkOption {
|
||||
description = "nvim-lspconfig sources";
|
||||
type = with types; attrsOf str;
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
}
|
||||
20
modules/plugins/lsp/lspkind/config.nix
Normal file
20
modules/plugins/lsp/lspkind/config.nix
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf nvim;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
in {
|
||||
config = mkIf (cfg.enable && cfg.lspkind.enable) {
|
||||
vim.startPlugins = ["lspkind"];
|
||||
vim.luaConfigRC.lspkind = nvim.dag.entryAnywhere ''
|
||||
local lspkind = require'lspkind'
|
||||
local lspkind_opts = {
|
||||
mode = '${cfg.lspkind.mode}'
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
||||
6
modules/plugins/lsp/lspkind/default.nix
Normal file
6
modules/plugins/lsp/lspkind/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./config.nix
|
||||
./lspkind.nix
|
||||
];
|
||||
}
|
||||
22
modules/plugins/lsp/lspkind/lspkind.nix
Normal file
22
modules/plugins/lsp/lspkind/lspkind.nix
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption mkOption types;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
in {
|
||||
options.vim.lsp = {
|
||||
lspkind = {
|
||||
enable = mkEnableOption "vscode-like pictograms for lsp [lspkind]";
|
||||
|
||||
mode = mkOption {
|
||||
description = "Defines how annotations are shown";
|
||||
type = with types; enum ["text" "text_symbol" "symbol_text" "symbol"];
|
||||
default = "symbol_text";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
20
modules/plugins/lsp/lsplines/config.nix
Normal file
20
modules/plugins/lsp/lsplines/config.nix
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf nvim;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
in {
|
||||
config = mkIf (cfg.enable && cfg.lsplines.enable) {
|
||||
vim.startPlugins = ["lsp-lines"];
|
||||
vim.luaConfigRC.lsplines = nvim.dag.entryAfter ["lspconfig"] ''
|
||||
require("lsp_lines").setup()
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_text = false,
|
||||
})
|
||||
'';
|
||||
};
|
||||
}
|
||||
6
modules/plugins/lsp/lsplines/default.nix
Normal file
6
modules/plugins/lsp/lsplines/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./config.nix
|
||||
./lsplines.nix
|
||||
];
|
||||
}
|
||||
9
modules/plugins/lsp/lsplines/lsplines.nix
Normal file
9
modules/plugins/lsp/lsplines/lsplines.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib) mkEnableOption;
|
||||
in {
|
||||
options.vim.lsp = {
|
||||
lsplines = {
|
||||
enable = mkEnableOption "diagnostics using virtual lines on top of the real line of code. [lsp_lines]";
|
||||
};
|
||||
};
|
||||
}
|
||||
49
modules/plugins/lsp/lspsaga/config.nix
Normal file
49
modules/plugins/lsp/lspsaga/config.nix
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) addDescriptionsToMappings mkIf mkSetLuaBinding mkMerge nvim optionalString;
|
||||
|
||||
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.maps.visual = mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').range_code_action";
|
||||
|
||||
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
|
||||
local saga = require 'lspsaga'
|
||||
saga.init_lsp_saga({
|
||||
${optionalString (config.vim.ui.borders.plugins.lspsaga.enable) ''
|
||||
border_style = '${config.vim.ui.borders.plugins.lspsaga.style}',
|
||||
''}
|
||||
})
|
||||
'';
|
||||
};
|
||||
}
|
||||
6
modules/plugins/lsp/lspsaga/default.nix
Normal file
6
modules/plugins/lsp/lspsaga/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./lspsaga.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
||||
28
modules/plugins/lsp/lspsaga/lspsaga.nix
Normal file
28
modules/plugins/lsp/lspsaga/lspsaga.nix
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib) mkEnableOption mkMappingOption;
|
||||
in {
|
||||
options.vim.lsp.lspsaga = {
|
||||
enable = mkEnableOption "LSP Saga";
|
||||
|
||||
mappings = {
|
||||
lspFinder = mkMappingOption "LSP Finder [LSPSaga]" "<leader>lf";
|
||||
renderHoveredDoc = mkMappingOption "Rendered hovered docs [LSPSaga]" "<leader>lh";
|
||||
|
||||
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]" "<leader>ls";
|
||||
};
|
||||
};
|
||||
}
|
||||
70
modules/plugins/lsp/module.nix
Normal file
70
modules/plugins/lsp/module.nix
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib) mkEnableOption mkMappingOption;
|
||||
in {
|
||||
options.vim.lsp = {
|
||||
enable = mkEnableOption "LSP, also enabled automatically through null-ls and lspconfig options";
|
||||
formatOnSave = mkEnableOption "format on save";
|
||||
mappings = {
|
||||
goToDefinition =
|
||||
mkMappingOption "Go to definition"
|
||||
"<leader>lgd";
|
||||
goToDeclaration =
|
||||
mkMappingOption "Go to declaration"
|
||||
"<leader>lgD";
|
||||
goToType =
|
||||
mkMappingOption "Go to type"
|
||||
"<leader>lgt";
|
||||
listImplementations =
|
||||
mkMappingOption "List implementations"
|
||||
"<leader>lgi";
|
||||
listReferences =
|
||||
mkMappingOption "List references"
|
||||
"<leader>lgr";
|
||||
nextDiagnostic =
|
||||
mkMappingOption "Go to next diagnostic"
|
||||
"<leader>lgn";
|
||||
previousDiagnostic =
|
||||
mkMappingOption "Go to previous diagnostic"
|
||||
"<leader>lgp";
|
||||
openDiagnosticFloat =
|
||||
mkMappingOption "Open diagnostic float"
|
||||
"<leader>le";
|
||||
documentHighlight =
|
||||
mkMappingOption "Document highlight"
|
||||
"<leader>lH";
|
||||
listDocumentSymbols =
|
||||
mkMappingOption "List document symbols"
|
||||
"<leader>lS";
|
||||
addWorkspaceFolder =
|
||||
mkMappingOption "Add workspace folder"
|
||||
"<leader>lwa";
|
||||
removeWorkspaceFolder =
|
||||
mkMappingOption "Remove workspace folder"
|
||||
"<leader>lwr";
|
||||
listWorkspaceFolders =
|
||||
mkMappingOption "List workspace folders"
|
||||
"<leader>lwl";
|
||||
listWorkspaceSymbols =
|
||||
mkMappingOption "List workspace symbols"
|
||||
"<leader>lws";
|
||||
hover =
|
||||
mkMappingOption "Trigger hover"
|
||||
"<leader>lh";
|
||||
signatureHelp =
|
||||
mkMappingOption "Signature help"
|
||||
"<leader>ls";
|
||||
renameSymbol =
|
||||
mkMappingOption "Rename symbol"
|
||||
"<leader>ln";
|
||||
codeAction =
|
||||
mkMappingOption "Code action"
|
||||
"<leader>la";
|
||||
format =
|
||||
mkMappingOption "Format"
|
||||
"<leader>lf";
|
||||
toggleFormatOnSave =
|
||||
mkMappingOption "Toggle format on save"
|
||||
"<leader>ltf";
|
||||
};
|
||||
};
|
||||
}
|
||||
37
modules/plugins/lsp/null-ls/config.nix
Normal file
37
modules/plugins/lsp/null-ls/config.nix
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf mkMerge nvim mapAttrs;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
in {
|
||||
config = mkIf cfg.null-ls.enable (mkMerge [
|
||||
{
|
||||
vim.lsp.enable = true;
|
||||
vim.startPlugins = ["none-ls"];
|
||||
|
||||
vim.luaConfigRC.null_ls-setup = nvim.dag.entryAnywhere ''
|
||||
local null_ls = require("null-ls")
|
||||
local null_helpers = require("null-ls.helpers")
|
||||
local null_methods = require("null-ls.methods")
|
||||
local ls_sources = {}
|
||||
'';
|
||||
vim.luaConfigRC.null_ls = nvim.dag.entryAfter ["null_ls-setup" "lsp-setup"] ''
|
||||
require('null-ls').setup({
|
||||
debug = false,
|
||||
diagnostics_format = "[#{m}] #{s} (#{c})",
|
||||
debounce = 250,
|
||||
default_timeout = 5000,
|
||||
sources = ls_sources,
|
||||
on_attach=default_on_attach
|
||||
})
|
||||
'';
|
||||
}
|
||||
{
|
||||
vim.luaConfigRC = mapAttrs (_: v: (nvim.dag.entryBetween ["null_ls"] ["null_ls-setup"] v)) cfg.null-ls.sources;
|
||||
}
|
||||
]);
|
||||
}
|
||||
6
modules/plugins/lsp/null-ls/default.nix
Normal file
6
modules/plugins/lsp/null-ls/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./config.nix
|
||||
./null-ls.nix
|
||||
];
|
||||
}
|
||||
20
modules/plugins/lsp/null-ls/null-ls.nix
Normal file
20
modules/plugins/lsp/null-ls/null-ls.nix
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption mkOption types;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
in {
|
||||
options.vim.lsp.null-ls = {
|
||||
enable = mkEnableOption "null-ls, also enabled automatically";
|
||||
|
||||
sources = mkOption {
|
||||
description = "null-ls sources";
|
||||
type = with types; attrsOf str;
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
}
|
||||
30
modules/plugins/lsp/nvim-code-action-menu/config.nix
Normal file
30
modules/plugins/lsp/nvim-code-action-menu/config.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) addDescriptionsToMappings mkIf mkSetBinding nvim;
|
||||
|
||||
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.maps.normal = mkSetBinding mappings.open ":CodeActionMenu<CR>";
|
||||
|
||||
vim.luaConfigRC.code-action-menu = nvim.dag.entryAnywhere ''
|
||||
-- border configuration
|
||||
vim.g.code_action_menu_window_border = '${config.vim.ui.borders.plugins.code-action-menu.style}'
|
||||
|
||||
-- show individual sections of the code action menu
|
||||
${lib.optionalString (cfg.nvimCodeActionMenu.show.details) "vim.g.code_action_menu_show_details = true"}
|
||||
${lib.optionalString (cfg.nvimCodeActionMenu.show.diff) "vim.g.code_action_menu_show_diff = true"}
|
||||
${lib.optionalString (cfg.nvimCodeActionMenu.show.actionKind) "vim.g.code_action_menu_show_action_kind = true"}
|
||||
'';
|
||||
};
|
||||
}
|
||||
6
modules/plugins/lsp/nvim-code-action-menu/default.nix
Normal file
6
modules/plugins/lsp/nvim-code-action-menu/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./nvim-code-action-menu.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib) mkEnableOption mkMappingOption;
|
||||
in {
|
||||
options.vim.lsp = {
|
||||
nvimCodeActionMenu = {
|
||||
enable = mkEnableOption "nvim code action menu";
|
||||
|
||||
show = {
|
||||
details = mkEnableOption "Show details" // {default = true;};
|
||||
diff = mkEnableOption "Show diff" // {default = true;};
|
||||
actionKind = mkEnableOption "Show action kind" // {default = true;};
|
||||
};
|
||||
|
||||
mappings = {
|
||||
open = mkMappingOption "Open code action menu [nvim-code-action-menu]" "<leader>ca";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue