Merge branch 'main' of github.com:NotAShelf/neovim-flake into nim-lang

This commit is contained in:
raf 2024-02-07 20:04:00 +03:00
commit 38bf156537
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
74 changed files with 2027 additions and 1509 deletions

74
modules/languages/css.nix Normal file
View 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;
})
]);
}

View file

@ -2,27 +2,29 @@
inherit (lib.nvim.languages) mkEnable;
in {
imports = [
./markdown
./tidal
./bash
./dart
./elixir
./bash
./markdown
./tidal
./clang.nix
./css.nix
./go.nix
./nix.nix
./python.nix
./rust.nix
./sql.nix
./ts.nix
./zig.nix
./html.nix
./svelte.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 = {

View file

@ -4,7 +4,7 @@
lib,
...
}: let
inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge;
inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge getExe;
cfg = config.vim.languages.java;
in {
@ -38,7 +38,7 @@ in {
cmd = ${
if isList cfg.lsp.package
then nvim.lua.expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/jdt-language-server", "-data", vim.fn.stdpath("cache").."/jdtls/workspace"}''
else ''{"${getExe cfg.lsp.package}", "-data", vim.fn.stdpath("cache").."/jdtls/workspace"}''
},
}
'';

View file

@ -4,9 +4,29 @@
lib,
...
}: let
inherit (lib) nvim mkIf mkMerge;
inherit (lib) nvim mkIf mkMerge mkBinding isList;
cfg = config.vim.languages.markdown;
self = import ./markdown.nix {
inherit lib config pkgs;
};
mappings = self.options.vim.languages.markdown.glow.mappings;
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 {
@ -18,13 +38,21 @@ in {
(mkIf cfg.glow.enable {
vim.startPlugins = ["glow-nvim"];
vim.globals = {
"glow_binary_path" = "${pkgs.glow}/bin";
};
vim.maps.normal = mkMerge [
(mkBinding cfg.glow.mappings.openPreview ":Glow<CR>" mappings.openPreview.description)
];
vim.configRC.glow = nvim.dag.entryAnywhere ''
autocmd FileType markdown noremap <leader>p :Glow<CR>
vim.luaConfigRC.glow = nvim.dag.entryAnywhere ''
require('glow').setup({
glow_path = "${pkgs.glow}/bin/glow"
});
'';
})
(mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.markdown-lsp = servers.${cfg.lsp.server}.lspConfig;
})
]);
}

View file

@ -4,17 +4,40 @@
lib,
...
}: let
inherit (lib) mkEnableOption mkOption types nvim;
inherit (builtins) attrNames;
inherit (lib) mkEnableOption mkMappingOption 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";
glow.enable = mkOption {
type = types.bool;
default = true;
description = "Enable markdown preview in neovim with glow";
glow = {
enable = mkOption {
type = types.bool;
default = true;
description = "Enable markdown preview in neovim with glow";
};
mappings = {
openPreview = mkMappingOption "Open preview" "<leader>p";
};
};
treesitter = {
@ -26,5 +49,22 @@ in {
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;
};
};
};
}

View 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;
})
]);
}

View file

@ -1,5 +1,5 @@
_: {
{
imports = [
./presence-nvim
./neocord
];
}

View file

@ -4,26 +4,30 @@
...
}: let
inherit (lib) mkIf nvim boolToString;
inherit (lib.nvim.lua) listToLuaTable;
inherit (lib.strings) escapeNixString;
inherit (builtins) toString;
cfg = config.vim.presence.presence-nvim;
cfg = config.vim.presence.neocord;
in {
config = mkIf cfg.enable {
vim.startPlugins = ["presence-nvim"];
vim.startPlugins = ["neocord"];
vim.luaConfigRC.presence-nvim = nvim.dag.entryAnywhere ''
-- Description of each option can be found in https://github.com/andweeb/presence.nvim
require("presence").setup({
vim.luaConfigRC.neocord = nvim.dag.entryAnywhere ''
-- Description of each option can be found in https://github.com/IogaMaster/neocord#lua
require("neocord").setup({
-- General options
auto_update = true,
neovim_image_text = "${cfg.image_text}",
logo = "${cfg.logo}",
logo_tooltip = "${cfg.logo_tooltip}",
main_image = "${cfg.main_image}",
client_id = "${cfg.client_id}",
log_level = nil,
debounce_timeout = 10,
enable_line_number = "${boolToString cfg.enable_line_number}",
blacklist = {},
buttons = "${boolToString cfg.buttons}",
file_assets = {},
log_level = ${
if cfg.log_level == null
then "nil"
else "${escapeNixString cfg.log_level}"
},
debounce_timeout = ${toString cfg.debounce_timeout},
blacklist = ${listToLuaTable cfg.blacklist},
show_time = "${boolToString cfg.show_time}",
-- Rich Presence text options
@ -34,6 +38,7 @@ in {
reading_text = "${cfg.rich_presence.reading_text}",
workspace_text = "${cfg.rich_presence.workspace_text}",
line_number_text = "${cfg.rich_presence.line_number_text}",
terminal_text = "${cfg.rich_presence.terminal_text}",
})
'';
};

View file

@ -1,6 +1,6 @@
_: {
{
imports = [
./config.nix
./presence-nvim.nix
./neocord.nix
];
}

View file

@ -1,31 +1,58 @@
{
config,
lib,
...
}: let
inherit (lib) mkEnableOption mkOption types;
{lib, ...}: let
inherit (lib) mkEnableOption mkOption types literalExpression mkRemovedOptionModule;
in {
options.vim.presence.presence-nvim = {
enable = mkEnableOption "presence.nvim plugin for discord rich presence";
imports = [
(mkRemovedOptionModule ["vim" "presence" "presence-nvim"] ''
The option vim.presence.presence-nvim has been deprecated in favor of the new neocord module.
Options provided by the plugin remain mostly the same, but manual migration is required.
image_text = mkOption {
Please see neocord documentation and the neovim-flake options for more info
'')
];
options.vim.presence.neocord = {
enable = mkEnableOption "neocord plugin for discord rich presence";
logo = mkOption {
type = types.str; # TODO: can the default be documented better, maybe with an enum?
default = "auto";
description = ''
Logo to be displayed on the RPC item
This must be either "auto" or an URL to your image of choice
'';
};
logo_tooltip = mkOption {
type = types.str;
default = "The One True Text Editor";
description = "Text displayed when hovering over the Neovim image";
};
main_image = mkOption {
type = types.str;
default = "neovim";
type = types.enum ["language" "logo"];
default = "language";
description = "Main image to be displayed";
};
client_id = mkOption {
type = types.str;
default = "79327144129396737";
default = "1157438221865717891";
description = "Client ID of the application";
};
log_level = mkOption {
type = with types; nullOr (enum ["debug" "info" "warn" "error"]);
default = null;
description = "Log level to be used by the plugin";
};
debounce_timeout = mkOption {
type = types.int;
default = 10;
description = "Number of seconds to debounce events";
};
auto_update = mkOption {
type = types.bool;
default = true;
@ -38,18 +65,19 @@ in {
description = "Show line number on the RPC item";
};
buttons = mkOption {
type = types.bool;
default = true;
description = "Show buttons on the RPC item";
};
show_time = mkOption {
type = types.bool;
default = true;
description = "Show time on the RPC item";
};
blacklist = mkOption {
type = with types; listOf str;
default = [];
example = literalExpression ''["Alpha"]'';
description = "List of filetypes to ignore";
};
rich_presence = {
editing_text = mkOption {
type = types.str;
@ -92,6 +120,12 @@ in {
default = "Line %s out of %s";
description = "Text displayed when showing line number";
};
terminal_text = mkOption {
type = types.str;
default = "Working on the terminal";
description = "Text displayed when working on the terminal";
};
};
};
}

View file

@ -20,10 +20,10 @@ in {
theme = "${cfg.theme}",
component_separators = {"${cfg.componentSeparator.left}","${cfg.componentSeparator.right}"},
section_separators = {"${cfg.sectionSeparator.left}","${cfg.sectionSeparator.right}"},
disabled_filetypes = { 'alpha' },
always_divide_middle = true,
disabled_filetypes = ${nvim.lua.listToLuaTable cfg.disabledFiletypes},
always_divide_middle = ${boolToString cfg.alwaysDivideMiddle},
globalstatus = ${boolToString cfg.globalStatus},
ignore_focus = {'NvimTree'},
ignore_focus = ${nvim.lua.listToLuaTable cfg.ignoreFocus},
extensions = {${optionalString config.vim.filetree.nvimTree.enable "'nvim-tree'"}},
refresh = {
statusline = ${toString cfg.refresh.statusline},
@ -31,6 +31,7 @@ in {
winbar = ${toString cfg.refresh.winbar},
},
},
-- active sections
sections = {
lualine_a = ${nvim.lua.luaTable (cfg.activeSection.a ++ cfg.extraActiveSection.a)},
@ -40,7 +41,8 @@ in {
lualine_y = ${nvim.lua.luaTable (cfg.activeSection.y ++ cfg.extraActiveSection.y)},
lualine_z = ${nvim.lua.luaTable (cfg.activeSection.z ++ cfg.extraActiveSection.z)},
},
--
-- inactive sections
inactive_sections = {
lualine_a = ${nvim.lua.luaTable (cfg.inactiveSection.a ++ cfg.extraInactiveSection.a)},
lualine_b = ${nvim.lua.luaTable (cfg.inactiveSection.b ++ cfg.extraInactiveSection.b)},
@ -49,9 +51,12 @@ in {
lualine_y = ${nvim.lua.luaTable (cfg.inactiveSection.y ++ cfg.extraInactiveSection.y)},
lualine_z = ${nvim.lua.luaTable (cfg.inactiveSection.z ++ cfg.extraInactiveSection.z)},
},
-- tabline (currently unsupported)
tabline = {},
${optionalString (breadcrumbsCfg.enable && breadcrumbsCfg.source == "nvim-navic") ''
-- enable winbar if nvim-navic is enabled
winbar = {
lualine_c = {
{

View file

@ -24,11 +24,13 @@ in {
description = "Refresh rate for lualine";
default = 1000;
};
tabline = mkOption {
type = types.int;
description = "Refresh rate for tabline";
default = 1000;
};
winbar = mkOption {
type = types.int;
description = "Refresh rate for winbar";
@ -42,6 +44,27 @@ in {
default = true;
};
alwaysDivideMiddle = mkOption {
type = types.bool;
description = "Always divide middle section";
default = true;
};
disabledFiletypes = mkOption {
type = with types; listOf str;
description = "Filetypes to disable lualine on";
default = ["alpha"];
};
ignoreFocus = mkOption {
type = with types; listOf str;
default = ["NvimTree"];
description = ''
If current filetype is in this list it'll always be drawn as inactive statusline
and the last window will be drawn as active statusline.
'';
};
theme = let
themeSupported = elem config.vim.theme.name supported_themes;
in
@ -175,6 +198,9 @@ in {
bg='${colorPuccin}',
fg='lavender'
},
separator = {
right = ''
},
}
''
];
@ -220,6 +246,9 @@ in {
end,
icon = ' ',
color = {bg='${colorPuccin}', fg='lavender'},
separator = {
left = '',
},
}
''
''

View file

@ -3,4 +3,5 @@
"onedark"
"catppuccin"
"oxocarbon"
"gruvbox"
]

View file

@ -92,4 +92,40 @@
'';
styles = ["dark" "light"];
};
gruvbox = {
setup = {
style ? "dark",
transparent ? false,
}: ''
-- Gruvbox theme
require("gruvbox").setup({
terminal_colors = true, -- add neovim terminal colors
undercurl = true,
underline = true,
bold = true,
italic = {
strings = true,
emphasis = true,
comments = true,
operators = false,
folds = true,
},
strikethrough = true,
invert_selection = false,
invert_signs = false,
invert_tabline = false,
invert_intend_guides = false,
inverse = true,
contrast = "",
palette_overrides = {},
overrides = {},
dim_inactive = false,
transparent_mode = ${lib.boolToString transparent},
})
vim.o.background = "${style}"
vim.cmd("colorscheme gruvbox")
'';
styles = ["dark" "light"];
};
}