Merge branch 'NotAShelf:main' into overhaul-spell

This commit is contained in:
Yavor Kolev 2023-08-11 16:56:47 +03:00 committed by GitHub
commit 97764f6140
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 243 additions and 170 deletions

View file

@ -64,6 +64,7 @@ inputs: let
enable = isMaximal; enable = isMaximal;
crates.enable = true; crates.enable = true;
}; };
java.enable = isMaximal;
ts.enable = isMaximal; ts.enable = isMaximal;
svelte.enable = isMaximal; svelte.enable = isMaximal;
go.enable = isMaximal; go.enable = isMaximal;

View file

@ -16,7 +16,9 @@ https://github.com/horriblename[horriblename]:
https://github.com/amanse[amanse]: https://github.com/amanse[amanse]:
* Added daily notes options for obsidian plugin.a * Added daily notes options for obsidian plugin.
* Added jdt-language-server for Java.
https://github.com/yavko[yavko]: https://github.com/yavko[yavko]:

View file

@ -13,7 +13,6 @@
else "'${value}'"; else "'${value}'";
# convert an expression to lua # convert an expression to lua
expToLua = exp: expToLua = exp:
if builtins.isList exp if builtins.isList exp
then listToLuaTable exp # if list, convert to lua table then listToLuaTable exp # if list, convert to lua table

View file

@ -15,7 +15,7 @@ with lib; {
sources = mkOption { sources = mkOption {
default = {}; default = {};
description = "List of debuggers to install"; description = "List of debuggers to install";
type = with types; attrsOf string; type = with types; attrsOf str;
}; };
mappings = { mappings = {

View file

@ -23,6 +23,7 @@ in {
./zig.nix ./zig.nix
./html.nix ./html.nix
./svelte.nix ./svelte.nix
./java.nix
]; ];
options.vim.languages = { options.vim.languages = {

View file

@ -0,0 +1,45 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.languages.java;
in {
options.vim.languages.java = {
enable = mkEnableOption "Java language support";
treesitter = {
enable = mkEnableOption "Enable 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";
type = types.package;
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 {
cmd = {"${cfg.lsp.package}/bin/jdt-language-server", "-data", vim.fn.stdpath("cache").."/jdtls/workspace"},
}
'';
})
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.package];
})
]);
}

View file

@ -56,9 +56,9 @@ with builtins; let
command = {"${cfg.format.package}/bin/nixpkgs-fmt"}, command = {"${cfg.format.package}/bin/nixpkgs-fmt"},
}, },
''} ''}
''}
}, },
}; },
''}
} }
''; '';
}; };

View file

@ -7,33 +7,40 @@ with lib;
with builtins; let with builtins; let
cfg = config.vim.notes.orgmode; cfg = config.vim.notes.orgmode;
in { in {
config = mkIf (cfg.enable) { config = mkIf cfg.enable (mkMerge [
vim.startPlugins = [ {
"orgmode-nvim" vim.startPlugins = [
]; "orgmode-nvim"
];
vim.luaConfigRC.orgmode = nvim.dag.entryAnywhere '' vim.luaConfigRC.orgmode = nvim.dag.entryAnywhere ''
-- Load custom treesitter grammar for org filetype -- Load custom treesitter grammar for org filetype
require('orgmode').setup_ts_grammar() require('orgmode').setup_ts_grammar()
-- Treesitter configuration -- Treesitter configuration
require('nvim-treesitter.configs').setup { require('nvim-treesitter.configs').setup {
-- If TS highlights are not enabled at all, or disabled via `disable` prop, -- If TS highlights are not enabled at all, or disabled via `disable` prop,
-- highlighting will fallback to default Vim syntax highlighting -- highlighting will fallback to default Vim syntax highlighting
highlight = { highlight = {
enable = true, enable = true,
-- Required for spellcheck, some LaTex highlights and -- Required for spellcheck, some LaTex highlights and
-- code block highlights that do not have ts grammar -- code block highlights that do not have ts grammar
additional_vim_regex_highlighting = {'org'}, additional_vim_regex_highlighting = {'org'},
}, },
ensure_installed = {'org'}, -- Or run :TSUpdate org }
}
require('orgmode').setup({ require('orgmode').setup({
org_agenda_files = ${cfg.orgAgendaFiles}, org_agenda_files = ${cfg.orgAgendaFiles},
org_default_notes_file = '${cfg.orgDefaultNotesFile}', org_default_notes_file = '${cfg.orgDefaultNotesFile}',
}) })
''; '';
}; }
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.orgPackage];
})
]);
} }

View file

@ -1,21 +1,30 @@
{ {
config, config,
lib, lib,
pkgs,
... ...
}: }:
with lib; with lib;
with builtins; { with builtins; {
options.vim.notes.orgmode = { options.vim.notes.orgmode = {
enable = mkEnableOption "nvim-orgmode: Neovim plugin for Emac Orgmode. Get the best of both worlds"; enable = mkEnableOption "nvim-orgmode: Neovim plugin for Emac Orgmode. Get the best of both worlds";
orgAgendaFiles = mkOption { orgAgendaFiles = mkOption {
type = types.str; type = types.str;
default = "{'~/Documents/org/*', '~/my-orgs/**/*'}"; default = "{'~/Documents/org/*', '~/my-orgs/**/*'}";
description = "List of org files to be used as agenda files."; description = "List of org files to be used as agenda files.";
}; };
orgDefaultNotesFile = mkOption { orgDefaultNotesFile = mkOption {
type = types.str; type = types.str;
default = "~/Documents/org/refile.org"; default = "~/Documents/org/refile.org";
description = "Default org file to be used for notes."; description = "Default org file to be used for notes.";
}; };
treesitter = {
enable = mkEnableOption "Enable Orgmode treesitter" // {default = config.vim.languages.enableTreesitter;};
orgPackage = nvim.types.mkGrammarOption pkgs "org";
};
}; };
} }

View file

@ -27,8 +27,13 @@
}; };
dracula = { dracula = {
setup = '' setup = {
require('dracula').setup({}); style ? null,
transparent,
}: ''
require('dracula').setup({
transparent_bg = ${lib.boolToString transparent},
});
require('dracula').load(); require('dracula').load();
''; '';
}; };

View file

@ -3,161 +3,165 @@
lib, lib,
... ...
}: }:
with lib;
with builtins; let with builtins; let
inherit (lib) optionalString boolToString mkIf optionals;
inherit (lib.nvim.lua) nullString;
cfg = config.vim.ui.breadcrumbs; cfg = config.vim.ui.breadcrumbs;
nb = cfg.navbuddy; nb = cfg.navbuddy;
nilOrStr = v:
if v == null
then "nil"
else toString v;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = vim.startPlugins =
[ [
"nvim-lspconfig" "nvim-lspconfig"
] ]
++ lib.optionals (config.vim.lsp.lspsaga.enable && cfg.source == "lspsaga") [ ++ optionals (cfg.source == "nvim-navic") [
"nvim-navic"
]
++ optionals (config.vim.lsp.lspsaga.enable && cfg.source == "lspsaga") [
"lspsaga" "lspsaga"
] ]
++ lib.optionals (cfg.navbuddy.enable || cfg.source == "nvim-navic") [ ++ optionals cfg.navbuddy.enable [
"nvim-navbuddy" "nvim-navbuddy"
"nui-nvim"
"nvim-navic" "nvim-navic"
]; ];
vim.luaConfigRC.breadcrumbs = nvim.dag.entryAfter ["lspconfig"] '' vim.luaConfigRC.breadcrumbs = lib.nvim.dag.entryAfter ["lspconfig"] ''
local navbuddy = require("nvim-navbuddy")
local navic = require("nvim-navic")
local actions = require("nvim-navbuddy.actions")
require("nvim-navic").setup { ${optionalString (cfg.source == "nvim-navic") ''
highlight = true local navic = require("nvim-navic")
} require("nvim-navic").setup {
highlight = true
-- TODO: wrap this in an optional string with navbuddy as the enable condition
navbuddy.setup {
window = {
border = "${nb.window.border}", -- "rounded", "double", "solid", "none"
size = "60%",
position = "50%",
scrolloff = ${(nilOrStr nb.window.scrolloff)},
sections = {
left = {
size = "20%",
border = ${(nilOrStr nb.window.sections.left.border)},
},
mid = {
size = "40%",
border = ${(nilOrStr nb.window.sections.mid.border)},
},
right = {
border = ${(nilOrStr nb.window.sections.right.border)},
preview = "leaf",
}
},
},
node_markers = {
enabled = ${boolToString nb.nodeMarkers.enable},
icons = {
leaf = "${nb.nodeMarkers.icons.leaf}",
leaf_selected = "${nb.nodeMarkers.icons.leafSelected}",
branch = "${nb.nodeMarkers.icons.branch}",
},
},
lsp = {
auto_attach = ${boolToString nb.lsp.autoAttach},
-- preference = nil, -- TODO: convert list to lua table if not null
},
source_buffer = {
follow_node = ${boolToString nb.sourceBuffer.followNode},
highlight = ${boolToString nb.sourceBuffer.highlight},
reorient = "${nb.sourceBuffer.reorient}",
scrolloff = ${nilOrStr nb.sourceBuffer.scrolloff}
},
icons = {
File = "${cfg.navbuddy.icons.file}",
Module = "${cfg.navbuddy.icons.module}",
Namespace = "${cfg.navbuddy.icons.namespace}",
Package = "${cfg.navbuddy.icons.package}",
Class = "${cfg.navbuddy.icons.class}",
Method = "${cfg.navbuddy.icons.method}",
Property = "${cfg.navbuddy.icons.property}",
Field = "${cfg.navbuddy.icons.field}",
Constructor = "${cfg.navbuddy.icons.constructor}",
Enum = "${cfg.navbuddy.icons.enum}",
Interface = "${cfg.navbuddy.icons.interface}",
Function = "${cfg.navbuddy.icons.function}",
Variable = "${cfg.navbuddy.icons.variable}",
Constant = "${cfg.navbuddy.icons.constant}",
String = "${cfg.navbuddy.icons.string}",
Number = "${cfg.navbuddy.icons.number}",
Boolean = "${cfg.navbuddy.icons.boolean}",
Array = "${cfg.navbuddy.icons.array}",
Object = "${cfg.navbuddy.icons.object}",
Key = "${cfg.navbuddy.icons.key}",
Null = "${cfg.navbuddy.icons.null}",
EnumMember = "${cfg.navbuddy.icons.enumMember}",
Struct = "${cfg.navbuddy.icons.struct}",
Event = "${cfg.navbuddy.icons.event}",
Operator = "${cfg.navbuddy.icons.operator}",
TypeParameter = "${cfg.navbuddy.icons.typeParameter}"
},
-- make those configurable
use_default_mappings = ${toString (cfg.navbuddy.useDefaultMappings)},
mappings = {
["${cfg.navbuddy.mappings.close}"] = actions.close(),
["${cfg.navbuddy.mappings.nextSibling}"] = actions.next_sibling(),
["${cfg.navbuddy.mappings.previousSibling}"] = actions.previous_sibling(),
["${cfg.navbuddy.mappings.close}"] = actions.parent(),
["${cfg.navbuddy.mappings.children}"] = actions.children(),
["${cfg.navbuddy.mappings.root}"] = actions.root(),
["${cfg.navbuddy.mappings.visualName}"] = actions.visual_name(),
["${cfg.navbuddy.mappings.visualScope}"] = actions.visual_scope(),
["${cfg.navbuddy.mappings.yankName}"] = actions.yank_name(),
["${cfg.navbuddy.mappings.yankScope}"] = actions.yank_scope(),
["${cfg.navbuddy.mappings.insertName}"] = actions.insert_name(),
["${cfg.navbuddy.mappings.insertScope}"] = actions.insert_scope(),
["${cfg.navbuddy.mappings.appendName}"] = actions.append_name(),
["${cfg.navbuddy.mappings.appendScope}"] = actions.append_scope(),
["${cfg.navbuddy.mappings.rename}"] = actions.rename(),
["${cfg.navbuddy.mappings.delete}"] = actions.delete(),
["${cfg.navbuddy.mappings.foldCreate}"] = actions.fold_create(),
["${cfg.navbuddy.mappings.foldDelete}"] = actions.fold_delete(),
["${cfg.navbuddy.mappings.comment}"] = actions.comment(),
["${cfg.navbuddy.mappings.select}"] = actions.select(),
["${cfg.navbuddy.mappings.moveDown}"] = actions.move_down(),
["${cfg.navbuddy.mappings.moveUp}"] = actions.move_up(),
["${cfg.navbuddy.mappings.telescope}"] = actions.telescope({
layout_strategy = "horizontal",
layout_config = {
height = 0.60,
width = 0.75,
prompt_position = "top",
preview_width = 0.50
},
}),
["${cfg.navbuddy.mappings.help}"] = actions.help(), -- Open mappings help window
},
} }
''}
${optionalString cfg.navbuddy.enable ''
local navbuddy = require("nvim-navbuddy")
local actions = require("nvim-navbuddy.actions")
navbuddy.setup {
window = {
border = "${nb.window.border}", -- "rounded", "double", "solid", "none"
size = "60%",
position = "50%",
scrolloff = ${(nullString nb.window.scrolloff)},
sections = {
left = {
size = "20%",
border = ${(nullString nb.window.sections.left.border)},
},
mid = {
size = "40%",
border = ${(nullString nb.window.sections.mid.border)},
},
right = {
border = ${(nullString nb.window.sections.right.border)},
preview = "leaf",
}
},
},
node_markers = {
enabled = ${boolToString nb.nodeMarkers.enable},
icons = {
leaf = "${nb.nodeMarkers.icons.leaf}",
leaf_selected = "${nb.nodeMarkers.icons.leafSelected}",
branch = "${nb.nodeMarkers.icons.branch}",
},
},
lsp = {
auto_attach = ${boolToString nb.lsp.autoAttach},
-- preference = nil, -- TODO: convert list to lua table if not null
},
source_buffer = {
follow_node = ${boolToString nb.sourceBuffer.followNode},
highlight = ${boolToString nb.sourceBuffer.highlight},
reorient = "${nb.sourceBuffer.reorient}",
scrolloff = ${nullString nb.sourceBuffer.scrolloff}
},
icons = {
File = "${cfg.navbuddy.icons.file}",
Module = "${cfg.navbuddy.icons.module}",
Namespace = "${cfg.navbuddy.icons.namespace}",
Package = "${cfg.navbuddy.icons.package}",
Class = "${cfg.navbuddy.icons.class}",
Method = "${cfg.navbuddy.icons.method}",
Property = "${cfg.navbuddy.icons.property}",
Field = "${cfg.navbuddy.icons.field}",
Constructor = "${cfg.navbuddy.icons.constructor}",
Enum = "${cfg.navbuddy.icons.enum}",
Interface = "${cfg.navbuddy.icons.interface}",
Function = "${cfg.navbuddy.icons.function}",
Variable = "${cfg.navbuddy.icons.variable}",
Constant = "${cfg.navbuddy.icons.constant}",
String = "${cfg.navbuddy.icons.string}",
Number = "${cfg.navbuddy.icons.number}",
Boolean = "${cfg.navbuddy.icons.boolean}",
Array = "${cfg.navbuddy.icons.array}",
Object = "${cfg.navbuddy.icons.object}",
Key = "${cfg.navbuddy.icons.key}",
Null = "${cfg.navbuddy.icons.null}",
EnumMember = "${cfg.navbuddy.icons.enumMember}",
Struct = "${cfg.navbuddy.icons.struct}",
Event = "${cfg.navbuddy.icons.event}",
Operator = "${cfg.navbuddy.icons.operator}",
TypeParameter = "${cfg.navbuddy.icons.typeParameter}"
},
-- make those configurable
use_default_mappings = ${boolToString cfg.navbuddy.useDefaultMappings},
mappings = {
["${cfg.navbuddy.mappings.close}"] = actions.close(),
["${cfg.navbuddy.mappings.nextSibling}"] = actions.next_sibling(),
["${cfg.navbuddy.mappings.previousSibling}"] = actions.previous_sibling(),
["${cfg.navbuddy.mappings.close}"] = actions.parent(),
["${cfg.navbuddy.mappings.children}"] = actions.children(),
["${cfg.navbuddy.mappings.root}"] = actions.root(),
["${cfg.navbuddy.mappings.visualName}"] = actions.visual_name(),
["${cfg.navbuddy.mappings.visualScope}"] = actions.visual_scope(),
["${cfg.navbuddy.mappings.yankName}"] = actions.yank_name(),
["${cfg.navbuddy.mappings.yankScope}"] = actions.yank_scope(),
["${cfg.navbuddy.mappings.insertName}"] = actions.insert_name(),
["${cfg.navbuddy.mappings.insertScope}"] = actions.insert_scope(),
["${cfg.navbuddy.mappings.appendName}"] = actions.append_name(),
["${cfg.navbuddy.mappings.appendScope}"] = actions.append_scope(),
["${cfg.navbuddy.mappings.rename}"] = actions.rename(),
["${cfg.navbuddy.mappings.delete}"] = actions.delete(),
["${cfg.navbuddy.mappings.foldCreate}"] = actions.fold_create(),
["${cfg.navbuddy.mappings.foldDelete}"] = actions.fold_delete(),
["${cfg.navbuddy.mappings.comment}"] = actions.comment(),
["${cfg.navbuddy.mappings.select}"] = actions.select(),
["${cfg.navbuddy.mappings.moveDown}"] = actions.move_down(),
["${cfg.navbuddy.mappings.moveUp}"] = actions.move_up(),
["${cfg.navbuddy.mappings.telescope}"] = actions.telescope({
layout_strategy = "horizontal",
layout_config = {
height = 0.60,
width = 0.75,
prompt_position = "top",
preview_width = 0.50
},
}),
["${cfg.navbuddy.mappings.help}"] = actions.help(), -- Open mappings help window
},
}
''}
''; '';
}; };
} }