mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-06-14 00:26:54 +00:00
Merge branch 'main' into deprecate-jump
This commit is contained in:
commit
35c31515b8
22 changed files with 577 additions and 76 deletions
|
|
@ -10,7 +10,6 @@
|
|||
# such as spellchecking, mappings, and the init script (init.vim).
|
||||
neovim = map (p: ./neovim + "/${p}") [
|
||||
"init"
|
||||
"mappings"
|
||||
];
|
||||
|
||||
# Individual plugin modules, separated by the type of plugin.
|
||||
|
|
|
|||
|
|
@ -5,8 +5,10 @@
|
|||
./clipboard.nix
|
||||
./debug.nix
|
||||
./diagnostics.nix
|
||||
./filetype.nix
|
||||
./highlight.nix
|
||||
./lsp.nix
|
||||
./mappings.nix
|
||||
./spellcheck.nix
|
||||
./util.nix
|
||||
];
|
||||
|
|
|
|||
123
modules/neovim/init/filetype.nix
Normal file
123
modules/neovim/init/filetype.nix
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkOption;
|
||||
inherit (lib.types) nullOr either oneOf attrsOf str listOf submodule ints;
|
||||
inherit (lib.nvim.types) luaInline;
|
||||
inherit (lib.nvim.dag) entryBefore;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim;
|
||||
|
||||
# vim.filetype.add() is quite robust, but this makes for a very
|
||||
# complex type that we have to handle. It takes a string, a Lua function
|
||||
# or a dictionary with the priority of the extension.
|
||||
ftOptionType = attrsOf (oneOf [
|
||||
str # "filetype"
|
||||
luaInline # `function(path, bufnr) ... end`
|
||||
|
||||
# { 'dosini', { priority = 10 } },
|
||||
(listOf (either (either str luaInline) (submodule {
|
||||
options = {
|
||||
priority = mkOption {
|
||||
type = ints.unsigned;
|
||||
description = ''
|
||||
`vim.filetype.add()` can take an optional priority value to resolve
|
||||
conflicts where a filetype is registered by multiple patterns. When
|
||||
priority is specified, file with the higher priority value will be
|
||||
matched first on conflict.
|
||||
'';
|
||||
};
|
||||
};
|
||||
})))
|
||||
]);
|
||||
in {
|
||||
options.vim.filetype = mkOption {
|
||||
type = submodule {
|
||||
options = {
|
||||
extension = mkOption {
|
||||
type = nullOr ftOptionType;
|
||||
default = null;
|
||||
description = "register a new filetype by extension";
|
||||
};
|
||||
|
||||
filename = mkOption {
|
||||
type = nullOr ftOptionType;
|
||||
default = null;
|
||||
description = "register a new filetype by file name";
|
||||
};
|
||||
|
||||
pattern = mkOption {
|
||||
type = nullOr ftOptionType;
|
||||
default = null;
|
||||
description = "register a new filetype by pattern";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
default = {};
|
||||
example = {
|
||||
filename = {
|
||||
".foorc" = "toml";
|
||||
"/etc/foo/config" = "toml";
|
||||
"todo.txt" = "todotxt";
|
||||
};
|
||||
|
||||
pattern = {
|
||||
".*%.scm" = "query";
|
||||
".*README.(%a+)" = ''
|
||||
function(path, bufnr, ext)
|
||||
if ext == 'md' then
|
||||
return 'markdown'
|
||||
elseif ext == 'rst' then
|
||||
return 'rst'
|
||||
end
|
||||
end,
|
||||
'';
|
||||
};
|
||||
|
||||
extension = {
|
||||
mdx = "markdown";
|
||||
bar = lib.generators.mkLuaInline ''
|
||||
{
|
||||
bar = function(path, bufnr)
|
||||
if some_condition() then
|
||||
return 'barscript', function(bufnr)
|
||||
-- Set a buffer variable
|
||||
vim.b[bufnr].barscript_version = 2
|
||||
end
|
||||
end
|
||||
return 'bar'
|
||||
end,
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
description = ''
|
||||
Additional filetypes to be registered through `vim.filetype.add()`
|
||||
|
||||
Filetype mappings can be added either by extension or by filename. The
|
||||
key can be either the "tail" or the full file path. The full file path
|
||||
is checked first, followed by the file name. If a match is not found
|
||||
using the filename, then the filename is matched against the list of
|
||||
Lua patterns (sorted by priority) until a match is found.
|
||||
|
||||
If a pattern matching does not find a filetype, then the file extension
|
||||
is used.
|
||||
|
||||
See `:h vim.filetype.add()` for more details.
|
||||
'';
|
||||
};
|
||||
|
||||
config = {
|
||||
# XXX: some plugins can be loaded on filetype, and unless the filetypes
|
||||
# are registered first, chances are custom filetypes will not be usable
|
||||
# for lazy-loading on ft.
|
||||
vim.luaConfigRC.filetype = entryBefore ["lazyConfigs"] ''
|
||||
vim.filetype.add(${toLuaObject cfg.filetype})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
@ -1,19 +1,32 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption mkOption literalMD;
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkMerge;
|
||||
inherit (lib.options) mkOption literalMD;
|
||||
inherit (lib.types) either str listOf attrsOf nullOr submodule;
|
||||
inherit (lib.attrsets) mapAttrsToList;
|
||||
inherit (lib.lists) flatten;
|
||||
inherit (lib.trivial) pipe;
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib.nvim.config) mkBool;
|
||||
|
||||
mapConfigOptions = {
|
||||
desc = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = "A description of this keybind, to be shown in which-key, if you have it enabled.";
|
||||
description = ''
|
||||
Description for the keybind, to be shown in which-key, if you have enabled
|
||||
in the module system.
|
||||
'';
|
||||
};
|
||||
|
||||
action = mkOption {
|
||||
type = str;
|
||||
description = "The command to execute.";
|
||||
};
|
||||
|
||||
lua = mkBool false ''
|
||||
If true, `action` is considered to be lua code.
|
||||
Thus, it will not be wrapped in `""`.
|
||||
|
|
@ -55,6 +68,22 @@
|
|||
});
|
||||
default = {};
|
||||
};
|
||||
|
||||
legacyMapModes = {
|
||||
normal = ["n"];
|
||||
insert = ["i"];
|
||||
select = ["s"];
|
||||
visual = ["v"];
|
||||
terminal = ["t"];
|
||||
normalVisualOp = ["n" "v" "o"];
|
||||
visualOnly = ["n" "x"];
|
||||
operator = ["o"];
|
||||
insertCommand = ["i" "c"];
|
||||
lang = ["l"];
|
||||
command = ["c"];
|
||||
};
|
||||
|
||||
cfg = config.vim;
|
||||
in {
|
||||
options.vim = {
|
||||
vendoredKeymaps.enable =
|
||||
|
|
@ -101,4 +130,27 @@ in {
|
|||
command = legacyMapOption "command-line";
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
vim.keymaps = mkMerge [
|
||||
(
|
||||
pipe cfg.maps
|
||||
[
|
||||
(mapAttrsToList (
|
||||
oldMode: keybinds:
|
||||
mapAttrsToList (
|
||||
key: bind:
|
||||
bind
|
||||
// {
|
||||
inherit key;
|
||||
mode = legacyMapModes.${oldMode};
|
||||
}
|
||||
)
|
||||
keybinds
|
||||
))
|
||||
flatten
|
||||
]
|
||||
)
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkMerge;
|
||||
inherit (lib.trivial) pipe;
|
||||
inherit (lib.attrsets) mapAttrsToList;
|
||||
inherit (lib.lists) flatten;
|
||||
|
||||
legacyMapModes = {
|
||||
normal = ["n"];
|
||||
insert = ["i"];
|
||||
select = ["s"];
|
||||
visual = ["v"];
|
||||
terminal = ["t"];
|
||||
normalVisualOp = ["n" "v" "o"];
|
||||
visualOnly = ["n" "x"];
|
||||
operator = ["o"];
|
||||
insertCommand = ["i" "c"];
|
||||
lang = ["l"];
|
||||
command = ["c"];
|
||||
};
|
||||
|
||||
cfg = config.vim;
|
||||
in {
|
||||
config = {
|
||||
vim.keymaps = mkMerge [
|
||||
(
|
||||
pipe cfg.maps
|
||||
[
|
||||
(mapAttrsToList (
|
||||
oldMode: keybinds:
|
||||
mapAttrsToList (
|
||||
key: bind:
|
||||
bind
|
||||
// {
|
||||
inherit key;
|
||||
mode = legacyMapModes.${oldMode};
|
||||
}
|
||||
)
|
||||
keybinds
|
||||
))
|
||||
flatten
|
||||
]
|
||||
)
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
imports = [
|
||||
./config.nix
|
||||
./options.nix
|
||||
];
|
||||
}
|
||||
|
|
@ -117,6 +117,9 @@ in {
|
|||
vim.treesitter = {
|
||||
enable = true;
|
||||
grammars = [cfg.treesitter.package];
|
||||
filetypeMappings = {
|
||||
yaml = ["dockercompose"];
|
||||
};
|
||||
};
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ in {
|
|||
|
||||
dap = {
|
||||
enable =
|
||||
mkEnableOption "Go Debug Adapter (DAP) via `nvim-dap-go"
|
||||
mkEnableOption "Go Debug Adapter"
|
||||
// {
|
||||
default = config.vim.languages.enableDAP;
|
||||
defaultText = literalExpression "config.vim.languages.enableDAP";
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
cfg = config.vim.languages.html;
|
||||
|
||||
defaultServers = ["superhtml"];
|
||||
servers = ["superhtml" "emmet-ls" "angular-language-server"];
|
||||
servers = ["superhtml" "emmet-ls" "angular-language-server" "stimulus-language-server"];
|
||||
|
||||
defaultFormat = ["superhtml"];
|
||||
formats = {
|
||||
|
|
|
|||
|
|
@ -2,19 +2,45 @@
|
|||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
inputs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) literalExpression mkEnableOption mkOption;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib) genAttrs;
|
||||
inherit (lib.types) listOf str;
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.options) literalExpression mkEnableOption mkOption;
|
||||
inherit (lib.types) listOf str enum package;
|
||||
inherit (lib.attrsets) attrNames genAttrs;
|
||||
inherit (lib.meta) getExe getExe';
|
||||
inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption enumWithRename;
|
||||
|
||||
cfg = config.vim.languages.java;
|
||||
|
||||
defaultServers = ["jdt-language-server"];
|
||||
servers = ["jdt-language-server"];
|
||||
servers = ["jdt-language-server" "jls"];
|
||||
|
||||
defaultDebugger = "jls";
|
||||
debuggers = {
|
||||
jls = let
|
||||
pkg = inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.jls;
|
||||
in {
|
||||
package = pkg;
|
||||
config = ''
|
||||
dap.adapters.jls= {
|
||||
type = 'executable',
|
||||
command = '${getExe' pkg "jls-dap"}',
|
||||
}
|
||||
dap.configurations.java = {
|
||||
{
|
||||
type = "jls",
|
||||
request = "attach",
|
||||
name = "Attach",
|
||||
hostName = "localhost",
|
||||
port = 5005,
|
||||
sourceRoots = vim.fn.glob("**/src/main/java", true, true),
|
||||
},
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.java = {
|
||||
enable = mkEnableOption "Java language support";
|
||||
|
|
@ -48,6 +74,72 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
dap = {
|
||||
enable =
|
||||
mkEnableOption "Java Debug Adapter"
|
||||
// {
|
||||
default = config.vim.languages.enableDAP;
|
||||
defaultText = literalExpression "config.vim.languages.enableDAP";
|
||||
};
|
||||
|
||||
debugger = mkOption {
|
||||
type = enum (attrNames debuggers);
|
||||
default = defaultDebugger;
|
||||
description = ''
|
||||
Java debugger to use.
|
||||
|
||||
**JLS**
|
||||
|
||||
For `jls` to work, you need to run your application with debug symbols and networking.
|
||||
|
||||
The `jls` configuration is hardcoded to listen on port `5005`.
|
||||
This matches the configuration described [upstream](https://github.com/idelice/jls#usage).
|
||||
You can change this by modifying `vim.debugger.nvim-dap.sources.java-debugger`.
|
||||
```nix
|
||||
vim.debugger.nvim-dap.sources.java-debugger = /* lua */ '''
|
||||
dap.adapters.jls= {
|
||||
type = 'executable',
|
||||
command = ''\'''${getExe' inputs.self.packages.''${pkgs.stdenv.hostPlatform.system}.jls "jls-dap"}',
|
||||
}
|
||||
dap.configurations.java = {
|
||||
{
|
||||
type = "jls",
|
||||
request = "attach",
|
||||
name = "Attach",
|
||||
hostName = "localhost",
|
||||
port = 6969, -- your custom port
|
||||
sourceRoots = vim.fn.glob("**/src/main/java", true, true),
|
||||
},
|
||||
}
|
||||
''';
|
||||
```
|
||||
|
||||
*Examples:*
|
||||
|
||||
- Manual:
|
||||
1. Build with debug symbols.
|
||||
```sh
|
||||
javac -g ...
|
||||
```
|
||||
1. Run with debug socket.
|
||||
```sh
|
||||
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar your.jar
|
||||
```
|
||||
- Springboot Maven:
|
||||
For Springboot you can just pass the JVM args directly into the `spring-boot:run`.
|
||||
```sh
|
||||
mvn spring-boot:run -Dspring-boot.run.jvmArguments="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005"
|
||||
```
|
||||
'';
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = package;
|
||||
default = debuggers.${cfg.dap.debugger}.package;
|
||||
description = "Java debugger package.";
|
||||
};
|
||||
};
|
||||
|
||||
extensions = {
|
||||
maven-nvim = {
|
||||
enable = mkEnableOption "maven integration";
|
||||
|
|
@ -88,6 +180,11 @@ 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 = {
|
||||
presets = genAttrs cfg.lsp.servers (_: {enable = true;});
|
||||
|
|
@ -97,9 +194,11 @@ in {
|
|||
};
|
||||
})
|
||||
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
(mkIf cfg.dap.enable {
|
||||
vim.debugger.nvim-dap = {
|
||||
enable = true;
|
||||
sources.java-debugger = debuggers.${cfg.dap.debugger}.config;
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf cfg.extensions.maven-nvim.enable {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
cfg = config.vim.languages.jinja;
|
||||
|
||||
defaultServers = ["jinja-lsp"];
|
||||
servers = ["jinja-lsp" "emmet-ls"];
|
||||
servers = ["jinja-lsp" "emmet-ls" "stimulus-language-server"];
|
||||
in {
|
||||
options.vim.languages.jinja = {
|
||||
enable = mkEnableOption "Jinja template language support";
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
cfg = config.vim.languages.ruby;
|
||||
|
||||
defaultServers = ["solargraph"];
|
||||
servers = ["ruby-lsp" "solargraph"];
|
||||
servers = ["ruby-lsp" "solargraph" "stimulus-language-server"];
|
||||
|
||||
# testing
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
cfg = config.vim.languages.tera;
|
||||
|
||||
defaultServers = [];
|
||||
servers = ["emmet-ls"];
|
||||
servers = ["emmet-ls" "stimulus-language-server"];
|
||||
in {
|
||||
options.vim.languages.tera = {
|
||||
enable = mkEnableOption "Tera templating language support";
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
cfg = config.vim.languages.twig;
|
||||
|
||||
defaultServers = ["twig-language-server"];
|
||||
servers = ["twig-language-server" "emmet-ls"];
|
||||
servers = ["twig-language-server" "emmet-ls" "stimulus-language-server"];
|
||||
|
||||
defaultFormat = ["djlint"];
|
||||
formats = {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
./intelephense.nix
|
||||
./jdt-language-server.nix
|
||||
./jinja-lsp.nix
|
||||
./jls.nix
|
||||
./jq-lsp.nix
|
||||
./julia-languageserver.nix
|
||||
./just-lsp.nix
|
||||
|
|
@ -61,6 +62,7 @@
|
|||
./solargraph.nix
|
||||
./some-sass-language-server.nix
|
||||
./sqls.nix
|
||||
./stimulus-language-server.nix
|
||||
./superhtml.nix
|
||||
./svelte-language-server.nix
|
||||
./tailwindcss-language-server.nix
|
||||
|
|
|
|||
34
modules/plugins/lsp/presets/jls.nix
Normal file
34
modules/plugins/lsp/presets/jls.nix
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
inputs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.types) mkLspPresetEnableOption;
|
||||
|
||||
cfg = config.vim.lsp.presets.jls;
|
||||
in {
|
||||
options.vim.lsp.presets.jls = {
|
||||
enable = mkLspPresetEnableOption "jls" "NeoVim Java" [];
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
vim.lsp.servers.jls = {
|
||||
enable = true;
|
||||
cmd = [(getExe inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.jls)];
|
||||
root_markers = [
|
||||
".git"
|
||||
".java-version"
|
||||
"pom.xml"
|
||||
"build.xml"
|
||||
"build.gradle"
|
||||
"build.gradle.kts"
|
||||
"settings.gradle"
|
||||
"settings.gradle.kts"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
26
modules/plugins/lsp/presets/stimulus-language-server.nix
Normal file
26
modules/plugins/lsp/presets/stimulus-language-server.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
inputs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.types) mkLspPresetEnableOption;
|
||||
|
||||
cfg = config.vim.lsp.presets.stimulus-language-server;
|
||||
in {
|
||||
options.vim.lsp.presets.stimulus-language-server = {
|
||||
enable = mkLspPresetEnableOption "stimulus-language-server" "Stimulus" [];
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
vim.lsp.servers.stimulus-language-server = {
|
||||
enable = true;
|
||||
cmd = [(getExe inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.stimulus-language-server) "--stdio"];
|
||||
root_markers = [".git"];
|
||||
workspace_required = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue