mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-07 02:41:33 +00:00
modules: make lib calls explicit where possible
This commit is contained in:
parent
bf1118eb28
commit
024e1a6845
41 changed files with 245 additions and 203 deletions
|
@ -5,7 +5,10 @@
|
|||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib) mkOption mkEnableOption types isList nvim;
|
||||
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
||||
inherit (lib.lists) isList;
|
||||
inherit (lib.types) enum either package listOf str bool;
|
||||
inherit (lib.nvim.lua) expToLua;
|
||||
|
||||
cfg = config.vim.languages.bash;
|
||||
|
||||
|
@ -19,7 +22,7 @@
|
|||
on_attach = default_on_attach;
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
then expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/bash-language-server", "start"}''
|
||||
};
|
||||
}
|
||||
|
@ -70,14 +73,14 @@ in {
|
|||
|
||||
server = mkOption {
|
||||
description = "Bash LSP server to use";
|
||||
type = with types; enum (attrNames servers);
|
||||
type = 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);
|
||||
example = literalExpression ''[lib.getExe pkgs.nodePackages.bash-language-server "start"]'';
|
||||
type = either package (listOf str);
|
||||
default = pkgs.nodePackages.bash-language-server;
|
||||
};
|
||||
};
|
||||
|
@ -85,25 +88,24 @@ in {
|
|||
format = {
|
||||
enable = mkOption {
|
||||
description = "Enable Bash formatting";
|
||||
type = types.bool;
|
||||
type = bool;
|
||||
default = config.vim.languages.enableFormat;
|
||||
};
|
||||
type = mkOption {
|
||||
description = "Bash formatter to use";
|
||||
type = with types; enum (attrNames formats);
|
||||
type = enum (attrNames formats);
|
||||
default = defaultFormat;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "Bash formatter package";
|
||||
type = types.package;
|
||||
type = 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;
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) isList nvim mkIf mkMerge;
|
||||
inherit (lib.lists) isList;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.lua) expToLua;
|
||||
|
||||
cfg = config.vim.languages.bash;
|
||||
diagnostics = {
|
||||
|
@ -44,7 +46,7 @@
|
|||
on_attach = default_on_attach;
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
then expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/bash-language-server", "start"}''
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
_: {
|
||||
{
|
||||
imports = [
|
||||
./bash.nix
|
||||
./config.nix
|
||||
|
|
|
@ -4,7 +4,12 @@
|
|||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) isList nvim mkIf mkMerge optionalString boolToString;
|
||||
inherit (lib.lists) isList;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.trivial) boolToString;
|
||||
inherit (lib.nvim.lua) expToLua;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
|
||||
cfg = config.vim.languages.dart;
|
||||
ftcfg = cfg.flutter-tools;
|
||||
|
@ -17,7 +22,7 @@
|
|||
on_attach=default_on_attach;
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
then expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/dart", "language-server", "--protocol=lsp"}''
|
||||
};
|
||||
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.dartOpts}"}
|
||||
|
@ -38,13 +43,13 @@ in {
|
|||
vim.lsp.lspconfig.sources.dart-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||
})
|
||||
|
||||
(mkIf (ftcfg.enable) {
|
||||
(mkIf ftcfg.enable {
|
||||
vim.startPlugins =
|
||||
if ftcfg.enableNoResolvePatch
|
||||
then ["flutter-tools-patched"]
|
||||
else ["flutter-tools"];
|
||||
|
||||
vim.luaConfigRC.flutter-tools = nvim.dag.entryAnywhere ''
|
||||
vim.luaConfigRC.flutter-tools = entryAnywhere ''
|
||||
require('flutter-tools').setup {
|
||||
lsp = {
|
||||
color = { -- show the derived colours for dart variables
|
||||
|
|
|
@ -5,7 +5,12 @@
|
|||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib) isList nvim mkEnableOption mkOption types optionalString;
|
||||
inherit (lib.lists) isList;
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.types) enum either listOf package nullOr str bool;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.nvim.lua) expToLua;
|
||||
inherit (lib.nvim.types) mkGrammarOption;
|
||||
|
||||
cfg = config.vim.languages.dart;
|
||||
defaultServer = "dart";
|
||||
|
@ -18,7 +23,7 @@
|
|||
on_attach=default_on_attach;
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
then expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/dart", "language-server", "--protocol=lsp"}''
|
||||
};
|
||||
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.dartOpts}"}
|
||||
|
@ -32,25 +37,25 @@ in {
|
|||
|
||||
treesitter = {
|
||||
enable = mkEnableOption "Dart treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
package = nvim.types.mkGrammarOption pkgs "dart";
|
||||
package = mkGrammarOption pkgs "dart";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "Dart LSP support";
|
||||
server = mkOption {
|
||||
description = "The Dart LSP server to use";
|
||||
type = with types; enum (attrNames servers);
|
||||
type = 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);
|
||||
type = 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;
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
|
@ -58,7 +63,7 @@ in {
|
|||
dap = {
|
||||
enable = mkOption {
|
||||
description = "Enable Dart DAP support via flutter-tools";
|
||||
type = types.bool;
|
||||
type = bool;
|
||||
default = config.vim.languages.enableDAP;
|
||||
};
|
||||
};
|
||||
|
@ -66,7 +71,7 @@ in {
|
|||
flutter-tools = {
|
||||
enable = mkOption {
|
||||
description = "Enable flutter-tools for flutter support";
|
||||
type = types.bool;
|
||||
type = bool;
|
||||
default = config.vim.languages.enableLSP;
|
||||
};
|
||||
|
||||
|
@ -76,7 +81,7 @@ in {
|
|||
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;
|
||||
type = bool;
|
||||
default = true;
|
||||
};
|
||||
|
||||
|
@ -84,13 +89,13 @@ in {
|
|||
enable = mkEnableOption "Whether or mot to highlight color variables at all";
|
||||
|
||||
highlightBackground = mkOption {
|
||||
type = types.bool;
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "Highlight the background";
|
||||
};
|
||||
|
||||
highlightForeground = mkOption {
|
||||
type = types.bool;
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "Highlight the foreground";
|
||||
};
|
||||
|
@ -99,7 +104,7 @@ in {
|
|||
enable = mkEnableOption "Show the highlight using virtual text";
|
||||
|
||||
character = mkOption {
|
||||
type = types.str;
|
||||
type = str;
|
||||
default = "■";
|
||||
description = "Virtual text character to highlight";
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
_: {
|
||||
{
|
||||
imports = [
|
||||
./dart.nix
|
||||
./config.nix
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) nvim mkIf getExe;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
|
||||
cfg = config.vim.languages.elixir;
|
||||
in {
|
||||
|
@ -13,14 +15,12 @@ in {
|
|||
"elixir-tools"
|
||||
];
|
||||
|
||||
vim.luaConfigRC.elixir-tools = nvim.dag.entryAnywhere ''
|
||||
vim.luaConfigRC.elixir-tools = 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}",
|
||||
|
@ -51,6 +51,7 @@ in {
|
|||
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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
_: {
|
||||
{
|
||||
imports = [
|
||||
./config.nix
|
||||
./elixir-tools.nix
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption;
|
||||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
in {
|
||||
options.vim.languages.elixir = {
|
||||
enable = mkEnableOption "Elixir language support";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue